The sequence of $$$m$$$ integers is called the permutation if it contains all integers from $$$1$$$ to $$$m$$$ exactly once. The number $$$m$$$ is called the length of the permutation.Dreamoon has two permutations $$$p_1$$$ and $$$p_2$$$ of non-zero lengths $$$l_1$$$ and $$$l_2$$$.Now Dreamoon concatenates these two permutations into another sequence $$$a$$$ of length $$$l_1 + l_2$$$. First $$$l_1$$$ elements of $$$a$$$ is the permutation $$$p_1$$$ and next $$$l_2$$$ elements of $$$a$$$ is the permutation $$$p_2$$$. You are given the sequence $$$a$$$, and you need to find two permutations $$$p_1$$$ and $$$p_2$$$. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10\,000$$$) denoting the number of test cases in the input. Each test case contains two lines. The first line contains one integer $$$n$$$ ($$$2 \leq n \leq 200\,000$$$): the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n-1$$$). The total sum of $$$n$$$ is less than $$$200\,000$$$.

For each test case, the first line of output should contain one integer $$$k$$$: the number of ways to divide $$$a$$$ into permutations $$$p_1$$$ and $$$p_2$$$. Each of the next $$$k$$$ lines should contain two integers $$$l_1$$$ and $$$l_2$$$ ($$$1 \leq l_1, l_2 \leq n, l_1 + l_2 = n$$$), denoting, that it is possible to divide $$$a$$$ into two permutations of length $$$l_1$$$ and $$$l_2$$$ ($$$p_1$$$ is the first $$$l_1$$$ elements of $$$a$$$, and $$$p_2$$$ is the last $$$l_2$$$ elements of $$$a$$$). You can print solutions in any order.

NoteIn the first example, two possible ways to divide $$$a$$$ into permutations are $$$\{1\} + \{4, 3, 2, 1\}$$$ and $$$\{1,4,3,2\} + \{1\}$$$.In the second example, the only way to divide $$$a$$$ into permutations is $$$\{2,4,1,3\} + \{2,1\}$$$.In the third example, there are no possible ways.

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

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 main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	T := NextInt()

	a := make([]int, 200010)
	was := make([]bool, 200010)
	left := make([]bool, 200010)
	right := make([]bool, 200010)
	for t := 0; t < T; t++ {
		n := NextInt()
		for i := 0; i < n; i++ {
			a[i] = NextInt() - 1
			was[i] = false
			left[i] = false
			right[i] = false
		}
		was[n] = false
		left[n] = false
		right[n] = false
		for i, mex := 0, 0; i < n; i++ {
			if was[a[i]] {
				break
			}
			was[a[i]] = true
			for was[mex] {
				mex++
			}
			left[i] = mex == i+1
		}
		for i := 0; i <= n; i++ {
			was[i] = false
		}
		for i, mex := n-1, 0; i >= 0; i-- {
			if was[a[i]] {
				break
			}
			was[a[i]] = true
			for was[mex] {
				mex++
			}
			right[i] = mex == n-i
		}

		res := 0
		for i := 0; i+1 < n; i++ {
			if left[i] && right[i+1] {
				res++
			}
		}
		fmt.Fprintln(out, res)
		for i := 0; i+1 < n; i++ {
			if left[i] && right[i+1] {
				fmt.Fprintln(out, i+1, n-(i+1))
			}
		}

	}

}

