use std::io::Read; use std::collections::{HashMap, HashSet}; fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let all_data: Vec<&str> = all_data.trim().split('\n').map(|s| s.trim()).collect(); let n: usize = all_data.iter().next().unwrap().parse().unwrap(); let mut island2bridges: HashMap = HashMap::new(); let mut parents: Vec> = vec![None; n]; all_data.iter().skip(1).take(n) .map(|s| s.split_whitespace().map(|i| i.parse().unwrap()).collect::>()) .for_each(|ab| { let mut a = ab[0]; let mut b = ab[1]; let mut a_parents: Vec = vec![]; let mut b_parents: Vec = vec![]; while parents[a].is_some() { a_parents.push(a); a = parents[a].unwrap(); } while parents[b].is_some() { b_parents.push(b); b = parents[b].unwrap(); } if a != b { parents[b] = Some(a); } for i in a_parents { parents[i] = Some(a); } for i in b_parents { parents[i] = Some(a); } ab.iter().for_each(|i| { if let Some(x) = island2bridges.get_mut(&i) { *x += 1; } else { island2bridges.insert(*i, 1); } }); }); for i in 0..n { let mut start = i; while parents[start].is_some() { start = parents[start].unwrap(); } if start != i { parents[i] = Some(start); } } let none_count = n - island2bridges.len(); let diff_count = parents.iter().filter(|i| i.is_some()).collect::>>().len(); if none_count + diff_count == 1 { println!("Bob"); } else if none_count + diff_count >= 3 { println!("Alice"); } else { if island2bridges.values().min().unwrap() == &1 { println!("Alice"); } else { println!("Bob"); } } }