We are sum for we are manySome NumberThis version of the problem differs from the next one only in the constraint on $$$t$$$. You can make hacks only if both versions of the problem are solved.You are given two positive integers $$$l$$$ and $$$r$$$.Count the number of distinct triplets of integers $$$(i, j, k)$$$ such that $$$l \le i < j < k \le r$$$ and $$$\operatorname{lcm}(i,j,k) \ge i + j + k$$$.Here $$$\operatorname{lcm}(i, j, k)$$$ denotes the least common multiple (LCM) of integers $$$i$$$, $$$j$$$, and $$$k$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$\bf{1 \le t \le 5}$$$). Description of the test cases follows. The only line for each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 2 \cdot 10^5$$$, $$$l + 2 \le r$$$).

For each test case print one integer — the number of suitable triplets.

NoteIn the first test case, there are $$$3$$$ suitable triplets:   $$$(1,2,3)$$$,  $$$(1,3,4)$$$,  $$$(2,3,4)$$$. In the second test case, there is $$$1$$$ suitable triplet:   $$$(3,4,5)$$$.

package main

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

type void struct{}
var member void

var (
	reader bufio.Reader
	writer bufio.Writer
)

const MAXN = 400000

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

	divs := make([][]int, MAXN + 1)
	for i := 1; i <= MAXN; i++ {
		for j := i * 2; j <= MAXN; j += i {
			divs[j] = append(divs[j], i)
		}
	}

	/*for i := 1; i <= 100; i++ {
		printf("%v : ", i)
		for _, x := range divs[i] {
			printf("%v ", x)
		}
		printf("\n")
	}*/

	var T int
	T = 1
	scan(&T)

	for ; T > 0; T-- {
		var l, r int
		scan(&l, &r)

		var length int64 = int64(r - l + 1)
		var big int64 = length * (length - 1) * (length - 2) / 6

		var cnt int64 = 0
		for k := l + 2; k <= r; k++ {
			var n int = len(divs[2 * k])
			for i := 0; i < n; i++ {
				if divs[2 * k][i] < l {
					continue
				}
				for j := i + 1; j < n - 1; j++ {
					if k % divs[2 * k][i] == 0 && k % divs[2 * k][j] == 0 ||
						 divs[2 * k][i] + divs[2 * k][j] > k {
						cnt++
					}
				}
			}
		}

		printf("%v\n", big - cnt)
	}
}

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

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

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		l, r := readTwoNums(reader)
		res := solve(l, r)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

func normalize(s string) string {

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

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

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

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

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

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

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

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

	return i
}

func solve(l int, r int) int64 {

	n := r - l + 1
	f := make([]int, n+1)

	for i := l; i+1 <= r; i++ {
		for j := 2; i*j <= r; j++ {
			f[i*j-l]++
		}
	}

	var ans int64

	for k := l + 2; k <= r; k++ {
		tot := int64(k-l) * int64(k-l-1) / 2
		tmp1 := int64(f[k-l]) * int64(f[k-l]-1) / 2
		var tmp2 int64
		if k%6 == 0 && k/2 >= l {
			tmp2++
		}
		if k%15 == 0 && k*2/5 >= l {
			tmp2++
		}
		ans += tot - tmp1 - tmp2
	}

	return ans
}

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

func lcm(a, b int) int {
	g := gcd(a, b)
	return a / g * b
}

