One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house.Karlsson's gaze immediately fell on n wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find.And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open.Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds t, in which he is able to bring all the cupboard doors in the required position.Your task is to write a program that will determine the required number of seconds t.

The first input line contains a single integer n — the number of cupboards in the kitchen (2 ≤ n ≤ 104). Then follow n lines, each containing two integers li and ri (0 ≤ li, ri ≤ 1). Number li equals one, if the left door of the i-th cupboard is opened, otherwise number li equals zero. Similarly, number ri equals one, if the right door of the i-th cupboard is opened, otherwise number ri equals zero. The numbers in the lines are separated by single spaces.

In the only output line print a single integer t — the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.

package main

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

func main() {
	n := readi()
	var leftCount, rightCount int
	for i := 0; i < n; i++ {
		l, r := readi(), readi()
		leftCount += l
		rightCount += r
	}
	fmt.Fprintln(writer, min(leftCount, n-leftCount)+min(rightCount, n-rightCount))
	writer.Flush()
}

func median(values []int) float64 {
	res := 0
	for _, v := range values {
		res += v
	}
	return float64(res) / float64(len(values))
}

func perfectPermutation(n int) string {
	if n%2 == 1 {
		return "-1"
	}
	values := make([]int, 0)
	for i := 0; i < n; i++ {
		values = append(values, n-i)
	}
	str := ""
	for _, v := range values {
		str += fmt.Sprint(v, " ")
	}
	return str
}

func isNextPrime(n, m int) bool {
	for i := n + 1; i < m; i++ {
		if isPrime(i) {
			return false
		}
	}
	return isPrime(m)
}

func isPrime(n int) bool {
	for x := 2; x*x <= n; x++ {
		if n%x == 0 {
			return false
		}
	}
	return n > 1
}

func withSameCase(word string) string {
	lowerCount := 0
	for _, letter := range word {
		if unicode.IsLower(letter) {
			lowerCount++
		}
	}
	if lowerCount*2 >= len(word) {
		return strings.ToLower(word)
	}
	return strings.ToUpper(word)
}

func solve(matrix [][]int) []string {
	n := 3
	state := make([][]byte, n)
	for i := range state {
		state[i] = make([]byte, n)
		for j := range matrix[i] {
			state[i][j] = byte(matrix[i][j])
			if i > 0 {
				state[i][j] += byte(matrix[i-1][j])
			}
			if i+1 < n {
				state[i][j] += byte(matrix[i+1][j])
			}
			if j > 0 {
				state[i][j] += byte(matrix[i][j-1])
			}
			if j+1 < n {
				state[i][j] += byte(matrix[i][j+1])
			}
			state[i][j] &= 1
			state[i][j] ^= 1
			state[i][j] += '0'
		}
	}
	res := make([]string, n)
	for i := range res {
		res[i] = string(state[i])
	}
	return res
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func max64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func read3i() (int, int, int) {
	return readi(), readi(), readi()
}

func read4i() (int, int, int, int) {
	return readi(), readi(), readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readi64s(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = readi64()
	}
	return res
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

import (
	"fmt"
)

func main() {
	var n,a,b,c,d,e,f int
	fmt.Scan(&n)
	a,b=0,0
	for i:=0;i<n;i++ {
		fmt.Scan(&c,&d)
		a+=c
		b+=d
	}
	if a>n-a {
		e=n-a
	} else {
		e=a
	}
	if b>n-b {
		f=n-b
	} else {
		f=b
	}
	fmt.Println(e+f)
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	left, right := 0, 0
	for i := 0; i < n; i++ {
		l, r := scanInt(scanner), scanInt(scanner)
		left += l
		right += r
	}
	if n-left < left {
		left = n-left
	}
	if n-right < right {
		right = n-right
	}
	writer.WriteString(fmt.Sprintf("%d\n", left+right))
}

package main

import "fmt"

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

func main() {
    var n,l,r int
    fmt.Scan(&n)
    L, R := 0, 0
    for i := 0; i < n; i++ {
        fmt.Scan(&l,&r)
        L += l
        R += r
    }
    fmt.Println(min(L,n-L)+min(R,n-R))
}

package main

import "fmt"

func min(a,b int) int { if a < b { return a } else { return b } }   // fungsi yang mengembalikan nilai terkecil di antara 2 bilangan

func main() {
    var n,l,r int               // membuat variabel n, l, dan r dengan tipe data int
    fmt.Scan(&n)                // menerima input n
    L, R := 0, 0                // membuat variabel L dan R dengan tipe data int dengan nilai awal 0
    for i := 0; i < n; i++ {    // looping sebanyak n kali
        fmt.Scan(&l,&r)         // menerima input l dan r
        L += l                  // tambahkan l ke L
        R += r                  // tambahkan r ke R
    }
    fmt.Println(min(L,n-L)+min(R,n-R))      // mencetak output nilai penjumlahan antara nilai minimum L dengan n-L dan nilai minimum R dengan n-R
}

package main

import (
	"bufio"
	"fmt"
	_ "math"
	"os"
	_ "sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.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...) }

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	left := map[int]bool{}
	right := map[int]bool{}

	for i :=0;i<n;i++ {
		var li,ri int
		scanf("%d %d\n", &li, &ri)
		if(li == 1) {
			left[i] = true
		}
		if(ri == 1) {
			right[i] = true
		}
	}
	ans := min(len(left), n-len(left)) + min(len(right), n-len(right))
	printf("%d\n", ans)
}

package main

import (
	"fmt"
)

func main() {
	var n, time, left, right, leftZeros, leftOnes, rightZeros, rightOnes uint16

	fmt.Scan(&n)

	for i := 0; i < int(n); i++ {
		fmt.Scan(&left)
		fmt.Scan(&right)

		switch left {
		case 1:
			leftOnes++
			break
		default:
			leftZeros++
		}

		switch right {
		case 1:
			rightOnes++
			break
		default:
			rightZeros++
		}
	}

	if leftZeros > leftOnes {
		time = leftOnes
	} else {
		time = leftZeros
	}

	if rightZeros > rightOnes {
		time += rightOnes
	} else {
		time += rightZeros
	}

	fmt.Println(time)
}

package main

import "fmt"

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

func main() {
    var n,l,r int
    fmt.Scan(&n)
    L, R := 0, 0
    for i := 0; i < n; i++ {
        fmt.Scanf("%d %d\n",&l,&r)
        L += l
        R += r
    }
    fmt.Println(min(L,n-L)+min(R,n-R))
}

package main

import (
	"bufio"
	"fmt"
	_ "math"
	"os"
	_ "sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.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...) }

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	left := map[int]bool{}
	right := map[int]bool{}

	for i :=0;i<n;i++ {
		var li,ri int
		scanf("%d %d\n", &li, &ri)
		if(li == 1) {
			left[i] = true
		}
		if(ri == 1) {
			right[i] = true
		}
	}
	ans := min(max(len(left), n-len(left)), max(len(right), n-len(right)))
	printf("%d\n", ans)
}

package main

import (
	"fmt"
)

func main() {
	var n, time, left, right, leftZeros, leftOnes, rightZeros, rightOnes uint8

	fmt.Scan(&n)

	for i := 0; i < int(n); i++ {
		fmt.Scan(&left)
		fmt.Scan(&right)

		switch left {
		case 1:
			leftOnes++
			break
		default:
			leftZeros++
		}

		switch right {
		case 1:
			rightOnes++
			break
		default:
			rightZeros++
		}
	}

	if leftZeros > leftOnes {
		time = leftOnes
	} else {
		time = leftZeros
	}

	if rightZeros > rightOnes {
		time += rightOnes
	} else {
		time += rightZeros
	}

	fmt.Println(time)
}


Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to tests it. He wants you to implement the program that checks the result of the printing.Printer works with a rectangular sheet of paper of size n × m. Consider the list as a table consisting of n rows and m columns. Rows are numbered from top to bottom with integers from 1 to n, while columns are numbered from left to right with integers from 1 to m. Initially, all cells are painted in color 0.Your program has to support two operations:   Paint all cells in row ri in color ai;  Paint all cells in column ci in color ai. If during some operation i there is a cell that have already been painted, the color of this cell also changes to ai.Your program has to print the resulting table after k operation.

The first line of the input contains three integers n, m and k (1  ≤  n,  m  ≤ 5000, n·m ≤ 100 000, 1 ≤ k ≤ 100 000) — the dimensions of the sheet and the number of operations, respectively. Each of the next k lines contains the description of exactly one query:    1 ri ai (1 ≤ ri ≤ n, 1 ≤ ai ≤ 109), means that row ri is painted in color ai;  2 ci ai (1 ≤ ci ≤ m, 1 ≤ ai ≤ 109), means that column ci is painted in color ai.

Print n lines containing m integers each — the resulting table after all operations are applied.

NoteThe figure below shows all three operations for the first sample step by step. The cells that were painted on the corresponding step are marked gray.

package main

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

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

    var n, m, k int;
    fmt.Fscan(in, &n, &m, &k)

    rows := make([]struct { time int; color int }, n)
    columns := make([]struct { time int; color int }, m)

    for i := 1; i <= k; i++ {
        var oper, index, color int
        fmt.Fscan(in, &oper, &index, &color)

        switch oper {
        case 1:
            rows[index-1].time = i
            rows[index-1].color = color
        case 2:
            columns[index-1].time = i
            columns[index-1].color = color
        }
    }

    for i := 0; i < n; i++ {
        for j := 0; j < m; j++ {
            if rows[i].time > columns[j].time {
                fmt.Fprint(out, rows[i].color)
            } else {
                fmt.Fprint(out, columns[j].color)
            }

            if (j < m - 1) {
                fmt.Fprint(out, " ")
            } else {
                fmt.Fprint(out, "\n")
            }
        }
    }

    out.Flush()
}

package main

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

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n, m, k int
    fmt.Fscan(stdin, &n, &m, &k)

    rowColor := make([]int, n)
    rowLast := make([]int, n)
    colColor := make([]int, m)
    colLast := make([]int, m)

    for i := 0; i < k; i++ {
      var t, x, c int
      fmt.Fscan(stdin, &t, &x, &c)
      x--
      if t == 1 {  // rows
        rowColor[x] = c
        rowLast[x] = i+1
      } else {  // cols
        colColor[x] = c
        colLast[x] = i+1
      }
    }

    for i := 0; i < n; i++ {
      for j := 0; j < m; j++ {
        if rowLast[i] > colLast[j] {
          fmt.Print(" ", rowColor[i])
        } else {
          fmt.Print(" ", colColor[j])
        }
      }
      fmt.Println()
    }
}

