package main

import (
	"bufio"
	"fmt"
	"os"
)

var n, m int
var alpha string
var graph [][]int
var used []bool
var ok []bool
var counts [][26]int
var best int

func dfs(v int) {
	used[v] = true
	for _, g := range graph[v] {
		if !used[g] {
			dfs(g)
		}
		for j := 0; j < 26; j++ {
			if counts[v][j] < counts[g][j] {
				counts[v][j] = counts[g][j]
			}
		}
	}
	counts[v][alpha[v] - 'a']++
}

func cycle(v int) bool {
	used[v] = true
	c := false
	for _, vnext := range graph[v] {
		if used[vnext] {
			return true
		}
		if !ok[vnext] {
			c = cycle(vnext)
			if c {
				return c
			}
		}
	}
	used[v] = false
	ok[v] = true
	return false
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n%s\n", &n, &m, &alpha)
	graph = make([][]int, n)
	used = make([]bool, n)
	ok = make([]bool, n)
	counts = make([][26]int, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		if t1 == t2 {
			fmt.Println(-1)
			return
		}

		graph[t1] = append(graph[t1], t2)
	}
	for i := 0; i < n; i++ {
		if !ok[i] && cycle(i) {
			fmt.Println("-1")
			return
		}
	}
	for i := 0; i < n; i++ {
		used[i] = false
	}
	for i := 0; i < n; i++ {
		if !used[i] {
			dfs(i)
		}
		for j := 0; j < 26; j++ {
			if counts[i][j] > best {
				best = counts[i][j]
			}
		}
	}
	fmt.Println(best)
}

package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF919D(_r io.Reader, _w io.Writer) {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b || b > '9'; b = rc() {
		}
		for ; '0' <= b && b <= '9'; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rs := func(n int) []byte {
		b := rc()
		for ; 'a' > b || b > 'z'; b = rc() {
		}
		s := make([]byte, 1, n)
		s[0] = b
		for i := 1; i < n; i++ {
			s = append(s, rc())
		}
		return s
	}
	n, m := r(), r()
	s := rs(n)
	g := make([][]int, n)
	d := make([]int, n)
	for ; m > 0; m-- {
		v, w := r()-1, r()-1
		g[v] = append(g[v], w)
		d[w]++
	}

	ans := 1
	dp := make([][26]int, n)
	q := []int{}
	for i, v := range d {
		if v == 0 {
			q = append(q, i)
			dp[i][s[i]-'a'] = 1
		}
	}
	c := 0
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		c++
		for _, w := range g[v] {
			for i, dv := range dp[w] {
				x := 0
				if byte(i) == s[w]-'a' {
					x = 1
				}
				if dv < dp[v][i]+x {
					dp[w][i] = dp[v][i] + x
					if dp[w][i] > ans {
						ans = dp[w][i]
					}
				}
			}
			d[w]--
			if d[w] == 0 {
				q = append(q, w)
			}
		}
	}
	if c < n {
		ans = -1
	}
	Fprint(_w, ans)
}

func main() { CF919D(os.Stdin, os.Stdout) }

package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF919D(_r io.Reader, _w io.Writer) {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b || b > '9'; b = rc() {
		}
		for ; '0' <= b && b <= '9'; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rs := func(n int) []byte {
		b := rc()
		for ; 'a' > b || b > 'z'; b = rc() {
		}
		s := make([]byte, n)
		s[0] = b
		for i := 1; i < n; i++ {
			s[i] = rc()
		}
		return s
	}
	n, m := r(), r()
	s := rs(n)
	g := make([][]int, n)
	d := make([]int, n)
	for ; m > 0; m-- {
		v, w := r()-1, r()-1
		g[v] = append(g[v], w)
		d[w]++
	}

	ans := 1
	dp := make([][26]int, n)
	q := []int{}
	for i, v := range d {
		if v == 0 {
			q = append(q, i)
			dp[i][s[i]-'a'] = 1
		}
	}
	c := 0
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		c++
		for _, w := range g[v] {
			for i, dv := range dp[w] {
				x := 0
				if byte(i) == s[w]-'a' {
					x = 1
				}
				if dv < dp[v][i]+x {
					dp[w][i] = dp[v][i] + x
					if dp[w][i] > ans {
						ans = dp[w][i]
					}
				}
			}
			d[w]--
			if d[w] == 0 {
				q = append(q, w)
			}
		}
	}
	if c < n {
		ans = -1
	}
	Fprint(_w, ans)
}

func main() { CF919D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF919D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, v, w, c int
	var s []byte
	Fscan(in, &n, &m, &s)
	g := make([][]int, n)
	d := make([]int, n)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		d[w]++
	}

	ans := 1
	dp := make([][26]int, n)
	q := []int{}
	for i, v := range d {
		if v == 0 {
			q = append(q, i)
			dp[i][s[i]-'a'] = 1
		}
	}
	for len(q) > 0 {
		v, q = q[0], q[1:]
		c++
		for _, w := range g[v] {
			for i, dv := range dp[w] {
				x := 0
				if byte(i) == s[w]-'a' {
					x = 1
				}
				if dv < dp[v][i]+x {
					dp[w][i] = dp[v][i] + x
					if dp[w][i] > ans {
						ans = dp[w][i]
					}
				}
			}
			d[w]--
			if d[w] == 0 {
				q = append(q, w)
			}
		}
	}
	if c < n {
		ans = -1
	}
	Fprint(_w, ans)
}

