#include <bits/stdc++.h>
#define pb emplace_back
#define fir first
#define sec second
using i64 = long long;
using pii = std::pair<int, int>;
constexpr int maxn = 2e5 + 5;
int n, q, ans[maxn];
std::vector<std::pair<int, int>> qry[maxn];
std::vector<int> G[maxn];
struct Fenwick {
int c[maxn];
void add(int x, int y) {
for (; x <= n; x += x & -x) {
c[x] += y;
}
return;
}
int query(int x) {
int ans = 0;
for (; x; x -= x & -x) {
ans += c[x];
}
return ans;
}
} tr;
int main() {
freopen("icekingdom.in", "r", stdin);
freopen("icekingdom.out", "w", stdout);
std::cin.tie(nullptr)->sync_with_stdio(false);
std::cin >> n >> q;
for (int i = 1; i < n; ++i) {
int u, v;
std::cin >> u >> v;
if (u > v) std::swap(u, v);
G[v].pb(u);
}
for (int i = 1; i <= q; ++i) {
int l, r;
std::cin >> l >> r;
qry[r].pb(l, i);
}
for (int i = 1; i <= n; ++i) {
for (auto& v : G[i]) {
tr.add(v, 1);
}
for (auto& [l, idx] : qry[i]) {
ans[idx] = i - l + 1 - (tr.query(i) - tr.query(l - 1));
}
}
for (int i = 1; i <= q; ++i) {
std::cout << ans[i] << '\n';
}
return 0;
}