package main

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

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

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriter(os.Stdout)
}

func nextToken() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(nextToken())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextToken(), 10, 64)
	return v
}

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

func printInt(x int) {
	writer.WriteString(strconv.Itoa(x))
}

func printInt64(x int64) {
	writer.WriteString(strconv.FormatInt(x, 10))
}

func printString(x string) {
	writer.WriteString(x)
}

type Pair struct {
	t, col int
}

func main() {
	n, m, k := nextInt(), nextInt(), nextInt()
	var r, c [5100]Pair
	for i := 1; i <= k; i++ {
		t, q, w := nextInt(), nextInt(), nextInt()
		q--
		if t == 1 {
			r[q].col = w
			r[q].t = i
		} else {
			c[q].col = w
			c[q].t = i
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if r[i].t < c[j].t {
				printInt(c[j].col)
			} else {
				printInt(r[i].col)
			}
			printString(" ")
		}
		printString("\n")
	}

	writer.Flush()
}

package main

import (
"fmt"
"bufio"
"os"
"strconv"
)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
func NextToken() string {
	in.Scan()
	return in.Text()
}
func nextInt() int {
	val, err := strconv.Atoi(NextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}

type pair struct {
    color, level int
}
func main() {
    in.Split(bufio.ScanWords)
    // p := bufio.NewWriter(os.Stdout)

    n := 0
    m := 0
    n = nextInt()
    m = nextInt()
    k := nextInt()

    rows := make([]pair, n + 1)
    cols := make([]pair, m + 1)

    for i:=0; i<k; i++ {
        a := nextInt()
        b := nextInt()
        c := nextInt()
        if a == 1 {
            rows[b] = pair{c, i + 1}
        } else {
            cols[b] = pair{c, i + 1}
        }
    }

    for i:=1; i<=n; i++ {
        for j:=1; j<=m; j++ {
            k := 0
            if rows[i].level > cols[j].level {
                k = rows[i].color
            } else {
                k = cols[j].color
            }
            fmt.Fprintf(out, "%d ", k)
        }
        fmt.Fprintf(out, "\n")
    }

    out.Flush()
}

package main

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

var (
	sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
	wr *bufio.Writer  = bufio.NewWriter(os.Stdout)
)

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

func printInts(ints ...int) {
	for _, v := range ints {
		wr.WriteString(strconv.Itoa(v))
		wr.WriteByte(' ')
	}
}

func println() {
	wr.WriteByte('\n')
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)

	var n, m, k int = readInt(), readInt(), readInt()
	n++
	m++
	rs := make([]int, n)
	rt := make([]int, n)
	cs := make([]int, m)
	ct := make([]int, m)
	var t, rc, a int
	for i := 1; i <= k; i++ {
		t, rc, a = readInt(), readInt(), readInt()
		if t == 1 {
			rs[rc] = a
			rt[rc] = i
		} else {
			cs[rc] = a
			ct[rc] = i
		}
	}

	for i := 1; i < n; i++ {
		for j := 1; j < m; j++ {
			var v int
			if rt[i] == ct[j] {
				v = 0
			} else if rt[i] > ct[j] {
				v = rs[i]
			} else {
				v = cs[j]
			}
			printInts(v)
		}
		println()
	}
}

package main

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

type PairInt struct {
	first, second int
}

func main() {
	scanner.Split(bufio.ScanWords)
	var N = NextInt()
	var M = NextInt()
	var K = NextInt()
	var qr, qc []PairInt
	qr = make([]PairInt, N)
	qc = make([]PairInt, M)

	for i := 0; i < K; i++ {
		var q, rc, color int
		q = NextInt()
		rc = NextInt()
		color = NextInt()
		rc--
		if q == 1 { //row
			qr[rc].first = color
			qr[rc].second = i + 1
		} else {
			qc[rc].first = color
			qc[rc].second = i + 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			if qr[i].second < qc[j].second {
				fmt.Print(qc[j].first, " ")
			} else {
				fmt.Print(qr[i].first, " ")
			}
		}
		fmt.Println()
	}
}

//---------------------------------template--------------------------------

var scanner = bufio.NewScanner(os.Stdin)

var writer = bufio.NewWriter(os.Stdout)

func NextToken() string {
	scanner.Scan()
	return scanner.Text()
}