/*
URL:
https://codeforces.com/problemset/problem/1330/B
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	forward, backward := make([]bool, n), make([]bool, n)

	cmax := 0
	fm := make(map[int]int)
	for i := 0; i < n; i++ {
		ChMax(&cmax, A[i])
		fm[A[i]]++

		if i+1 == len(fm) && cmax == len(fm) {
			forward[i] = true
		} else {
			forward[i] = false
		}
	}

	cmax = 0
	bm := make(map[int]int)
	for i := n - 1; i >= 0; i-- {
		ChMax(&cmax, A[i])
		bm[A[i]]++

		if n-i == len(bm) && cmax == len(bm) {
			backward[i] = true
		} else {
			backward[i] = false
		}
	}

	answers := [][2]int{}
	for i := 0; i < n-1; i++ {
		if forward[i] && backward[i+1] {
			answers = append(answers, [2]int{i + 1, n - (i + 1)})
		}
	}

	fmt.Println(len(answers))
	for _, P := range answers {
		fmt.Println(P[0], P[1])
	}
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

type node struct {
	lr       [2]*node
	priority uint
	key      int
	dupCnt   int
	sz       int
}

func (o *node) size() int {
	if o != nil {
		return o.sz
	}
	return 0
}

func (o *node) pushUp() { o.sz = 1 + o.lr[0].size() + o.lr[1].size() }

func (o *node) rotate(d int8) *node {
	x := o.lr[d^1]
	o.lr[d^1] = x.lr[d]
	x.lr[d] = o
	o.pushUp()
	x.pushUp()
	return x
}

type treap struct {
	rd   uint
	root *node
}

func (t *treap) fastRand() uint {
	t.rd ^= t.rd << 13
	t.rd ^= t.rd >> 17
	t.rd ^= t.rd << 5
	return t.rd
}

func (t *treap) less(a, b int) int8 {
	switch {
	case a < b:
		return 0
	case a > b:
		return 1
	default:
		return -1
	}
}

func (t *treap) _put(o *node, key int) *node {
	if o == nil {
		return &node{priority: t.fastRand(), key: key, dupCnt: 1, sz: 1}
	}
	if d := t.less(key, o.key); d >= 0 {
		o.lr[d] = t._put(o.lr[d], key)
		if o.lr[d].priority > o.priority {
			o = o.rotate(d ^ 1)
		}
	} else {
		o.dupCnt++
	}
	o.pushUp()
	return o
}

func (t *treap) put(key int) { t.root = t._put(t.root, key) }

func (t *treap) _delete(o *node, key int) *node {
	if o == nil {
		return nil
	}
	if d := t.less(key, o.key); d >= 0 {
		o.lr[d] = t._delete(o.lr[d], key)
	} else {
		if o.dupCnt > 1 {
			o.dupCnt--
		} else {
			if o.lr[1] == nil {
				return o.lr[0]
			}
			if o.lr[0] == nil {
				return o.lr[1]
			}
			d = 0
			if o.lr[0].priority > o.lr[1].priority {
				d = 1
			}
			o = o.rotate(d)
			o.lr[d] = t._delete(o.lr[d], key)
		}
	}
	o.pushUp()
	return o
}

func (t *treap) delete(key int) { t.root = t._delete(t.root, key) }

func (t *treap) get(key int) *node {
	for o := t.root; o != nil; {
		if d := t.less(key, o.key); d >= 0 {
			o = o.lr[d]
		} else {
			return o
		}
	}
	return nil
}

func (t *treap) min() (min *node) {
	for o := t.root; o != nil; o = o.lr[0] {
		min = o
	}
	return
}

func (t *treap) max() (max *node) {
	for o := t.root; o != nil; o = o.lr[1] {
		max = o
	}
	return
}

func newTreap() *treap { return &treap{rd: 1} }

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

	solve := func() {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		s1, s2 := newTreap(), newTreap()
		s1.put(a[0])
		for _, v := range a[1:] {
			s2.put(v)
		}
		ans := [][2]int{}
		for i := 1; i < n; i++ {
			if s1.root.size() == i && s2.root.size() == n-i {
				if s1.min().key == 1 && s1.max().key == i {
					if s2.min().key == 1 && s2.max().key == n-i {
						ans = append(ans, [2]int{i, n - i})
					}
				}
			}
			s1.put(a[i])
			s2.delete(a[i])
		}
		Fprintln(out, len(ans))
		for _, v := range ans {
			Fprintln(out, v[0],v[1])
		}
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		solve()
	}
}

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


This version of the problem differs from the next one only in the constraint on $$$n$$$.A tree is a connected undirected graph without cycles. A weighted tree has a weight assigned to each edge. The distance between two vertices is the minimum sum of weights on the path connecting them.You are given a weighted tree with $$$n$$$ vertices, each edge has a weight of $$$1$$$. Denote $$$d(v)$$$ as the distance between vertex $$$1$$$ and vertex $$$v$$$.Let $$$f(x)$$$ be the minimum possible value of $$$\max\limits_{1 \leq v \leq n} \ {d(v)}$$$ if you can temporarily add an edge with weight $$$x$$$ between any two vertices $$$a$$$ and $$$b$$$ $$$(1 \le a, b \le n)$$$. Note that after this operation, the graph is no longer a tree.For each integer $$$x$$$ from $$$1$$$ to $$$n$$$, find $$$f(x)$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 3000$$$). Each of the next $$$n−1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le n$$$) indicating that there is an edge between vertices $$$u$$$ and $$$v$$$. It is guaranteed that the given edges form a tree. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3000$$$.

For each test case, print $$$n$$$ integers in a single line, $$$x$$$-th of which is equal to $$$f(x)$$$ for all $$$x$$$ from $$$1$$$ to $$$n$$$.

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

const N = int(3e5 + 10)
const LOGN = int(19)

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int
var subTreeDiam []int

var preOrder []int
var preOrderInv []int
var subTreeSize []int
var firstAtDepth []int
var lastAtDepth []int

var ancestor [N][LOGN]int

func buildAncestors(n int) {
	// assuming ancestor[i][0] is the parent of i, for i in [0,n)
	for j := 0; j+1 < LOGN; j++ {
		for i := 0; i < n; i++ {
			ancestor[i][j+1] = ancestor[ancestor[i][j]][j]
		}
	}
}

func lca(a, b int) int {
	if depth[a] < depth[b] {
		a, b = b, a
	}
	var depthDiff = depth[a] - depth[b]
	for j := LOGN - 1; j >= 0; j-- {
		if ((depthDiff >> j) & 1) > 0 {
			a = ancestor[a][j]
		}
	}
	if a == b {
		return a
	}
	for j := LOGN - 1; j >= 0; j-- {
		if ancestor[a][j] != ancestor[b][j] {
			a = ancestor[a][j]
			b = ancestor[b][j]
		}
	}
	return ancestor[a][0]
}

func rootTree(i, pi int) {
	preOrderInv[i] = len(preOrder)
	preOrder = append(preOrder, i)
	ancestor[i][0] = pi
	if firstAtDepth[depth[i]] == -1 {
		firstAtDepth[depth[i]] = i
	}
	lastAtDepth[depth[i]] = i

	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			sons[i] = append(sons[i], j)
			rootTree(j, i)
		}
	}

	diam := 0
	var longestPaths [2]int = [2]int{depth[i], depth[i]}
	maxDepth[i] = depth[i]
	subTreeSize[i] = 1
	for _, j := range sons[i] {
		if maxDepth[j] > longestPaths[0] {
			longestPaths[1] = longestPaths[0]
			longestPaths[0] = maxDepth[j]
		} else if maxDepth[j] > longestPaths[1] {
			longestPaths[1] = maxDepth[j]
		}
		maxDepth[i] = max(maxDepth[i], maxDepth[j])
		subTreeSize[i] += subTreeSize[j]
		diam = max(subTreeDiam[j], diam)
	}

	diam = max(diam, longestPaths[0]+longestPaths[1]-2*depth[i])
	subTreeDiam[i] = diam
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	subTreeDiam = make([]int, n)

	preOrderInv = make([]int, n)
	subTreeSize = make([]int, n)

	firstAtDepth = make([]int, n)
	lastAtDepth = make([]int, n)

	for i := 0; i < n; i++ {
		firstAtDepth[i] = -1
	}

	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)
	buildAncestors(n)

	for i := n - 1; i > 0; i-- {
		if firstAtDepth[i] == -1 {
			continue
		}
		if firstAtDepth[i-1] == -1 {
			firstAtDepth[i-1] = firstAtDepth[i]
			lastAtDepth[i-1] = lastAtDepth[i]
		} else {
			if preOrderInv[firstAtDepth[i]] < preOrderInv[firstAtDepth[i-1]] {
				firstAtDepth[i-1] = firstAtDepth[i]
			}
			if preOrderInv[lastAtDepth[i]] > preOrderInv[lastAtDepth[i-1]] {
				lastAtDepth[i-1] = lastAtDepth[i]
			}
		}
	}
	// printf("after:\n")
	// for i := 0; i < n; i++ {
	// 	printf("depth %d: %d, %d\n", i, firstAtDepth[i]+1, lastAtDepth[i]+1)
	// }

	// For every k, find the minimum x that can get me answer=k
	for i := 1; i <= n; i++ {
		ans[i] = maxDepth[0]
	}
	for k := 1; k <= n; k++ {
		var x int
		if k+1 >= n || firstAtDepth[k+1] == -1 {
			x = 0
		} else {
			node := lca(firstAtDepth[k+1], lastAtDepth[k+1])
			// printf("nodes = %d -> [%d,%d]. diam=%d\n", node+1, firstAtDepth[k+1]+1, lastAtDepth[k+1]+1, subTreeDiam[node])
			x = k - (subTreeDiam[node]+1)/2
		}
		if x >= 1 {
			ans[x] = min(k, ans[x])
		}
		// printf("minimum to get ans=%d is %d\n", k, x)
	}

	for i := n - 1; i >= 1; i-- {
		ans[i] = min(ans[i], ans[i+1])
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int

func rootTree(i, pi int) {
	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			sons[i] = append(sons[i], j)
			rootTree(j, i)
		}
	}

	maxDepth[i] = depth[i]
	for _, j := range sons[i] {
		maxDepth[i] = max(maxDepth[i], maxDepth[j])
	}
}

func solve(i, x int) int {
	r := min(maxDepth[i], maxDepth[i]-depth[i]+x)

	if len(sons[i]) == 0 {
		return r
	}

	var worst [2]int = [2]int{0, 0}
	for _, j := range sons[i] {
		if maxDepth[j] > worst[0] {
			worst[1] = worst[0]
			worst[0] = maxDepth[j]
		} else if maxDepth[j] > worst[1] {
			worst[1] = maxDepth[j]
		}
	}

	for _, j := range sons[i] {
		var other = worst[0]
		if maxDepth[j] == other {
			other = worst[1]
		}
		other = max(other, depth[i])
		r = min(r, max(other, solve(j, x)))
	}

	return r
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)

	for x := 1; x <= n; x++ {
		ans[x] = solve(0, x)
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int

func rootTree(i, pi int) {
	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			maxDepth[j] = depth[j]
			rootTree(j, i)
			if maxDepth[i] < maxDepth[j] {
				maxDepth[i] = maxDepth[j]
			}
			sons[i] = append(sons[i], j)
		}
	}
}

func solve(i, x int) int {
	r := maxDepth[i]
	if len(sons[i]) == 0 {
		// printf("solve(%d)=%d (leaf case)\n", i+1, r)
		return min(r, x)
	}

	var worst [2]int = [2]int{0, 0}
	for _, j := range sons[i] {
		if maxDepth[j] > worst[0] {
			worst[1] = worst[0]
			worst[0] = maxDepth[j]
		} else if maxDepth[j] > worst[1] {
			worst[1] = maxDepth[j]
		}
	}

	// printf("worst for %d: %v. r=%d\n", i+1, worst, r)
	for _, j := range sons[i] {
		// make edge from j to 0
		var other = worst[0]
		if maxDepth[j] == other {
			other = worst[1]
		}
		// printf("j = %d, other = %d (%d-%d+%d)\n", j+1, other, maxDepth[j], depth[j], x)
		// make edge from j to root
		r = min(
			r,
			max(max(other, depth[i]), maxDepth[j]-depth[j]+x),
		)
		r = min(r, max(max(other, depth[i]), solve(j, x)))
	}

	// printf("solve(%d)=%d\n", i+1, r)
	return r
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)
	// for i := 0; i < n; i++ {
	// 	printf("depths[%d] = %d,%d\n", i+1, depth[i], maxDepth[i])
	// }

	for x := 1; x <= n; x++ {
		ans[x] = solve(0, x)
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

/*
The added edge always goes from some i to 1.

*/

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int

func rootTree(i, pi int) {
	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			maxDepth[j] = depth[j]
			rootTree(j, i)
			if maxDepth[i] < maxDepth[j] {
				maxDepth[i] = maxDepth[j]
			}
			sons[i] = append(sons[i], j)
		}
	}
}

func solve(i, x int) int {
	r := maxDepth[i]
	if len(sons[i]) == 0 {
		// printf("solve(%d)=%d (leaf case)\n", i+1, r)
		return min(r, x)
	}

	var worst [2]int
	for _, j := range sons[i] {
		if maxDepth[j] > worst[0] {
			worst[1] = worst[0]
			worst[0] = maxDepth[j]
		} else if maxDepth[j] > worst[1] {
			worst[1] = maxDepth[j]
		}
	}

	// printf("worst for %d: %v. r=%d\n", i+1, worst, r)
	for _, j := range sons[i] {
		// make edge from j to 0
		var other = worst[0]
		if maxDepth[j] == other {
			other = worst[1]
		}
		// printf("j = %d, other = %d (%d-%d+%d)\n", j+1, other, maxDepth[j], depth[j], x)
		// make edge from j to root
		r = min(
			r,
			max(max(other, depth[i]), maxDepth[j]-depth[j]+x),
		)
		r = min(r, max(max(other, depth[i]), solve(j, x)))
	}

	// printf("solve(%d)=%d\n", i+1, r)
	return r
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)
	// for i := 0; i < n; i++ {
	// 	printf("depths[%d] = %d,%d\n", i+1, depth[i], maxDepth[i])
	// }

	for x := 1; x <= n; x++ {
		ans[x] = solve(0, x)
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

/*
The added edge always goes from some i to 1.

*/

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int

func rootTree(i, pi int) {
	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			maxDepth[j] = depth[j]
			rootTree(j, i)
			if maxDepth[i] < maxDepth[j] {
				maxDepth[i] = maxDepth[j]
			}
			sons[i] = append(sons[i], j)
		}
	}
}

func solve(i, x int) int {
	r := maxDepth[i]
	if len(sons[i]) == 0 {
		// printf("solve(%d)=%d (leaf case)\n", i+1, r)
		return min(r, x)
	}

	var worst [2]int
	for _, j := range sons[i] {
		if maxDepth[j] > worst[0] {
			worst[1] = worst[0]
			worst[0] = maxDepth[j]
		} else if maxDepth[j] > worst[1] {
			worst[1] = maxDepth[j]
		}
	}

	// printf("worst for %d: %v. r=%d\n", i+1, worst, r)
	for _, j := range sons[i] {
		// make edge from j to 0
		var other = worst[0]
		if maxDepth[j] == other {
			other = worst[1]
		}
		// printf("j = %d, other = %d (%d-%d+%d)\n", j+1, other, maxDepth[j], depth[j], x)
		// make edge from j to root
		r = min(
			r,
			max(other, maxDepth[j]-depth[j]+x),
		)
		r = min(r, max(max(other, depth[i]), solve(j, x)))
	}

	// printf("solve(%d)=%d\n", i+1, r)
	return r
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)
	// for i := 0; i < n; i++ {
	// 	printf("depths[%d] = %d,%d\n", i+1, depth[i], maxDepth[i])
	// }

	for x := 1; x <= n; x++ {
		ans[x] = solve(0, x)
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

/*
The added edge always goes from some i to 1.

*/

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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
}

// ----------------------------- TEMPLATE END ----------------------------------

var ans []int
var graph [][]int
var sons [][]int
var depth []int
var maxDepth []int

func rootTree(i, pi int) {
	for _, j := range graph[i] {
		if j != pi {
			depth[j] = depth[i] + 1
			maxDepth[j] = depth[j]
			rootTree(j, i)
			if maxDepth[i] < maxDepth[j] {
				maxDepth[i] = maxDepth[j]
			}
			sons[i] = append(sons[i], j)
		}
	}
}

func solve(i, x int) int {
	r := maxDepth[i]
	if len(sons[i]) == 0 {
		// printf("solve(%d)=%d (leaf case)\n", i+1, r)
		return r
	}
	var worst [2]int
	for _, j := range sons[i] {
		if maxDepth[j] > worst[0] {
			worst[1] = worst[0]
			worst[0] = maxDepth[j]
		} else if maxDepth[j] > worst[1] {
			worst[1] = maxDepth[j]
		}
	}

	// printf("worst for %d: %v. r=%d\n", i+1, worst, r)
	for _, j := range sons[i] {
		// make edge from j to 0
		var other = worst[0]
		if maxDepth[j] == other {
			other = worst[1]
		}
		// printf("j = %d, other = %d (%d-%d+%d)\n", j+1, other, maxDepth[j], depth[j], x)
		r = min(
			r,
			max(other, maxDepth[j]-depth[j]+x),
		)
		r = min(r, max(other, solve(j, x)))
	}

	// printf("solve(%d)=%d\n", i+1, r)
	return r
}

func solveCase() {
	var n int
	scan(&n)
	ans = make([]int, n+1)
	graph = make([][]int, n)
	sons = make([][]int, n)
	depth = make([]int, n)
	maxDepth = make([]int, n)
	var a, b int
	for edges := 0; edges < n-1; edges++ {
		scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	rootTree(0, 0)
	// for i := 0; i < n; i++ {
	// 	printf("depths[%d] = %d,%d\n", i+1, depth[i], maxDepth[i])
	// }

	for x := 1; x <= n; x++ {
		ans[x] = solve(0, x)
	}

	for i := 1; i <= n; i++ {
		if i > 1 {
			printf(" ")
		}
		printf("%d", ans[i])
	}
	printf("\n")
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

/*
The added edge always goes from some i to 1.

*/


Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.Please help Dr. Banner.

The only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.

I hate it
I hate that I love it
I hate that I love that I hate it

package main

// https://codeforces.com/problemset/problem/705/A

import "fmt"

func taskSolution(n int) (ans string) {
	ans = "I hate"
	a := []string{" that I love", " that I hate"}
	for i := 2; i <= n; i += 1 {
		ans += a[i%2]
	}
	return ans + " it"
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(n))
}

package main

import "fmt"

func main() {
	h1:="I hate it "
	h2:="I hate that "
	l1:="I love it "
	l2:="I love that "

	var size int
	fmt.Scan(&size)

	flag:=true
	for size>0  {
		if size ==1 &&flag==true{
			fmt.Print(h1)
			size--
		}else if size ==1 &&flag==false{
			fmt.Print(l1)
			size--
		}else {
			if flag ==true{
				fmt.Print(h2)
				flag=false
				size--
			}else {
				fmt.Print(l2)
				flag=true
				size--
			}
		}

	}

}

package main
import "fmt"
func main() {
    var n int
    i := 0
    fmt.Scan(&n)
    fmt.Print("I hate")
    for i < n-1{
        if i % 2 == 0{
            fmt.Print(" that I love ")
        }else{
            fmt.Print(" that I hate")
        }
        i++
    }
    fmt.Print(" it");
}

package main
import "fmt"
func main() {
    var n, i int
    i = 0
    fmt.Scan(&n)
    fmt.Print("I hate")
    for i < n-1{
        if i % 2 == 0{
            fmt.Print(" that I love ")
        }else{
            fmt.Print(" that I hate")
        }
        i++
    }
    fmt.Print(" it");
}

package main
import (
    "fmt"
)
var print = fmt.Println
func main(){
	var n int
	fmt.Scan(&n)

	var s string = ""

	for i:=0; i<n ;i++ {
		if i%2 == 0{
			s += "I hate that "
		}else if i%2 == 1{
			s += "I love that "
		}
	}
	s = string(s[:len(s)-5])+"it"
	print(s)
}

package main

import "fmt"

func hulk(t int){

	for i:= 1 ; i <= t ; i++ {
		if i == t {
				if t % 2 == 0 {
							fmt.Print("I love it")
				} else{
							fmt.Print("I hate it")
				}
		}
		if i < t {
			if i % 2 == 1 {
					fmt.Print("I hate that ")
			}else {
					fmt.Print("I love that ")
			}
		}
	}
return
}

func main(){

		var t int
		fmt.Scan(&t)
		hulk(t)
}

package main

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

func main() {
	var n int
	var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())

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

		if i & 1 == 0 {
			fmt.Print("I hate")
		} else {
			fmt.Print("I love")
		}

		if i < n - 1 {
			fmt.Print(" that ")
		} else {
			fmt.Println(" it")
		}
	}
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	for i:=1;i<=n;i++ {
		if i==1 {
			fmt.Printf("I hate")
		} else if i%2==0 {
			fmt.Printf(" that I love")
		} else {
			fmt.Printf(" that I hate")
		}
	}
	fmt.Printf(" it")
}

package main

import "fmt"

func main()  {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= n; i ++{
		fmt.Print("I ")
		if i % 2 == 1 {
			fmt.Print("hate ")
		}else {
			fmt.Print("love ")
		}
		if i == n {
			fmt.Print("it ")
		} else{
			fmt.Print("that ")
		}
	}
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	a := "I love that"
	b := "I hate that"
	c := "I hate it"
	d := "I love it"
	for i := 1; i <= n; i++ {
		if i == n {
			if i%2 == 1 {
				O(c, "")
			} else {
				O(d, "")
			}
		} else {
			if i%2 == 1 {
				O(b, " ")
			} else {
				O(a, " ")
			}
		}
	}
	O("", "\n")
}

package main

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

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	var ans strings.Builder
	ans.WriteString("I hate ")
	for i := 1; i < n; i++ {
		ans.WriteString("that ")
		if i%2 == 0 {
			ans.WriteString("I hate ")
		} else {
			ans.WriteString("I love ")
		}
	}
	ans.WriteString("it")
	fmt.Println(ans.String())
}

// A. Hulk
/*
Dr. Bruce Banner hates his enemies (like others don't). As we all know,
he can barely talk when he turns into the incredible Hulk.
That's why he asked you to help him to express his feelings.

Hulk likes the Inception so much, and like that his feelings are complicated.
They have n layers. The first layer is hate, second one is love,
third one is hate and so on...

For example if n = 1, then his feeling is "I hate it" or if n = 2 it's
"I hate that I love it", and if n = 3 it's "I hate that I love that I hate it"
and so on.

Please help Dr. Banner.

Input
The only line of the input contains a single integer n (1 ≤ n ≤ 100) —
the number of layers of love and hate.

Output
Print Dr.Banner's feeling in one line.

Examples
Input
1

Output
I hate it

Input
2

Output
I hate that I love it

Input
3

Output
I hate that I love that I hate it
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()

	i, _ := strconv.Atoi(string(input))
	fmt.Println(sol795A(i))
}

func sol795A(c int) string {
	output := []string{}
	for i := 1; i <= c; i++ {
		s := ""
		if i%2 == 1 {
			if i == c {
				s = "I hate it"
			} else {
				s = "I hate that"
			}
		} else {
			if i == c {
				s = "I love it"
			} else {
				s = "I love that"
			}
		}
		output = append(output, s)
	}

	return strings.Join(output, " ")
}

// A. Hulk
/*
Dr. Bruce Banner hates his enemies (like others don't). As we all know,
he can barely talk when he turns into the incredible Hulk.
That's why he asked you to help him to express his feelings.

Hulk likes the Inception so much, and like that his feelings are complicated.
They have n layers. The first layer is hate, second one is love,
third one is hate and so on...

For example if n = 1, then his feeling is "I hate it" or if n = 2 it's
"I hate that I love it", and if n = 3 it's "I hate that I love that I hate it"
and so on.

Please help Dr. Banner.

Input
The only line of the input contains a single integer n (1 ≤ n ≤ 100) —
the number of layers of love and hate.

Output
Print Dr.Banner's feeling in one line.

Examples
Input
1

Output
I hate it

Input
2

Output
I hate that I love it

Input
3

Output
I hate that I love that I hate it
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()

	i, _ := strconv.Atoi(string(input))
	// fmt.Println(sol705A(i))
	sol2_705A(i)
}

func sol705A(c int) string {
	output := []string{}
	for i := 1; i <= c; i++ {
		s := ""
		if i%2 == 1 {
			if i == c {
				s = "I hate it"
			} else {
				s = "I hate that"
			}
		} else {
			if i == c {
				s = "I love it"
			} else {
				s = "I love that"
			}
		}
		output = append(output, s)
	}

	return strings.Join(output, " ")
}

func sol2_705A(c int) {
	for i := 1; i <= c; i++ {
		if i%2 == 1 {
			fmt.Print("I hate ")
		} else {
			fmt.Print("I love ")
		}
		if i == c {
			fmt.Print("it")
		} else {
			fmt.Print("that ")
		}
	}
}

package main

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

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

	in.Split(bufio.ScanWords)
	defer out.Flush()

	a := []string{"I hate", "I love"}

	in.Scan()
	n, _ := strconv.Atoi(in.Text())

	for i := 0; i < n; i++ {
		out.WriteString(a[i&1])
		if i < n-1 {
			out.WriteString(" that ")
		} else {
			out.WriteString(" it")
		}
	}
	out.WriteByte('\n')
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var answer string
	fmt.Scan(&n)
	for k := 1; k < n+1; k++ {
		if k%2 == 1 {
			answer += "I hate "
		} else {
			answer += "I love "
		}
		if n == k {
			answer += "it"
		} else {
			answer += "that "
		}
	}
	fmt.Println(answer)
}

package main

import "fmt"

func main() {
	var a int
	var output string
	fmt.Scan(&a)
	for i := 0; i < a; i++ {
		if i%2 == 0 {
			output = output + "I hate "
		} else if i%2 == 1 {
			output = output + "I love "
		}
		if i+1 != a {
			output = output + "that "
		} else {
			output = output + "it"
		}
	}
	fmt.Println(output)
}

package main

import "fmt"

func main() {
	a := "I hate"
	b := "I love"
	e := " it"
	plus := " that "
	s := "I hate"
	var n int
	fmt.Scan(&n)
	for i := 1; i < n; i++ {
		if i%2 == 1 {
			s = s + plus + b
		} else {
			s = s + plus + a
		}
	}
	s = s + e
	fmt.Println(s)
}

package main

import(
    "fmt"
)

type u16 uint16

func main(){
    var(
        n,i u16
        s1,s2,s3,s4 = "I hate it","I hate that","I love it","I love that"
    )
    fmt.Scan(&n)
    if n==1{
        fmt.Println(s1)
    }else{
        for i=0;i<n-1;i++{
            if (i+1)%2==1{
                fmt.Print(s2," ")
            }else{
                fmt.Print(s4," ")
            }
        }
        if n%2==0{
            fmt.Println(s3)
        }else{
            fmt.Println(s1)
        }
    }
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var ans = ""
	_, _ = fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		if i % 2 == 1 {
			ans += "I hate "
		} else {
			ans += "I love "
		}
		if i != n {
			ans += "that "
		}
	}
	ans += "it"
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	odd := "I hate"
	even := "I love"
	s := ""

	for i := 1; i <= n; i++ {
		if i != 1 {
			s += " that "
		}
		if i%2 == 1 {
			s += odd
		} else {
			s += even
		}
	}
	s += " it"
	fmt.Println(s)
}

package main

import "fmt"

func main(){
    var n int
	fmt.Scan(&n)
	for i := 1 ; i <= n ; i++ {
		if i == 1 {
			fmt.Printf("I hate")
		} else if i % 2 == 0 {
			fmt.Printf(" that I love")
		} else {
			fmt.Printf(" that I hate")
		}
	}
	fmt.Printf(" it")
}

package main

import "fmt"

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

	str := ""
	for i := range make([]struct{}, n) {
		if i != 0 {
			str += "that "
		}
		if i%2 == 0 {
			str += "I hate "
		} else {
			str += "I love "
		}
	}
	str += "it"
	fmt.Println(str)
}

package main

import "fmt"

func main() {
	var n int
	s1 := "I love"
	s2 := "I hate"

	fmt.Scan(&n)

	r := ""
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			r = r + s1
			if i != n {
				r = r + " that "
			}
		} else {
			r = r + s2
			if i != n {
				r = r + " that "
			}
		}
	}
	r = r + " it"
	fmt.Print(r)
}

package main

import (
	"fmt"
)

func main() {
	hate := "I hate"
	love := "I love"
	var c int
	fmt.Scan(&c)
	finalString := ""
	for i := 1; i <= c; i++ {
		if i%2 == 0 {
			if i != c {
				finalString = finalString + love + " that "
			} else {
				finalString = finalString + love + " it"
			}
		} else {
			if i != c {
				finalString = finalString + hate + " that "
			} else {
				finalString = finalString + hate + " it"
			}
		}
	}
	fmt.Printf(finalString + "")
}

// Халк
//Например, для n = 1 чувства Халка выражаются как "I hate it", для n = 2 это уже "I hate that I love it", а для n = 3 — "I hate that I love that I hate it".
package main

import "fmt"

func main() {
	var n int
	var th string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			th += "I hate "
		} else {
			th += "I love "
		}
		if i != n-1 {
			th += "that "
		} else {
			th += "it"
		}
	}
	fmt.Println(th)
}

package main

import "fmt"

func main(){
        hateStatement := "I hate "
        loveStatement := "I love "
        var n int
        fmt.Scanf("%d",&n)
        for i:=0;i<n;i++{
                if i%2==0{
                        fmt.Print(hateStatement)
                        if i!=n-1{
                                fmt.Print("that ")
                        } else {
                                fmt.Println("it")
                        }
                } else {
                        fmt.Print(loveStatement)
                        if i!=n-1{
                                fmt.Print("that ")
                        } else {
                                fmt.Println("it")
                        }
                }
        }
}

package main

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

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

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

func Println(a ...interface{}) {
	fmt.Println(a...)
}

func main() {
	var n int
	scan(&n)
	fmt.Print("I hate ")
	for i:=0; i<n-1;i++{
		if i%2==0{
			fmt.Print("that I love ")
		} else {
			fmt.Print("that I hate ")
		}
	}
	fmt.Print("it")
}

package main

import "fmt"

func main() {
	h1 := "I hate it "
	h2 := "I hate that "
	l1 := "I love it "
	l2 := "I love that "

	var size int
	fmt.Scan(&size)

	flag := true
	for size > 0 {
		if size == 1 && flag == true {
			fmt.Print(h1)
			size--
		} else if size == 1 && flag == false {
			fmt.Print(l1)
			size--
		} else {
			if flag == true {
				fmt.Print(h2)
				flag = false
				size--
			} else {
				fmt.Print(l2)
				flag = true
				size--
			}
		}

	}
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    /*str1 := "I hate"
    str2 := "I love"*/
    var str3 string
    /*if n == 0 {
        str3 = str3 + "I hate it"
    } */
    for i := 0; i < n; i++ {
        if i%2 == 0 && i != n-1 {
            str3 = str3 + "I hate that "
        }
        if i%2 == 0 && i == n-1 {
            str3 = str3 + "I hate it"
		}
        if i%2 == 1 && i != n-1 {
            str3 = str3 + "I love that "
        }
        if i%2 == 1 && i == n-1 {
            str3 = str3 + "I love it"
        }
	}
	fmt.Println(str3)
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    if n == 1 {
        fmt.Println("I hate it")
        return
    }
    res := "I hate"
    for i := 2; i <= n; i ++ {
        if i%2 == 0 {
            res += " that I love"
        } else {
            res += " that I hate"
        }
    }
    res += " it"
    fmt.Println(res)
}

package main

import "fmt"

func main() {
   var n int
   fmt.Scan(&n)
   var ans string
   for i := 0; i < n - 1; i ++ {
      if i % 2 == 0 {
         ans += "I hate that"
      } else {
         ans += " I love that "
      }
   }
   if (n - 1) % 2 == 0 {
      ans += "I hate it"
   } else {
      ans += " I love it "
   }
   fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {

	var n int
	fmt.Scanf("%d\n", &n)

	love := "I love"
	hate := "I hate"
	i:=0
	for ; i < n - 1; i+=1 {
		if i%2 == 0 {
			fmt.Print(hate, " that ")
		} else {
			fmt.Print(love, " that ")
		}
	}
	if i%2 == 0 {
		fmt.Print(hate, " it")
	} else {
		fmt.Print(love, " it")
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	s := "I hate"
	fmt.Scanf("%d \n", &n)
	for i := 1; i < n; i++ {
		s += " that I "
		if i % 2 == 1 {
			s += "love"
		} else {
			s += "hate"
		}
	}
	s += " it"
	fmt.Print(s)
}

package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	if n%2==0{
		for i:=1;i<n/2;i++{
			fmt.Print("I hate that I love that ")
		}
		fmt.Println("I hate that I love it")
	}else{
		for i:=0;i<n/2;i++{
			fmt.Print("I hate that I love that ")
		}
		fmt.Println("I hate it")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:=0;i<n;i++{
		if i%2==0 && i!=n-1 {
			fmt.Printf("I hate that ")
		} else if i%2==1 && i!=n-1 {
			fmt.Printf("I love that ")
		} else if i==n-1 && i%2==0{
			fmt.Printf("I hate it")
		} else if i==n-1 && i%2==1 {
			fmt.Printf("I love it")
		}
	}
}

package  main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d",&n)
	ans := "";
	for i := 0 ; i < n; i++ {
		if len(ans) > 0{
			ans += " that ";
		}
		if i & 1 == 1 {
			ans += "I love"
		} else {
			ans += "I hate"
		}
	}
	ans += " it";
	fmt.Println(ans);
}

package main

import "fmt"

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

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			fmt.Print("I hate ")
		} else {
			fmt.Print("I love ")
		}
		if i == n-1 {
			fmt.Print("it")
		} else {
			fmt.Print("that ")
		}
	}
	fmt.Print("\n")
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	var n int
	fmt.Sscanf(readLine(reader), "%d", &n)
	var s []string
	for i:=1; i<=n; i++ {
		if i % 2 != 0 {
			s = append(s, "I hate")
		} else {
			s = append(s, "I love")
		}
	}
	res := strings.Join(s, " that ")
	fmt.Printf("%s it\n", res)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import "fmt"

func main() {
	var n int
	var str string
	fmt.Scan(&n)
	str = str + "I hate "
	for i:=0; i<n-1; i++ {
		if i % 2 == 0 {
			str = str + "that I love "
		} else {
			str = str + "that I hate "
		}
	}
	fmt.Println(str + "it")
}

package main

import (
	"fmt"
)

func main() {
	var n, k uint
	var st string
	k = 1
	fmt.Scan(&n)
	for k <= n {
		if k%2 == 0 {
			st += "I love that "
		} else {
			st += "I hate that "
		}

		k++
	}
	st = st[:len(st)-5] + "it"
	fmt.Println(st)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var output = make([]string, n)
	if n%2 == 1 {
		output[n-1] = "I hate it"
	} else {
		output[n-1] = "I love it"
	}
	n--
	for n > 0 {

		if n%2 == 0 {
			output[n-1] = " I love that"
		} else {
			output[n-1] = " I hate that"
		}
		n--

	}
	fmt.Print(strings.Join(output, " "))
}

package main

import (
	"fmt"
	"strings"
)
func main() {
	var a int
	res := []string{}
	fmt.Scan(&a)
	b := a / 2
	c := a % 2
	for i := 0; i<b; i++ {
		res = append(res, "I hate that I love")
	}
	stro := strings.Join(res, " that ")
	if c == 0 {
		fmt.Println(stro, "it")
	} else {
		if a != 1 {
			fmt.Println(stro, "that I hate it")
		} else {
			fmt.Println("I hate it")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Print("I hate ")
	for i := 2; i <= n; i++ {
		if i % 2 == 0 {
			fmt.Print("that I love ")
		} else {
			fmt.Print("that I hate ")
		}
	}
	fmt.Println("it")
}

package main

import (
	"fmt"
)

func main(){
	var n int
	fmt.Scan(&n)
	fmt.Println(solve("I hate",1,n))
}

func solve(s string, n int, N int) string{
	//fmt.Println("inside ",n)
	if n == N{
		return s+" it"
	}else if n%2 == 1{
		s = s + " that I love"
		return solve(s,n+1,N)
	}else{
		s = s + " that I hate"
		return solve(s,n+1,N)
	}
}

package main

import "fmt"

func main() {
	var feelings []string
	var layers int

	fmt.Scan(&layers)
	for i := 0; i<layers; i++ {
		if i%2 == 0 {
			feelings = append(feelings, "I hate")
		} else {
			feelings = append(feelings, "I love")
		}
		if i != layers-1 {
			feelings = append(feelings, " that ")
		}
	}
	if layers > 0{
		feelings = append(feelings, " it")
	}

	for _, val := range feelings {
		fmt.Printf("%s", val)
		// if ind != layers -1 {
		// 	fmt.Printf(" ")
		// }
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		n int
		ans string
	)

	fmt.Scanf("%d", &n)

	for i := n-1; i >= 1; i-- {

		if i % 2 == 0 {
			ans = "I love that " + ans
		}else {
			ans = "I hate that " + ans
		}

	}

	if n % 2 == 0 {
		//even, ends with "I love it"
		ans += "I love it"
	} else {
		//odd, ends with "I hate it"
		ans += "I hate it"
	}

	fmt.Println(ans)
}

package main

import "fmt"

func main() {

	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Print("that ")
		}
		if i%2 != 0 {
			fmt.Print("I love ")
		} else {
			fmt.Print("I hate ")
		}
	}
	fmt.Println("it")
}

package main

import "fmt"

func main() {
	var a uint8
	var b string
	fmt.Scanf("%d", &a)
	for i := uint8(1); i <= a; i++ {
		if i%2 == 0 {
			b += "I love "
		} else {
			b += "I hate "
		}
		if i != a {
			b += "that "
		} else {
			b += "it"
		}
	}
	fmt.Println(b)
}

package main

import (
	"fmt"
)

func main() {
	var n, i int
	fmt.Scan(&n)
	hIt := "I hate it"
	lIt := "I love it"
	hThat := "I hate that"
	lThat := "I love that"
	if n == 1 {
		fmt.Println(hIt)
	} else if n == 2 {
		fmt.Println(hThat + " " + lIt)
	} else {
		if n%2 == 1 {
			for i = 1; i < n-1; i+=2 {
				fmt.Print(hThat)
				fmt.Print(" " + lThat + " ")
			}
			fmt.Print(hIt)
		} else {
			fmt.Print(hThat)
			for i = 1; i < n-2; i+=2 {
				fmt.Print(" " + lThat + " ")
				fmt.Print(hThat)
			}
			fmt.Print(" " + lIt)
		}
	}
}

package main

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

func getNextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, _ := strconv.Atoi(string(scanner.Bytes()))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	i, _ := strconv.ParseInt(string(scanner.Bytes()), 10, 64)
	return i
}

func main() {

	reader := bufio.NewReader(os.Stdin)
	scanner := bufio.NewScanner(reader)
	// Set the split function for the scanning operation.
	scanner.Split(bufio.ScanWords)
	nbCase := getNextInt(scanner)

	messages := []string{"I hate that","I love that"}
	lastMessages := []string{"I hate it","I love it"}

	for i:=0; i<nbCase; i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		if i == nbCase-1 {
			fmt.Print(lastMessages[i%2])
		} else {
			fmt.Print(messages[i%2])
		}
	}

}

package main

import (
	"fmt"
)

func main() {

	var n int
	storage := "I hate"
	fmt.Scanln(&n)
	for i := 1; i <= n; i++ {
		if i == n {
			storage += " it"
			break
		} else {
			storage += " that"
		}
		if i%2 == 0 {
			storage += " I hate"
		} else {
			storage += " I love"
		}
	}
	fmt.Println(storage)
}

package main

import "fmt"

func main() {
  var n int
  fmt.Scanf("%d", &n)

  var feelings string
  for i := 1; i <= n-1; i++ {
    if i%2 == 1 {
      feelings += "I hate that "
      continue
    }
    feelings += "I love that "
  }
  if n%2 == 1 {
    fmt.Println(feelings + "I hate it")
    return
  }
  fmt.Println(feelings + "I love it")
}

package main

import (
	"fmt"
)

func main() {

	var phrase1 string = "I hate"
	var phrase2 string = "I love"
	var number int
	fmt.Scan(&number)
	var count int = 0
	for count+1 < number {
		if count+1 < number {
			count = count + 1
			fmt.Print(phrase1, " that ")
		}
		if count+1 < number {
			count = count + 1
			fmt.Print(phrase2, " that ")
		}
	}
	if count%2 == 1 {
		fmt.Print(phrase2, " it ")
	} else if count%2 == 0 {
		fmt.Print(phrase1, " it ")
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i:=1;i<=n;i++ {
        if (i%2==1) {
            fmt.Print(" I hate ")
        } else {
            fmt.Print(" I love ")
        }
        if (i==n) {
            fmt.Print("it")
        } else {
            fmt.Print("that")
        }
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	delim := ""
	for i := 0; i < n; i++ {
		fmt.Printf(delim + "I ")
		if i%2 == 0 {
			fmt.Printf("hate ")
		} else {
			fmt.Printf("love ")
		}
		delim = "that "
	}
	fmt.Printf("it\n")
}

package main

import "fmt"

var t int
var s string

func main() {
    fmt.Scanf("%d", &t)
    for i := 0; i < t; i++ {
        if i % 2 == 0 {
            s += "I hate"
        } else {
            s += "I love"
        }
        if i == t - 1 {
            s += " it"
        } else {
            s += " that "
        }
    }
    fmt.Println(s)
}

package main

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

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 main() {
	defer writer.Flush()

	var (
		n int
	)

	scanf("%d\n", &n)

	printf("I hate ")
	for i := 1; i < n; i++ {
		if i%2 == 0 {
			printf("that I hate ")
		} else {
			printf("that I love ")
		}
	}

	printf("it\n")
}

package main

import (
	"fmt"
)

func main() {

	var n int
	storage := "I hate"
	fmt.Scanln(&n)
	for i := 1; i <= n; i++ {
		if i == n {
			storage += " it"
			break
		}
		if i%2 == 0 {
			storage += " that I hate"
		} else {
			storage += " that I love"
		}
	}
	fmt.Println(storage)
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	count := 0
	for scanner.Scan() {
		count, _ = strconv.Atoi(scanner.Text())
	}
	for i := 1; i < count; i++ {
		if i%2 == 0 {
			fmt.Print("I love that ")
		} else {
			fmt.Print("I hate that ")
		}
	}
	if count%2 == 0 {
		fmt.Print("I love it ")
	} else {
		fmt.Print("I hate it ")
	}
}

package main
import "fmt"
func main(){
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++{
		if i%2==1 {
			fmt.Printf("I love ")
		} else {
			fmt.Printf("I hate ")
		}
		if i != n-1{
			fmt.Printf("that ")
		}
	}
	fmt.Printf("it\n")
}

package main

import (
	"fmt"
	"strings"
)

func main() {

	var level int
	_, err := fmt.Scanf("%d", &level)
	if err != nil {
		panic(err)
	}

	var levels = []string{"I hate", "I love"}

	var result []string
	for i := 0; i < level; i++ {
	    result = append(result, levels[i % 2])
	}

	fmt.Println(strings.Join(result, " that "), "it")
}

package main

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

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

func scanf(f string, a... interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

const (
	HATE = "I hate it"
	LOVE = "I love it"
)

func main() {

	var T, i uint

	scanf("%d\n", &T)

	result := "I hate it"
	for i=2; i<=T; i++ {

		if i % 2 == 0 {
			result = strings.ReplaceAll(result, "it", "that " + LOVE )
		}else {
			result = strings.ReplaceAll(result, "it", "that " + HATE )
		}

	}

	fmt.Println(result)

}

package main
import "fmt"
func main() {
	var n int
	fmt.Scan(&n)
	n+=1
	for i := 1; i < n; i++ {
	    if i%2 == 0 {
	        fmt.Print("I love ")
	        if i == n-1 { fmt.Print("it") }
	        if i != n-1 { fmt.Print("that") }
	        if i != n-1 { fmt.Print(" ") }
	    } else {
	        fmt.Print("I hate ")
	        if i == n-1 { fmt.Print("it") }
	        if i != n-1 { fmt.Print("that") }
	        if i != n-1 { fmt.Print(" ") }

	    }
	}
	fmt.Println()
}

package main

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

var scanner *bufio.Scanner
func read() string {
    if !scanner.Scan() {
		panic("Scan returned false")
	}
	return scanner.Text()
}
func readInt() int {
	num, _ := strconv.Atoi(read())
	return num
}
func main() {
    scanner = bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    n := readInt()

    f := []string{"I hate", "I love"}
    var fls []string

    for i := 0 ; i < n; i++ {
        fls =  append(fls, f[i % 2])
    }

    fmt.Println(strings.Join(fls, " that "), "it")
}

package main
import "fmt"

func print(t string) {
	fmt.Print("I " + t)
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 1; i < n; i++ {
		if i % 2 == 0 {
			print("love that ")
		} else {
			print("hate that ")
		}
	}
	if n % 2 == 0 {
		print("love it")
	} else {
		print("hate it")
	}
}

package main
import (
	"fmt"
	"strings"
)

var types = []string{"I love", "I hate"}

func main() {
	var n int
	fmt.Scanln(&n)
	var result []string
	for i := 1; i <= n; i++ {
		result = append(result, types[i % 2])
	}
	fmt.Println(strings.Join(result, " that "), "it")
}

package main

import	"fmt"

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

	for i:=1;i<n;i++ {
		if i%2 == 1 {
			fmt.Print("I hate that ")
		} else {
			fmt.Print("I love that ")
		}
	}
	if n%2==0{
		fmt.Print("I love it ")
	}else{
		fmt.Print("I hate it ")
}

}

package main

import (
	"fmt"
	"strings"
)

func main() {
	layer := 0
	fmt.Scan(&layer)
	var phrase []string
	love, hate := "I love", "I hate"
	for l:=1; l<=layer; l++ {
		if l % 2 == 0 {phrase = append(phrase, love)} else {phrase = append(phrase, hate)}
		if l != layer {phrase = append(phrase, "that")}
	}
	phrase = append(phrase, "it")
	fmt.Println(strings.Join(phrase, " "))
}

package main

import "fmt"

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

	var hol bool //hate or love

	var sum string
	sum = "I hate "
	for i := 1; i < n; i++ {
		var holstr string
		if hol {
			holstr = "hate "
			hol = !hol
		} else {
			holstr = "love "
			hol = !hol
		}
		sum += "that I " + holstr
	}
	sum += "it"
	fmt.Print(sum)
}

//package FirstGoProj
package main

import (
	"fmt"
)

func main(){
	var firstNum int
	var s1, s2 = "I hate", "I love"
	fmt.Scan(&firstNum)
	for i := 0; i<firstNum; i++ {
		if i>0{
			fmt.Print(" that ")
		}
		if i%2 == 0 {
			fmt.Print(s1)
		} else {
			fmt.Print(s2)
		}
	}
	fmt.Print(" it")
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var a int
	s := []string{}
	fmt.Scan(&a)
	b := a / 2
	c := a % 2
	for i := 0; i<b; i++ {
		s = append(s, "I hate that I love")
	}
	stro := strings.Join(s, " that ")
	if c == 0 {
		fmt.Println(stro, "it")
	} else {
		if a != 1 {
			fmt.Println(stro, "that I hate it")
		} else {
			fmt.Println("I hate it")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

const (
	hate      = "I hate"
	love      = "I love"
	delimiter = " that "
	end       = " it"
)

func main() {
	var n int

	fmt.Scanf("%d", &n)
	fmt.Printf("%s", hulk(n))
}

func hulk(n int) string {
	var retSlice []string
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			retSlice = append(retSlice, hate)
		} else {
			retSlice = append(retSlice, love)
		}
	}
	ret := strings.Join(retSlice, delimiter)
	return ret + end
}

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	ans := ""
	for i := 0; i < N; i++ {
		if len(ans) > 0 {
			ans += " that "
		}
		if i % 2 == 0 {
			ans += "I hate"
		} else {
			ans += "I love"
		}
	}
	ans += " it"
	fmt.Println(ans)

}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int

	fmt.Scan(&n)

	s := []string{}

	for i := 0; i < n; i++ {
		if ((i + 1) % 2) == 0 {
			s = append(s, "I love")
		} else {
			s = append(s, "I hate")
		}

		if (n - i) == 1 {
			s = append(s, " it")
		} else {
			s = append(s, " that ")
		}
	}

	result := strings.Join(s, "")

	fmt.Println(result)
}

package main

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

var scanner *bufio.Scanner

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 max(a,b int) int { if a > b { return a } else { return b } }

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

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

const alphabets = "abcdefghijklmnopqrstuvwxyz"

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

	Problem705A()
}

func Problem705A() {
	n := getI()
	str := ""
	for i:=0;i<n;i++ {
		if i % 2 == 0 {
			str += "I hate "
		}else {
			str += "I love "
		}
		if i + 1 < n {
			str += "that "
		}else {
			str += "it"
		}
	}
	printf(str)
}

package main

import (
	"fmt"
	"strings"
)

var love string = "I love"
var hate string = "I hate"
var end string = "it"
var conj string = "that"

func main() {
	var layers int
	fmt.Scanf("%d\n", &layers)

	response := make([]string, 0)

	for i:= 1; i <= layers; i++ {
		if i > 1 {
			response = append(response, conj)
		}
		if i % 2 == 1 {
			response = append(response, hate)
		} else {
			response = append(response,love)
		}
	}
	response = append(response, end)

	fmt.Printf("%+v\n", strings.Join(response," "))

}

package main

import "fmt"

func so(n int ) {
	for i:=0; i<n; i++ {
		if i%2==0&&i!=n-1 {
			fmt.Print(" I hate that")
		}
		if i%2==1&&i!=n-1 {
			fmt.Print(" I love that")
		}
		if i%2==0&&i==n-1 {
			fmt.Print("  I hate it")

		}
		if i%2==1&&i==n-1 {
			fmt.Print(" I love it ")
		}
	}
}
func main(){
 var n int
 fmt.Scan(&n)
	so(n)
	}

package main

import "fmt"

func main() {
	n := 0

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			fmt.Print("I hate")
		} else {
			fmt.Print("I love")
		}

		if i + 1 < n {
			fmt.Print(" that ")
		}
	}

	fmt.Println(" it")
}

package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scanf("%d\n", &n)

	var feeling string
	for i := 1; i <= n; i++ {
		var layer string

		if i%2 == 1 {
			layer = "hate"
		} else {
			layer = "love"
		}

		end := " that "
		if i == n {
			end = " it "
		}

		feeling = feeling + "I " + layer + end
	}

	fmt.Println(feeling)
}

package main

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

import "strings"

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")

	c, _ := strconv.Atoi(s[0])
	//x, _ := strconv.ParseInt(s[1], 10, 64)
	for i := 0; i < c; i++ {
		fmt.Print("I ")
		if (i % 2) == 0 {
			fmt.Print("hate ")
		} else {
			fmt.Print("love ")
		}
		if i == c-1 {
			fmt.Println("it")
		} else {
			fmt.Print("that ")
		}

		text, _ := reader.ReadString('\n')
		text = strings.TrimRight(text, "\r\n")
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	str := ""
	for i := 1; i <= n; i++ {
		if i&1 == 1 {
			str += "I hate"
		} else {
			str += "I love"
		}
		if i != n {
			str += " that "
		}
	}
	str += " it"
	fmt.Println(str)
}

package main

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

// https://codeforces.com/problemset/problem/705/A
// A. Hulk
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.

// Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...

// For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.

// Please help Dr. Banner.
// Input

// The only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.
// Output

// Print Dr.Banner's feeling in one line.

func main() {
	solveTheProblem()
}

func solveTheProblem() {
	bufStdin := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(bufStdin, &n)

	var feeling strings.Builder
	feeling.Grow(4096)

	feeling.WriteString("I hate")
	for i := 1; i < n; i++ {
		feeling.WriteString(" that")
		if i%2 == 0 {
			feeling.WriteString(" I hate")
		} else {
			feeling.WriteString(" I love")
		}
	}
	feeling.WriteString(" it")

	fmt.Print(feeling.String())
}

package main

import "fmt"

func main(){
	result := ""
	var1 := "I hate"
	var2 := "I love"
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			result += var1 + " "
			if i == n - 1 {
				result += "it"
			}else {
				result += "that" + " "
			}
		}else {
			result += var2 + " "
			if i == n - 1 {
				result += "it"
			}else {
				result += "that" + " "
			}
		}
	}
	fmt.Println(result)
}

package main

import "fmt"

func main()  {
	s := ""
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			s += "I hate "
		} else {
			s += "I love "
		}
		if i == n-1 {
			s += "it"
		} else {
			s += "that "
		}
	}
	fmt.Println(s)
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/705/A
// комментарий к решению
//
func taskSolution(n int) string {
	ans := []byte("I hate")
	a := [][]byte{[]byte(" that I love"), []byte(" that I hate")}
	for i := 2; i <= n; i += 1 {
		ans = append(ans, a[i%2]...)
	}
	ans = append(ans, " it"...)
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(n))
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	O("I hate that", "")
	a := " I love it"
	b := " I hate it"
	for i := 0; i < n-1; i++ {
		if i%2 == 0 {
			O(a, "")
		} else {
			O(b, "")
		}
	}
	O("", "\n")
}

package main

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

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	var ans strings.Builder
	ans.WriteString("i hate ")
	for i := 1; i < n; i++ {
		ans.WriteString("that ")
		if i%2 == 0 {
			ans.WriteString("i hate ")
		} else {
			ans.WriteString("i love ")
		}
	}
	ans.WriteString("it")
	fmt.Println(ans.String())
}

package main

import "fmt"

func main() {
	var a int
	var output string
	fmt.Scan(&a)
	for i := 0; i > a; i++ {
		if i%2 == 0 {
			output = output + "I hate "
		} else if i%2 == 1 {
			output = output + "I love "
		}
		if i+1 != a {
			output = output + "that "
		} else {
			output = output + "it"
		}
	}
	fmt.Println(output)
}

package main

import (
	"fmt"
)

func main() {
	hate := "I hate"
	love := "I love"
	var c int
	fmt.Scan(&c)
	finalString := ""
	for i := 1; i <= c; i++ {
		if i%2 == 0 {
			if i != c {
				finalString = finalString + love + " that "
			} else {
				finalString = finalString + love + " this"
			}
		} else {
			if i != c {
				finalString = finalString + hate + " that "
			} else {
				finalString = finalString + hate + " this"
			}
		}
	}
	fmt.Printf(finalString + "")
}

package main

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

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

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

func Println(a ...interface{}) {
	fmt.Println(a...)
}

func main() {
	var n int
	scan(&n)
	fmt.Print("I hate ")
	for i:=0; i<n-1;i++{
		if i%2==0{
			fmt.Print("that i love ")
		} else {
			fmt.Print("that i hate ")
		}
	}
	fmt.Print("it")
}

package main

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

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

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

func Println(a ...interface{}) {
	fmt.Println(a...)
}

func main() {
	var n int
	scan(&n)
	fmt.Print("i hate ")
	for i:=0; i<n-1;i++{
		if i%2==0{
			fmt.Print("that i love ")
		} else {
			fmt.Print("that i hate ")
		}
	}
	fmt.Print("it")
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    if n == 1 {
        fmt.Println("I hate it")
    }
    res := "I hate"
    for i := 2; i <= n; i ++ {
        if i%2 == 0 {
            res += " that I love"
        } else {
            res += " that I hate"
        }
    }
    res += " it"
    fmt.Println(res)
}

package main

import "fmt"

func main() {
   var n int
   fmt.Scan(&n)
   var ans string
   for i := 0; i < n; i ++ {
      if i % 2 == 0 {
         ans += "I hate it"
      } else {
         ans += " I love it "
      }
   }
   fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {

	var n int
	fmt.Scanf("%d\n", &n)

	love := "I love it"
	hate := "I hate it"
	i:=0
	for ; i < n - 1; i+=1 {
		if i%2 == 0 {
			fmt.Print(hate, " ")
		} else {
			fmt.Print(love, " ")
		}
	}
	if i%2 == 0 {
		fmt.Print(hate)
	} else {
		fmt.Print(love)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n==1{
		fmt.Printf("I hate it")
	} else if n==2 {
		fmt.Printf("I hate that I love it")
	}else {
		fmt.Printf("I hate that I love that I hate it")
	}
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	var n int
	fmt.Sscanf(readLine(reader), "%d", &n)
	var s []string
	for i:=1; i<=n; i++ {
		if i % 2 != 0 {
			s = append(s, "I hate it")
		} else {
			s = append(s, "I love it")
		}
	}
	fmt.Println(strings.Join(s, " "))
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

//package FirstGoProj
package main

import (
	"fmt"
)

func main(){
	var firstNum int
	var s1, s2 = "I hate it", "I love it"
	fmt.Scan(&firstNum)
	for i := 0; i<firstNum; i++ {
		if i>0{
			fmt.Print(" that ")
		}
		if i%2 == 0 {
			fmt.Print(s1)
		} else {
			fmt.Print(s2)
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	var str string
	fmt.Scan(&n)
	str = str + "i hate "
	for i:=0; i<n-1; i++ {
		if i % 2 == 0 {
			str = str + "that I love "
		} else {
			str = str + "that I hate "
		}
	}
	fmt.Println(str + "it")
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var output = make([]string, n)
	if n%2 == 1 {
		output[n-1] = "I hate it"
	} else {
		output[n-1] = "I love it"
	}
	n--
	for n > 0 {

		if n%2 == 0 {
			output[n-1] = " I love that"
		} else {
			output[n-1] = " I hate that"
		}
		n--

	}
	fmt.Print(strings.Join(output, " ")[1:])
}

package main

import (
	"fmt"
)

func main() {
	var n, i int
	fmt.Scan(&n)
	hIt := "I hate it"
	lIt := "I love it"
	hThat := "I hate that"
	lThat := "I love that"
	if n == 1 {
		fmt.Println(hIt)
	} else if n == 2 {
		fmt.Println(hThat + " " + lIt)
	} else {
		if n%2 == 1 {
			for i = 1; i < n-1; i++ {
				fmt.Print(hThat)
				fmt.Print(" " + lThat + " ")
			}
			fmt.Print(hIt)
		} else {
			fmt.Print(hThat)
			for i = 1; i < n-2; i++ {
				fmt.Print(" " + lThat + " ")
				fmt.Print(hThat)
			}
			fmt.Print(" " + lIt)
		}
	}
}

package main

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

func getNextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, _ := strconv.Atoi(string(scanner.Bytes()))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	i, _ := strconv.ParseInt(string(scanner.Bytes()), 10, 64)
	return i
}

func main() {

	reader := bufio.NewReader(os.Stdin)
	scanner := bufio.NewScanner(reader)
	// Set the split function for the scanning operation.
	scanner.Split(bufio.ScanWords)
	nbCase := getNextInt(scanner)

	messages := []string{"I hate it","I love it"}

	for i:=0; i<nbCase; i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(messages[i%2])
	}

}

package main

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

func getNextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, _ := strconv.Atoi(string(scanner.Bytes()))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	i, _ := strconv.ParseInt(string(scanner.Bytes()), 10, 64)
	return i
}

func main() {

	reader := bufio.NewReader(os.Stdin)
	scanner := bufio.NewScanner(reader)
	// Set the split function for the scanning operation.
	scanner.Split(bufio.ScanWords)
	nbCase := getNextInt(scanner)

	messages := []string{"I hate it ","I love it "}

	for i:=0; i<nbCase; i++ {
		fmt.Print(messages[i%2])
	}

}

package main

import "fmt"

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

  for i := 1; i <= n; i++ {
    if i%2 == 1 {
      fmt.Print("I hate that ")
      continue
    }
    fmt.Print("I love that ")
  }
  fmt.Print("it")
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	count := 0
	for scanner.Scan() {
		count, _ = strconv.Atoi(scanner.Text())
	}
	for i := 1; i <= count; i++ {
		if i%2 == 0 {
			fmt.Print("I love that ")
		} else {
			fmt.Print("I hate it ")
		}
	}
}

package main
import "fmt"
func main() {
	var n int
	fmt.Scan(&n)
	n+=1
	for i := 1; i < n; i++ {
	    if i%2 == 0 {
	        fmt.Print("I love it")
	        fmt.Print(" ")
	    }else {
	        fmt.Print("I hate that")
	        if i != n-1 { fmt.Print(" ") }
	    }
	}
	fmt.Println()
}

package main

import	"fmt"

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

		if n%3==1{
			fmt.Print("I hate it")
		}else if n%3==2{
			fmt.Print("I hate that I love it")
		}else{
			fmt.Print("I hate that I love that I hate it")
		}

}

package main

import (
	"fmt"
	"strings"
)

const (
	hate      = "I hate"
	love      = "I love"
	delimiter = " that "
	end       = " it"
)

func main() {
	var n int

	fmt.Scanf("%d", &n)
	hulk(n)
}

func hulk(n int) string {
	var retSlice []string
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			retSlice = append(retSlice, hate)
		} else {
			retSlice = append(retSlice, love)
		}
	}
	ret := strings.Join(retSlice, delimiter)
	return ret + end
}

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	ans := ""
	for i := 0; i < N; i++ {
		if len(ans) > 0 {
			ans += " that "
		}
		if i % 2 == 0 {
			ans += "I hate"
		} else {
			ans += "I love"
		}
	}
	ans += " it."
	fmt.Println(ans)
}


Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change — he took all the coins whose release year dated from l to r inclusively and put them in the reverse order. That is, he took a certain segment [l, r] and reversed it. At that the segment's endpoints did not coincide. For example, if n = 8, then initially Vasya's coins were kept in the order 1 2 3 4 5 6 7 8. If Vasya's younger brother chose the segment [2, 6], then after the reversal the coin order will change to 1 6 5 4 3 2 7 8. Vasya suspects that someone else could have spoilt the permutation after his brother. Help him to find that out. Check if the given permutation can be obtained from the permutation 1 2 ... n using exactly one segment reversal. If it is possible, find the segment itself.

The first line contains an integer n (1 ≤ n ≤ 1000) which is the number of coins in Vasya's collection. The second line contains space-separated n integers which are the spoilt sequence of coins. It is guaranteed that the given sequence is a permutation, i.e. it contains only integers from 1 to n, and every number is used exactly 1 time.

If it is impossible to obtain the given permutation from the original one in exactly one action, print 0 0. Otherwise, print two numbers l r (1 ≤ l < r ≤ n) which are the endpoints of the segment that needs to be reversed to obtain from permutation 1 2 ... n the given one.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF56B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, st, end int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		if st == 0 && a[i] != i+1 {
			st, end = i+1, a[i]
		}
	}
	for i, j := st-1, end-1; i < j; i++ {
		a[i], a[j] = a[j], a[i]
		j--
	}
	for i, v := range a {
		if v != i+1 {
			st, end = 0, 0
			break
		}
	}
	Fprint(_w, st, end)
}

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


This is the hard version of the problem. The only difference between the easy version and the hard version is the constraints on $$$n$$$. You can only make hacks if both versions are solved.A permutation of $$$1, 2, \ldots, n$$$ is a sequence of $$$n$$$ integers, where each integer from $$$1$$$ to $$$n$$$ appears exactly once. For example, $$$[2,3,1,4]$$$ is a permutation of $$$1, 2, 3, 4$$$, but $$$[1,4,2,2]$$$ isn't because $$$2$$$ appears twice in it.Recall that the number of inversions in a permutation $$$a_1, a_2, \ldots, a_n$$$ is the number of pairs of indices $$$(i, j)$$$ such that $$$i < j$$$ and $$$a_i > a_j$$$.Let $$$p$$$ and $$$q$$$ be two permutations of $$$1, 2, \ldots, n$$$. Find the number of permutation pairs $$$(p,q)$$$ that satisfy the following conditions:  $$$p$$$ is lexicographically smaller than $$$q$$$.  the number of inversions in $$$p$$$ is greater than the number of inversions in $$$q$$$. Print the number of such pairs modulo $$$mod$$$. Note that $$$mod$$$ may not be a prime.

The only line contains two integers $$$n$$$ and $$$mod$$$ ($$$1\le n\le 500$$$, $$$1\le mod\le 10^9$$$).

Print one integer, which is the answer modulo $$$mod$$$.


Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.They love equilateral triangles and want to create $$$n$$$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexagon edge should pass through any of the triangles).You are allowed to add straight lines parallel to the edges of the hexagons. Given $$$n$$$, what is the minimum number of lines you need to add to create at least $$$n$$$ equilateral triangles as described?  Adding two red lines results in two new yellow equilateral triangles.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^{9}$$$) — the required number of equilateral triangles.

For each test case, print the minimum number of lines needed to have $$$n$$$ or more equilateral triangles.

NoteIn the first and second test cases only 2 lines are needed. After adding the first line, no equilateral triangles will be created no matter where it is added. But after adding the second line, two more triangles will be created at once.   In the third test case, the minimum needed is 3 lines as shown below.

package main

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

const (
	maxn = 40000
	top  = 1000000001
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	in.Buffer(nil, 1e9)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	nextInt := func() int {
		in.Scan()
		vv, _ := strconv.Atoi(in.Text())
		return vv
	}
	z := make([]int, maxn)
	z[0] = 0
	z[1] = 0
	up := 0
	for i := 2; i < maxn; i++ {
		t := i / 3
		m := i % 3
		a := t
		b := t
		c := t
		if m == 2 {
			a++
			b++
		}
		if m == 1 {
			a++
		}
		z[i] = 2 * (a*b + b*c + a*c)
		if z[i] > top {
			up = i
			break
		}
	}
	t := nextInt()
	sol := func() int {
		n := nextInt()
		l, h := 0, up
		for l < h {
			m := (l + h + 1) / 2
			if z[m] < n {
				l = m
			} else {
				h = m - 1
			}
		}
		return h + 1
	}
	for ; t > 0; t-- {
		fmt.Fprintln(out, sol())
	}
}

package main

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

const (
	maxn = 40000
	top  = 1000000001
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	in.Buffer(nil, 1e9)

	nextInt := func() int {
		in.Scan()
		vv, _ := strconv.Atoi(in.Text())
		return vv
	}
	z := make([]int, maxn)
	z[0] = 0
	z[1] = 0
	up := 0
	for i := 2; i < maxn; i++ {
		t := i / 3
		m := i % 3
		a := t
		b := t
		c := t
		if m == 2 {
			a++
			b++
		}
		if m == 1 {
			a++
		}
		z[i] = 2 * (a*b + b*c + a*c)
		if z[i] > top {
			up = i
			break
		}
	}
	t := nextInt()
	sol := func() int {
		n := nextInt()
		l, h := 0, up
		for l < h {
			m := (l + h + 1) / 2
			if z[m] < n {
				l = m
			} else {
				h = m - 1
			}
		}
		return h + 1
	}
	for ; t > 0; t-- {
		fmt.Println(sol())
	}
}

package main

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

const (
	maxn = 1000000
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	in.Buffer(nil, 1e9)

	nextInt := func() int {
		in.Scan()
		vv, _ := strconv.Atoi(in.Text())
		return vv
	}
	z := make([]int64, maxn)
	z[0] = 0
	z[1] = 0
	for i := 2; i < maxn; i++ {
		t := int64(i / 3)
		m := i % 3
		a := t
		b := t
		c := t
		if m == 2 {
			a++
			b++
		}
		if m == 1 {
			a++
		}
		z[i] = 2 * (a*b + b*c + a*c)
		// fmt.Println(i, z[i])
	}

	t := nextInt()
	sol := func() int {
		n := int64(nextInt())
		l, h := 0, maxn-1
		for l < h {
			m := (l + h + 1) / 2
			if z[m] < n {
				l = m
			} else {
				h = m - 1
			}
		}
		return h + 1
	}
	for ; t > 0; t-- {
		fmt.Println(sol())
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove(T int) {

}

type entry struct {
	x, y int
}

func main() {
	defer w.Flush()
	var T int
	fmt.Fscan(r, &T)
	reme := make([]entry, 0)
	i := 0
	cnt := 0
	diff := 0
	for {
		if i % 3 != 2 {
			diff += 2
		}
		cnt += diff
		i += 1
		reme = append(reme, entry{cnt, i})
		if cnt > 1e9 {
			break
		}
	}
	for t:=1;t<=T;t++ {
		var n int
		fmt.Fscan(r, &n)
		i := sort.Search(len(reme), func(i int) bool {
			return reme[i].x >= n
		})
		fmt.Fprintln(w, reme[i].y + 1)
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var t int
	Fscan(in, &t)

	f := make([]Int, 0, 100000)

	var a, b, c Int

	for {
		s := (a*b + a*c + b*c) << 1
		if s <= 1e9 {
			f = append(f, s)
		} else {
			break
		}
		c++
		a, b, c = b, c, a
	}

	for tt := 0; tt < t; tt++ {
		var n Int
		Fscan(in, &n)
		ans := sort.Search(len(f), func(i int) bool {
			return f[i] >= n
		})
		Fprintln(out, ans)
	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

func check(i Int) Int {
	m := i - 1
	k := m/3 - 1

	ans := 3 + (1+k)*k/2*3*2 + k*3

	if m%3 == 0 {
		ans += m / 3 * 2
		ans += 0
	} else if m%3 == 1 {
		ans += m / 3 * 4
		ans += 1
	} else if m%3 == 2 {
		ans += m / 3 * 6
		ans += 3
	}
	return ans * 2

}

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n Int
		Fscan(in, &n)

		ans := sort.Search(100000, func(i int) bool {
			return check(Int(i)) >= n
		})
		Fprintln(out, ans)
	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi()
		check := func(k int) bool {
			i1 := k/3; i2 := i1; i3 := i1; m := k%3; if m > 0 { i1++ }; if m > 1 { i2++ }
			return 2*i1*i2+2*i1*i3+2*i2*i3 >= N
		}
		l,r := 1,39000
		for r-l > 1 { m := (r+l)>>1; if check(m) { r = m } else { l = m } }
		fmt.Fprintln(wrtr,r)
	}
}

package main

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

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

func main() {
	defer out.Flush()

	triangles := []int{0, 0, 2, 6}
	var a, b, c int = 1, 1, 1
	var cross, plus int = 0, 3
	for i := 4; triangles[len(triangles)-1] < 1e9; i++ {
		a, b, c = c+1, a, b
		cross++
		plus += b + c - 3
		triangles = append(triangles, cross*6+plus*2)
	}

	var tc int
	for fmt.Fscan(in, &tc); tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		fmt.Fprintln(out, sort.SearchInts(triangles, n))
	}
}

package main

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

func main() {
	var reader *bufio.Reader = bufio.NewReader(os.Stdin)
	var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var T int
	fmt.Scan(&T)
	var n int
	precalc := make([]int, 0)
	vals := []int{0, 0, 0}
	cur := 0
	for i := 0; ; i++ {
		x := i % 3
		lines := vals[(x+1)%3] + vals[(x+2)%3]
		lines *= 2
		cur += lines
		precalc = append(precalc, cur)
		if cur > 1000000000 {
			break
		}
		vals[x]++
	}
	for t := 0; t < T; t++ {
		fmt.Fscan(reader, &n)
		ans := sort.SearchInts(precalc, n)
		fmt.Fprintln(writer, ans+1)
	}
}