func main() { CF919D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

var n, m int
var alpha string
var graph [][]int
var used []bool
var ok []bool
var counts [][26]int
var best int

func dfs(v int) {
	used[v] = true
	for _, g := range graph[v] {
		if !used[g] {
			dfs(g)
			for j := 0; j < 26; j++ {
				if counts[v][j] < counts[g][j] {
					counts[v][j] = counts[g][j]
				}
			}
		}
	}
	counts[v][alpha[v] - 'a']++
}

func cycle(v int) bool {
	used[v] = true
	c := false
	for _, vnext := range graph[v] {
		if used[vnext] {
			return true
		}
		if !ok[vnext] {
			c = cycle(vnext)
			if c {
				return c
			}
		}
	}
	used[v] = false
	ok[v] = true
	return false
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n%s\n", &n, &m, &alpha)
	graph = make([][]int, n)
	used = make([]bool, n)
	ok = make([]bool, n)
	counts = make([][26]int, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		if t1 == t2 {
			fmt.Println(-1)
			return
		}

		graph[t1] = append(graph[t1], t2)
	}
	for i := 0; i < n; i++ {
		if !ok[i] && cycle(i) {
			fmt.Println("-1")
			return
		}
	}
	for i := 0; i < n; i++ {
		used[i] = false
	}
	for i := 0; i < n; i++ {
		if !used[i] {
			dfs(i)
		}
		for j := 0; j < 26; j++ {
			if counts[i][j] > best {
				best = counts[i][j]
			}
		}
	}
	fmt.Println(best)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var n, m int
var alpha string
var graph [][]int
var used []bool
var ok []bool
var counts [][26]int
var best int

func dfs(v int) {
	counts[v][alpha[v] - 'a']++
	used[v] = true
	for _, g := range graph[v] {
		if !used[g] {
			dfs(g)
			for j := 0; j < 26; j++ {
				counts[v][j] += counts[g][j]
			}
		}
	}
}

func cycle(v int) bool {
	used[v] = true
	c := false
	for _, vnext := range graph[v] {
		if !ok[vnext] {
			if used[vnext] {
				return true
			}
			c = c && cycle(vnext)
			if !c {
				return c
			}
		}
	}
	used[v] = false
	ok[v] = true
	return false
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n%s\n", &n, &m, &alpha)
	graph = make([][]int, n)
	used = make([]bool, n)
	ok = make([]bool, n)
	counts = make([][26]int, n)
	for i := 0; i < m; i++ {
		var t1, t2 int
		fmt.Fscanf(buf, "%d %d\n", &t1, &t2)
		t1--
		t2--
		graph[t1] = append(graph[t1], t2)
	}
	for i := 0; i < n; i++ {
		if !used[i] && cycle(i) {
			fmt.Println("-1")
			return
		}
	}
	for i := 0; i < n; i++ {
		used[i] = false
	}
	for i := 0; i < n; i++ {
		if !used[i] {
			dfs(i)
		}
		for j := 0; j < 26; j++ {
			if counts[i][j] > best {
				best = counts[i][j]
			}
		}
	}
	fmt.Println(best)
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var k, x, n, m int64
	fmt.Scan(&k, &x, &n, &m)
	var fa, fb int64 = 1, 1
	for i := int64(3); i < k; i++ {
		fa, fb = fb, fa+fb
	}
	var fbb, fx int64 = 0, 1
	for i := int64(4); i < k; i++ {
		fbb, fx = fx, fbb+fx+i%2
	}
	for s1 := int64(0); s1 <= n/2; s1++ {
		for s2 := int64(0); s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2)))
				fmt.Println(strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2)))
				return
			}
			if m-s2*2 > 1 {
				if s1*fa+s2*fb+fbb == x {
					fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2)))
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 1 {
				if (s1+1*fa)-k%2+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)))
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-1)))
					return
				} else if (s1+1)*fa-k%2+s2*fb == x {
					fmt.Println("C" + strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)))
					fmt.Println(strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-1)) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 1 {
				if (s1+1)*fa+s2*fb+fbb == x {
					fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-k%2+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-2)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

// A B AB BAB ABBAB BABABBAB ABBABBABABBAB BABABBABABBABBABABBAB ABBABBABABBABBABABBABABBABBABABBAB BABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB ABBABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBABABBABBABABBABBABABBABABBABBABABBAB
// 1 1 3 4 8 12 21
// AZA
// CA
// AZACA
// CAAZACA
// AZACACAAZACA
// CAAZACAAZACACAAZACA

package main

import (
	"fmt"
	"strings"
)

func main() {
	var k, x, n, m int64
	fmt.Scan(&k, &x, &n, &m)
	var fa, fb int64 = 1, 1
	for i := int64(3); i < k; i++ {
		fa, fb = fb, fa+fb
	}
	var fbb, fx int64 = 0, 1
	for i := int64(4); i < k; i++ {
		fbb, fx = fx, fbb+fx+i%2
	}
	for s1 := int64(0); s1 <= n/2; s1++ {
		for s2 := int64(0); s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2)))
				fmt.Println(strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2)))
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-1)))
					return
				} else if (s1+1)*fa-k%2+s2*fb == x {
					fmt.Println("C" + strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)))
					fmt.Println(strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-1)) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 1 {
				if (s1+1)*fa+s2*fb+fbb == x {
					fmt.Println(strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-1)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-k%2+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", int(s1)) + strings.Repeat("B", int(n-s1*2-2)) + "A")
					fmt.Println("C" + strings.Repeat("AC", int(s2)) + strings.Repeat("B", int(m-s2*2-2)) + "A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fbb, fx, fa, fb := 0, 0, 1, 1
	for i := 3; i < k; i++ {
		fbb, fx, fa, fb = fx, fa, fb, fa+fb
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2))
				fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2))
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1))
					return
				} else if (s1+1)*fa-k%2+s2*fb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1))
					fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 1 {
				if (s1+1)*fa+s2*fb+fbb == x {
					fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-2) + "A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-k%2+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-2) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-2) + "A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fbb, fa, fb := 0, 1, 1
	for k > 3 {
		fbb, fa, fb = fa, fb, fa+fb
		k--
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2))
				fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2))
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1))
					return
				} else if (s1+1)*fa-1+s2*fb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1))
					fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1) + "A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-1+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-2) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-2) + "A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

package main