func NextInt() int {
	val, err := strconv.Atoi(NextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}

func PrintInt(x int) {
	writer.WriteString(strconv.Itoa(x))
}
func PrintString(x string) {
	writer.WriteString(x)
}

package main

import (
	"fmt"
)

type ord struct {
	v, o int
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	mm := make([][]int, n+1)
	m0 := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		mm[i] = make([]int, m+1)
		m0[i] = make([]int, m+1)
	}

	rs := make([]ord, n+1)
	cs := make([]ord, m+1)
	var t, rc, a int
	for i := 0; i < k; i++ {
		fmt.Scan(&t, &rc, &a)
		if t == 1 {
			rs[rc] = ord{a, i}
		} else {
			cs[rc] = ord{a, i}
		}
	}

	rsize := 0
	for i, or := range rs {
		if or.v == 0 && or.o == 0 {
			continue
		}
		for j := 1; j <= m; j++ {
			mm[i][j] = or.v
			m0[i][j] = or.o
		}
		rsize++
	}
	if rsize != n {

		for j, or := range cs {
			if or.v == 0 && or.o == 0 {
				continue
			}
			for i := 1; i <= n; i++ {
				if or.o >= m0[i][j] {
					mm[i][j] = or.v
				}
			}
		}
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			fmt.Printf("%d ", mm[i][j])
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
)

type ord struct {
	v, o int
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	mm := make([][]int, n+1)
	m0 := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		mm[i] = make([]int, m+1)
		m0[i] = make([]int, m+1)
	}

	rs := make([]ord, n+1)
	cs := make([]ord, m+1)
	var t, rc, a int
	for i := 0; i < k; i++ {
		fmt.Scan(&t, &rc, &a)
		if t == 1 {
			rs[rc] = ord{a, i}
		} else {
			cs[rc] = ord{a, i}
		}
	}

	for i, or := range rs {
		if or.v == 0 && or.o == 0 {
			continue
		}
		for j := 1; j <= m; j++ {
			mm[i][j] = or.v
			m0[i][j] = or.o
		}
	}
	for j, or := range cs {
		if or.v == 0 && or.o == 0 {
			continue
		}
		for i := 1; i <= n; i++ {
			if or.o > m0[i][j] {
				mm[i][j] = or.v
			}
		}
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			fmt.Printf("%d ", mm[i][j])
		}
		fmt.Println()
	}
}

package main

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

type PairInt struct {
	first, second int
}

func main() {
	scanner.Split(bufio.ScanWords)
	var N = NextInt()
	var M = NextInt()
	var K = NextInt()
	var qr, qc []PairInt
	qr = make([]PairInt, N)
	qc = make([]PairInt, M)

	for i := 0; i < K; i++ {
		var q, rc, color int
		q = NextInt()
		rc = NextInt()
		color = NextInt()
		rc--
		if q == 1 { //row
			qr[rc].first = color
			qr[rc].second = i
		} else {
			qc[rc].first = color
			qc[rc].second = i
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			if qr[i].second < qc[j].second {
				fmt.Print(qc[j].first, " ")
			} else {
				fmt.Print(qr[i].first, " ")
			}
		}
		fmt.Println()
	}
}

//---------------------------------template--------------------------------

var scanner = bufio.NewScanner(os.Stdin)

var writer = bufio.NewWriter(os.Stdout)

func NextToken() string {
	scanner.Scan()
	return scanner.Text()
}

func NextInt() int {
	val, err := strconv.Atoi(NextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}

func PrintInt(x int) {
	writer.WriteString(strconv.Itoa(x))
}
func PrintString(x string) {
	writer.WriteString(x)
}


Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the i-th minute friends will send ai requests.Polycarp plans to test Fakebook under a special kind of load. In case the information about Fakebook gets into the mass media, Polycarp hopes for a monotone increase of the load, followed by a monotone decrease of the interest to the service. Polycarp wants to test this form of load.Your task is to determine how many requests Polycarp must add so that before some moment the load on the server strictly increases and after that moment strictly decreases. Both the increasing part and the decreasing part can be empty (i. e. absent). The decrease should immediately follow the increase. In particular, the load with two equal neigbouring values is unacceptable.For example, if the load is described with one of the arrays [1, 2, 8, 4, 3], [1, 3, 5] or [10], then such load satisfies Polycarp (in each of the cases there is an increasing part, immediately followed with a decreasing part). If the load is described with one of the arrays [1, 2, 2, 1], [2, 1, 2] or [10, 10], then such load does not satisfy Polycarp.Help Polycarp to make the minimum number of additional requests, so that the resulting load satisfies Polycarp. He can make any number of additional requests at any minute from 1 to n.

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the duration of the load testing. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the number of requests from friends in the i-th minute of the load testing.

Print the minimum number of additional requests from Polycarp that would make the load strictly increasing in the beginning and then strictly decreasing afterwards.

NoteIn the first example Polycarp must make two additional requests in the third minute and four additional requests in the fourth minute. So the resulting load will look like: [1, 4, 5, 6, 5]. In total, Polycarp will make 6 additional requests.In the second example it is enough to make one additional request in the third minute, so the answer is 1.In the third example the load already satisfies all conditions described in the statement, so the answer is 0.

package main

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

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

	var n int
	Fscan(in, &n)
	arr := make([]int64, n)
	for i := range arr {
		Fscan(in, &arr[i])
	}

	l, r := 0, n-1
	for ; l < n-1 && arr[l] < arr[l+1]; l++ {
	}
	for ; r > 0 && arr[r-1] > arr[r]; r-- {
	}
	incSum := int64(0)
	for l < r {
		if l+1 == r {
			if arr[l] == arr[r] {
				incSum++
			}
			break
		}
		if arr[l] <= arr[r] {
			// 先追平右侧
			if delta := arr[l] + 1 - arr[l+1]; delta >= 0 {
				incSum += delta
				arr[l+1] += delta
			}
			l++
		} else {
			// 先追平左侧
			if delta := arr[r] + 1 - arr[r-1]; delta >= 0 {
				incSum += delta
				arr[r-1] += delta
			}
			r--
		}
	}
	Fprintln(out, incSum)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	arr := make([]int64, n)
	for i := range arr {
		Fscan(in, &arr[i])
	}

	l, r := 0, n-1
	for ; l < n-1 && arr[l] < arr[l+1]; l++ {}
	for ; r > 0 && arr[r-1] > arr[r]; r-- {}
	sum := int64(0)
	for l < r {
		if l+1 == r {
			if arr[l] == arr[r] {
				sum++
			}
			break
		}
		if arr[l] <= arr[r] {
			if d := arr[l] + 1 - arr[l+1]; d >= 0 {
				sum += d
				arr[l+1] += d
			}
			l++
		} else {
			if d := arr[r] + 1 - arr[r-1]; d >= 0 {
				sum += d
				arr[r-1] += d
			}
			r--
		}
	}
	Print(sum)
}


The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has n observation binoculars located at the OX axis. For each i between 1 and n, inclusive, there exists a single binocular located at the point with coordinates (i, 0). There are m flamingos in the Zoo, located at points with positive coordinates. The flamingos are currently sleeping and you can assume that they don't move.In order to get a good view over the flamingos, each of the binoculars can be independently rotated to face any angle (not necessarily integer). Then, the binocular can be used to observe all flamingos that is located at the straight line passing through the binocular at the angle it is set. In other words, you can assign each binocular a direction corresponding to any straight line passing through the binocular, and the binocular will be able to see all flamingos located on that line.Today, some kids from the prestigious Codeforces kindergarten went on a Field Study to the Zoo. Their teacher would like to set each binocular an angle to maximize the number of flamingos that can be seen by the binocular. The teacher is very interested in the sum of these values over all binoculars. Please help him find this sum.

The first line contains two space-separated integers n and m (1 ≤ n ≤ 106, 1 ≤ m ≤ 250), denoting the number of binoculars and the number of flamingos, respectively. Then m lines follow, the i-th line will contain two space-separated integers xi and yi (1 ≤ xi, yi ≤ 109), which means that the i-th flamingo is located at point (xi, yi).  All flamingos will be located at distinct points.

