package main import ( "bufio" "fmt" "os" "strconv" ) func getScanner(fp *os.File) *bufio.Scanner { scanner := bufio.NewScanner(fp) scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 500001), 500000) return scanner } func getNextString(scanner *bufio.Scanner) string { scanner.Scan() return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextUint64(scanner *bufio.Scanner) uint64 { i, _ := strconv.ParseUint(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout cnt := 0 if os.Getenv("MASPY") == "ますピ" { fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT")) cnt = 2 } if os.Getenv("MASPYPY") == "ますピッピ" { wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10")) } scanner := getScanner(fp) writer := bufio.NewWriter(wfp) solve(scanner, writer) for i := 0; i < cnt; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } writer.Flush() } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := getNextInt(scanner) uf := make([]int, n) dd := make([]int, n) for i := 0; i < n; i++ { uf[i] = i } for i := 0; i < n-1; i++ { u := getNextInt(scanner) v := getNextInt(scanner) dd[u]++ dd[v]++ r1 := root(u, uf) r2 := root(v, uf) if r1 < r2 { uf[r2] = r1 continue } uf[r1] = r2 } im := map[int]int{} for i := 0; i < n; i++ { r := root(i, uf) if im[r] == 0 || im[r] > dd[i] { im[r] = dd[i] } } if len(im) == 1 { fmt.Fprintln(writer, "Bob") return } if len(im) > 2 { fmt.Fprintln(writer, "Alice") return } for _, c := range im { if c == 1 { fmt.Fprintln(writer, "Alice") return } } fmt.Fprintln(writer, "Bob") } func root(i int, uf []int) int { if i == uf[i] { return i } uf[i] = root(uf[i], uf) return uf[i] }