func search(l, r int, f func(int) bool) int {
	for l < r {
		mid := (l + r) / 2
		if f(mid) {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return r
}

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


You are given an integer $$$n$$$ ($$$n \ge 0$$$) represented with $$$k$$$ digits in base (radix) $$$b$$$. So,$$$$$$n = a_1 \cdot b^{k-1} + a_2 \cdot b^{k-2} + \ldots a_{k-1} \cdot b + a_k.$$$$$$For example, if $$$b=17, k=3$$$ and $$$a=[11, 15, 7]$$$ then $$$n=11\cdot17^2+15\cdot17+7=3179+255+7=3441$$$.Determine whether $$$n$$$ is even or odd.

The first line contains two integers $$$b$$$ and $$$k$$$ ($$$2\le b\le 100$$$, $$$1\le k\le 10^5$$$) — the base of the number and the number of digits. The second line contains $$$k$$$ integers $$$a_1, a_2, \ldots, a_k$$$ ($$$0\le a_i < b$$$) — the digits of $$$n$$$. The representation of $$$n$$$ contains no unnecessary leading zero. That is, $$$a_1$$$ can be equal to $$$0$$$ only if $$$k = 1$$$.

Print "even" if $$$n$$$ is even, otherwise print "odd". You can print each letter in any case (upper or lower).

NoteIn the first example, $$$n = 3 \cdot 13^2 + 2 \cdot 13 + 7 = 540$$$, which is even.In the second example, $$$n = 123456789$$$ is odd.In the third example, $$$n = 32 \cdot 99^4 + 92 \cdot 99^3 + 85 \cdot 99^2 + 74 \cdot 99 + 4 = 3164015155$$$ is odd.In the fourth example $$$n = 2$$$.

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func main() {
	var b, k int
	fmt.Fscan(in, &b, &k)
	sum := 0
	for i := 0; i < k; i++ {
		var a int
		fmt.Fscan(in, &a)
		if i+1 == k {
			sum += a
		} else {
			sum += a * b
		}
	}
	if sum%2 == 0 {
		fmt.Println("even")
	} else {
		fmt.Println("odd")
	}
}

package main

import "fmt"

func main() {
	var b, k int
	fmt.Scan(&b)
	fmt.Scan(&k)

	rbt := isOdd(b)
	sum := false
	for i := 0; i < k; i++ {
		bt := rbt
		if i == k-1 {
			bt = true
		}
		var a int
		fmt.Scan(&a)
		at := isOdd(a)
		s := false
		if at && bt {
			s = true
		}
		if (sum && !s) || (s && !sum) {
			sum = true
		} else {
			sum = false
		}
	}

	if sum {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

func isOdd(n int) bool {
	if n%2 == 0 {
		return false
	}
	return true
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var a, b int
	fmt.Fscan(reader, &a, &b)
	k := make([]int, b)
	for i := 0; i < b; i++ {
		fmt.Fscan(reader, &k[i])
	}
	if a%2 == 0 {
		if k[b-1]%2 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
		return
	}
	parity := 0
	for i := 0; i < b; i++ {
		parity += k[i] % 2
	}
	if parity%2 == 1 {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

package main

import "fmt"

func main() {
	var b, k int
	fmt.Scan(&b, &k)
	a := make([]int, k)
	for i := 0; i < k; i++ {
		fmt.Scan(&a[k-i-1])
	}
	counter := 0
	for i := 0; i < k; i++ {
		if a[i]%2 == 0 || (b%2 == 0 && i > 0) {
			continue
		}
		counter++
	}
	if counter%2 == 0 {
		fmt.Println("even")
	} else {
		fmt.Println("odd")
	}
}

package main

import "fmt"

func main() {
	var b, k, a int
	fmt.Scan(&b, &k)
	even := true
	for i := 0; i < k; i++ {
		fmt.Scan(&a)
		if a%2 == 0 || (b%2 == 0 && i < k-1) {
			continue
		}
		even = !even
	}
	if even {
		fmt.Println("even")
	} else {
		fmt.Println("odd")
	}
}

package main

import (
	"fmt"
)

func main() {
	var b,k int
	fmt.Scan(&b,&k)
	last:=0
	count:=0
	for i:=0;i<k;i++{
		fmt.Scan(&last)
		if b%2!=0 && last%2!=0{
			count++
		}
	}
	if (b%2!=0 && count%2!=0) || (b%2==0 && last%2!=0){
		fmt.Println("odd")
	} else{
		fmt.Println("even")
	}
}

package main

import (
	"fmt"
	"bufio"
	"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 main() {
	var b,k int
	scan(&b,&k)
	last:=0
	count:=0
	for i:=0;i<k;i++{
		scan(&last)
		if b%2!=0 && last%2!=0{
			count++
		}
	}
	if (b%2!=0 && count%2!=0) || (b%2==0 && last%2!=0){
		fmt.Println("odd")
	} else{
		fmt.Println("even")
	}
}

package main

import "fmt"

func printEO(a int) {
	if a == 0 {
		fmt.Printf("even")
	} else {
		fmt.Printf("odd")
	}
	return
}

func main() {
	b, k := 0, 0
	fmt.Scanf("%d %d\n", &b, &k)
	s := b % 2
	s1 := 0
	a := []int{}
	for i := 0; i < k; i++ {
		a = append(a, 0)
		fmt.Scanf("%d", &a[i])

	}
	if s == 0 {
		printEO(a[k-1] % 2)
		return
	} else {
		for i := 0; i < k; i++ {
			if a[i]%2 == 1 {
				s1 = 1 - s1
			}
		}
		printEO(s1)
		return
	}

	return
}

package main

import (
	"fmt"
)

func main(){
	var b, k int
	fmt.Scan(&b, &k)
	var a [100005]int
	var count int
	for i := 0;i < k;i++ {
		fmt.Scan(&a[i])
		if a[i] & 1 == 1 {
			count++
		}
	}
	if (b % 2 == 0 && a[k-1] % 2 == 1) || (b % 2 == 1 && count % 2 == 1) {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

package main

import "fmt"

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    for i := int32(0); i < k; i++ {
        fmt.Scanf("%d", &tmp)
        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

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

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    input := bufio.NewReader(os.Stdin)
    is, _ := input.ReadString('\n')
    iss := strings.Split(strings.TrimSpace(is), " ")
    for _, v := range iss {
        tmp, _ = strconv.Atoi(v)

        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

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 b, k, t1 int
	arr := []int{}
	scanf("%d %d\n", &b, &k)
	for i := 0; i < k; i++ {
		scanf("%d", &t1)
		arr = append(arr, t1)
	}
	pb := 1
	ans := 0
	for i := k - 1; i >= 0; i-- {

		t1 = arr[i] * pb
		t1 %= 2
		pb *= b
		pb %= 2
		t1 %= 2
		ans += t1

	}

	if ans%2 == 0 {
		printf("even")
	} else {
		printf("odd")
	}
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math/big"
	"os"
)

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

func println(a ...interface{}) {
	_, _ = fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(writer, format, a...)
}

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

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

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}

func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func main() {
	defer writer.Flush()

	b := NextInt()
	k := NextInt()

	a := NextIntArray(k)

	if b%2 == 0 {
		if a[k-1]%2 == 0 {
			println("even")
		} else {
			println("odd")
		}
		return
	}
	var s int
	for i := 0; i < k; i++ {
		s = (s + a[i]) % 2
	}

	if s%2 == 0 {
		println("even")
	} else {
		println("odd")
	}
}

package main

import (
	"fmt"
)

//go:generate go run main.go < input.txt > output.txt
func main() {
	var b, k int
	fmt.Scan(&b, &k)
	last := 0
	count := 0
	for i := 0; i < k; i++ {
		fmt.Scan(&last)
		if b%2 != 0 && last%2 != 0 {
			count++
		}
	}
	if (b%2 != 0 && count%2 != 0) || (b%2 == 0 && last%2 != 0) {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var a, b int
	fmt.Fscan(reader, &a, &b)
	k := make([]int, b)
	for i := 0; i < b; i++ {
		fmt.Fscan(reader, &k[i])
	}
	if a%2 == 1 {
		if k[b-1]%2 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
		return
	}
	parity := 0
	for i := 0; i < b; i++ {
		parity += k[i] % 2
	}
	if parity%2 == 1 {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

package main

import (
	"fmt"
	"bufio"
	"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 main() {
	var b,k int
	scan(&b,&k)
	last:=0
	count:=0
	for i:=0;i<k;i++{
		scan(&last)
		if b%2!=0 && last%2!=0{
			count++
		}
	}
	if (b%2!=0 && count%2!=0) || (b%2==0 && last%2!=0){
		print("odd")
	} else{
		print("even")
	}
}

package main

import "fmt"

func printEO(a int) {
	if a == 0 {
		fmt.Printf("even")
	} else {
		fmt.Printf("odd")
	}
	return
}

func main() {
	b, k := 0, 0
	fmt.Scanf("%d %d", &b, &k)
	s := b % 2
	s1 := 0
	a := []int{}
	for i := 0; i < k; i++ {
		a = append(a, 0)
		fmt.Scanf("%d", &a[i])

	}
	if s == 0 {
		printEO(a[k-1] % 2)
		return
	} else {
		for i := 0; i < k; i++ {
			if a[i]%2 == 1 {
				s1 = 1 - s1
			}
		}
		printEO(s1)
		return
	}

	return
}

package main

import (
	"fmt"
)

func main(){
	var b, k int
	fmt.Scan(&b, &k)
	var a [100005]int
	var count int
	for i := 0;i < k;i++ {
		fmt.Scan(&a[i])
		if a[i] & 1 == 1 {
			count++
		}
	}
	if (b == 2 && a[k-1] == 1) || (b > 2 && count % 2 == 1) {
		fmt.Println("odd")
	} else {
		fmt.Println("even")
	}
}

package main

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

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    input := bufio.NewReader(os.Stdin)
    is, _ := input.ReadString('\n')
    iss := strings.Split(is[:len(is)-1], " ")
    for _, v := range iss {
        tmp, _ = strconv.Atoi(v)
       fmt.Println(tmp)
       x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

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

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    input := bufio.NewReader(os.Stdin)
    is, _ := input.ReadString('\n')
    iss := strings.Split(is, " ")
    for _, v := range iss {
        tmp, err := strconv.Atoi(v)
        fmt.Println(tmp, err)
        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

import "fmt"

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    for i := int32(0); i < k; i++ {
        fmt.Scanf("%d", &tmp)
        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
        fmt.Println("even")
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

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

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    input := bufio.NewReader(os.Stdin)
    is, _ := input.ReadString('\n')
    iss := strings.Split(is[:len(is)-1], " ")
    for _, v := range iss {
        tmp, _ = strconv.Atoi(v)
        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

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

func main() {
    var b, k int32
    fmt.Scanf("%d %d\n", &b, &k)
    var x, tmp int
    input := bufio.NewReader(os.Stdin)
    is, _ := input.ReadString('\n')
    iss := strings.Split(is, " ")
    for _, v := range iss {
        tmp, _ = strconv.Atoi(v)
        x ^= (tmp & 1)
    }

    if b & 1 == 0 {
		if tmp & 1 == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
    } else {
        if x & 1 == 1 {
            fmt.Println("odd")
        } else {
            fmt.Println("even")
        }
    }
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math/big"
	"os"
)

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

func println(a ...interface{}) {
	_, _ = fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(writer, format, a...)
}

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

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

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}

func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func main() {
	defer writer.Flush()

	b := NextInt()
	k := NextInt()

	a := NextIntArray(k)

	if b%2 == 0 {
		if a[k-1]%2 == 0 {
			println("even")
		} else {
			println("odd")
		}
		return
	}
	var s int
	for i, s := 0, 0; i < k; i, s = i+1, (s+a[i])%2 {
	}

	if s%2 == 0 {
		println("even")
	} else {
		println("odd")
	}
}

package main

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

//go:generate sh -c "go run main.go < input.txt > output.txt"
func main() {
	reader := bufio.NewReader(os.Stdin)

	l1, _ := reader.ReadString('\n')
	l1 = l1[:len(l1)-1]
	vals := strings.Split(l1, " ")
	b, _ := strconv.Atoi(vals[0])
	_, _ = strconv.Atoi(vals[1]) // k unused

	l2, _ := reader.ReadString('\n')
	l2 = l2[:len(l2)-1]
	arr := strings.Split(l2, " ")

	total := 0
	for i, v := range arr {
		num, _ := strconv.Atoi(v)
		total += num * pow(b, len(arr)-i-1)
	}

	if total%2 == 0 {
		fmt.Println("even")
	} else {
		fmt.Println("odd")
	}
}

func pow(a, b int) int {
	ret := 1
	for i := 0; i < b; i++ {
		ret *= a
	}
	return ret
}


There is an array $$$a$$$ of length $$$n$$$. You may perform the following operation any number of times:  Choose two indices $$$l$$$ and $$$r$$$ where $$$1 \le l < r \le n$$$ and $$$a_l = a_r$$$. Then, set $$$a[l \ldots r] = [a_{l+1}, a_{l+2}, \ldots, a_r, a_l]$$$. You are also given another array $$$b$$$ of length $$$n$$$ which is a permutation of $$$a$$$. Determine whether it is possible to transform array $$$a$$$ into an array $$$b$$$ using the above operation some number of times.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10 ^ 5$$$)  — the length of array $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$)  — elements of the array $$$a$$$. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le b_i \le n$$$)  — elements of the array $$$b$$$. It is guaranteed that $$$b$$$ is a permutation of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10 ^ 5$$$

For each test case, print "YES" (without quotes) if it is possible to transform array $$$a$$$ to $$$b$$$, and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteIn the first test case, we can choose $$$l=2$$$ and $$$r=5$$$ to form $$$[1, 3, 3, 2, 2]$$$.In the second test case, we can choose $$$l=2$$$ and $$$r=4$$$ to form $$$[1, 4, 2, 2, 1]$$$. Then, we can choose $$$l=1$$$ and $$$r=5$$$ to form $$$[4, 2, 2, 1, 1]$$$.In the third test case, it can be proven that it is not possible to transform array $$$a$$$ to $$$b$$$ using the operation.

package main

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

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

var t int
var n int

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

	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n)
		a, b := make([]int, n), make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}

		ans := "YES"
		p1, p2 := n-1, n-1
		cnt := make(map[int]int)
		cur := -1
		for ; p2 >= 0; p2-- {
			if b[p2] == cur {
				cnt[b[p2]]++
			} else {
				vis := false
				for p1 >= p2 {
					if a[p1] == b[p2] {
						vis = true
						p1--
						break
					}
					cnt[a[p1]]--
					if cnt[a[p1]] < 0 {
						ans = "NO"
						goto out
					}
					p1--
				}
				if !vis {
					ans = "NO"
					goto out
				}
			}
			cur = b[p2]
		}
	out:
		Fprintln(out, ans)
	}
}

package main

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

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)

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

		a := make([]int, n)
		b := make([]int, n)

		aCnt := make(map[int]int)
		aPos := make(map[int]int)
		as := 0

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		for i := n - 1; i >= 0; i-- {
			if aCnt[a[i]] == 0 {
				as++
				aPos[a[i]] = as
			}
			aCnt[a[i]]++
		}

		bCnt := make(map[int]int)
		bPos := make(map[int]int)
		bs := 0
		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
		}

		for i := n - 1; i >= 0; i-- {
			if bCnt[b[i]] == 0 {
				bs++
				bPos[b[i]] = bs
			}
			bCnt[b[i]]++
		}

		ans := "YES"
		for k, v := range aPos {
			if bPos[k] != v {
				ans = "NO"
				break
			}
		}

		if ans == "YES" {

			i := 0
			p := 0
			blast := -1
			alast := -1

			cnt := make(map[int]int)
			for i < n {
				for i < n && p < n && a[p] == b[i] {
					alast = a[p]
					aCnt[a[p]]--
					p++
					blast = b[i]
					i++
				}
				if i < n {
					if b[i] == blast && cnt[b[i]] > 0 && alast == b[i] {
						cnt[b[i]]--
						blast = b[i]
						i++
					} else {
						if p < n && aCnt[b[i]] > 0 {
							cnt[a[p]]++
							alast = a[p]
							p++
						} else {
							ans = "NO"
							break
						}
					}
				}
			}
		}
		Fprintln(out, ans)
	}

}

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
}

package main

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

type pii struct {
	x, y int
}
type P []pii

func (p P) Len() int {
	return len(p)
}

func (p P) Less(i, j int) bool {
	return p[i].x < p[j].x
}

func (p P) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

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

func solve() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	b := make([]int, n)
	cnt := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &b[i])
	}

	var l, r int
	ok := true
	for l < n {
		if r < n && a[r] == b[l] {
			l++
			r++
			continue
		}

		if cnt[b[l]-1] > 0 && b[l] == b[l-1] {
			cnt[b[l]-1]--
			l++
		} else if r < n {
			cnt[a[r]-1]++
			r++
		} else {
			ok = false
			break
		}
	}
	if ok {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}

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

/*
5
5
1 2 3 3 2
1 3 3 2 2
5
1 2 4 2 1
4 2 2 1 1
5
2 4 5 5 2
2 2 4 5 5
3
1 2 3
1 2 3
3
1 1 2
2 1 1
*/

package main

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

type pii struct {
	x, y int
}
type P []pii

func (p P) Len() int {
	return len(p)
}

func (p P) Less(i, j int) bool {
	return p[i].x < p[j].x
}

func (p P) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

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

func solve() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	b := make([]int, n)
	cnt := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &b[i])
	}

	var l, r int
	ok := true
	for l < n {
		if l > 0 && b[l] == b[l-1] && cnt[b[l]-1] > 0 {
			cnt[b[l]-1]--
			l++
			continue

		}
		for a[r] != b[l] && r < n-1 {
			cnt[a[r]-1]++
			r++
		}

		if r == n-1 && a[r] != b[l] {
			ok = false
		}
		//fmt.Fprintln(out, r, l)
		//fmt.Fprintln(out, a[r], b[l])
		l++
		if r < n-1 {
			r++
		}
	}
	if ok {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}

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

/*
5
5
1 2 3 3 2
1 3 3 2 2
5
1 2 4 2 1
4 2 2 1 1
5
2 4 5 5 2
2 2 4 5 5
3
1 2 3
1 2 3
3
1 1 2
2 1 1
*/