Print a single integer denoting the maximum total number of flamingos that can be seen by all the binoculars.

NoteThis picture shows the answer to the example test case.

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/183/B

package main

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

type Point struct {
	X     int64
	Y     int64
	Index int
}

type Line struct {
	Dx                   int64
	Dy                   int64
	P                    Point
	Q                    Point
	XIntercept           int64
	HasIntegerXIntercept bool
}

func getLine(p Point, q Point) Line {
	Dy := q.Y - p.Y
	Dx := q.X - p.X
	if Dy == 0 {
		return Line{Dx: Dx, Dy: Dy, P: p, Q: q}
	}
	return Line{
		Dx:                   Dx,
		Dy:                   Dy,
		P:                    p,
		Q:                    q,
		XIntercept:           -p.Y*Dx/Dy + p.X,
		HasIntegerXIntercept: (-p.Y*Dx)%Dy == 0,
	}
}

func isPointOnLine(point Point, line Line) bool {
	if line.P.X == point.X || line.Q.X == point.X {
		return false
	}
	return (line.Dx * (point.Y - line.P.Y)) == (line.Dy * (point.X - line.P.X))
}

func Solve(n int, m int, flamingos []Point) int {
	lines := []Line{}
	for i := 0; i < m; i++ {
		for j := i + 1; j < m; j++ {
			line := getLine(flamingos[i], flamingos[j])
			if line.Dy != 0 {
				lines = append(lines, line)
			}
		}
	}
	maxCount := make([]int, n)
	for i := 0; i < n; i++ {
		maxCount[i] = 1
	}
	for _, line := range lines {
		flamingoCount := 2
		for i, flamingo := range flamingos {
			if line.P.Index == i || line.Q.Index == i {
				continue
			}
			if line.Dx == 0 && flamingo.X == line.P.X {
				flamingoCount += 1
			} else if !(line.Dx == 0) && isPointOnLine(flamingo, line) {
				flamingoCount += 1
			}
		}
		if 1 <= line.XIntercept && line.XIntercept <= int64(n) && line.HasIntegerXIntercept {
			if flamingoCount > maxCount[line.XIntercept-1] {
				maxCount[line.XIntercept-1] = flamingoCount
			}
		}
	}
	sum := 0
	for _, elem := range maxCount {
		sum += elem
	}
	return sum
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	flamingos := make([]Point, m)
	for i := 0; i < m; i++ {
		flamingos[i].Index = i
		fmt.Fscanf(reader, "%d %d\n", &flamingos[i].X, &flamingos[i].Y)
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, m, flamingos))
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/183/B

package main

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

type Point struct {
	X     int
	Y     int
	Index int
}

type Line struct {
	Dx                   int
	Dy                   int
	P                    Point
	Q                    Point
	XIntercept           int
	HasIntegerXIntercept bool
}

func getLine(p Point, q Point) Line {
	Dy := q.Y - p.Y
	Dx := q.X - p.X
	if Dy == 0 {
		return Line{Dx: Dx, Dy: Dy, P: p, Q: q}
	}
	return Line{
		Dx:                   Dx,
		Dy:                   Dy,
		P:                    p,
		Q:                    q,
		XIntercept:           -p.Y*Dx/Dy + p.X,
		HasIntegerXIntercept: (-p.Y*Dx)%Dy == 0,
	}
}

func isPointOnLine(point Point, line Line) bool {
	if line.P.X == point.X || line.Q.X == point.X {
		return false
	}
	return (line.Dx * (point.Y - line.P.Y)) == (line.Dy * (point.X - line.P.X))
}

func Solve(n int, m int, flamingos []Point) int {
	lines := []Line{}
	for i := 0; i < m; i++ {
		for j := i + 1; j < m; j++ {
			line := getLine(flamingos[i], flamingos[j])
			if line.Dy != 0 {
				lines = append(lines, line)
			}
		}
	}
	maxCount := make([]int, n)
	for i := 0; i < n; i++ {
		maxCount[i] = 1
	}
	for _, line := range lines {
		flamingoCount := 2
		for i, flamingo := range flamingos {
			if line.P.Index == i || line.Q.Index == i {
				continue
			}
			if line.Dx == 0 && flamingo.X == line.P.X {
				flamingoCount += 1
			} else if !(line.Dx == 0) && isPointOnLine(flamingo, line) {
				flamingoCount += 1
			}
		}
		if 1 <= line.XIntercept && line.XIntercept <= n && line.HasIntegerXIntercept {
			if flamingoCount > maxCount[line.XIntercept-1] {
				maxCount[line.XIntercept-1] = flamingoCount
			}
		}
	}
	sum := 0
	for _, elem := range maxCount {
		sum += elem
	}
	return sum
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	flamingos := make([]Point, m)
	for i := 0; i < m; i++ {
		flamingos[i].Index = i
		fmt.Fscanf(reader, "%d %d\n", &flamingos[i].X, &flamingos[i].Y)
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, m, flamingos))
}


This is an easy version of the problem. In this version, all numbers in the given array are distinct and the constraints on $$$n$$$ are less than in the hard version of the problem.You are given an array $$$a$$$ of $$$n$$$ integers (there are no equals elements in the array). You can perform the following operations on array elements:  choose any index $$$i$$$ ($$$1 \le i \le n$$$) and move the element $$$a[i]$$$ to the begin of the array;  choose any index $$$i$$$ ($$$1 \le i \le n$$$) and move the element $$$a[i]$$$ to the end of the array. For example, if $$$n = 5$$$, $$$a = [4, 7, 2, 3, 9]$$$, then the following sequence of operations can be performed:   after performing the operation of the first type to the second element, the array $$$a$$$ will become $$$[7, 4, 2, 3, 9]$$$;  after performing the operation of the second type to the second element, the array $$$a$$$ will become $$$[7, 2, 3, 9, 4]$$$. You can perform operations of any type any number of times in any order.Find the minimum total number of operations of the first and second type that will make the $$$a$$$ array sorted in non-decreasing order. In other words, what is the minimum number of operations that must be performed so the array satisfies the inequalities $$$a[1] \le a[2] \le \ldots \le a[n]$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the test. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 3000$$$) — length of the array $$$a$$$. Then follow $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$) — an array that needs to be sorted by the given operations. All numbers in the given array are distinct. The sum of $$$n$$$ for all test cases in one test does not exceed $$$3000$$$.

For each test case output one integer — the minimum total number of operations of the first and second type, which will make the array sorted in non-decreasing order.

NoteIn the first test case, you first need to move 3, and then 2 to the beginning of the array. Therefore, the desired sequence of operations: $$$[4, 7, 2, 3, 9] \rightarrow [3, 4, 7, 2, 9] \rightarrow [2, 3, 4, 7, 9]$$$.In the second test case, you need to move the 1 to the beginning of the array, and the 8 — to the end. Therefore, the desired sequence of operations: $$$[3, 5, 8, 1, 7] \rightarrow [1, 3, 5, 8, 7] \rightarrow [1, 3, 5, 7, 8]$$$.In the third test case, the array is already sorted.

package main

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

type Node struct {
	i, v, l int
}

type dataSlice []Node

func (p dataSlice) Len() int           { return len(p) }
func (p dataSlice) Less(i, j int) bool { return p[i].v < p[j].v }
func (p dataSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		datas := make(dataSlice, n)
		for i := 0; i < n; i++ {
			if i+1 == n {
				fmt.Fscanf(reader, "%d\n", &datas[i].v)
			} else {
				fmt.Fscanf(reader, "%d ", &datas[i].v)
			}
			datas[i].i = i
			datas[i].l = 1
		}

		sort.Sort(datas)
		ans := 1

		for i := 1; i < n; i++ {
			if datas[i].i > datas[i-1].i {
				datas[i].l = datas[i-1].l + 1
			}

			if datas[i].l > ans {
				ans = datas[i].l
			}
		}

		fmt.Println(n - ans)
	}
}

package main

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

type Node struct {
	i, v, l int
}

type dataSlice []Node

func (p dataSlice) Len() int           { return len(p) }
func (p dataSlice) Less(i, j int) bool { return p[i].v < p[j].v }
func (p dataSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		datas := make(dataSlice, n)
		for i := 0; i < n; i++ {
			if i+1 == n {
				fmt.Fscanf(reader, "%d\n", &datas[i].v)
			} else {
				fmt.Fscanf(reader, "%d ", &datas[i].v)
			}
			datas[i].i = i
			datas[i].l = 1
		}

		sort.Sort(datas)
		ans := 0

		for i := 1; i < n; i++ {
			if datas[i].i > datas[i-1].i {
				datas[i].l = datas[i-1].l + 1
			}

			if datas[i].l > ans {
				ans = datas[i].l
			}
		}

		fmt.Println(n - ans)
	}
}


You are given a positive integer $$$n$$$.The weight of a permutation $$$p_1, p_2, \ldots, p_n$$$ is the number of indices $$$1\le i\le n$$$ such that $$$i$$$ divides $$$p_i$$$. Find a permutation $$$p_1,p_2,\dots, p_n$$$ with the minimum possible weight (among all permutations of length $$$n$$$).A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^4$$$). The description of the test cases follows. The only line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the length of permutation. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print a line containing $$$n$$$ integers $$$p_1, p_2,\dots, p_n$$$ so that the permutation $$$p$$$ has the minimum possible weight. If there are several possible answers, you can print any of them.

NoteIn the first test case, the only valid permutation is $$$p=[1]$$$. Its weight is $$$1$$$.In the second test case, one possible answer is the permutation $$$p=[2,1,4,3]$$$. One can check that $$$1$$$ divides $$$p_1$$$ and $$$i$$$ does not divide $$$p_i$$$ for $$$i=2,3,4$$$, so the weight of this permutation is $$$1$$$. It is impossible to find a permutation of length $$$4$$$ with a strictly smaller weight.

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s string
	s, _ = reader.ReadString('\n')

	tests, _ := strconv.Atoi(s[:len(s)-2])

	var n int
	for i := 0; i < tests; i++ {
		s, _ = reader.ReadString('\n')
		n, _ = strconv.Atoi(s[:len(s)-2])
		printPerm(n)
	}
}

func printPerm(n int) {
	fmt.Print(n)
	for i := 1; i < n; i++ {
		fmt.Printf(" %d", i)
	}
	fmt.Print("\n")
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s string
	var err error

	s, err = reader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	tests, err := strconv.Atoi(s[:len(s)-2])
	if err != nil {
		panic(err)
	}

	var n int
	for i := 0; i < tests; i++ {
		s, err = reader.ReadString('\n')
		if err != nil {
			panic(err)
		}

		n, err = strconv.Atoi(s[:len(s)-2])
		if err != nil {
			panic(err)
		}

		printPerm(n)
	}
}

func printPerm(n int) {
	for i := 0; i < n; i++ {
		if i == 0 {
			fmt.Print(n)
		} else {
			fmt.Printf(" %d", i)
		}

	}
	fmt.Print("\n")

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s string
	var err error

	s, err = reader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	tests, err := strconv.Atoi(s[:len(s)-2])
	if err != nil {
		panic(err)
	}

	var n int
	for i := 0; i < tests; i++ {
		s, err = reader.ReadString('\n')
		if err != nil {
			panic(err)
		}

		n, err = strconv.Atoi(s[:len(s)-2])
		if err != nil {
			panic(err)
		}

		printPerm(minPerm(n))
	}
}

func minPerm(n int) []int {
	ret := make([]int, n)
	ret[0] = n
	for i := n - 1; i > 0; i-- {
		ret[i] = i
	}

	return ret
}

func printPerm(perm []int) {
	for i := range perm {
		if i == 0 {
			fmt.Print(perm[i])
		} else {
			fmt.Printf(" %d", perm[i])
		}

	}
	fmt.Print("\n")
}

package main

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

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

func CF1711A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n int64
		fmt.Fscan(r, &n)
		for i := int64(1); i<n; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		fmt.Fprintln(w, 1 )
	}
}

package main

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

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

func CF1711A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n int64
		fmt.Fscan(r, &n)
		for i := int64(1); i<n; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		fmt.Fprintln(w,  1)
	}
}

package main

import "fmt"

func main() {
	var (
		t int
		n int
	)
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&n)
		fmt.Printf("%d ", n)
		for i := 1; i < n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
	var (
		t int
		n int
	)
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println(n)
			continue
		}
		if n % 2 == 0 {
			for i := 0; i < n; i++ {
				if i % 2 == 0 {
					fmt.Printf("%d ", i + 2)
				} else {
					fmt.Printf("%d ", i)
				}
			}
		} else {
			fmt.Printf("%d ", n)
			for i := 1; i < n; i++ {
				fmt.Printf("%d ", i)
			}
		}

		fmt.Println()
	}
}

package main

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

type CF11711A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF11711A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF11711A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF11711A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF11711A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF11711A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF11711A
Date: 29/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1711/A
Problem: CF11711A
**/
func (in *CF11711A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		ans := strings.Builder{}
		ans.WriteString(fmt.Sprintf("%d", n))
		for i := 1; i < n; i++ {
			ans.WriteString(fmt.Sprintf(" %d", i))
		}
		fmt.Println(ans.String())
	}
}

func NewCF11711A(r *bufio.Reader) *CF11711A {
	return &CF11711A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF11711A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

func solve() {
	var n int
	_, _ = fmt.Fscan(bufferedStdin, &n)
	_, _ = fmt.Fprintf(bufferedStdout, "%d ", n)
	for i := 1; i < n; i++ {
		_, _ = fmt.Fprintf(bufferedStdout, "%d ", i)
	}
	_, _ = fmt.Fprintf(bufferedStdout, "\n")
}

func main() {
	var t = 1
	_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve()
	}
	_ = bufferedStdout.Flush()
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		fmt.Fprintf(out,"%v ",n)
		for j:=1;j<n;j++{
			fmt.Fprintf(out,"%v ",j)
		}
		fmt.Fprintln(out,)
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func  gcd(a, b int) int {
  for b != 0 {
      a, b = b, a%b
  }
  return a
}

func pl(a ...interface{}) { fmt.Println(a...) }
func pf(format string, a ...interface{}) { fmt.Printf(format, a...) }
func scan(a ...interface{}) { fmt.Fscan(in, a...) }

func solve() {
  var n int
  scan(&n)
  for i := 2; i <= n; i++ { pf("%d ", i) }
  pf("1\n")
}

func main() {
	var T int
	scan(&T)
	for ; T > 0; T-- {
    solve()
	}
}

func ys(b bool) string { return map[bool]string {true: "YES", false: "NO"}[b] }

package main

import "fmt"

func main() {
	var t int
	fmt.Scanln(&t)

	for varr := 0; varr <t; varr++ {
		var n int
		fmt.Scanln(&n)

		fmt.Print(n, " ")
		for i := 1; i <= n-1; i++ {
			fmt.Print(i, " ")
		}

		fmt.Println()
	}

}

package main

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

func main() {
	// f, _ := os.Open("input.txt")
	var reader = bufio.NewReader(os.Stdin)
	// var reader = bufio.NewReader(f)

	var tests int
	fmt.Fscan(reader, &tests)
	for t := 0; t < tests; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if n == 1 {
			fmt.Println(1)
			continue
		}
		for i := 2; i <= n; i++ {
			fmt.Print(i, " ")
		}
		fmt.Println(1)

	}
}

package main

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

var dnl = "%d\n"
var dws = "%d "

func main() {
	defer writer.Flush()
	var t, n, q uint32
	nlPtr := &dnl
	wsPtr := &dws
	scanf(*nlPtr, &t)
	for ; t > 0; t-- {
		scanf(*nlPtr, &n)
		for q = 2; q <= n; q++ {
			printf(*wsPtr, q)
		}
		printf(*nlPtr, 1)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

package main

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

var dnl = "%d\n"
var dws = "%d "

func main() {
	defer writer.Flush()
	var t, n int
	nlPtr := &dnl
	wsPtr := &dws
	scanf(*nlPtr, &t)
	for ; t > 0; t-- {
		scanf(*nlPtr, &n)
		incr := Incrementor()
		for q := 0; q < n-1; q++ {
			printf(*wsPtr, <-incr)
		}
		printf(*nlPtr, 1)
	}
}

func Incrementor() <-chan int {
	outCh := make(chan int)
	go func() {
		for i := 2; ; i++ {
			outCh <- i
		}
	}()
	return outCh
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		res := solve(n)
		for i := 0; i < n; i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) []int {
	// i % p[i] = 0
	res := make([]int, n)
	for i := 1; i < n; i++ {
		res[i-1] = i + 1
	}
	res[n-1] = 1

	return res
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	var t, n int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &n)
		if n%2 == 1 {
			fmt.Fprintf(out, "1")
			for i := 2; i <= n; i += 2 {
				fmt.Fprintf(out, " %d %d", i+1, i)
			}
		} else {
			for i := 1; i <= n; i += 2 {
				fmt.Fprintf(out, "%d %d ", i+1, i)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	var n int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&n)
		fmt.Print(n, " ")
		for i := 1; i < n; i++ {
			fmt.Print(i, " ")
		}
		fmt.Println()

	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		for j := 0; j < n-1; j++ {
			fmt.Printf("%d ", j+2)
		}
		fmt.Printf("%d\n", 1)
	}
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scan(&m)
		print(m)
	}
}

func print(m int) {
	result := make([]string, m)
	for i := 1; i <= m; i++ {
		p := i - 1
		if p == 0 {
			p = m
		}
		result[i-1] = strconv.FormatInt(int64(p), 10)
	}
	fmt.Println(strings.Join(result, " "))
}

// You can edit this code!
// Click here and start typing.
package main

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

type Element struct {
	value int
	pos   int
}

var a []Element
var res []Element
var dp [100004]int64
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.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 min(a int64, b int64) int64 {
	if a <= b {
		return a
	}
	return b
}
func max(a int64, b int64) int64 {
	if a >= b {
		return a
	}
	return b
}
func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}
func main() {
	defer writer.Flush()
	var t, n int
	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		scanf("%d\n", &n)
		printf("%v", n)
		for j := 1; j < n; j++ {
			printf(" %v", j)
		}
		printf("\n")
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int) string {
	rs := make([]string, n)
	rs = append(rs, fmt.Sprint(n))
	for i := 1; i < n; i++ {
		rs = append(rs, fmt.Sprint(i))
	}
	return strings.Join(rs, " ")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		fmt.Println(solve(n))
	}
}

package main

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

func A4() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n int
		Fscan(in, &n)
		Fprint(out, n, " ")
		for i := 1; i < n; i++ {
			Fprint(out, i, " ")
		}
		Fprintln(out)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}
func main() { A4() }

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

func main() {
    in := bufio.NewReader(os.Stdin)
    tc := readInt(in)
    for tc > 0 {
        n := readInt(in)
        if n == 1 {
            fmt.Println(1)
            tc--
            continue
        }
        fmt.Printf("2")
        for i:=2; i<n; i++ {
            fmt.Printf(" %d", i+1)
        }
        fmt.Printf(" 1\n")
        tc--
    }
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

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 < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		if n%2 == 0 {
			for i := 0; i < n; i++ {
				d := i
				if d%2 == 0 {
					d += 2
				}
				fmt.Fprintf(out, "%d ", d)
			}
		} else {
			fmt.Fprintf(out, "%d ", 1)
			for i := 1; i < n; i++ {
				d := i
				if i%2 != 0 {
					d += 2
				}
				fmt.Fprintf(out, "%d ", d)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

func solve() {
	n := get()
	put(n)
	space()
	for i := 1; i < n; i++ {
		put(i)
		space()
	}
	line()
}

const (
	once       = false
	maxBufSize = 0 //10000000
)

var (
	splitFunc = bufio.ScanWords //bufio.SplitFunc(nil)
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	if splitFunc != nil {
		in.Split(splitFunc)
	}
	if maxBufSize > 0 {
		in.Buffer(make([]byte, maxBufSize), maxBufSize)
	}

	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}

	t := get()
	for t > 0 {
		solve()
		t--
	}
}

var (
	in  *bufio.Scanner
	out *bufio.Writer
)

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func geta1(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get() - 1
	}
	return a
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func get64a(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64()
	}
	return a
}

func get64a1(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64() - 1
	}
	return a
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func getfa(n int) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = getf()
	}
	return a
}

func gets() string {
	scan()
	return in.Text()
}

func scanN(n int) {
	for n > 0 {
		scan()
		n--
	}
}

func scan() {
	in.Scan()
}

func putc(c rune) {
	out.WriteRune(c)
}

func line() {
	putc('\n')
}

func space() {
	putc(' ')
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func putln(i int) {
	put(i)
	line()
}

func puta(a []int) {
	for _, v := range a {
		put(v)
		space()
	}
	line()
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func put64ln(x int64) {
	put64(x)
	line()
}

func put64a(a []int64) {
	for _, v := range a {
		put64(v)
		space()
	}
	line()
}

func puts(s string) {
	out.WriteString(s)
}

func putsln(s string) {
	puts(s)
	line()
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES\n")
}

func no() {
	puts("NO\n")
}

func putf(x float64) {
	out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
}

func putfln(x float64) {
	putf(x)
	line()
}

func putfa(a []float64) {
	for _, v := range a {
		putf(v)
		space()
	}
	line()
}

type IntTp interface {
	int | int64
}

type Tp interface {
	IntTp | float64
}

func abs[T IntTp](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func fabs(x float64) float64 {
	return math.Abs(x)
}

func max1[T Tp](x T, y T) T {
	if x > y {
		return x
	}
	return y
}

func max[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = max1(r, x)
	}
	return r
}

func maxa[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] <= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func min1[T Tp](x T, y T) T {
	if x < y {
		return x
	}
	return y
}

func min[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = min1(r, x)
	}
	return r
}

func mina[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] >= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func L(i int) int64 {
	return int64(i)
}

func F(i int) float64 {
	return float64(i)
}

func ints(n int, val int) (a []int) {
	a = make([]int, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func int64s(n int, val int64) (a []int64) {
	a = make([]int64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func floats(n int, val float64) (a []float64) {
	a = make([]float64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

const heapBase = 4

func children(i int) (int, int) {
	start := heapBase * i
	return start + 1, start + (1 + heapBase)
}

func parent(i int) int {
	return (i - 1) / heapBase
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		n := readInt(input)
		fmt.Print(n)
		for i := 1; i < n; i++ {
			fmt.Print(" ")
			fmt.Print(i)
		}
		fmt.Println("")
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

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

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		for i := 1; i <= n; i++ {
			c := i + 1
			if c > n {
				c -= n
			}
			printf("%d ", c)
		}
		printf("\n")
	}
}

package main

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

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	fmt.Fprint(out, n, " ")
	for i := 1; i < n; i++ {
		fmt.Fprint(out, i, " ")
	}
	fmt.Fprintln(out)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var ntests int
	fmt.Fscan(scanner, &ntests)
	for iter := 0; iter < ntests; iter++ {
		var n int
		fmt.Fscan(scanner, &n)
		for i := 2; i <= n; i++ {
			fmt.Fprintf(writer, "%d ", i)
		}
		fmt.Fprintln(writer, 1)
	}
}

package main

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

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

func CF1711A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n int64
		fmt.Fscan(r, &n)
		for i := int64(3); i<n; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		for i := int64(0); i<3; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		fmt.Fprintln(w )
	}
}

package main

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

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

func CF1711A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n int64
		fmt.Fscan(r, &n)
		for i := int64(0); i<n; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

func CF1711A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n int64
		fmt.Fscan(r, &n)
		for i := int64(0); i<n; i++ {
			fmt.Fprint(w,  i+1, " ")
		}
		// fmt.Fprintln(w,  1)
	}
}

package main

import "fmt"

func main() {
	var (
		t int
		n int
	)
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println(n)
			continue
		}
		for i := 0; i < n; i++ {
			if i % 2 == 0 {
				fmt.Printf("%d ", i + 2)
			} else {
				fmt.Printf("%d ", i)
			}
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
	var (
		t int
		n int
	)
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&n)
		for i := 0; i < n; i++ {
			if i % 2 == 0 {
				fmt.Printf("%d ", i + 2)
			} else {
				fmt.Printf("%d ", i)
			}
		}
		fmt.Println()
	}
}

