#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) (int)v.size()
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(5e5)+7;
const int LOG = 20;
int n , q , a[maxN]; string s;
vector<int> g[maxN];
int d[maxN] , in[maxN] , out[maxN] , DfsTime = 0 , fa[maxN];
int p[maxN] , h[maxN] , sz[maxN] , numChain = 0 , numPos = 0 , chain[maxN] , pos[maxN] , head[maxN];
void dfs(int u){
d[u] = d[p[u]] + a[u];
in[u] = ++DfsTime;
sz[u] = 1;
for (int v : g[u]){
if (v != p[u]){
p[v] = u;
h[v] = h[u] + 1;
dfs(v);
sz[u] += sz[v];
}
}
out[u] = DfsTime;
}
void hld(int u){
if (head[numChain] == 0) head[numChain] = u;
chain[u] = numChain;
pos[u] = ++numPos;
int heavy = -1;
for (int v : g[u]){
if (v != p[u] && (heavy == -1 || sz[heavy] < sz[v])) heavy = v;
}
if (heavy != -1) hld(heavy);
for (int v : g[u]){
if (v != p[u] && v != heavy){
numChain++;
hld(v);
}
}
}
int lca(int u , int v){
while (chain[u] != chain[v]){
if (h[head[chain[u]]] > h[head[chain[v]]]) swap(u , v);
v = p[head[chain[v]]];
}
if (h[u] > h[v]) swap(u , v);
return u;
}
struct fenwick{
int t[maxN];
void reset(){
for (int i = 1 ; i <= n ; i++) t[i] = 0;
}
void update(int x , int y){
for (; x <= n ; x += x&-x) t[x] += y;
}
void update(int l , int r , int x){
update(l , +x);
update(r + 1 , -x);
}
int get(int x){
int ans = 0;
for (; x >= 1 ; x -= x&-x) ans += t[x];
return ans;
}
} fen;
ii E[maxN];
int res[maxN];
vector<int> event[2 * maxN] , query[2 * maxN];
void TH1(){
for (int i = 1 ; i <= n ; i++){
event[d[p[i]] + maxN].push_back(i);
}
for (int i = 1 ; i <= q ; i++){
query[d[E[i].fi] + maxN].push_back(i);
}
for (int i = -n ; i <= +n ; i++){
for (int id : query[i + maxN]){
int u = E[id].fi;
int v = E[id].se;
int x = fa[id];
res[id] += fen.get(in[u]) - fen.get(in[p[x]]);
}
for (int id : event[i + maxN]){
fen.update(in[id] , out[id] , +1);
}
}
}
void TH2(){
for (int i = -n ; i <= +n ; i++) event[i + maxN].clear() , query[i + maxN].clear();
fen.reset();
for (int i = 1 ; i <= n ; i++){
event[d[i] + maxN].push_back(i);
}
for (int i = 1 ; i <= q ; i++){
int u = E[i].fi;
int v = E[i].se;
int x = fa[i];
query[d[p[x]] - (d[u] - d[x]) + maxN].push_back(i);
}
for (int i = +n ; i >= -n ; i--){
for (int id : query[i + maxN]){
int u = E[id].fi;
int v = E[id].se;
int x = fa[id];
res[id] += fen.get(in[v]) - fen.get(in[p[x]]);
if (d[u] - d[p[x]] > 0) res[id]--;
}
for (int id : event[i + maxN]){
fen.update(in[id] , out[id] , +1);
}
}
}
void solve(){
cin >> n >> q >> s;
s = '#' + s;
for (int i = 1 ; i <= n ; i++) a[i] = (s[i] == '+') ? +1 : -1;
for (int i = 1 ; i < n ; i++){
int u , v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
d[0] = 0;
dfs(1);
hld(1);
for (int i = 1 ; i <= q ; i++){
int u , v;
cin >> u >> v;
E[i] = {u , v};
fa[i] = lca(u , v);
}
TH1();
TH2();
for (int i = 1 ; i <= q ; i++) cout << res[i] << "\n";
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen(name".inp" , "r" , stdin);
// freopen(name".out" , "w" , stdout);
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBhbGwodikgdi5iZWdpbigpICwgdi5lbmQoKQojZGVmaW5lIHN6KHYpIChpbnQpdi5zaXplKCkKI2RlZmluZSB1bnEodikgc29ydChh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mFjayhpKTsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxIDsgaSA8PSBxIDsgaSsrKXsKICAgICAgICBpbnQgdSA9IEVbaV0uZmk7CiAgICAgICAgaW50IHYgPSBFW2ldLnNlOwogICAgICAgIGludCB4ID0gZmFbaV07CiAgICAgICAgcXVlcnlbZFtwW3hdXSAtIChkW3VdIC0gZFt4XSkgKyBtYXhOXS5wdXNoX2JhY2soaSk7CiAgICB9CiAgICBmb3IgKGludCBpID0gK24gOyBpID49IC1uIDsgaS0tKXsKICAgICAgICBmb3IgKGludCBpZCA6IHF1ZXJ5W2kgKyBtYXhOXSl7CiAgICAgICAgICAgIGludCB1ID0gRVtpZF0uZmk7CiAgICAgICAgICAgIGludCB2ID0gRVtpZF0uc2U7CiAgICAgICAgICAgIGludCB4ID0gZmFbaWRdOwogICAgICAgICAgICByZXNbaWRdICs9IGZlbi5nZXQoaW5bdl0pIC0gZmVuLmdldChpbltwW3hdXSk7CiAgICAgICAgICAgIGlmIChkW3VdIC0gZFtwW3hdXSA+IDApIHJlc1tpZF0tLTsKICAgICAgICB9CiAgICAgICAgZm9yIChpbnQgaWQgOiBldmVudFtpICsgbWF4Tl0pewogICAgICAgICAgICBmZW4udXBkYXRlKGluW2lkXSAsIG91dFtpZF0gLCArMSk7CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIHNvbHZlKCl7CiAgICBjaW4gPj4gbiA+PiBxID4+IHM7CiAgICBzID0gJyMnICsgczsKICAgIGZvciAoaW50IGkgPSAxIDsgaSA8PSBuIDsgaSsrKSBhW2ldID0gKHNbaV0gPT0gJysnKSA/ICsxIDogLTE7CiAgICBmb3IgKGludCBpID0gMSA7IGkgPCBuIDsgaSsrKXsKICAgICAgICBpbnQgdSAsIHY7CiAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICBnW3VdLnB1c2hfYmFjayh2KTsKICAgICAgICBnW3ZdLnB1c2hfYmFjayh1KTsKICAgIH0KICAgIGRbMF0gPSAwOwogICAgZGZzKDEpOwogICAgaGxkKDEpOwogICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IHEgOyBpKyspewogICAgICAgIGludCB1ICwgdjsKICAgICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAgIEVbaV0gPSB7dSAsIHZ9OwogICAgICAgIGZhW2ldID0gbGNhKHUgLCB2KTsKICAgIH0KICAgIFRIMSgpOwogICAgVEgyKCk7CiAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gcSA7IGkrKykgY291dCA8PCByZXNbaV0gPDwgIlxuIjsKfQoKI2RlZmluZSBuYW1lICJBIgoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgLy8gZnJlb3BlbihuYW1lIi5pbnAiICwgInIiICwgc3RkaW4pOwogICAgLy8gZnJlb3BlbihuYW1lIi5vdXQiICwgInciICwgc3Rkb3V0KTsKICAgIGludCB0ID0gMTsgLy9jaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQo=