// #define DEBUGGING #include #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() using ll = std::int64_t; using ull = std::uint64_t; using PLL = std::pair; using TLL = std::tuple; template using V = std::vector; template using VV = V>; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } #define mv_rec make_v(init, tail...) template T make_v(T init) { return init; } template auto make_v(T init, size_t s, Tail... tail) { return V(s, mv_rec); } #undef mv_rec using namespace std; #ifdef DEBUGGING #include "../../debug/debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif struct LowLink { ll N; const VV &edges; V low, ord; V visited; V is_articulation; ll dfs_counter; LowLink(const VV &edges) : N(edges.size()), edges(edges), low(edges.size()), ord(edges.size()), visited(edges.size()), is_articulation(edges.size()), dfs_counter(0) { for (ll i = 0; i < N; i++) if (!visited[i]) dfs(i, -1); } void dfs(ll cur, ll pre) { visited[cur] = true; ord[cur] = dfs_counter++; low[cur] = ord[cur]; ll children = 0; bool art = false; for (ll nxt : edges[cur]) { if (!visited[nxt]) { children++; dfs(nxt, cur); chmin(low[cur], low[nxt]); art |= (pre == -1 ? 2 <= children : ord[cur] <= low[nxt]); } else if (nxt != pre) { chmin(low[cur], ord[nxt]); } } is_articulation[cur] = art; } bool is_art(ll cur) { return is_articulation[cur]; } // u -> v bool is_bridge(ll from, ll to) { return ord[from] < low[to]; } V enum_bridges() { V ret; for (ll from = 0; from < N; from++) { for (ll to : edges[from]) { if (!(from < to)) continue; if (is_bridge(from, to)) ret.emplace_back(from, to); } } return ret; } }; struct UnionFind { V rank; V parent; UnionFind(ll N) : rank(N, 0), parent(N) { iota(parent.begin(), parent.end(), 0ll); } ll find(ll child) { return (child == parent[child] ? child : parent[child] = find(parent[child])); } void unit(ll x, ll y) { ll px = find(x); ll py = find(y); if(px == py) { return; } if(rank[px] < rank[py]) { swap(px, py); } parent[py] = px; rank[px] += (rank[px] == rank[py]); } bool same(ll x, ll y) { return (find(x) == find(y)); } }; bool solve() { ll N; cin >> N; VV edges(N); UnionFind uf(N); for (ll i = 1; i < N; i++) { ll u, v; cin >> u >> v; uf.unit(u, v); edges[u].push_back(v); edges[v].push_back(u); } set pset; for (ll i = 0; i < N; i++) pset.insert(uf.find(i)); if (pset.size() == 1) return true; if (3 <= pset.size()) return false; LowLink low(edges); for (ll i = 0; i < N; i++) for (ll j : edges[i]) if (low.is_bridge(i, j)) return false; return true; } int main() { cout << (!solve() ? "Alice" : "Bob") << endl; return 0; }