#include using namespace std; using ll = long long; struct LCA{ int n,m,cnt; vector > data,e; vector depth,vis; LCA(int n):n(n){ int ni = 1; cnt = 0; while(ni >(n,vector(cnt+1,-1)); e = vector >(n); depth = vector(n,-1); } void addedge(int a,int b){ e[a].push_back(b); e[b].push_back(a); } void dfs(int ni,int p,int now){ depth[ni] = now; data[ni][0] = p; vis[ni] = 1; for(int to:e[ni]) if(to!=p){ dfs(to,ni,now+1); } } void build(int root = 0){ vis = vector (n,0); dfs(root,-1,0); for(int i = 0;i depth[b]) swap(a,b); int need = depth[b] - depth[a]; int nj = 0; while (need!=0){ if(need&1) b = data[b][nj]; nj++; need >>= 1; } if(a==b) return a; int now = cnt; while(now>=0){ if(data[a][now]!=data[b][now]){ a = data[a][now]; b = data[b][now]; } now--; } return data[a][0]; } int dist(int a,int b){ int c = query(a,b); return depth[a] + depth[b] - 2*depth[c]; } int get(int i,int k){ int j = i; int now = 0; while(k){ if(k&1) j = data[j][now]; if(j==-1) return j; k>>=1; now++; } return j; } }; int n,q; vector g[2<<17]; vector sz[2<<17]; int nn[2<<17]; int d1(int ni,int p){ sort(g[ni].begin(),g[ni].end()); nn[ni]++; sz[ni] = vector(g[ni].size(),0); for(int i = 0;i>n>>q; LCA lca(n); for(int i = 0;i>u>>v; u--;v--; g[u].push_back(v); g[v].push_back(u); lca.addedge(u,v); } d1(0,-1); d2(0,-1,0); lca.build(); while(q--){ int x,y; cin>>x>>y; x--;y--; int t = lca.query(x,y); int dd = lca.dist(x,y); if(dd%2==1){ cout<<0<