#pragma once //# pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ll=long long; using ld=long double; using ull=unsigned long long; typedef pair P; #define vec vector #define pb emplace_back #define pcnt __builtin_popcountll #define rep(i,n) for(ll i=0;i<(n);i++) #define rng(i,s,t) for(ll i=s;i bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template void printvec(itr begin, itr end) { for (itr p = begin; p < end; p++){ if(p!=begin)cout<<" "; cout << *p; } cout << endl; } template T makevec(T value) {return value;} template 0), int> = 0> auto makevec(std::size_t n, Args... args) { auto inner = makevec(args...); return std::vector(n, inner); } #include"atcoder/all" using namespace atcoder; struct S{ long long val,idx; }; S op(S x,S y){ if(x.val>y.val)return y; return x; } S e() { return {LLONG_MAX,-1}; } struct LCA{ int N; vectorvs,depth,id,id_depth; vector> G; segtree seg; LCA(int n,vector>&g){ N=n; G=g; vs.resize(2*N-1);//DFSでの訪問順 depth.resize(2*N-1);// 訪問順での根からの深さ id.resize(N); //id[i]:iが初めて現れるindex id_depth.resize(N);//頂点iの深さ seg=segtree(2*N-1); int k=0; dfs(0,-1,0,k); rep(i,2*N-1){ seg.set(i,{depth[i],i}); } } int lca(int u,int v){ return vs[seg.prod(min(id[u],id[v]),max(id[u],id[v])+1).idx]; } void dfs(int now,int par,int d,int& k){ id[now]=k; id_depth[now]=d; vs[k]=now; depth[k++]=d; for(auto e:G[now]){ if(e==par)continue; dfs(e,now,d+1,k); vs[k]=now; depth[k++]=d; } } }; int main(){ ll n; cin>>n; vec>graph(n); vecu(n),v(n); rep(i,n-1){ cin>>u[i]>>v[i]; u[i]--; v[i]--; graph[u[i]].push_back(v[i]); graph[v[i]].push_back(u[i]); } LCA lca(n,graph); ll q; cin>>q; while(q--){ ll a,b; cin>>a>>b; a--; b--; ll target=lca.lca(a,b); if(a==target){ cout<<"Alice"<