N = gets.to_i G = Hash.new { |h, k| h[k] = [] } (N - 1).times do u, v = gets.split.map(&:to_i) G[u] << v G[v] << u end def bfs(v, visited) queue = [v] until queue.empty? v = queue.shift visited[v] = true G[v].each do |u| next if visited[u] queue << u end end end visited = Hash.new(false) cnt = 0 N.times do |i| next if visited[i] cnt += 1 bfs(i, visited) end if cnt >= 3 puts 'Alice' elsif cnt == 1 puts 'Bob' else c = (0...N).count { |v| G[v].size == 2 } if c == N - 1 puts 'Bob' else puts 'Alice' end end