#include <bits/stdc++.h>

using namespace std;
const long long maxn = 2e6+5;
vector <long long> g[maxn];
long long par[maxn];
long long sub[maxn];
long long ans = 0;
long long dfs(long long v, long long _par = -1){
    sub[v] = 1;
    for(auto u : g[v]){
        if (u == _par) continue;
        par[u] = v;
        sub[v] += dfs(u, v);
        ans += sub[u];
    }
    return sub[v];

}
long long ret_h(long long u, long long p){
    long long k = 0;
    while(u != p)
    {
        k++;
        u = par[u];
    }
    return k;
}

void recalc(long long v, long long p, long long h){
    long long rem = 0;
    if (v == p) return;
    while(par[v] != p){
        ans = ans - (long long) (h-1)*sub[v];
        sub[par[v]] -= sub[v] + rem;
        rem += sub[v];
        long long tmp = par[v];
        par[v] = p;
        v = tmp;
        h--;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, q;
    long long u, v;
    long long i, j;
    cin >> n >> q;
    for(i = 1; i < n; i++){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    long long p;
    for( i = 1; i <=q ; i++){
        cin >> p >> v;
        long long h = ret_h(v, p);
        recalc(v, p, h);
        cout << ans << "\n";

    }
    return 0;
}
