#pragma GCC optimize("Ofast") #include #define rep(i,n) for(int i=0;i>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin() #define UB(a,x) ub(all(a),x)-a.begin() #define mod 1000000007 //#define mod 998244353 #define FS fixed< using V=vector; using Graph = vector>; using P=pair; typedef unsigned long long ull; typedef long double ldouble; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline void out(T a){ cout << a << '\n'; } void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;} //void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;} const ll INF=1e18; const int mx=200005; class UnionFind{ public: vector par,num; int find(ll v){ return (par[v]==v)? v: (par[v]=find(par[v])); } explicit UnionFind(ll N):par(N),num(N,1){ iota(par.begin(),par.end(),0); } void unite(ll u,ll v){ u=find(u),v=find(v); if(u==v)return ; if(num[u]>n; UnionFind uf(n); V a(n-1),b(n-1); rep(i,n-1){ //int a,b; cin>>a[i]>>b[i]; //a--;b--; uf.unite(a[i],b[i]); } set st; rep(i,n) st.insert(uf.find(i)); bool f=1; if(st.size()==2){ bool sz_1=0; rep(i,n){ if(uf.size(i)==1) sz_1=1; } if(sz_1){ UnionFind uf2(n); V deg(n,0); int pos; rep(i,n-1){ if(!uf2.same(a[i],b[i])){ uf2.unite(a[i],b[i]); deg[a[i]]++; deg[b[i]]++; }else pos=i; } bool dd=1; rep(i,n){ if(deg[i]>2) dd=0; } if(dd){ V aa; rep(i,n){ if(deg[i]==1) aa.push_back(i); } sort(all(aa)); V bb; bb.pb(a[pos]); bb.pb(b[pos]); sort(all(bb)); if(aa!=bb) f=0; } } }else if(st.size()==1) f=0; if(!f) out("Bob"); else out("Alice"); }