package main

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

/*
3
1
5
5
2
2 3
3 2
3
2 4 1
1 4 2
---
YES
NO
NO
========
4
8
1 2 1 4 3 4 5 1
1 1 4 5 1 2 3 4
6
1 2 1 5 2 1
5 1 2 1 1 2
5
1 2 2 1 3
2 2 1 1 3
8
1 2 1 3 1 4 2 5
3 1 1 1 4 2 2 5
---
NO
NO
YES
YES
======
4
7
3 1 2 4 1 5 2
3 4 1 1 5 2 2
7
2 1 4 5 4 1 6
2 5 4 4 1 1 6
6
3 6 3 1 2 2
6 3 3 1 2 2
6
1 5 2 4 1 2
5 4 1 1 2 2
---
YES
YES
YES
YES
=======
2
6
2 1 3 2 3 4
1 2 2 3 3 4
7
3 1 2 1 3 3 2
1 1 3 3 3 2 2
---
YES
YES
======
1
7
5 2 1 3 2 3 4
5 1 2 2 3 3 4
---
YES

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	b := make([]int, n)

	equal := true

	for i := range b {
		scanf("%d", &b[i])

		if a[i] != b[i] {
			equal = false
		}
	}
	scanf("\n")

	if equal {
		fmt.Fprintln(writer, "YES")
		return
	}

	prevB := -1
	shiftB := 0

	setB := make(map[int]int)

	i := n - 1
	for ; i-shiftB >= 0; i-- {
		if a[i] != b[i-shiftB] {
			if b[i-shiftB] == prevB {
				setB[b[i-shiftB]]++
				shiftB++
				i++
			} else if _, ok := setB[a[i]]; ok {
				setB[a[i]]--
				if setB[a[i]] == 0 {
					delete(setB, a[i])
				}
				shiftB--
			} else {
				fmt.Fprintln(writer, "NO")
				return
			}
		} else {
			prevB = b[i-shiftB]
		}
	}

	for ; i >= 0; i-- {
		setB[a[i]]--
		if setB[a[i]] == 0 {
			delete(setB, a[i])
		} else if setB[a[i]] < 0 {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	if len(setB) > 0 {
		fmt.Fprintln(writer, "NO")
	} else {
		fmt.Fprintln(writer, "YES")
	}
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int) []int {
	factors := []int{1}

	sqrtA := int(math.Sqrt(float64(num)))

	for ftr := 2; ftr <= sqrtA; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > sqrtA {
		factors = append(factors, num)
	}

	return factors
}

package main

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

const MOD int64 = 1000000007

var n int

var a, b []int

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

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		a = make([]int, n)
		b = make([]int, n)

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

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

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	//a == 3 3 4 5 3 6 4 3 1 4 1 1 3

	//b == 4 6 ... . . .. 33

	i, j := 0, 0
	mp := make([]int, n + 1)

	for ;i < n; {
		curB := b[i]

		if j < n {
			curA := a[j]

			if curA == curB {
				i++
				j++
				continue
			}

			//2 1

			//3 5 4 3 3 4
			//3 5 4 3 3

			if i > 0 {
				if b[i - 1] == b[i] && mp[b[i]] > 0 {
					mp[b[i]]--
					i++
					continue
				}
			}

			mp[a[j]]++
			j++

		} else {

			if i > 0 {
				if b[i - 1] == b[i] && mp[b[i]] > 0 {
					mp[b[i]]--
					i++
					continue
				}
			}
			fmt.Println("NO")
			return
		}
	}

	for _, v := range mp {
		if v > 0 {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")

	//1 5 4 4 6 7 3 3 6 5 2 1 3 3
}

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

package main

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

type Box struct {
	val   int
	count int
}

func getBoxes(a []int) []Box {
	boxes := []Box{}
	curval := a[len(a)-1]
	curcount := 1
	for curindex := len(a) - 2; curindex >= 0; curindex-- {
		if curval != a[curindex] {
			boxes = append(boxes, Box{val: curval, count: curcount})
			curval = a[curindex]
			curcount = 1
		} else {
			curcount++
		}
	}
	boxes = append(boxes, Box{val: curval, count: curcount})
	return boxes
}

func possible(a []int, b []int) bool {
	aboxes := getBoxes(a)
	bboxes := getBoxes(b)
	// want bboxes >= aboxes
	bindex := 0
	acounts := map[int]int{}
	bcounts := map[int]int{}
	for _, abox := range aboxes {
		val := abox.val
		acounts[val] += abox.count
		if bindex < len(bboxes) && val == bboxes[bindex].val {
			bbox := bboxes[bindex]
			bcounts[bbox.val] += bbox.count
			bindex++
		}
		if bcounts[val] < acounts[val] {
			return false
		}
	}
	return true
}

func main() {
	input := bufio.NewReader(os.Stdin)
	t := readInt(input)
	for i := 0; i < t; i++ {
		readInt(input)
		a := readArrInt(input)
		b := readArrInt(input)
		if possible(a, b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

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

package main
import("bufio";."fmt";"os")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		b := make([]int, n)
		for i := range b {
			Fscan(in, &b[i])
		}
		c := make([]int, n+1)
		for i, j := n-1, n-1; i >= 0; i-- {
			if i < n-1 && b[i] == b[i+1] {
				c[b[i]]++ // a 中 <=j 的任意位置可以塞个 b[i]
				continue
			}
			for ; a[j] != b[i]; j-- {
				if c[a[j]] == 0 {
					Fprintln(out, "NO")
					continue o
				}
				c[a[j]]--
			}
			j--
		}
		Fprintln(out, "YES")
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for K := 1; K <= T; K++ {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
		if K == 32 {
			Println(a, b)
		}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for K := 0; K < T; K++ {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for K := 0; K < T; K++ {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
			if K == 33 || K == 32 || K == 31 {
				Println(a)
				Println(b)
			}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for K := 0; K < T; K++ {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
		if K == 32 {
			Println(a)
			Println(b)
		}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for K := 0; K < T; K++ {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
		if K == 31 {
			Println(a)
			Println(b)
		}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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

var T int
var N int

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

	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &N)
		a, b := make([]int, N), make([]int, N)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := range b {
			Fscan(in, &b[i])
		}
		aa, bb := []int{}, []int{}
		vis := make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[a[i]] {
				aa = append(aa, a[i])
				vis[a[i]] = true
			}
		}
		vis = make(map[int]bool)
		for i := N - 1; i >= 0; i-- {
			if !vis[b[i]] {
				bb = append(bb, b[i])
				vis[b[i]] = true
			}
		}
		if len(aa) != len(bb) {
			Fprintln(out, "NO")
		}
		for i := range aa {
			if aa[i] != bb[i] {
				Fprintln(out, "NO")
				goto H1
			}
		}
		Fprintln(out, "YES")
	H1:
	}
}

package main

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

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)

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

		a := make([]int, n)
		b := make([]int, n)

		aCnt := make(map[int]int)
		aPos := make(map[int]int)
		as := 0

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		for i := n - 1; i >= 0; i-- {
			if aCnt[a[i]] == 0 {
				as++
				aPos[a[i]] = as
			}
			aCnt[a[i]]++
		}

		bCnt := make(map[int]int)
		bPos := make(map[int]int)
		bs := 0
		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
		}

		for i := n - 1; i >= 0; i-- {
			if bCnt[b[i]] == 0 {
				bs++
				bPos[b[i]] = bs
			}
			bCnt[b[i]]++
		}

		ans := "YES"
		for k, v := range aPos {
			if bPos[k] != v {
				ans = "NO"
				break
			}
		}

		if ans == "YES" {

			i := 0
			p := 0
			blast := -1
			alast := -1

			cnt := make(map[int]int)
			for i < n {
				for i < n && p < n && a[p] == b[i] {
					alast = a[p]
					p++
					blast = b[i]
					i++
				}
				if i < n {
					if b[i] != blast {
						if p < n {
							cnt[a[p]]++
							alast = a[p]
							p++
						} else {
							ans = "NO"
							break
						}
					} else {
						if cnt[b[i]] > 0 && alast == b[i] {
							cnt[b[i]]--
							blast = b[i]
							i++
						} else {
							ans = "NO"
							break
						}
					}
				}
			}
		}
		Fprintln(out, ans)
	}

}

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
}

package main

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

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)

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

		a := make([]int, n)
		b := make([]int, n)

		aCnt := make(map[int]int)

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
		}

		ans := "YES"
		i := 0
		p := 0
		blast := -1
		alast := -1
		for i < n {
			for i < n && p < n && a[p] == b[i] {
				alast = a[p]
				p++
				blast = b[i]
				i++
			}
			if i < n {
				if b[i] != blast {
					if p < n {
						aCnt[a[p]]++
						alast = a[p]
						p++
					} else {
						ans = "NO"
						break
					}
				} else {
					if aCnt[b[i]] > 0 && alast == b[i] {
						aCnt[b[i]]--
						blast = b[i]
						i++
					} else {
						ans = "NO"
						break
					}
				}
			}
		}
		Fprintln(out, ans)
	}

}

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
}

package main

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

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)

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

		a := make([]int, n)
		b := make([]int, n)

		aCnt := make(map[int]int)

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
		}

		ans := "YES"
		i := 0
		p := 0
		last := -1
		for i < n {
			for i < n && p < n && a[p] == b[i] {
				p++
				last = b[i]
				i++
			}
			if i < n {
				if b[i] != last {
					if p < n {
						aCnt[a[p]]++
						p++
					} else {
						ans = "NO"
						break
					}
				} else {
					if aCnt[b[i]] > 0 {
						aCnt[b[i]]--
						last = b[i]
						i++
					} else {
						ans = "NO"
						break
					}
				}
			}
		}
		Fprintln(out, ans)
	}

}

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
}

package main

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

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)

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

		a := make([]int, n)
		b := make([]int, n)

		aCnt := make(map[int]int)
		aPos := make(map[int]int)
		as := 0

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		for i := n - 1; i >= 0; i-- {
			if aCnt[a[i]] == 0 {
				as++
				aPos[a[i]] = as
			}
			aCnt[a[i]]++
		}

		bCnt := make(map[int]int)
		bPos := make(map[int]int)
		bs := 0
		for i := 0; i < n; i++ {
			Fscan(in, &b[i])
		}

		for i := n - 1; i >= 0; i-- {
			if bCnt[b[i]] == 0 {
				bs++
				bPos[b[i]] = bs
			}
			bCnt[b[i]]++
		}

		ans := "YES"
		for k, v := range aPos {
			if bPos[k] != v {
				ans = "NO"
				break
			}
		}
		Fprintln(out, ans)
	}

}

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
}

package main

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

type pii struct {
	x, y int
}
type P []pii

func (p P) Len() int {
	return len(p)
}

func (p P) Less(i, j int) bool {
	return p[i].x < p[j].x
}

func (p P) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

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

func solve() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	b := make([]int, n)
	A := make([]pii, n+1)
	B := make([]pii, n+1)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
		A[a[i]].x = i
		A[a[i]].y++

	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &b[i])
		B[b[i]].x = i
		B[b[i]].y++
	}

	work := func(p P, t []int) []int {
		sort.Sort(p)
		var s []int
		for _, v := range p {
			//fmt.Fprintln(out, s[v.x], v.x, v.y)
			for i := 0; i < v.y; i++ {
				s = append(s, t[v.x])
			}
		}
		return s
	}

	workA := work(P(A), a)
	workB := work(P(B), b)
	ok := true
	for i, _ := range workA {
		//	fmt.Fprintln(out, workA[i], workB[i])
		if workA[i] != workB[i] {
			ok = false
			break
		}
	}
	if ok {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}

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

package main

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

/*
3
1
5
5
2
2 3
3 2
3
2 4 1
1 4 2
---
YES
NO
NO
========
4
8
1 2 1 4 3 4 5 1
1 1 4 5 1 2 3 4
6
1 2 1 5 2 1
5 1 2 1 1 2
5
1 2 2 1 3
2 2 1 1 3
8
1 2 1 3 1 4 2 5
3 1 1 1 4 2 2 5
---
NO
NO
YES
YES

======

1
5
1 2 3 3 2
1 3 3 2 2
---
YES
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	b := make([]int, n)

	equal := true
	numToCnt := make(map[int]int)

	for i := range b {
		scanf("%d", &b[i])

		if a[i] != b[i] {
			equal = false
		}

		numToCnt[b[i]]++
	}
	scanf("\n")

	if equal {
		fmt.Fprintln(writer, "YES")
		return
	}

	prevB := -1
	shiftB := 0

	setB := make(map[int]int)

	i := n - 1
	for ; i-shiftB >= 0; i-- {
		if a[i] != b[i-shiftB] {
			if b[i-shiftB] == prevB {
				setB[b[i-shiftB]]++
				shiftB++
				i++
			} else if _, ok := setB[a[i]]; ok {
				setB[b[i-shiftB]]++
				setB[a[i]]--
				if setB[a[i]] == 0 {
					delete(setB, a[i])
				}
			} else {
				fmt.Fprintln(writer, "NO")
				return
			}
		} else {
			prevB = b[i-shiftB]
		}
	}

	for ; i >= 0; i-- {
		setB[a[i]]--
		if setB[a[i]] == 0 {
			delete(setB, a[i])
		} else if setB[a[i]] < 0 {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	if len(setB) > 0 {
		fmt.Fprintln(writer, "NO")
	} else {
		fmt.Fprintln(writer, "YES")
	}
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int) []int {
	factors := []int{1}

	sqrtA := int(math.Sqrt(float64(num)))

	for ftr := 2; ftr <= sqrtA; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > sqrtA {
		factors = append(factors, num)
	}

	return factors
}


Fifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi access point. This access point can be accessed within a range of r meters (this range can be chosen by Fifa) from its position. Fifa must put the access point inside the flat which has a circular shape of radius R. Fifa wants to minimize the area that is not covered by the access point inside the flat without letting Fafa or anyone outside the flat to get access to the internet.The world is represented as an infinite 2D plane. The flat is centered at (x1, y1) and has radius R and Fafa's laptop is located at (x2, y2), not necessarily inside the flat. Find the position and the radius chosen by Fifa for his access point which minimizes the uncovered area.

The single line of the input contains 5 space-separated integers R, x1, y1, x2, y2 (1 ≤ R ≤ 105, |x1|, |y1|, |x2|, |y2| ≤ 105).

Print three space-separated numbers xap, yap, r where (xap, yap) is the position which Fifa chose for the access point and r is the radius of its range.  Your answer will be considered correct if the radius does not differ from optimal more than 10 - 6 absolutely or relatively, and also the radius you printed can be changed by no more than 10 - 6 (absolutely or relatively) in such a way that all points outside the flat and Fafa's laptop position are outside circle of the access point range.

package main

import (
	"fmt"
    "math"
)

func main() {
	var R,x1,y1,x2,y2 int64
	fmt.Scan(&R, &x1, &y1, &x2, &y2)
    x := x1 - x2
    y := y1 - y2
    if (x*x + y*y >= R * R) {
        fmt.Print(x1,y1,R)
    } else {
        if (x == 0 && y == 0) {
            dist := float64(R) / 2
            fmt.Print(float64(x1) + dist, float64(y1), dist)
        } else {
            l := math.Sqrt(float64(x*x+y*y))
            dist := (float64(R) + l) / 2
            xd := float64(x) / l * dist
            yd := float64(y) / l * dist
            fmt.Print(float64(x2) + xd, float64(y2) + yd, dist)
        }
    }
}

package main

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

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

	var flatR, x1, y1, x2, y2 float64
	Fscan(in, &flatR, &x1, &y1, &x2, &y2)
	x2 -= x1
	y2 -= y1
	if x2 == 0 && y2 == 0 {
		Fprint(out, x1+flatR/2, y1, flatR/2)
		return
	}
	if x2*x2+y2*y2 >= flatR*flatR {
		Fprint(out, x1, y1, flatR)
		return
	}
	r2 := math.Hypot(x2, y2)
	r := (r2 + flatR) / 2
	k := (r - r2) / r2
	Fprint(out, x1-k*x2, y1-k*y2, r)
}

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

package main

import (
	"fmt"
	"math"
)

type Point struct {
	x, y float64
}

var R int
var p1, p2 Point

func main() {
	fmt.Scanf("%d %g %g %g %g", &R, &p1.x, &p1.y, &p2.x, &p2.y)
	diff := Point {
		x: p1.x - p2.x,
		y: p1.y - p2.y,
	}
	z := math.Sqrt(float64(math.Pow(float64(diff.y), 2) + math.Pow(float64(diff.x), 2)))
	r := (float64(R) + z) / 2
	if r > float64(R) {
		fmt.Printf("%g %g %g", p1.x, p1.y, float64(R))
		return
	}
	theta := math.Atan2(diff.y, diff.x)
	res := Point {
		x: p2.x + r * math.Cos(theta),
		y: p2.y + r * math.Sin(theta),
	}
	fmt.Printf("%g %g %g", res.x, res.y, r)
}

package main

import (
	"fmt"
    "math"
)

func main() {
	var R,x1,y1,x2,y2 int64
	fmt.Scan(&R, &x1, &y1, &x2, &y2)
    x := x1 - x2
    y := y1 - y2
    if (x*x + y*y >= R * R) {
        fmt.Print(x1,y1,R)
    } else {
        if (x == 0 && y == 0) {
            dist := float64(R) / 2
            fmt.Print(float64(x1) + dist, float64(y1) + dist, dist)
        } else {
            l := math.Sqrt(float64(x*x+y*y))
            dist := (float64(R) + l) / 2
            xd := float64(x) / l * dist
            yd := float64(y) / l * dist
            fmt.Print(float64(x2) + xd, float64(y2) + yd, dist)
        }
    }
}

package main

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

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

	var flatR, x1, y1, x2, y2 int64
	Fscan(in, &flatR, &x1, &y1, &x2, &y2)
	x2 -= x1
	y2 -= y1
	if x2 == 0 && y2 == 0 {
		Fprint(out, x1, y1, 0)
		return
	}
	if x2*x2+y2*y2 >= flatR*flatR {
		Fprint(out, x1, y1, flatR)
		return
	}
	r2 := math.Hypot(float64(x2), float64(y2))
	r := (r2 + float64(flatR)) / 2
	k := (r - r2) / r2
	Fprint(out, float64(x1)-k*float64(x2), float64(y1)-k*float64(y2), r)
}

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

package main

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

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

	var flatR, x1, y1, x2, y2 float64
	Fscan(in, &flatR, &x1, &y1, &x2, &y2)
	x2 -= x1
	y2 -= y1
	if x2 == 0 && y2 == 0 {
		Fprint(out, x1, y1, flatR)
		return
	}
	if x2*x2+y2*y2 >= flatR*flatR {
		Fprint(out, x1, y1, flatR)
		return
	}
	r2 := math.Hypot(x2, y2)
	r := (r2 + flatR) / 2
	k := (r - r2) / r2
	Fprint(out, x1-k*x2, y1-k*y2, r)
}

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

package main

import (
	"fmt"
	"math"
)

type Point struct {
	x, y float64
}

var R int
var p1, p2 Point

func main() {
	fmt.Scanf("%d %g %g %g %g", &R, &p1.x, &p1.y, &p2.x, &p2.y)
	diff := Point {
		x: p1.x - p2.x,
		y: p1.y - p2.y,
	}
	z := math.Sqrt(float64(math.Pow(float64(diff.y), 2) + math.Pow(float64(diff.x), 2)))
	r := (float64(R) + z) / 2
	theta := math.Atan2(diff.y, diff.x)
	res := Point {
		x: p2.x + r * math.Cos(theta),
		y: p2.y + r * math.Sin(theta),
	}
	fmt.Printf("%g %g %g", res.x, res.y, r)
}


Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.A common divisor for two positive numbers is a number which both numbers are divisible by.But your teacher wants to give you a harder task, in this task you have to find the greatest common divisor d between two integers a and b that is in a given range from low to high (inclusive), i.e. low ≤ d ≤ high. It is possible that there is no common divisor in the given range.You will be given the two integers a and b, then n queries. Each query is a range from low to high and you have to answer each query.

The first line contains two integers a and b, the two integers as described above (1 ≤ a, b ≤ 109). The second line contains one integer n, the number of queries (1 ≤ n ≤ 104). Then n lines follow, each line contains one query consisting of two integers, low and high (1 ≤ low ≤ high ≤ 109).

Print n lines. The i-th of them should contain the result of the i-th query in the input. If there is no common divisor in the given range for any query, you should print -1 as a result for this query.

package main

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

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

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

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

  a, b := getI(), getI()
  if a > b {
    a, b = b, a
  }
  isFactor := map[int]bool{}
  for d := 1; d*d <= a; d++ {
    if a%d == 0 {
      if b%d == 0 {
        isFactor[d] = true
      }
      c := a/d
      if b%c == 0 {
        isFactor[c] = true
      }
    }
  }
  factors := []int{}
  for d := range isFactor {
    factors = append(factors, d)
  }
  sort.Ints(factors)
  for _, d := range factors {
    fmt.Fprintf(os.Stderr, "%d ", d)
  }
  fmt.Fprintf(os.Stderr, "\n")
  n := getI()
  for i := 0; i < n; i++ {
    low, high := getI(), getI()
    result := -1
    for j := len(factors)-1; j >= 0; j-- {
      d := factors[j]
      if low <= d && d <= high {
        result = d
        break
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", result))
  }
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF75C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var l, r, q int
	Fscan(in, &l, &r, &q)
	g := gcd(l, r)
	ds := []int{}
	for d := 1; d*d <= g; d++ {
		if g%d == 0 {
			ds = append(ds, d)
			if d*d < g {
				ds = append(ds, g/d)
			}
		}
	}
	sort.Ints(ds)
	for ; q > 0; q-- {
		Fscan(in, &l, &r)
		if i := sort.SearchInts(ds, r+1); i > 0 && ds[i-1] >= l {
			Fprintln(out, ds[i-1])
		} else {
			Fprintln(out, -1)
		}
	}
}

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

package main

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

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

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

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

  a, b := getI(), getI()
  if a > b {
    a, b = b, a
  }
  isFactor := map[int]bool{}
  for d := 1; d*d <= a; d++ {
    if a%d == 0 && b%d == 0 {
      isFactor[d] = true
      c := a/d
      if b%c == 0 {
        isFactor[c] = true
      }
    }
  }
  factors := []int{}
  for factor := range isFactor {
    factors = append(factors, factor)
  }
  sort.Ints(factors)
  n := getI()
  for i := 0; i < n; i++ {
    low, high := getI(), getI()
    result := -1
    for j := len(factors)-1; j >= 0; j-- {
      d := factors[j]
      if low <= d && d <= high {
        result = d
        break
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", result))
  }
}

package main

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

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

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

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

  a, b := getI(), getI()
  if a > b {
    a, b = b, a
  }
  isFactor := map[int]bool{}
  for d := 1; d*d <= a; d++ {
    if a%d == 0 && b%d == 0 {
      isFactor[d] = true
      isFactor[a/d] = true
      isFactor[b/d] = true
    }
  }
  factors := []int{}
  for factor := range isFactor {
    factors = append(factors, factor)
  }
  sort.Ints(factors)
  n := getI()
  for i := 0; i < n; i++ {
    low, high := getI(), getI()
    result := -1
    for j := len(factors)-1; j >= 0; j-- {
      d := factors[j]
      if low <= d && d <= high {
        result = d
        break
      }
    }
    writer.WriteString(fmt.Sprintf("%d\n", result))
  }
}


Disclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)Rick and Morty like to go to the ridge High Cry for crying loudly — there is an extraordinary echo. Recently they discovered an interesting acoustic characteristic of this ridge: if Rick and Morty begin crying simultaneously from different mountains, their cry would be heard between these mountains up to the height equal the bitwise OR of mountains they've climbed and all the mountains between them. Bitwise OR is a binary operation which is determined the following way. Consider representation of numbers x and y in binary numeric system (probably with leading zeroes) x = xk... x1x0 and y = yk... y1y0. Then z = x | y is defined following way: z = zk... z1z0, where zi = 1, if xi = 1 or yi = 1, and zi = 0 otherwise. In the other words, digit of bitwise OR of two numbers equals zero if and only if digits at corresponding positions is both numbers equals zero. For example bitwise OR of numbers 10 = 10102 and 9 = 10012 equals 11 = 10112. In programming languages C/C++/Java/Python this operation is defined as «|», and in Pascal as «or».Help Rick and Morty calculate the number of ways they can select two mountains in such a way that if they start crying from these mountains their cry will be heard above these mountains and all mountains between them. More formally you should find number of pairs l and r (1 ≤ l < r ≤ n) such that bitwise OR of heights of all mountains between l and r (inclusive) is larger than the height of any mountain at this interval.

The first line contains integer n (1 ≤ n ≤ 200 000), the number of mountains in the ridge. Second line contains n integers ai (0 ≤ ai ≤ 109), the heights of mountains in order they are located in the ridge.

Print the only integer, the number of ways to choose two different mountains.

NoteIn the first test case all the ways are pairs of mountains with the numbers (numbering from one):(1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)In the second test case there are no such pairs because for any pair of mountains the height of cry from them is 3, and this height is equal to the height of any mountain.

package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    var n int64
    const N int = 200005
    pos := make(map[int64]int64)
    fmt.Fscan(in, &n)
    var a [N] int64
    var ans int64 = n * (n + 1) / 2
    var dpl [N][30] int64
    var dpr [N][30] int64
    for i := 1 ; i <= int(n); i++ {
        fmt.Fscan(in, &a[i])
    }
    for i := 1; i <= int(n); i++ {
        var k int64 = 1
        for j := 0 ; j < 30; j++ {
            if (a[i] & k) > 0 {
                dpl[i][j] = int64(i)
            } else {
                dpl[i][j] = dpl[i - 1][j]
            }
            k = k * 2
        }
    }
    for i := 0; i < 30; i++ {
       dpr[n + 1][i] = n + 1
    }
    for i := int(n); i > 0; i-- {
        var k int64 = 1
        for j := 0 ; j < 30; j++ {
            if (a[i] & k) > 0 {
                dpr[i][j] = int64(i)
            } else {
                dpr[i][j] = dpr[i + 1][j]
            }
            k = k * 2
        }
    }
    for i := 1; i <= int(n); i++ {
        var l int64 = pos[a[i]]
        var r int64 = n + 1
        for j := 0; j < 30; j++ {
            if dpl[i][j] != int64(i) {
                if l < dpl[i - 1][j]{
                    l = dpl[i - 1][j]
                }
                if r > dpr[i + 1][j]{
                    r = dpr[i + 1][j]
                }
            }
        }
        ans = ans - (int64(i) - l) * (r - int64(i))
        pos[a[i]] = int64(i);
    }
    fmt.Println(ans)
}


This is an interactive problem. In the interaction section below you will see the information about flushing the output.In this problem, you will be playing a game with Hongcow. How lucky of you!Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find .To do this, you can ask Hongcow some questions.A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.When you are ready to answer, print out a single integer  - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.You will get Wrong Answer verdict if   Your question or answers are not in the format described in this statement.  You ask strictly more than 20 questions.  Your question contains duplicate indices.  The value of k in your question does not lie in the range from 1 to n, inclusive.  Your final answer is not correct.  You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).

The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).

To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!

NoteIn the first sample, Hongcow has the hidden matrix [ [0, 3, 2], [5, 0, 7], [4, 8 ,0],]Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant. 3              3              1 2 30 0 0              1              32 7 0              2              1 20 0 4              1              23 0 8              1              10 5 4              -1              2 5 4For the second sample, it is possible for off-diagonal elements of the matrix to be zero.

package main

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

const sz = 20
const take = 10

type Comb [sz]bool

func combs() []Comb {
    res := []Comb{}

    cur := Comb{}
    var gen func(i int)
    gen = func(i int) {
        if i == sz {
            cnt := 0
            for i := range cur {
                if cur[i] {
                    cnt++
                }
            }
            if cnt == take {
                res = append(res,cur)
            }
        } else {
            cur[i] = true
            gen(i+1)
            cur[i] = false
            gen(i+1)
        }
    }
    gen(0)
    return res
}

func solve() {
    n := readInt()
    reqs := [sz][]int{}
    cs := combs()
    for i, k := 0, 1; k <= n; k++ {
        for j, v := range cs[i] {
            if v {
                reqs[j] = append(reqs[j], k)
            }
        }
        i++
    }
    ans := [sz][]int{}
    for i, r := range reqs {
        if l := len(r); l > 0 {
            fmt.Println(l)
            for _, k := range r {
                fmt.Print(k, " ")
            }
            fmt.Println()
            ans[i] = readIntArray(n)
        }
    }

    res := make([]int, n)
    for i, k := 0, 0; k < n; k++ {
        res[k] = 1000*1000*1000+9
        for j, v := range cs[i] {
            if !v  && len(ans[j]) > 0 {
                res[k] = min(res[k], ans[j][k])
            }
        }
        i++
    }
    fmt.Println(-1)
    for _, v := range res {
        fmt.Print(v, " ")
    }
    fmt.Println()

}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

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

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

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