package main import ( "bufio" "fmt" "os" "sort" "strconv" "strings" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, err := strconv.Atoi(sc.Text()) if err != nil { panic(err) } return i } func nextLine() string { sc.Scan() return sc.Text() } // Person ... type Person struct { H int W int Name string } // People ... type People []Person func (a People) Len() int { return len(a) } func (a People) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a People) Less(i, j int) bool { if a[i].H == a[j].H { return a[i].W < a[j].W } return a[i].H > a[j].H } func main() { var vs People alphas := []string{"A", "B", "C"} for i := 0; i < 3; i++ { c := strings.Split(nextLine(), " ") x, _ := strconv.Atoi(c[0]) y, _ := strconv.Atoi(c[1]) vs = append(vs, Person{ H: x, W: y, Name: alphas[i], }) } sort.Sort(People(vs)) for _, p := range vs { fmt.Println(p.Name) } }