package main

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

type CF11711A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF11711A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF11711A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF11711A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF11711A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF11711A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF11711A
Date: 29/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1711/A
Problem: CF11711A
**/
func (in *CF11711A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		ans := strings.Builder{}
		for i := 0; i < n; i++ {
			ans.WriteString(fmt.Sprintf("%d ", n-i))
		}
		fmt.Println(ans.String())
	}
}

func NewCF11711A(r *bufio.Reader) *CF11711A {
	return &CF11711A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF11711A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

type CF11711A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF11711A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF11711A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF11711A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF11711A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF11711A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF11711A
Date: 29/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1711/A
Problem: CF11711A
**/
func (in *CF11711A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		ans := strings.Builder{}
		for i := 0; i < n; i++ {
			ans.WriteString(fmt.Sprintf("%d ", i+1))
		}
		fmt.Println(ans.String())
	}
}

func NewCF11711A(r *bufio.Reader) *CF11711A {
	return &CF11711A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF11711A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

func solve() {
	var n int
	_, _ = fmt.Fscan(bufferedStdin, &n)
	_, _ = fmt.Fprintf(bufferedStdout, "%d ", n)
	for i := 2; i <= n; i++ {
		_, _ = fmt.Fprintf(bufferedStdout, "%d ", i)
	}
	_, _ = fmt.Fprintf(bufferedStdout, "\n")
}

func main() {
	var t = 1
	_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve()
	}
	_ = bufferedStdout.Flush()
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

func solve() {
	var n int
	_, _ = fmt.Fscan(bufferedStdin, &n)
	_, _ = fmt.Fprintf(bufferedStdout, "%d ", n)
	for i := 2; i <= n; i++ {
		_, _ = fmt.Fprintf(bufferedStdout, "%d ", i)
	}
	_, _ = fmt.Fprintf(bufferedStdout, "\n")
}

func main() {
	var t = 1
	//_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve()
	}
	_ = bufferedStdout.Flush()
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		for j:=1;j<=n;j++{
			fmt.Fprintf(out,"%v ",j)
		}
		fmt.Fprintln(out,)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)

	fmt.Print(n, " ")
	for i := 1; i <= n-1; i++ {
		fmt.Print(i, " ")
	}

	fmt.Println()
}

package main

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

func main() {
	// f, _ := os.Open("input.txt")
	var reader = bufio.NewReader(os.Stdin)
	//var reader = bufio.NewReader(f)

	var tests int
	fmt.Fscan(reader, &tests)
	for t := 0; t < tests; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if n == 1 {
			fmt.Println(1)
			continue
		}
		if n == 3 {
			fmt.Println("1 3 2")
			continue
		}
		if n % 2 == 0 {
			for i := n; i >= 1; i-- {
				fmt.Print(i, " ")
			}
		} else {
			var mid = n / 2 + 1
			fmt.Print(mid, " ")
			for i := n; i >= 1; i-- {
				if i != mid {
					fmt.Print(i, " ")
				}
			}
		}

		fmt.Println()
	}
}


Burenka and Tonya are playing an old Buryat game with a chip on a board of $$$n \times m$$$ cells.At the beginning of the game, the chip is located in the lower left corner of the board. In one move, the player can move the chip to the right or up by any odd number of cells (but you cannot move the chip both to the right and up in one move). The one who cannot make a move loses.Burenka makes the first move, the players take turns. Burenka really wants to win the game, but she is too lazy to come up with a strategy, so you are invited to solve the difficult task of finding it. Name the winner of the game (it is believed that Burenka and Tonya are masters of playing with chips, so they always move in the optimal way).    Chip's starting cell is green, the only cell from which chip can't move is red. if the chip is in the yellow cell, then blue cells are all options to move the chip in one move.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The following is a description of the input data sets. The only line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^9$$$) — the dimensions of the game board.

For each test case print a single line — the name of the winner of the game ("Burenka" or "Tonya").

Tonya
Burenka
Burenka
Tonya
Burenka
Burenka

NoteIn the first case, Burenka has no move, so Tonya wins.In the second case, Burenka can move $$$3$$$ cells to the right, after which Tony will not be able to make a move, which means that Burenka wins.In the third case, Burenka can move $$$5$$$ squares to the right. Then we can say that we have a game on a board of $$$1 \times 5$$$ cells, and Tonya is the first player. In such game the second player wins, so in the original one Burenka will win.

package main

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

const MOD int64 = 1000000007

var n, m int

var h[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

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)

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() string {
	if (n + m) % 2 == 1 {
		return "Burenka"
	}
	return "Tonya"
}

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
    "fmt"
    "sort"
)

/*
type IA []int
func (a IA) Len int { return len(a) }
func (a IA) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a IA) Less(i, j int) bool { return a[i]<a[j] }
*/

func sorti(a []int) {
    sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
}

func main() {
    var tc int;
    fmt.Scanf("%d\n", &tc)
    var m, n int64
    // m, n := 0, 0
    // ia, ib := make([]byte, 1024), make([]byte, 1024)
    for ti:=0; ti<tc; ti++ {
        fmt.Scanf("%d %d\n", &n, &m)
        n = n&1
        m = m&1
        n ^= m;
        if n==0 {
            fmt.Println("Tonya")
        } else {
            fmt.Println("Burenka")
        }
        // fmt.Scanf("%s %s", &ia, &ib)
        // fmt.Println(len(ia), len(ib))
    }
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var n, m int
		fmt.Scanf("%d %d\n", &n, &m)
		sum := n + m
		if sum%2 == 0 {
			fmt.Println("Tonya")
		} else {
			fmt.Println("Burenka")
		}
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var r,c int
		fmt.Fscan(in,&r,&c)
		if (r%2 == 0 && c%2 == 0) || (r%2 != 0 && c%2 != 0) {
			fmt.Fprintln(out,"Tonya")
		} else {
			fmt.Fprintln(out,"Burenka")
		}
	}
}

package main

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