import (
	"fmt"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fa, fb := 1, 1
	for k > 3 {
		fa, fb = fa, fa+fb
		k--
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				i := ac(s1)
				for i < n {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				i = ac(s2)
				for i < m {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if 2*s1*fa+s2*fb == x {
					i := ac(s1)
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					return
				} else if (2*s1-1)*fa+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					i = ac(s2)
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (3*s1-1)*fa+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

func ac(n int) int {
	for i := 0; i < n; i++ {
		fmt.Print("AC")
	}
	return 2 * n
}

// A B AB ABB ABBAB ABBABABB ABBABABBABBAB ABBABABBABBABABBABABB ABBABABBABBABABBABABBABBABABBABBAB
// f_k*x + f_{k+1}*y

package main

import (
	"fmt"
	"strings"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fa, fb := 1, 1
	for i := 3; i < k; i++ {
		fa, fb = fb, fa+fb
	}
	fbb, fx := 0, 1
	for i := 4; i < k; i++ {
		fbb, fx = fx, fbb+fx+i%2
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2))
				fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2))
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1))
					return
				} else if (s1+1)*fa-k%2+s2*fb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1))
					fmt.Println(strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-1) + "A")
					return
				}
			}
			if n-s1*2 > 0 && m-s2*2 > 1 {
				if (s1+1)*fa+s2*fb+fbb == x {
					fmt.Println(strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-1) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-2) + "A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-k%2+s2*fb+fbb == x {
					fmt.Println("C" + strings.Repeat("AC", s1) + strings.Repeat("B", n-s1*2-2) + "A")
					fmt.Println("C" + strings.Repeat("AC", s2) + strings.Repeat("B", m-s2*2-2) + "A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

package main

import (
	"fmt"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fa, fb := 1, 1
	for k > 3 {
		fa, fb = fb, fa+fb
		k--
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				i := ac(s1)
				for i < n {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				i = ac(s2)
				for i < m {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					i := ac(s1)
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					return
				} else if (s1+1)*fa-1+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					i = ac(s2)
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-1+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

func ac(n int) int {
	for i := 0; i < n; i++ {
		fmt.Print("AC")
	}
	return 2 * n
}

package main

import (
	"fmt"
)

func main() {
	var k, x, n, m int
	fmt.Scan(&k, &x, &n, &m)
	fa, fb := 1, 1
	for k > 3 {
		fa, fb = fa, fa+fb
		k--
	}
	for s1 := 0; s1 <= n/2; s1++ {
		for s2 := 0; s2 <= m/2; s2++ {
			if s1*fa+s2*fb == x {
				i := ac(s1)
				for i < n {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				i = ac(s2)
				for i < m {
					fmt.Print("B")
					i++
				}
				fmt.Println()
				return
			}
			if n-s1*2 > 0 && m-s2*2 > 0 {
				if (s1+1)*fa+s2*fb == x {
					i := ac(s1)
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					return
				} else if (s1+1)*fa-1+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n {
						fmt.Print("B")
						i++
					}
					fmt.Println()
					i = ac(s2)
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
			if n-s1*2 > 1 && m-s2*2 > 1 {
				if (s1+2)*fa-1+s2*fb == x {
					fmt.Print("C")
					i := ac(s1) + 1
					for i < n-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					fmt.Print("C")
					i = ac(s2) + 1
					for i < m-1 {
						fmt.Print("B")
						i++
					}
					fmt.Println("A")
					return
				}
			}
		}
	}
	fmt.Println("Happy new year!")
}

func ac(n int) int {
	for i := 0; i < n; i++ {
		fmt.Print("AC")
	}
	return 2 * n
}

// A B AB ABB ABBAB ABBABABB ABBABABBABBAB ABBABABBABBABABBABABB ABBABABBABBABABBABABBABBABABBABBAB
// f_k*x + f_{k+1}*y


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(n int64, m int64, k int) string {
	max := int64(n*(n-1)) >> 1
	if n == 1 {
		if k > 1 {
			return "YES"
		} else {
			return "NO"
		}
	} else if m < max {
		if k > 3 {
			return "YES"
		} else {
			return "NO"
		}
	} else if k > 2 {
		return "YES"
	} else {
		return "NO"
	}
}
func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var k int
	var n, m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n * (n - 1) / 2)
		if m > max || m < n-1 {
			Fprintln(out, "NO")
			continue
		}
		Fprintln(out, solve(n, m, k))
		//     switch k {
		//     case 0:
		//     case 1:
		//         Fprintln(out, "NO")
		//     case 2:
		//         if n == 1 {
		//             Fprintln(out, "YES")
		//         } else {
		//             Fprintln(out, "NO")
		//         }
		//     case 3:
		//         if m == max {
		//             Fprintln(out, "YES")
		//         } else {
		//             Fprintln(out, "NO")
		//         }
		//     default:
		//         Fprintln(out, "YES")
		//     }
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(n int64, m int64, k int) string {
	max := int64(n * (n - 1) / 2)
	if n == 1 {
		if k > 1 {
			return "YES"
		} else {
			return "NO"
		}
	} else if m < max {
		if k > 3 {
			return "YES"
		} else {
			return "NO"
		}
	} else if k > 2 {
		return "YES"
	} else {
		return "NO"
	}
}
func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var k int
	var n, m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n * (n - 1) / 2)
		if m > max || m < n-1 {
			Fprintln(out, "NO")
			continue
		}
		// Fprintln(out, solve(n, m, k))
		switch k {
		// Fprintln(out, "NO")
		case 0, 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"os"
)

func main() {
	var t int64
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	read_int64 := func() (x int64) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int64(c-'0')
		}
		return
	}
	t = read_int64()
	for ; t > 0; t-- {
		var n, m, k int64
		ans := false
		n = read_int64()
		m = read_int64()
		k = read_int64()
		if 1 == n {
			if k >= 2 && 0 == m {
				ans = true
			}
		} else if 3 == k {
			if m == n*(n-1)/2 {
				ans = true
			}
		} else if k >= 4 {
			if m >= n-1 && m <= n*(n-1)/2 {
				ans = true
			}
		}
		if ans {
			out.WriteString("YES\n")
		} else {
			out.WriteString("NO\n")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, k int
	var n, m int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m, &k)
		if m < n-1 || m > n*(n-1)/2 {
			Fprintln(out, "NO")
			continue
		}
		d := 0
		if n > 1 {
			if m == n*(n-1)/2 {
				d = 1
			} else {
				d = 2
			}
		}
		if d < k-1 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1581B(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {

		var n, m, k int64
		fmt.Fscan(input, &n, &m, &k)

		// ARRAY := make([]int, n)
		// for i := 0; i < n; i++ {
		// 	fmt.Fscan(input, &ARRAY[i])

		// }

		// String := make([]byte, 0)
		// fmt.Fscan(input, &String)

		if m < n-1 || m > n*(n-1)/2 {
			fmt.Println("NO")
		} else {
			if k <= 1 {
				fmt.Println("NO")
			} else {
				if k == 2 {
					if n == 1 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				} else {
					if k == 3 {
						if m == n*(n-1)/2 {
							fmt.Println("YES")
						} else {
							fmt.Println("NO")
						}
					} else {
						fmt.Println("YES")
					}
				}
			}

		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 2000005
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}
func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}
func solve() {
	t := iost.GetNextInt()
	for i := 0; i < t; i++ {
		testcase()
	}
}
func testcase() {
	n := iost.GetNextInt64()
	m := iost.GetNextInt64()
	k := iost.GetNextInt64()
	if m+1 < n {
		iost.Println("NO")
		return
	}
	if m > n*(n-1)/2 {
		iost.Println("NO")
		return
	}
	switch k {
	case 0, 1:
		iost.Println("NO")
	case 2:
		if n == 1 {
			iost.Println("YES")
			return
		}
		iost.Println("NO")
	case 3:
		if m == n*(n-1)/2 {
			iost.Println("YES")
			return
		}
		iost.Println("NO")
	default:
		iost.Println("YES")
	}

}

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int64

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}
	if m > n * (n - 1)/2 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}

	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == (n * (n - 1))/2 {
			return "YES"
		}
		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}
	if m > n * (n - 1)/2 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}

	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == (n * (n - 1))/2 {
			return "YES"
		}
		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}
	if m > n * (n - 1)/2 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}

	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == (n * (n - 1))/2 {
			return "YES"
		}
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}
	if m > n * (n - 1)/2 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if m == (n * (n - 1))/2 {
		if k >= 3 {
			return "YES"
		}
		return "NO"
	}

	if k > 3 {
		return "YES"
	}

	return "NO"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}
	if m > n * (n - 1)/2 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k >= 3 {
		if m == (n * (n - 1))/2 {
			return "YES"
		}

		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == (n * (n - 1))/2 {
			return "YES"
		}

		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == n * (n - 1)/2 {
			return "YES"
		}
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if k == 3 {
		if m == n * (n - 1)/2 {
			return "YES"
		}
		return "NO"
	}

	return "YES"

}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 {
		return "NO"
	}
	if k == 2 {
		if n == 1 {
			return "YES"
		}
		return "NO"
	}

	if m == (n * (n - 1))/2 {
		if k >= 3 {
			return "YES"
		}
		return "NO"
	}

	if k >= 4 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 || k == 2{
		return "NO"
	}

	if m == n * (n - 1)/2 {
		if k >= 3 {
			return "YES"
		}
		return "NO"
	}

	if k - 1 >=3 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1 || k == 2{
		return "NO"
	}

	if m == n * (n - 1)/2 {
		if k - 1 >= 1 {
			return "YES"
		}
		return "NO"
	}

	if k - 1 >=3 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 || k == 1{
		return "NO"
	}
	if k == 2 {
		if m == 0 {
			return "YES"
		}
		return "NO"
	}

	if m == n * (n - 1)/2 {
		if k - 1 >= 1 {
			return "YES"
		}
		return "NO"
	}

	if k - 1 >=3 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if k == 0 {
		return "NO"
	}
	if k == 1 {
		if m == 0 {
			return "YES"
		}
		return "NO"
	}

	if m == n * (n - 1)/2 {
		if k - 1 >= 1 {
			return "YES"
		}
		return "NO"
	}

	if k - 1 >=3 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	"os"
	"fmt"
)

var n, m, k int

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &k)

		fmt.Println(solve())
	}
}

func solve() string {
	if m < n - 1 {
		return "NO"
	}

	if m == n * (n - 1)/2 {
		if k - 1 >= 1 {
			return "YES"
		}
		return "NO"
	}

	if k - 1 >=3 {
		return "YES"
	}
	return "NO"
}

// k = 3,  d < 2, k >= 4

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(n int64, m int64, k int) string {
	max := int64(n * (n - 1) / 2)
	if n == 1 {
		if k > 1 {
			return "YES"
		} else {
			return "NO"
		}
	} else if m < max {
		if k > 3 {
			return "YES"
		} else {
			return "NO"
		}
	} else if k > 2 {
		return "YES"
	} else {
		return "NO"
	}
}
func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var k int
	var n, m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n * (n - 1) / 2)
		if m > max || m < n-1 {
			Fprintln(out, "NO")
			continue
		}
		// Fprintln(out, solve(n, m, k))
		switch k {
		case 0:
		case 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(n int, m int64, k int) string {
	max := int64(n*(n-1)) >> 1
	if n == 1 {
		if k > 1 {
			return "YES"
		} else {
			return "NO"
		}
	} else if m < max {
		if k > 3 {
			return "YES"
		} else {
			return "NO"
		}
	} else if k > 2 {
		return "YES"
	} else {
		return "NO"
	}
}
func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, k int
	var m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n*(n-1)) >> 1
		if m > max || m < int64(n-1) {
			Fprintln(out, "NO")
			continue
		}
		Fprintln(out, solve(n, m, k))
		//     switch k {
		//     case 0:
		//     case 1:
		//         Fprintln(out, "NO")
		//     case 2:
		//         if n == 1 {
		//             Fprintln(out, "YES")
		//         } else {
		//             Fprintln(out, "NO")
		//         }
		//     case 3:
		//         if m == max {
		//             Fprintln(out, "YES")
		//         } else {
		//             Fprintln(out, "NO")
		//         }
		//     default:
		//         Fprintln(out, "YES")
		//     }
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, k int
	var m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n*(n-1)) >> 1
		if m > max || m < int64(n-1) {
			Fprintln(out, "NO")
			continue
		}
		switch k {
		case 0:
		case 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, k int
	var m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := int64(n) * int64((n-1)>>1)
		if m > max || m < int64(n-1) {
			Fprintln(out, "NO")
			continue
		}
		switch k {
		case 0:
		case 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, m, k int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := (n * (n - 1)) >> 1
		if m > max || m < n-1 {
			Fprintln(out, "NO")
			continue
		}
		switch k {
		case 0:
		case 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func CF1581B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, m, k int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m, &k)
		max := (n * (n - 1)) >> 1
		if m > max {
			Fprintln(out, "NO")
			continue
		}
		switch k {
		case 0:
		case 1:
			Fprintln(out, "NO")
		case 2:
			if n == 1 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		case 3:
			if m == max {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		default:
			Fprintln(out, "YES")
		}
	}
}

func main() {
	CF1581B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		var n, m, k int
		ans := false
		n = read_int()
		m = read_int()
		k = read_int()
		if 1 == n {
			if k >= 2 && 0 == m {
				ans = true
			}
		} else if 3 == k {
			if m == n*(n-1)/2 {
				ans = true
			}
		} else if k >= 4 {
			if m >= n-1 && m <= n*(n-1)/2 {
				ans = true
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	read_int := func() (x int) {
		c, _ := in.ReadByte()
		for ; c < '0'; c, _ = in.ReadByte() {
		}
		for ; c >= '0'; c, _ = in.ReadByte() {
			x = x*10 + int(c-'0')
		}
		return
	}
	t = read_int()
	for ; t > 0; t-- {
		var n, m, k int
		ans := false
		n = read_int()
		m = read_int()
		k = read_int()
		if 1 == n {
			if k >= 2 {
				ans = true
			}
		} else if 3 == k {
			if m == n*(n-1)/2 {
				ans = true
			}
		} else if k >= 4 {
			if m >= n-1 && m <= n*(n-1)/2 {
				ans = true
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


package main

import (
	. "fmt"
	. "math/big"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	const mx = 1e3
	ps := []int{}
	v := [mx]bool{}
	for i := 2; i < mx; i++ {
		if !v[i] {
			ps = append(ps, i)
			for j := 2 * i; j < mx; j += i {
				v[j] = true
			}
		}
	}
	upper := NewInt(1e18)

	var t int
	var g int64
	for Scan(&t); t > 0; t-- {
		ans := 1
		es := [mx]int{}
		for i := 0; i < 22; i++ {
			checks := []int64{}
			q := NewInt(1)
		o:
			for _, p := range ps {
				if e := es[p]; e >= 0 {
					for ; e >= 0; e-- {
						p := NewInt(int64(p))
						if new(Int).Mul(q, p).Cmp(upper) > 0 {
							break o
						}
						q.Mul(q, p)
					}
					checks = append(checks, int64(p))
				}
			}
			Println("?", q.Int64())
			Scan(&g)
			for _, p := range checks {
				e := 0
				for ; g%p == 0; g /= p {
					e++
				}
				if e > es[p] {
					es[p] = e
					if i == 21 {
						ans *= e + 1
					}
				} else {
					es[p] = -1
					ans *= e + 1
				}
			}
		}
		ans *= 2
		if ans < 8 {
			ans = 8
		}
		Println("!", ans)
	}
}

package main

import (
	. "fmt"
	"math/big"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	const mx int = 1e3
	ps := []int{}
	isP := [mx]bool{}
	for i := range isP {
		isP[i] = true
	}
	isP[0], isP[1] = false, false
	for i := 2; i < mx; i++ {
		if isP[i] {
			ps = append(ps, i)
			for j := 2 * i; j < mx; j += i {
				isP[j] = false
			}
		}
	}
	upper := big.NewInt(1e18)

	var t int
	var g int64
	for Scan(&t); t > 0; t-- {
		ans := 1
		es := [mx]int{}
		for i := 0; i < 22; i++ {
			checks := []int64{}
			q := big.NewInt(1)
		o:
			for _, p := range ps {
				if e := es[p]; e >= 0 {
					for ; e >= 0; e-- {
						p := big.NewInt(int64(p))
						if new(big.Int).Mul(q, p).Cmp(upper) > 0 {
							break o
						}
						q.Mul(q, p)
					}
					checks = append(checks, int64(p))
				}
			}
			Println("?", q.Int64())
			Scan(&g)
			for _, p := range checks {
				e := 0
				for ; g%p == 0; g /= p {
					e++
				}
				if e > es[p] {
					es[p] = e
					if i == 21 {
						ans *= e + 1
					}
				} else {
					es[p] = -1
					ans *= e + 1
				}
			}
		}
		ans *= 2
		if ans < 8 {
			ans = 8
		}
		Println("!", ans)
	}
}

package main

import (
	. "fmt"
	"math/big"
)

// github.com/EndlessCheng/codeforces-go
func CF1355F() {
	const mx int = 1e3
	primes := []int{}
	isP := [mx]bool{}
	for i := range isP {
		isP[i] = true
	}
	isP[0], isP[1] = false, false
	for i := 2; i < mx; i++ {
		if isP[i] {
			primes = append(primes, i)
			for j := 2 * i; j < mx; j += i {
				isP[j] = false
			}
		}
	}
	upper := big.NewInt(1e18)

	var t int
	var g int64
	for Scan(&t); t > 0; t-- {
		ans := 1
		es := [mx]int{}
		for i := 0; i < 22; i++ {
			checks := []int64{}
			q := big.NewInt(1)
		o:
			for _, p := range primes {
				if e := es[p]; e >= 0 {
					for ; e >= 0; e-- {
						p := big.NewInt(int64(p))
						if new(big.Int).Mul(q, p).Cmp(upper) > 0 {
							break o
						}
						q.Mul(q, p)
					}
					checks = append(checks, int64(p))
				}
			}
			Println("?", q.Int64())
			Scan(&g)
			for _, p := range checks {
				e := 0
				for ; g%p == 0; g /= p {
					e++
				}
				if e > es[p] {
					es[p] = e
					if i == 21 {
						ans *= e + 1
					}
				} else {
					es[p] = -1
					ans *= e + 1
				}
			}
		}
		ans *= 2
		if ans < 8 {
			ans = 8
		}
		Println("!", ans)
	}
}

func main() { CF1355F() }


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t int
	var n, a, b int
	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n, &a, &b)
		var s strings.Builder
		alph := 'a'
		countUnique := 0
		strlen := 0
		for i := 0; i < n; i++ {
			if countUnique < b-1 {
				s.WriteString(string(alph))
				countUnique++
				strlen++
				alph++
			} else {
				for ; i < n && strlen < a; i++ {
					s.WriteString(string(alph))
					strlen++
				}
				break
			}
		}
		temp := s.String()
		for i := 0; i < n/a; i++ {
			s.WriteString(temp)
		}
		sol := s.String()
		Fprintln(out, sol[:n])
	}
}

func main() {
	run(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, a, b int
		fmt.Fscan(in, &n, &a, &b)
		for i := 0; i < n; i++ {
			fmt.Fprint(out, string('a'+i%b))
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, a, b int
		fmt.Fscan(in, &n, &a, &b)
		for i := 0; i < n; i++ {
			if i%a < b {
				fmt.Fprint(out, string('a'+i%a))
			} else {
				fmt.Fprint(out, string('a'))
			}
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

var letters = []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n, a, b int
	scanf("%d %d %d\n", &n, &a, &b)

	j := 0
	k := 0
	for i := 0; i < n; i++ {
		if j == a {
			j = 0
			k = 0
		}
		printf("%s", string(letters[k]))
		j++
		if k != b-1 {
			k++
		}
	}
	printf("\n")
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in, err := os.Open("input.txt")
	if err == nil {
		os.Stdin = in
	}

	var t int
	fmt.Scan(&t)

	for ; t > 0; t-- {
		var n, a, b int
		fmt.Scan(&n, &a, &b)

		for i := 0; i < n; i++ {
			fmt.Printf("%c", 'a'+i%b)
		}
		fmt.Printf("\n")
	}
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strings"
)

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()

    var t, n, a, b int
    fmt.Fscan(in, &t)
    for ;t >0; t-- {
        fmt.Fscan(in, &n, &a, &b)
        var s strings.Builder
        for i := 0; i < n; i++ {
            s.WriteRune(rune('a' + i%b))
        }
        fmt.Fprintln(out, s.String())
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(n int, a int, b int) string {
	firstLetter := byte('a')
	res := make([]byte, n)
	subStr := make([]byte, a)
	j := 0

	for i := range subStr {
		subStr[i] = (firstLetter + byte(j%b))
		j++
	}

	j = 0
	for i := range res {
		res[i] = subStr[j%a]
		j++
	}

	return string(res)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var t, n, a, b int
	fmt.Fscanf(r, "%d\n", &t)

	for tc := 0; tc < t; tc++ {
		fmt.Fscanf(r, "%d %d %d\n", &n, &a, &b)
		fmt.Fprintf(os.Stdout, "%s\n", solve(n, a, b))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const N = 2020
var nt, n, a, b int
var s[N] uint8

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &nt)
	for nt > 0 {
		nt--
		fmt.Fscanf(reader, "%d %d %d\n", &n, &a, &b)
		for i := 0; i < a; i++ {
			s[i] = uint8('a' + i % b)
		}
		for i := a; i < n; i++ {
			s[i] = s[i % a]
		}
		for i := 0; i < n; i++ {
			fmt.Fprintf(writer,"%c", s[i])
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

import (
	"fmt"
)

func main() {
	alphbet:= [26]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	var t int
	fmt.Scan(&t)
	for j := 0; j < t; j++ {
		var n, a, b int
		fmt.Scan(&n, &a, &b)
		var k int
		k = 0
		var s string
		s = ""
		for i := 0; i < n; i++ {
			s += alphbet[k]
			if k < b-1 {
				k++
			} else {
				k = 0
			}
		}
		fmt.Println(s)
	}
}

package main

import (
	"bytes"
	"fmt"
)

func main() {
	var t, n, a, b int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &a, &b)
		var buf bytes.Buffer
		for j := 0; j < a; j++ {
			if j < b {
				buf.WriteByte(byte('a' + j))
			} else {
				buf.WriteByte('a')
			}
		}
		pattern := buf.String()
		for j := 0; j < (n-1)/a; j++ {
			buf.WriteString(pattern)
		}
		fmt.Println(buf.String()[0:n])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime"
	"strconv"
	"strings"
)

func repeater(num int64, rep []byte) string {
	result := make([]byte, num)
	copy(result, rep)
	for bp := len(rep); bp < len(result); bp *= 2 {
		copy(result[bp:], result[:bp])
	}
	return string(result)
}

func main() {
	var truncator string
	if runtime.GOOS == "windows" {
		truncator = "\r\n"
	} else {
		truncator = "\n"
	}
	lowercase := []byte("abcdefghijklmnopqrstuvwxyz")

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimSuffix(text, truncator)
	testcase, _ := strconv.ParseInt(text, 10, 64)

	var i int64
	input := make([][]int64, testcase)
	result := make([]string, testcase)
	for i = 0; i < testcase; i++ {
		input[i] = readInt(3, reader)
		usinglower := lowercase[0:input[i][2]]
		result[i] = repeater(input[i][0], usinglower)
	}

	output := strings.Join(result, "\n")
	fmt.Printf("%s\n", output)
}

func readInt(size int, reader *bufio.Reader) []int64 {
	text, _ := reader.ReadString('\n')
	split := strings.Fields(text)
	result := make([]int64, len(split))
	for i := range result {
		result[i], _ = strconv.ParseInt(split[i], 10, 64)
	}
	return result
}

// Author: sighduck
// URL: https://codeforces.com/contest/1335/problem/B

package main

import (
	"bufio"
	"fmt"
	"os"
)

func Solve(n, a, b int) string {
	letters := "abcdefghijklmnopqrstuvwxyz"
	order := letters[:b]
	ans := make([]byte, n)
	for i := 0; i < n; i++ {
		ans[i] = order[i%b]
	}
	return string(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n, a, b int
		fmt.Fscanf(reader, "%d %d %d\n", &n, &a, &b)
		fmt.Fprintf(writer, "%s\n", Solve(n, a, b))
	}
}

package main

import (
    "bufio"
    "fmt"
    "io"
    "os"
)

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n, a, b := reader.NextInt64(), reader.NextInt64(), reader.NextInt64()
        writer.Printf("%s\n", sol(n, a, b))
    }
}

func sol(n, a, b int64) string {
    s := formString(a, b)
    ret := []byte{}
    ptr := 0
    for ; n > 0; n-- {
        ret = append(ret, s[ptr])
        ptr++
        if ptr == len(s) {
            ptr = 0
        }
    }
    return string(ret)
}

// 5, 3 => abccc
func formString(a, b int64) []byte {
    ret := []byte{}
    i := int64(0)
    for ; i < b; i++ {
        ret = append(ret, 'a' + byte(i))
    }
    i--
    for rem := a-b; rem > 0; rem-- {
        ret = append(ret, 'a' + byte(i))
    }
    return ret
}


// cf569b project main.go
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	z := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&z[i])
	}
	sort.Ints(z)
	m := 0
	for i := 1; i < n; i++ {
		for ; z[i-1] >= z[i]; z[i]++ {
			m++
		}
	}
	fmt.Println(m)

}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	ans := 0
	for i := range a[1:] {
		if a[i] >= a[i+1] {
			ans += a[i] - a[i+1] + 1
			a[i+1] = a[i] + 1
		}
	}
	fmt.Println(ans)
}

package main

import "fmt"

const (
	MAX_N = 8000
)

var (
	n int
	a [MAX_N]int
)

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		a[v]++
	}
	r := 0
	for i := 0; i < MAX_N - 1; i++ {
		if a[i] > 1 {
			v := a[i] - 1
			r += v
			a[i] -= v
			a[i + 1] += v
		}
	}
	fmt.Printf("%d\n", r)
}

package main
import (
	"fmt"
)
const(
	max=8000
)
var (
	j int
	a[8000] int
)
func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[j]++
	}
	s := 0
	for i := 0; i < 8000- 1; i++ {
		if a[i] > 1 {
			q:= a[i] - 1
			s += q
			a[i] -= q
			a[i + 1] += q
		}
	}
	fmt.Printf("%d\n", s)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, 10000)
	coin, coolness := 0, 0

	for i := 0; i < n; i++ {
		a[nextInt()]++
	}

	for i := 1; i < 10000; i++ {
		coin += coolness

		if coolness > 0 {
			if a[i] == 0 {
				coolness -= 1
			}
		}

		if a[i] > 1 {
			coolness += a[i] - 1
		}
	}

	println(coin)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
  "os"
  "bufio"
  "sort"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  badges := make([]int, n)
  for i := range badges {
    badges[i] = getI()
  }
  sort.Ints(badges)
  peak := 0
  result := 0
  for _, badge := range badges {
    if badge > peak {
      peak = badge
    } else {
      peak++
      result += peak-badge
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    //io
    scanner := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    //---
    var n, a, ans int
    var used [9999]int
    fmt.Fscan(scanner, &n)

    for i := 0; i < n; i++ {
        fmt.Fscan(scanner, &a)
        used[a]++
    }

    for i := 1; i <= n; i++ {
        for used[i] > 1 {
            j := i
            for used[j] > 0 {
                j++
                ans++
            }
            used[j]++
            used[i]--
        }
    }

    writer.WriteString(strconv.Itoa(ans))
    writer.Flush()
}

package main

import (
	"fmt"
)

func main() {
	var n, a int
	fmt.Scan(&n)

	counts := make([]int, 2*n, 2*n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		counts[a]++
	}

	next := 1
	ans := 0
	for i := 1; i <= n; i++ {
		for counts[i] > 1 {
			counts[i]--
			for next <= i || counts[next] != 0 {
				next++
			}
			ans += next - i
			counts[next]++
		}
	}

	fmt.Println(ans)
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	n := nextInt()
	cnt := make([]int, 2*n+100)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
		cnt[a[i]]++
	}
	ans := 0
	for i := range cnt {
		for cnt[i] > 1 {
			j := i
			for cnt[j] > 1 {
				cnt[j]--
				j++
				ans++
				cnt[j]++
			}
		}
	}
	fmt.Println(ans)
}

func init() {
	// maybe defer writer.Flush() in main

	lineScanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	/*
		inputFile, err := os.Open("a.in")
		if err != nil {
			panic(err)
		}
		outputFile, err := os.Create("a.out")
		if err != nil {
			panic(err)
		}
		lineScanner = bufio.NewScanner(inputFile)
		writer = bufio.NewWriter(outputFile)
	*/

	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

var writer *bufio.Writer

func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

package main
import (
	"fmt"
)
const(
	max=5000
)
var (
	j int
	a[5000] int
)
func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[j]++
	}
	s := 0
	for i := 0; i < 5000 - 1; i++ {
		if a[i] > 1 {
			q:= a[i] - 1
			s += q
			a[i] -= q
			a[i + 1] += q
		}
	}
	fmt.Printf("%d\n", s)
}

package main

import (
	"fmt"
)

func main() {
	var n, a int
	fmt.Scan(&n)

	counts := make([]int, 2*n, 2*n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		counts[a]++
	}

	next := 1
	ans := 0
	for i := 1; i <= n; i++ {
		for counts[i] > 1 {
			counts[i]--
			for next <= i || counts[next] != 0 {
				next++
			}
			ans += next - i
		}
	}

	fmt.Println(ans)
}


package main

import "fmt"

func main() {
    var a,b,c,d float64
    fmt.Scan(&a,&b,&c,&d)
    fmt.Println((a/b)/(1-((1-a/b)*(1-c/d))))
}

//312B
package main
import "fmt"

func main() {
    var e, f, g, h, x float64 // variabel e, f, g, h, x adlah float64
    fmt.Scan(&e, &f, &g, &h) // meminta input e, f, g, h
    x=(e*h)/(f*g + e*h - e*g) // perhitungannya
    fmt.Printf("%.12f\n", x) // mencetak output
}

// 312B
package main

import (
	"fmt"
)

func main() {
	var j, k, l, m float64
	fmt.Scan(&j, &k, &l, &m)
	fmt.Print((j * m) / (k*l + j*m - j*l))
}

package main

import (
	"fmt"
)

func solve(a, b, c, d float64) {
	p := a / b
	q := (1 - c/d) * (1 - a/b)

	fmt.Println(p / (1 - q))
}

func main() {
	var a, b, c, d float64

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)

	solve(a, b, c, d)
}

// 312B-mic
package main

import (
    "fmt"
)

func main() {
    var a, b, c, d float64
    fmt.Scan(&a, &b, &c, &d)
    p := a / b
    q := (1 - a/b) * (1 - c/d)
    res := p / (1 - q)
    fmt.Println(res)
}

package main

import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
	//"unicode"
	//"strings"
	//"math"
)

func main() {
    var a,b,c,d,ans float64
    fmt.Scan(&a,&b,&c,&d)
    ans=(a*d)/((a*d)+(b*c)-(a*c))
    fmt.Println(ans)
}

package main

import (
	"bufio"
	"os"
	"strconv"
)

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextInt() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}

type Fraction struct {
	delim int64
	denom int64
}

func GCD(p int64, q int64) int64 {
	if q == 0 {
		return p
	}
	return GCD(q, p%q)
}

func NewFraction(p int64, q int64) *Fraction {
	ans := new(Fraction)
	g := GCD(p, q)
	ans.delim = p / g
	ans.denom = q / g
	return ans
}

func (frac *Fraction) Add(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom+frac.denom*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Sub(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom-frac.denom*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Mul(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Div(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom,
		frac.denom*frac2.delim)
}

func (frac *Fraction) Reverse() *Fraction {
	return NewFraction(frac.denom, frac.delim)
}

func (frac *Fraction) Rational() float64 {
	return float64(frac.delim) / float64(frac.denom)
}

func main() {
	scanner.Split(bufio.ScanWords)
	p, q := NewFraction(int64(NextInt()), int64(NextInt())),
		NewFraction(int64(NextInt()), int64(NextInt()))
	ans := p.Div(p.Add(q).Sub(p.Mul(q))).Rational()
	w.WriteString(strconv.FormatFloat(ans, 'f', 7, 64))
	w.WriteByte('\n')
	w.Flush()
}

//312B
package main
import "fmt"

func main() {
	var e, f, g, h, x float64
	fmt.Scan(&e, &f, &g, &h)
	x=(e*h)/(f*g + e*h - e*g)
	fmt.Printf("%.12f\n", x)
}

package main

import (
	"bufio"
	"os"
	"strconv"
)

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextInt() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}

type Fraction struct {
	delim int
	denom int
}

func GCD(p int, q int) int {
	if q == 0 {
		return p
	}
	return GCD(q, p%q)
}

func NewFraction(p int, q int) *Fraction {
	ans := new(Fraction)
	g := GCD(p, q)
	ans.delim = p / g
	ans.denom = q / g
	return ans
}

func (frac *Fraction) Add(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom+frac.denom*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Sub(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom-frac.denom*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Mul(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Div(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom,
		frac.denom*frac2.delim)
}

func (frac *Fraction) Reverse() *Fraction {
	return NewFraction(frac.denom, frac.delim)
}

func (frac *Fraction) Round() int {
	return frac.delim / frac.denom
}

func (frac *Fraction) Rational() float64 {
	return float64(frac.delim) / float64(frac.denom)
}

func main() {
	scanner.Split(bufio.ScanWords)
	p, q := NewFraction(NextInt(), NextInt()),
		NewFraction(NextInt(), NextInt())
	ans := p.Div(p.Add(q).Sub(p.Mul(q))).Rational()
	w.WriteString(strconv.FormatFloat(ans, 'f', 7, 64))
	w.WriteByte('\n')
	//p/(1-(1-p)(1-q)) = p/(p+q-pq)
	w.Flush()
}

package main

import (
	"bufio"
	"os"
	"strconv"
)

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func NextInt() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}

type Fraction struct {
	delim int
	denom int
}

func GCD(p int, q int) int {
	if q == 0 {
		return p
	}
	return GCD(q, p%q)
}

func NewFraction(p int, q int) *Fraction {
	ans := new(Fraction)
	g := GCD(p, q)
	ans.delim = p / g
	ans.denom = q / g
	return ans
}

func (frac *Fraction) Sub(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.denom-frac.denom*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Mul(frac2 *Fraction) *Fraction {
	return NewFraction(frac.delim*frac2.delim,
		frac.denom*frac2.denom)
}

func (frac *Fraction) Reverse() *Fraction {
	return NewFraction(frac.denom, frac.delim)
}

func (frac *Fraction) Rational() float64 {
	return float64(frac.delim) / float64(frac.denom)
}

func main() {
	scanner.Split(bufio.ScanWords)
	p, q := NewFraction(NextInt(), NextInt()),
		NewFraction(NextInt(), NextInt())
	ans := p.Mul(NewFraction(1, 1).Sub(p.Mul(q)).Reverse()).Rational()
	w.WriteString(strconv.FormatFloat(ans, 'f', 7, 64))
	w.WriteByte('\n')
	w.Flush()
}

package main
import "fmt"

func main() {
	var e, f, g, h, x float64
	fmt.Scan(&e, &f, &g, &h)
	x=(f*g)/(f*g + e*h - e*g)
	fmt.Printf("%.12f\n", x)
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF598D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := [...]pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, m, q, x, y int
	Fscan(in, &n, &m, &q)
	g := make([][]byte, n)
	for i := range g {
		Fscan(in, &g[i])
	}
	ans := make([][]int, n)
	for i := range ans {
		ans[i] = make([]int, m)
	}
	for ; q > 0; q-- {
		Fscan(in, &x, &y)
		x--
		y--
		if ans[x][y] == 0 {
			todo, c := []pair{}, 0
			ans[x][y] = 1
			for q := []pair{{x, y}}; len(q) > 0; {
				p := q[0]
				q = q[1:]
				todo = append(todo, p)
				for _, d := range dir4 {
					if x, y := p.x+d.x, p.y+d.y; g[x][y] == '*' {
						c++
					} else if ans[x][y] == 0 {
						ans[x][y] = 1
						q = append(q, pair{x, y})
					}
				}
			}
			for _, p := range todo {
				ans[p.x][p.y] = c
			}
		}
		Fprintln(out, ans[x][y])
	}
}

func main() { CF598D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var museum [][]bool
var visited [][]bool
var resp [][]int
var n int
var m int

type Stack struct {
	Arr [][]int
}

func (s *Stack) Push(p []int) {
	s.Arr = append(s.Arr, p)
}

func (s *Stack) Pop() []int {
	curr := s.Arr[len(s.Arr)-1]
	s.Arr = s.Arr[:len(s.Arr)-1]
	return curr
}

func (s *Stack) Top() []int {
	return s.Arr[len(s.Arr) - 1]
}

func (s *Stack) Len() int {
	return len(s.Arr)
}

func (s *Stack) isEmpty() bool {
	return len(s.Arr) == 0
}

func currPicturesSeeing(x int, y int) int {
	resp := 0
	if x > 0 && !museum[x-1][y] {
		resp += 1
	}
	if y > 0 && !museum[x][y-1] {
		resp += 1
	}
	if x < n-1 && !museum[x+1][y] {
		resp += 1
	}
	if y < m-1 && !museum[x][y+1] {
		resp += 1
	}
	return resp
}

func picturesSeen(startX int, startY int) int {
	if visited[startX][startY] {
		return resp[startX][startY]
	}

	var currConn [][]int
	s := &Stack{}

	startPt := []int{startX, startY}
	s.Push(startPt)
	visited[startX][startY] = true
	picturesVis := 0
	for !s.isEmpty() {
		currPt := s.Pop()
		currConn = append(currConn, currPt)
		x := currPt[0]
		y := currPt[1]
		picturesVis += currPicturesSeeing(x, y)

		if x > 0 && museum[x-1][y] && !visited[x-1][y] {
			s.Push([]int{x-1, y})
			visited[x-1][y] = true
		}
		if y > 0 && museum[x][y-1] && !visited[x][y-1] {
			s.Push([]int{x, y-1})
			visited[x][y-1] = true
		}
		if x < n-1 && museum[x+1][y] && !visited[x+1][y] {
			s.Push([]int{x+1, y})
			visited[x+1][y] = true
		}
		if y < m-1 && museum[x][y+1] && !visited[x][y+1] {
			s.Push([]int{x, y+1})
			visited[x][y+1] = true
		}
	}

	for idx := range currConn {
		currPt := currConn[idx]
		resp[currPt[0]][currPt[1]] = picturesVis
	}
	return picturesVis
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	if !scanner.Scan() || scanner.Err() != nil {
		panic(scanner.Err())
	}
	nmkStr := scanner.Text()
	nmkArr := strings.Split(nmkStr, " ")
	var err error
	n, err = strconv.Atoi(nmkArr[0])
	if err != nil {
		panic(err)
	}
	m, err = strconv.Atoi(nmkArr[1])
	if err != nil {
		panic(err)
	}
	k, err := strconv.Atoi(nmkArr[2])
	if err != nil {
		panic(err)
	}

	museum = make([][]bool, n)
	for idx := range museum {
		museum[idx] = make([]bool, m)

		if !scanner.Scan() || scanner.Err() != nil {
			panic(scanner.Err())
		}
		currRowStr := scanner.Text()
		for j := range museum[idx] {
			if string(currRowStr[j]) == "." {
				museum[idx][j] = true
			}
		}
	}

	visited = make([][]bool, n)
	for idx := range visited {
		visited[idx] = make([]bool, m)
	}

	resp = make([][]int, n)
	for idx := range resp {
		resp[idx] = make([]int, m)
	}

	for i := 0; i < k; i++ {
		if !scanner.Scan() || scanner.Err() != nil {
			panic(scanner.Err())
		}
		startStr := scanner.Text()
		startArr := strings.Split(startStr, " ")
		startX, err := strconv.Atoi(startArr[0])
		if err != nil {
			panic(err)
		}
		startX -= 1

		startY, err := strconv.Atoi(startArr[1])
		if err != nil {
			panic(err)
		}
		startY -= 1

		fmt.Println(picturesSeen(startX, startY))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var museum [][]bool
var visited [][]bool
var resp [][]int
var n int
var m int

type Stack struct {
	Arr [][]int
}

func (s *Stack) Push(p []int) {
	s.Arr = append(s.Arr, p)
}

func (s *Stack) Pop() []int {
	curr := s.Arr[len(s.Arr)-1]
	s.Arr = s.Arr[:len(s.Arr)-1]
	return curr
}

func (s *Stack) Top() []int {
	return s.Arr[len(s.Arr) - 1]
}

func (s *Stack) Len() int {
	return len(s.Arr)
}

func (s *Stack) isEmpty() bool {
	return len(s.Arr) == 0
}

func currPicturesSeeing(x int, y int) int {
	resp := 0
	if x > 0 && !museum[x-1][y] {
		resp += 1
	}
	if y > 0 && !museum[x][y-1] {
		resp += 1
	}
	if x < n-1 && !museum[x+1][y] {
		resp += 1
	}
	if y < m-1 && !museum[x][y+1] {
		resp += 1
	}
	return resp
}

func picturesSeen(startX int, startY int) int {
	if visited[startX][startY] {
		return resp[startX][startY]
	}

	var currConn [][]int
	s := &Stack{}

	startPt := []int{startX, startY}
	s.Push(startPt)

	picturesVis := 0
	for !s.isEmpty() {
		currPt := s.Pop()
		currConn = append(currConn, currPt)
		x := currPt[0]
		y := currPt[1]
		picturesVis += currPicturesSeeing(x, y)
		visited[x][y] = true
		if x > 0 && museum[x-1][y] && !visited[x-1][y] {
			s.Push([]int{x-1, y})
		}
		if y > 0 && museum[x][y-1] && !visited[x][y-1] {
			s.Push([]int{x, y-1})
		}
		if x < n-1 && museum[x+1][y] && !visited[x+1][y] {
			s.Push([]int{x+1, y})
		}
		if y < m-1 && museum[x][y+1] && !visited[x][y+1] {
			s.Push([]int{x, y+1})
		}
	}

	for idx := range currConn {
		currPt := currConn[idx]
		resp[currPt[0]][currPt[1]] = picturesVis
	}
	return picturesVis
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	if !scanner.Scan() || scanner.Err() != nil {
		panic(scanner.Err())
	}
	nmkStr := scanner.Text()
	nmkArr := strings.Split(nmkStr, " ")
	var err error
	n, err = strconv.Atoi(nmkArr[0])
	if err != nil {
		panic(err)
	}
	m, err = strconv.Atoi(nmkArr[1])
	if err != nil {
		panic(err)
	}
	k, err := strconv.Atoi(nmkArr[2])
	if err != nil {
		panic(err)
	}

	museum = make([][]bool, n)
	for idx := range museum {
		museum[idx] = make([]bool, m)

		if !scanner.Scan() || scanner.Err() != nil {
			panic(scanner.Err())
		}
		currRowStr := scanner.Text()
		for j := range museum[idx] {
			if string(currRowStr[j]) == "." {
				museum[idx][j] = true
			}
		}
	}

	visited = make([][]bool, n)
	for idx := range visited {
		visited[idx] = make([]bool, m)
	}

	resp = make([][]int, n)
	for idx := range resp {
		resp[idx] = make([]int, m)
	}

	for i := 0; i < k; i++ {
		if !scanner.Scan() || scanner.Err() != nil {
			panic(scanner.Err())
		}
		startStr := scanner.Text()
		startArr := strings.Split(startStr, " ")
		startX, err := strconv.Atoi(startArr[0])
		if err != nil {
			panic(err)
		}
		startX -= 1

		startY, err := strconv.Atoi(startArr[1])
		if err != nil {
			panic(err)
		}
		startY -= 1

		fmt.Println(picturesSeen(startX, startY))
	}
}


package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return Gcd(b, a%b)
}

const mod = 1000000007

func Add(a, b int64) int64 {
	return (a + b) % mod
}

func Mult(a, b int64) int64 {
	return (a * b) % mod
}

func Sub(a, b int64) int64 {
	return (a - b + mod) % mod
}

func solve() {
	n := nextInt()
	res := make([]int, n)

	curr := 0
	for i := 1; i < n; i++ {
		printf("? %d %d\n", curr+1, i+1)
		printf("? %d %d\n", i+1, curr+1)
		out.Flush()
		x, y := nextInt(), nextInt()
		if x < y {
			res[i] = y
		} else {
			res[curr] = x
			curr = i
		}
	}
	has := map[int]bool{}
	for _, v := range res {
		has[v] = true
	}
	for i := 1; i <= n; i++ {
		if !has[i] {
			res[curr] = i
		}
	}
	printf("! ")
	for _, v := range res {
		printf("%d ", v)
	}
	printf("\n")
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "foreign"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		file2, err := os.Create(name + ".out")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file1, 8192)
		out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()
	// start := time.Now()

	// for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
	// 	printf("Case #%d:\n", i)
	solve()
	// }

	// printf("%v\n", time.Now().Sub(start))
}

package main

import (
	"fmt"
)

func main()  {
	//fileInput, _ := os.Open("input.txt")
	//os.Stdin = fileInput

	var n int
	fmt.Scan(&n)

	mxi := 1
	a := make([]int, 10004)
	var kx, ky int
	for i:=2; i<=n; i++ {
		fmt.Println("? ", mxi, " ", i)
		fmt.Scan(&ky)
		fmt.Println("? ", i, " ", mxi)
		fmt.Scan(&kx)
		if kx > ky {
			a[i] = kx
		} else {
			a[mxi] = ky
			mxi = i
		}
	}
	a[mxi] = n
	fmt.Print("! ")
	for i := 1; i<=n; i++ {
		fmt.Print(a[i], " ")
	}
	fmt.Println("")
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)

	n := io.NextInt()
	ans := make([]int, n+1)
	i := 1
	for j := 2; j <= n; j++ {
		io.Println("?", i, j)
		ij := io.NextInt()
		io.Println("?", j, i)
		ji := io.NextInt()
		if ij < ji {
			ans[j] = ji
		} else {
			ans[i] = ij
			i = j
		}
	}
	ans[i] = n
	io.Print("! ")
	io.PrintlnInts(ans[1:])
}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
	f.Flush()
}

func (f *FastIO) PrintInts(a []int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a []int) {
	f.PrintInts(a)
	f.Println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func () int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n := in()

	a := make([]int, n)

	for n > 1 {
		b := make([]int, 0, n)

		for i := range a {
			if a[i] == 0 {
				b = append(b, i)
			}
		}

		for i := 0; i < len(b)-1; i += 2{
			j := b[i]
			k := b[i+1]

			fmt.Println("?", j+1, k+1)
			a1 := in()
			fmt.Println("?", k+1, j+1)
			a2 := in()

			if a1 > a2 {
				a[j] = a1
			} else {
				a[k] = a2
			}
			n--
		}
	}

	for i := range a {
		if a[i] == 0 {
			a[i] = len(a)
		}
	}

	fmt.Print("! ")

	for i := range a {
		fmt.Print(a[i], " ")
	}
}

package main

import (
	"fmt"
)

func main()  {
	//fileInput, _ := os.Open("input.txt")
	//os.Stdin = fileInput

	var n int
	fmt.Scan(&n)

	mxi := 1
	a := make([]int, 10004)
	var kx, ky int
	for i:=2; i<=n; i++ {
		fmt.Printf("? %d %d\n", mxi, i)
		fmt.Printf("? %d %d\n", i, mxi)
		fmt.Scan(&kx, &ky)
		if kx > ky {
			a[i] = kx
		} else if kx < ky {
			a[mxi] = ky
			mxi = i
		} else if kx == 1 {
			a[i] = 1
		}
	}
	a[mxi] = n
	fmt.Print("! ")
	for i := 1; i<=n; i++ {
		fmt.Print(a[i], " ")
	}
	fmt.Println("")
}

package main

import (
	"fmt"
	"os"
)

func main()  {
	fileInput, _ := os.Open("input.txt")
	os.Stdin = fileInput

	var n int
	fmt.Scan(&n)

	mxi := 1
	a := make([]int, 10004)
	var kx, ky int
	for i:=2; i<=n; i++ {
		fmt.Printf("? % %\n", mxi, i)
		fmt.Printf("? % %\n", i, mxi)
		fmt.Scan(kx, ky)
		if kx > ky {
			a[i] = kx
		} else if kx < ky {
			a[mxi] = ky
			mxi = i
		} else if kx == 1 {
			a[i] = 1
		}
	}
	a[mxi] = n
	fmt.Print("! ")
	for i := 1; i<=n; i++ {
		fmt.Print(a[i], " ")
	}
	fmt.Println("")
}

package main

import (
	"fmt"
	"os"
)

func main()  {
	fileInput, _ := os.Open("input.txt")
	os.Stdin = fileInput

	var n int
	fmt.Scan(&n)

	mxi := 1
	a := make([]int, 10004)
	var kx, ky int
	for i:=2; i<=n; i++ {
		fmt.Printf("? % %\n", mxi, i)
		fmt.Printf("? % %\n", i, mxi)
		fmt.Scan(&kx, &ky)
		if kx > ky {
			a[i] = kx
		} else if kx < ky {
			a[mxi] = ky
			mxi = i
		} else if kx == 1 {
			a[i] = 1
		}
	}
	a[mxi] = n
	fmt.Print("! ")
	for i := 1; i<=n; i++ {
		fmt.Print(a[i], " ")
	}
	fmt.Println("")
}

package main

import (
	"fmt"
)

func main()  {
	//fileInput, _ := os.Open("input.txt")
	//os.Stdin = fileInput

	var n int
	fmt.Scan(&n)

	mxi := 1
	a := make([]int, 10004)
	var kx, ky int
	for i:=2; i<=n; i++ {
		fmt.Printf("? % %\n", mxi, i)
		fmt.Printf("? % %\n", i, mxi)
		fmt.Scan(&kx, &ky)
		if kx > ky {
			a[i] = kx
		} else if kx < ky {
			a[mxi] = ky
			mxi = i
		} else if kx == 1 {
			a[i] = 1
		}
	}
	a[mxi] = n
	fmt.Print("! ")
	for i := 1; i<=n; i++ {
		fmt.Print(a[i], " ")
	}
	fmt.Println("")
}