var in *bufio.Reader = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for t > 0 {
		var n, m int
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		if (n+m)%2 == 1 {
			fmt.Println("Burenka")
		} else {
			fmt.Println("Tonya")
		}
		t--
	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n, m int
	scan(&n, &m)
	if (n+m)%2 == 0 {
		printf("Tonya\n")
	} else {
		printf("Burenka\n")
	}

}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

type CF1719A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1719A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1719A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1719A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1719A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1719A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1719A
Date: 8/19/2022
User: wotan
URL: https://codeforces.com/contest/1719/problem/A
Problem: CF1719A
**/
func (in *CF1719A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, m := in.NextInt64(), in.NextInt64()
		if (n+m)%2 == 0 {
			fmt.Println("Tonya")
		} else {
			fmt.Println("Burenka")
		}
	}
}

func NewCF1719A(r *bufio.Reader) *CF1719A {
	return &CF1719A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1719A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &m)
		if (m%2 == 0 && n%2 == 0) || (m%2 == 1 && n%2 == 1) {
			fmt.Println("Tonya")
		} else {
			fmt.Println("Burenka")
		}
	}
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t, n, m int
)

func solve(n, m int) string {
	var r int
	if (n-1)%2 == 1 {
		r++
	}
	if (m-1)%2 == 1 {
		r++
	}
	if r%2 == 0 {
		return "Tonya"
	}
	return "Burenka"
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &m)
		fmt.Println(solve(n, m))
	}
}

// 00
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, m int64
		fmt.Fscan(reader, &n, &m)
		total := n + m - 1
		if total%2 == 1 {
			fmt.Println("Tonya")
		} else {
			fmt.Println("Burenka")
		}

	}
}

package main

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

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)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	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)
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewWriter(writer io.Writer) Writer {
	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()
}

func main() {
	reader := NewWordScanner(os.Stdin)
	writer := NewWriter(os.Stdout)
	defer writer.Flush()
	t := reader.NextInt()
	for i := 0; i < t; i++ {
		n := reader.NextInt()
		m := reader.NextInt()
		if n == m {
			writer.Printf("Tonya\n")
		} else if (n%2 == 0 && m%2 == 0) || (n%2 != 0 && m%2 != 0) {
			writer.Printf("Tonya\n")
		} else {
			writer.Printf("Burenka\n")
		}
	}
}

package main

import "fmt"

func main() {
	var t, n, m int
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&n, &m)
		if (n+m)&1 == 0 {
			fmt.Println("Tonya")
		} else {
			fmt.Println("Burenka")
		}
	}
}

package main

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

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

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

	var T int
	var x int
	var y int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		Fscan(in, &y)

		ans := "Burenka"
		if (x + y ) % 2 == 0 {
			ans = "Tonya"
		}

		Fprintln(out, ans)
	}
}

package main

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

var (
	in   *bufio.Scanner
	out  *bufio.Writer
	once = false
)

func solve() {
	in.Scan()
	m, _ := strconv.Atoi(in.Text())
	in.Scan()
	n, _ := strconv.Atoi(in.Text())
	if m < n {
		n, m = m, n
	}
	if (m-n)%2 == 0 {
		out.WriteString("Tonya\n")
	} else {
		out.WriteString("Burenka\n")
	}
}

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

	if once {
		solve()
		return
	}
	in.Scan()
	x, _ := strconv.Atoi(in.Text())
	for t := 0; t < x; t++ {
		solve()
	}
}

package main

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

const N int = 1e5 + 7
const INF int = math.MaxInt

var a []int = make([]int, N)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, n, m int64

	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		fmt.Fscan(in, &n, &m)
		ans := ((n % 2) + (m % 2)) % 2
		if ans == 0 {
			fmt.Fprintln(out, "Tonya")
		} else {
			fmt.Fprintln(out, "Burenka")
		}
	}
}

package main

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

var (
	reader bufio.Reader
	writer bufio.Writer
)

func main() {
	inp, err := os.Open("in.txt")
	if err == nil {
		os.Stdin = inp
		outp, _ := os.Create("out.txt")
		os.Stdout = outp
		defer outp.Close()
		defer inp.Close()
	}
	reader = *bufio.NewReader(os.Stdin)
	writer = *bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	scan(&T)

	for ; T > 0; T-- {
		var n, m int
		scan(&n, &m)

		if (n + m) % 2 == 0 {
			printf("Tonya\n")
		} else {
			printf("Burenka\n")
		}
	}
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(&reader, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(&writer, format, a...)
}

package main

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

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

	var t, n, m int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		fmt.Fscan(in, &n, &m)
		if n < m {
			n, m = m, n
		}
		if (n - m) % 2 == 1 {
			fmt.Fprintln(out, "Burenka")
		} else {
			fmt.Fprintln(out, "Tonya")
		}

	}

}

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

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		arr := readArrInt(input)
		n := arr[0]
		m := arr[1]
		fmt.Println(solve(n, m))
	}
}

func solve(n, m int) string {
	if (n+m)%2 == 0 {
		return "Tonya"
	} else {
		return "Burenka"
	}

}

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 readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

const MOD int64 = 1000000007

var n, m int

var h[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

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)

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() string {
	if (n + m) % 1 == 0 {
		return "Burenka"
	}
	return "Tonya"
}

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

const MOD int64 = 1000000007

var n, m int

var h[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

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)

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() string {
	if n == 2 && m == 2 {
		return "Tonya"
	}
	if n % 2 == 0 && m % 2 == 0 {
		return "Burenka"
	}
	if (n % 2 == 0 && m % 2 == 1) || (n % 2 == 1 && m % 2 == 0) {
		return "Burenka"
	}
	return "Tonya"
}

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

const MOD int64 = 1000000007

var n, m int

var h[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

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)

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() string {
	if n == 1 && m == 1 {
		return "Tonya"
	}
	if n % 2 == 0 && m % 2 == 0 {
		return "Tonya"
	}
	if (n % 2 == 0 && m % 2 == 1) || (n % 2 == 1 && m % 2 == 0) {
		return "Burenka"
	}
	return "Burenka"
}

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
    "fmt"
    "sort"
)

/*
type IA []int
func (a IA) Len int { return len(a) }
func (a IA) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a IA) Less(i, j int) bool { return a[i]<a[j] }
*/

func sorti(a []int) {
    sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
}

func main() {
    var tc int;
    fmt.Scanf("%d\n", &tc)
    var m, n int64
    // m, n := 0, 0
    // ia, ib := make([]byte, 1024), make([]byte, 1024)
    for ti:=0; ti<tc; ti++ {
        fmt.Scanf("%d %d\n", &n, &m)
        n = n/2
        m = m/2
        n ^= m;
        if n==0 {
            fmt.Println("Tonya")
        } else {
            fmt.Println("Burenka")
        }
        // fmt.Scanf("%s %s", &ia, &ib)
        // fmt.Println(len(ia), len(ib))
    }
}

package main

import (
    "fmt"
    "sort"
)

/*
type IA []int
func (a IA) Len int { return len(a) }
func (a IA) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a IA) Less(i, j int) bool { return a[i]<a[j] }
*/

func sorti(a []int) {
    sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
}

func main() {
    var tc int;
    fmt.Scanf("%d", &tc)
    var m, n int64
    // m, n := 0, 0
    // ia, ib := make([]byte, 1024), make([]byte, 1024)
    for ti:=0; ti<tc; ti++ {
        fmt.Scanf("%d %d", &n, &m)
        n = n/2
        m = m/2
        n ^= m;
        if n==0 {
            fmt.Println("Tonya")
        } else {
            fmt.Println("Burenka")
        }
        // fmt.Scanf("%s %s", &ia, &ib)
        // fmt.Println(len(ia), len(ib))
    }
}