You are given a positive integer $$$n$$$. Your task is to find any three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 10^9$$$) for which $$$(a\oplus b)+(b\oplus c)+(a\oplus c)=n$$$, or determine that there are no such integers.Here $$$a \oplus b$$$ denotes the bitwise XOR of $$$a$$$ and $$$b$$$. For example, $$$2 \oplus 4 = 6$$$ and $$$3 \oplus 1=2$$$.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The following lines contain the descriptions of the test cases. The only line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

For each test case, print any three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 10^9$$$) for which $$$(a\oplus b)+(b\oplus c)+(a\oplus c)=n$$$. If no such integers exist, print $$$-1$$$.

NoteIn the first test case, $$$a=3$$$, $$$b=3$$$, $$$c=1$$$, so $$$(3 \oplus 3)+(3 \oplus 1) + (3 \oplus 1)=0+2+2=4$$$.In the second test case, there are no solutions.In the third test case, $$$(2 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12$$$.

package main
import "fmt"

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

        fmt.Scanf("%d ", &n)
        if (n%2 == 0) {
            fmt.Printf("0 0 %d\n", n/2)
        } else {
            fmt.Println("-1")
        }

        testCase--;
    }
}

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if n%2==1{
			Fprintln(out,-1)
		}else{
			Fprintln(out,"0 0 ",n/2)
		}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scanln(&t)
	for ; t>0; t-- {
		var n int
		fmt.Scanln(&n)
		if n%2==1 {
			fmt.Println("-1")
		}else {
			fmt.Println("0 0 ",n/2)
		}
	}
}

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

package main

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

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

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

package main

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

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

func solve(n int) string {
	if n%2 == 1 {
		return "-1"
	}
	return fmt.Sprintf("%d %d %d", 0, 0, n/2)
}

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

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 gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
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 makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
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()
		if N % 2 == 1 { fmt.Fprintln(wrtr,-1) } else { fmt.Fprintf(wrtr,"%v %v %v\n",0,0,N/2) }
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1699A
Date: 10/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1699/A
Problem: CF1699A
**/
func (in *CF1699A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		if n%2 == 0 {
			fmt.Println( n/2, n/2, 0)
		} else {
			fmt.Println(-1)
		}

	}
}

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

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

package main

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

func Solve(testCaseIndex int, reader io.Reader) {
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	if n % 2 == 1 {
		fmt.Fprintln(writer, "-1")
	} else {
		fmt.Fprintf(writer, "0 %d %d\n", n / 2, n / 2)
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var testCaseCount int
	fmt.Fscanln(reader, &testCaseCount)
	for t := 0; t < testCaseCount; t++ {
		Solve(t, reader)
	}
}

package main

import "fmt"

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

	for test > 0 {
		test--
		var n int
		fmt.Scanln(&n)
		if n%2 == 0 {
			fmt.Println(n/2, 0, 0)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

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

func tc() {
	var n int
	fmt.Fscan(r, &n)
	if n%2 == 1 {
		fmt.Fprintln(w, -1)
	} else {
		fmt.Fprintln(w, 0, 0, n/2)
	}

}

func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for i := 0; i < t; i++ {
		tc()
	}
}

package main

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

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

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

	var T int
	var x int

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

		if x&1 == 1 {
			Fprintln(out, -1)

		} else {
			Fprintln(out, 0, 0^(x/2), 0^(x/2))
		}
	}
}

package main

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

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

	var n int
	var arr []uint32

	_, err := fmt.Fscan(in, &n)
	if err != nil {
		os.Exit(2)
	}

	for i := 0; i < n; i++ {
		var tmp uint32 = 0
		if _, err = fmt.Fscan(in, &tmp); err != nil {
			os.Exit(2)
		}
		arr = append(arr, tmp)
	}

	for _, el := range arr {
		ok, a, b, c := FindABC(el)
		if !ok {
			fmt.Fprintln(out, -1)
		} else {
			fmt.Fprintln(out, a, b, c)
		}
	}

	out.Flush()
}

func FindABC(n uint32) (ok bool, a, b, c uint32) {
	if n%2 == 1 {
		return
	}

	n /= 2

	var i uint32 = 1
	for ; i <= n; i <<= 1 {
		if n&i != 0 {
			a |= i
		} else {
			a |= i
			b |= i
		}
	}

	ok = true
	c = a
	return
}

// 1328A. Divisibility Problem
package main

import (
	"fmt"
)

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

	}

}

package main

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

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

func main() {
	defer out.Flush()

	var tc int
	for fmt.Fscan(in, &tc); tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		if n%2 == 1 {
			fmt.Fprintln(out, -1)
			continue
		}
		var a, b int
		n /= 2
		for p := 1; n > 0; n, p = n/2, p*2 {
			if n%2 == 1 {
				a, b = a+p, b+p
			}
		}
		fmt.Fprintln(out, a, b, 0)
	}
}

package main

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

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

func solve() {
	var n int
	fmt.Fscan(r, &n)
	if n%2 == 1 {
		fmt.Fprintln(w, -1)
	} else {
		fmt.Fprintln(w, 0, 0, n/2)
	}

}
func main() {
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

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

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

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

		if n%2 != 0 {
			fmt.Fprintln(out, -1)
		} else {
			n /= 2
			fmt.Fprintln(out, n, n, 0)
		}
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(rr, &n)
	if n % 2 == 1 {
		fmt.Fprintln(ww, -1)
	} else {
		fmt.Fprintln(ww, n/2, n/2, 0)
	}
}

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

package main
import "fmt"

func main() {
    var testCase int
    fmt.Scanln("%d", &testCase)
    for testCase>0 {
        var n int

        fmt.Scanln("%d", &n)
        if (n%2 == 0) {
            fmt.Printf("0 0 %d\n", n/2)
        } else {
            fmt.Println("-1")
        }

        testCase--;
    }
}

package main
import "fmt"

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

        fmt.Scanf("%d", &n)
        if (n%2 == 0) {
            fmt.Printf("0 0 %d\n", n/2)
        } else {
            fmt.Println("-1")
        }

        testCase--;
    }
}

package main
import "fmt"

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

        fmt.Scanf("%d", &n)
        if (n%2 == 0) {
            fmt.Println("0 0", n/2)
        } else {
            fmt.Println("-1")
        }

        testCase--;
    }
}


While working at DTL, Ela is very aware of her physical and mental health. She started to practice various sports, such as Archery, Yoga, and Football.Since she started engaging in sports activities, Ela switches to trying a new sport on days she considers being "Luxury" days. She counts the days since she started these activities, in which the day she starts is numbered as day $$$1$$$. A "Luxury" day is the day in which the number of this day is a luxurious number. An integer $$$x$$$ is called a luxurious number if it is divisible by $$${\lfloor \sqrt{x} \rfloor}$$$.Here $$$\lfloor r \rfloor$$$ denotes the "floor" of a real number $$$r$$$. In other words, it's the largest integer not greater than $$$r$$$.For example: $$$8$$$, $$$56$$$, $$$100$$$ are luxurious numbers, since $$$8$$$ is divisible by $$$\lfloor \sqrt{8} \rfloor = \lfloor 2.8284 \rfloor = 2$$$, $$$56$$$ is divisible $$$\lfloor \sqrt{56} \rfloor = \lfloor 7.4833 \rfloor = 7$$$, and $$$100$$$ is divisible by $$$\lfloor \sqrt{100} \rfloor = \lfloor 10 \rfloor = 10$$$, respectively. On the other hand $$$5$$$, $$$40$$$ are not, since $$$5$$$ are not divisible by $$$\lfloor \sqrt{5} \rfloor = \lfloor 2.2361 \rfloor = 2$$$, and $$$40$$$ are not divisible by $$$\lfloor \sqrt{40} \rfloor = \lfloor 6.3246 \rfloor = 6$$$.Being a friend of Ela, you want to engage in these fitness activities with her to keep her and yourself accompanied (and have fun together, of course). Between day $$$l$$$ and day $$$r$$$, you want to know how many times she changes the activities.

Each test contains multiple test cases. The first line has the number of test cases $$$t$$$ ($$$1 \le t \le 10\ 000$$$). The description of the test cases follows. The only line of each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 10^{18}$$$) — the intervals at which you want to know how many times Ela changes her sports.

For each test case, output an integer that denotes the answer.

NoteIn the first test case, $$$5$$$ luxury numbers in range $$$[8, 19]$$$ are: $$$8, 9, 12, 15, 16$$$.

package main

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

const cf = true

func solve() {
	var l, r uint64
	fmt.Fscan(in, &l, &r)
	start, end := sqrt(l), sqrt(r)
	ans := (end - start) + (end-start-1)*2
	for i := l; i < (start+1)*(start+1); i = (i + start) - i%start {
		if i%start == 0 {
			ans++
		}
	}
	for i := end*end + 1; i <= r; i = (i + end) - i%end {
		if i%end == 0 {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

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

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var l, r uint64
		fmt.Scan(&l, &r)

		cnt := func (x uint64) uint64 {
			var res uint64 = 0
			if x == 0 {
				return res
			}
			low, high, sq := uint64(1), uint64(2e9), uint64(0)
			for low <= high {
				mid := low + (high - low) / 2
				if mid * mid <= x {
					sq = mid
					low = mid + 1
					continue
				}
				high = mid - 1
			}

			res = (sq - 1) * 3
			cur := sq * sq
			for cur <= x {
				res++
				cur += sq
			}
			return res
		}
		res := cnt(r) - cnt(l-1)
		fmt.Println(res)
	}
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

func solve() int64 {
	var l, r int64
	fmt.Fscan(in, &l, &r)
	if l == r {
		x := int64(math.Sqrt(float64(l)))
		if x*x > l {
			x--
		}
		if l%x == 0 {
			return 1
		}
		return 0
	}

	lo := int64(math.Sqrt(float64(l)))
	hi := int64(math.Sqrt(float64(r)))

	if lo*lo > l {
		lo--
	}
	if hi*hi > r {
		hi--
	}
	hi++

	// fmt.Println(lo, hi)

	if hi-lo == 1 {
		res := int64(0)
		for i := lo * lo; i <= hi*hi; i += lo {
			if i >= l && i <= r {
				res++
			}
		}
		return res
	}
	res := (hi - lo - 2) * 3
	mid := lo + 1
	for i := lo * lo; i < mid*mid; i += lo {
		if i >= l && i <= r {
			res++
		}
	}
	mid = hi - 1
	for i := mid * mid; i <= hi*hi; i += mid {
		if i >= l && i <= r {
			res++
		}
	}
	return res
}

package main

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

func get_sqrt(l, r, s int) int {
	if r-l <= 1 { return l }
	m := (l + r)/2
	if m > 1e9 || m*m > s { return get_sqrt(l, m, s) }
	return get_sqrt(m, r, s)
}

func get_cnt(l, r, x int) int {
	cnt := 0
	if x*x >= l && x*x <= r { cnt++ }
	if x*x+x >= l && x*x+x <= r { cnt++ }
	if x*x + 2*x >=l && x*x + 2*x <=r { cnt++ }
	return cnt
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var a, b, res int
		fmt.Fscan(r, &a, &b)

		x := get_sqrt(1, a, a)
		y := get_sqrt(1, b, b)

		/*
		fmt.Fprintf(w, "a:%d b:%d x:%d y:%d\n", a, b, x, y) // ***
		fmt.Fprintf(w, "A:%d\n", get_cnt(a, b, x)) // ***
		fmt.Fprintf(w, "B1:%d B2:%d B3:%d\n", 3*(y-x-1), get_cnt(a, x*x+2*x, x), get_cnt(y*y, b, y)) // ***
		*/
		if x == y {
			res = get_cnt(a, b, x)
		} else {
			res = 3*(y-x-1) + get_cnt(a, x*x+2*x, x) + get_cnt(y*y, b, y)
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

const cf = true

func sqrt(val uint64) uint64 {
	return uint64(math.Floor(math.Sqrt(float64(val))))
}

func solve() {
	var l, r uint64
	fmt.Fscan(in, &l, &r)
	start, end := sqrt(l), sqrt(r)
	ans := (end - start) + (end-start-1)*2
	for i := l; i < (start+1)*(start+1); i = (i + start) - i%start {
		if i%start == 0 {
			ans++
		}
	}
	for i := end*end + 1; i <= r; i = (i + end) - i%end {
		if i%end == 0 {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

const cf = true

func sqrt(val int) int {
	return int(math.Sqrt(float64(val)))
}

func solve() {
	var l, r int
	fmt.Fscan(in, &l, &r)
	start, end := sqrt(l), sqrt(r)
	ans := (end - start) + (end-start-1)*2
	for i := l; i < (start+1)*(start+1); i = (i + start) - i%start {
		if i%start == 0 {
			ans++
		}
	}
	for i := end*end + 1; i <= r; i = (i + end) - i%end {
		if i%end == 0 {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

const cf = true

func sqrt(val int) int {
	return int(math.Sqrt(float64(val)))
}

func solve() {
	var l, r int
	fmt.Fscan(in, &l, &r)
	if l == r {
		if l%sqrt(l) == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, 0)
		}
		return
	} else if r < 4 {
		fmt.Fprintln(out, r-l+1)
		return
	}
	start, end := sqrt(l), sqrt(r)
	ans := (end - start) + (end-start-1)*2
	for i := l; i < (start+1)*(start+1); i = (i + start) / start * start {
		if i%start == 0 {
			ans++
		}
	}
	for i := r; i > end*end; i = (i - (end - 1)) / (end - 1) * (end - 1) {
		if i%end == 0 {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var l, r uint64
		fmt.Scan(&l, &r)

		cnt := func (x uint64) uint64 {
			var res uint64 = 0
			if x == 0 {
				return res
			}
			sq := uint64(math.Sqrt(float64(x)))
			res = (sq - 1) * 3
			cur := sq * sq
			for cur <= x {
				res++
				cur += sq
			}
			return res
		}
		res := cnt(r) - cnt(l-1)
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var l, r int64
		fmt.Scan(&l, &r)

		cnt := func (x int64) int64 {
			var res int64 = 0
			if x == 0 {
				return res
			}
			sq := int64(math.Sqrt(float64(x)))
			res = (sq - 1) * 3
			cur := sq * sq
			for cur <= x {
				res++
				cur += sq
			}
			return res
		}
		res := cnt(r) - cnt(l-1)
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var l, r int64
		fmt.Scan(&l, &r)

		// cnt := func (x int64) int64 {
		// 	var res int64 = 0
		// 	var cur int64 = 1
		// 	var val int64 = 1
		// 	rem := 0
		// 	for val <= x {
		// 		res++
		// 		rem++
		// 		val += cur
		// 		if rem == 3 {
		// 			cur++
		// 			val = cur * cur
		// 			rem = 0
		// 			continue
		// 		}
		// 	}
		// 	return res
		// }

		cnt1 := func (x int64) int64 {
			var res int64 = 0
			if x == 0 {
				return res
			}
			sq := int64(math.Sqrt(float64(x)))
			res += (sq - 1) * 3
			cur := sq * sq
			// fmt.Println(res, cur, sq)
			for cur <= x {
				res++
				cur += sq
				// fmt.Println(res, cur, sq)
			}
			return res
		}
		res := cnt1(r) - cnt1(l-1)
		fmt.Println(res)
	}
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

func solve() int64 {
	var l, r int64
	fmt.Fscan(in, &l, &r)
	if l == r {
		x := int64(math.Sqrt(float64(l)))
		if x*x > l {
			x--
		}
		if l%x == 0 {
			return 1
		}
		return 0
	}

	lo := int64(math.Sqrt(float64(l)))
	hi := int64(math.Sqrt(float64(r))) + 1

	if lo*lo > l {
		lo--
	}
	if hi*hi < r {
		hi++
	}

	// fmt.Println(lo, hi)

	if hi-lo == 1 {
		res := int64(0)
		for i := lo * lo; i <= hi*hi; i += lo {
			if i >= l && i <= r {
				res++
			}
		}
		return res
	}
	res := (hi - lo - 2) * 3
	mid := lo + 1
	for i := lo * lo; i < mid*mid; i += lo {
		if i >= l && i <= r {
			res++
		}
	}
	mid = hi - 1
	for i := mid * mid; i <= hi*hi; i += mid {
		if i >= l && i <= r {
			res++
		}
	}
	return res
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

func solve() int64 {
	var l, r int64
	fmt.Fscan(in, &l, &r)
	if l == r {
		x := int64(math.Sqrt(float64(l)))
		if l%x == 0 {
			return 1
		}
		return 0
	}

	lo := int64(math.Sqrt(float64(l)))
	hi := int64(math.Sqrt(float64(r))) + 1

	if lo*lo > l {
		lo--
	}
	if hi*hi < r {
		hi++
	}

	// fmt.Println(lo, hi)

	if hi-lo == 1 {
		res := int64(0)
		for i := lo * lo; i <= hi*hi; i += lo {
			if i >= l && i <= r {
				res++
			}
		}
		return res
	}
	res := (hi - lo - 2) * 3
	mid := lo + 1
	for i := lo * lo; i < mid*mid; i += lo {
		if i >= l && i <= r {
			res++
		}
	}
	mid = hi - 1
	for i := mid * mid; i <= hi*hi; i += mid {
		if i >= l && i <= r {
			res++
		}
	}
	return res
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

func solve() int64 {
	var l, r int64
	fmt.Fscan(in, &l, &r)
	if l == r {
		x := int64(math.Sqrt(float64(l)))
		if l%x == 0 {
			return 1
		}
		return 0
	}

	lo := int64(math.Sqrt(float64(l)))
	hi := int64(math.Sqrt(float64(r))) + 1

	// fmt.Println(lo, hi)

	if hi-lo == 1 {
		res := int64(0)
		for i := lo * lo; i <= hi*hi; i += lo {
			if i >= l && i <= r {
				res++
			}
		}
		return res
	}
	res := (hi - lo - 2) * 3
	mid := lo + 1
	for i := lo * lo; i < mid*mid; i += lo {
		if i >= l && i <= r {
			res++
		}
	}
	mid = hi - 1
	for i := mid * mid; i <= hi*hi; i += mid {
		if i >= l && i <= r {
			res++
		}
	}
	return res
}


Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.Rules of the game are very simple: at first number of rounds n is defined. In every round each of the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player, whose value after throwing the dice is greater, wins the round. In case if player dice values are equal, no one of them is a winner.In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw.Mishka is still very little and can't count wins and losses, so she asked you to watch their game and determine its result. Please help her!

NoteIn the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.In the third sample case Chris wins the first round, but there is no winner of the next two rounds. The winner of the game is Chris.

package main

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

func main() {
	var n, a, b int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	count := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a, &b)
		if a > b {
			count++
		} else if a < b {
			count--
		}
	}
	if count > 0 {
		fmt.Println("Mishka")
	} else if count < 0 {
		fmt.Println("Chris")
	} else {
		fmt.Println("Friendship is magic!^^")
	}
}

// A. Mishka and Game
/*
Mishka is a little polar bear. As known, little bears loves spending their
free time playing dice for chocolates. Once in a wonderful sunny morning,
walking around blocks of ice, Mishka met her friend Chris, and they started
playing the game.

Rules of the game are very simple: at first number of rounds n is defined.
In every round each of the players throws a cubical dice with distinct numbers
from 1 to 6 written on its faces. Player, whose value after throwing the dice
is greater, wins the round. In case if player dice values are equal, no one of
them is a winner.

In average, player, who won most of the rounds, is the winner of the game.
In case if two players won the same number of rounds, the result of the
game is draw.

Mishka is still very little and can't count wins and losses, so she asked you
to watch their game and determine its result. Please help her!

Input
The first line of the input contains single integer n n (1 ≤ n ≤ 100) —
the number of game rounds.

The next n lines contains rounds description. i-th of them contains pair of
integers mi and ci (1 ≤ mi,  ci ≤ 6) — values on dice upper face after
Mishka's and Chris' throws in i-th round respectively.

Output
If Mishka is the winner of the game, print "Mishka" (without quotes)
in the only line.

If Chris is the winner of the game, print "Chris" (without quotes) in the
only line.

If the result of the game is draw, print "Friendship is magic!^^"
(without quotes) in the only line.

Examples
Input
3
3 5
2 1
4 2

Output
Mishka

Input
2
6 1
1 6

Output
Friendship is magic!^^

Input
3
1 5
3 3
2 2

Output
Chris

Note
In the first sample case Mishka loses the first round, but wins second and
third rounds and thus she is the winner of the game.

In the second sample case Mishka wins the first round, Chris wins the second
round, and the game ends with draw with score 1:1.

In the third sample case Chris wins the first round, but there is no winner of
the next two rounds. The winner of the game is Chris.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	mWin, cWin := 0, 0
	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")

		m, _ := strconv.Atoi(arr[0])
		c, _ := strconv.Atoi(arr[1])

		if m > c {
			mWin++
		} else if c > m {
			cWin++
		}
	}

	if mWin > cWin {
		fmt.Print("Mishka")
	} else if cWin > mWin {
		fmt.Print("Chris")
	} else {
		fmt.Print("Friendship is magic!^^")
	}
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

	mwin := 0
	cwin := 0

	var m, c int
	for i := 0; i < n; i++ {
		fmt.Fscan(bufin, &m, &c)
		if m > c {
			mwin++
		} else if m < c {
			cwin++
		}
	}

	if mwin > cwin {
		fmt.Fprintln(bufout, "Mishka")
	} else if mwin < cwin {
		fmt.Fprintln(bufout, "Chris")
	} else {
		fmt.Fprintln(bufout, "Friendship is magic!^^")
	}
}

package main

import "fmt"

func main() {
	var n, m, c int
	var mishka, chris = 0, 0
	_, _ = fmt.Scan(&n)
	for ; n > 0; n-- {
		_, _ = fmt.Scan(&m, &c)
		if m > c {
			mishka += 1
		} else if m < c {
			chris += 1
		} else {
			continue
		}
	}
	if mishka > chris {
		fmt.Println("Mishka")
	} else if chris > mishka {
		fmt.Println("Chris")
	} else {
		fmt.Println("Friendship is magic!^^")
	}
}

package main

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

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

	n := NextInt()
	m := 0
	c := 0
	for i := 0; i < n; i++ {
		mi := NextInt()
		ci := NextInt()
		switch {
		case mi > ci:
			m++
		case mi < ci:
			c++
		default:
		}
	}

	switch {
	case m > c:
		Println("Mishka")
	case c > m:
		Println("Chris")
	default:
		Println("Friendship is magic!^^")
	}
}

/******************/
/* IO boilerplate */
/******************/

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

func NextInt() int {
	ret, _ := strconv.Atoi(Next())
	return ret
}

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

func Print(s string) {
	writer.WriteString(s)
}

func Println(s string) {
	writer.WriteString(s)
	writer.WriteByte('\n')
}

package main

import "fmt"

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

	for range make([]struct{}, n) {
		var a, b int
		fmt.Scan(&a, &b)

		switch {
		case a > b:
			m++
		case b > a:
			c++
		}
	}

	switch {
	case m > c:
		fmt.Println("Mishka")
	case c > m:
		fmt.Println("Chris")
	default:
		fmt.Println("Friendship is magic!^^")
	}
}

package main

import (
	"fmt"
)

func main() {
	var a, b, n int
	r := 0
	fmt.Scanf("%d \n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		if a > b {
			r++
		}
		if b > a {
			r--
		}
	}
	if r > 0 {
		fmt.Print("Mishka")
	} else if r < 0 {
		fmt.Print("Chris")
	} else {
		fmt.Print("Friendship is magic!^^")
	}
}

package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    n := 0
    fmt.Fscan(in, &n)
    one := 0
    two := 0
    var a, b int
    for i := 0; i < n; i++ {
        fmt.Fscan(in, &a, &b)
        if a < b {
            two++
        } else if b < a {
            one++
        }
    }
    if one == two {
        fmt.Println("Friendship is magic!^^")
    } else if one > two {
        fmt.Println("Mishka")
    } else {
        fmt.Println("Chris")
    }
}

package main

import "fmt"

func new_game(result [2]int) [2]int {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		result[0] += 1
	} else if a < b {
		result[1] += 1
	}
	return result
}
func main() {
	result := [...]int{0, 0}
	var res1 int = 0
	var res2 int = 0
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		result := new_game(result)
		res1 += result[0]
		res2 += result[1]
	}
	if res1 == res2 {
		fmt.Print("Friendship is magic!^^")
	} else if res2 > res1 {
		fmt.Print("Chris")
	} else if res1 > res2 {
		fmt.Print("Mishka")
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, mi, ch, ms, cs int
	fmt.Scan(&n)

	for i:=0; i < n; i++{
		fmt.Scan(&mi, &ch)
		if mi > ch {
			ms++
		}else if ch > mi{
			cs++
		}
	}
	if ms > cs {
		fmt.Println("Mishka")
	}else if cs > ms {
		fmt.Println("Chris")
	}else{
		fmt.Println("Friendship is magic!^^")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, a, b uint8
	var m, c uint8
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint8(i) < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a > b {
			m++
		} else if a < b {
			c++
		}
	}
	if c == m {
		fmt.Println("Friendship is magic!^^")
	} else if m > c {
		fmt.Println("Mishka")
	} else if m < c {
		fmt.Println("Chris")
	}

}

package main

import "fmt"

func newgame(result [2]int) [2]int {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		result[0] += 1
	} else if a < b {
		result[1] += 1
	}
	return result
}
func main() {
	result := [...]int{0, 0}
	var result1, result2 int = 0, 0
	var n int
	fmt.Scan(&n)
	for i := 1; i < n+1; i++ {
		result := newgame(result)
		//fmt.Print(result)
		result1 += result[0]
		result2 += result[1]
	}
	if result1 > result2 {
		fmt.Print("Mishka")
	} else if result2 > result1 {
		fmt.Print("Chris")
	} else if result1 == result2 {
		fmt.Print("Friendship is magic!^^")
	}
}

package main

import (
	"fmt"
)

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

	ans := 0
	for i := 0; i < n; i++ {
		m, c := 0, 0
		fmt.Scan(&m, &c)
		if m > c {
			ans++
		} else if c > m {
			ans--
		}
	}

	if ans > 0 {
		fmt.Println("Mishka")
	} else if ans < 0 {
		fmt.Println("Chris")
	} else {
		fmt.Println("Friendship is magic!^^")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var aw, bw int
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if a > b {
			aw++
		}
		if b > a {
			bw++
		}
	}
	if aw > bw {
		fmt.Print("Mishka")
	} else if aw == bw {
		fmt.Print("Friendship is magic!^^")
	} else {
		fmt.Print("Chris")
	}
}

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])

	var ms int64
	var cs int64
	//x, _ := strconv.ParseInt(s[1], 10, 64)
	for i := 0; i < c; i++ {
		text, _ := reader.ReadString('\n')
		text = strings.TrimRight(text, "\r\n")
		s := strings.Split(text, " ")
		c1, _ := strconv.Atoi(s[0])
		c2, _ := strconv.Atoi(s[1])
		if c1 > c2 {
			ms += 1
		} else if c2 > c1 {
			cs += 1
		}
	}

	if ms > cs {
		fmt.Println("Mishka")
	} else if cs > ms {
		fmt.Println("Chris")
	} else {
		fmt.Println("Friendship is magic!^^")
	}
}

package main

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

// https://codeforces.com/problemset/problem/703/A
// Rules of the game are very simple: at first number of rounds n is defined. In every round each of the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player, whose value after throwing the dice is greater, wins the round. In case if player dice values are equal, no one of them is a winner.

// In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw.

// Mishka is still very little and can't count wins and losses, so she asked you to watch their game and determine its result. Please help her!
// Input

// The first line of the input contains single integer n n (1 ≤ n ≤ 100) — the number of game rounds.

// The next n lines contains rounds description. i-th of them contains pair of integers mi and ci (1 ≤ mi,  ci ≤ 6) — values on dice upper face after Mishka's and Chris' throws in i-th round respectively.
// Output

// If Mishka is the winner of the game, print "Mishka" (without quotes) in the only line.

// If Chris is the winner of the game, print "Chris" (without quotes) in the only line.

// If the result of the game is draw, print "Friendship is magic!^^" (without quotes) in the only line.

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

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

	var mWins, cWins int
	for i := 0; i < n; i++ {
		var mi, ci int
		_, _ = fmt.Fscan(bufStdin, &mi, &ci)

		if mi > ci {
			mWins++
		} else if ci > mi {
			cWins++
		}
	}

	if mWins > cWins {
		_, _ = fmt.Print("Mishka")
	} else if cWins > mWins {
		_, _ = fmt.Print("Chris")
	} else {
		_, _ = fmt.Print("Friendship is magic!^^")
	}
}

package main

import "fmt"

func main() {
	var n, c1, c2, a, b int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		if a > b {
			c1++
		} else if a < b {
			c2++
		} else {
			c1++
			c2++
		}
	}
	if c1 > c2 {
		fmt.Println("Mishka")
	} else if c1 < c2 {
		fmt.Println("Chris")
	} else {
		fmt.Println("Friendship is magic!^^")
	}
}

package main

import "fmt"

type roll struct {
	m int
	c int
}

// https://codeforces.com/problemset/problem/703/A
// комментарии к решению
// Малый объем входных данных (n <= 100) позволяет задействовать fmt.Scan .
func taskSolution(a []roll) string {
	res := 0
	for _, r := range a {
		if r.m > r.c {
			res += 1
		} else if r.m < r.c {
			res -= 1
		}
	}
	if res > 0 {
		return "Mishka"
	} else if res < 0 {
		return "Chris"
	}
	return "Friendship is magic!^^"
}

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

	a := []roll{}
	for i := 0; i < n; i += 1 {
		var m, c int
		if _, err := fmt.Scan(&m, &c); err != nil {
			panic(err)
		}
		a = append(a, roll{m, c})
	}

	fmt.Println(taskSolution(a))
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, a, b uint8
	var m, c uint16
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint8(i) < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		m += uint16(a)
		c += uint16(b)
	}
	if c == m {
		fmt.Println("Friendship is magic!^^")
	} else if m > c {
		fmt.Println("Mishka")
	} else if m < c {
		fmt.Println("Chris")
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, a, b uint8
	var m, c uint16
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint8(i) < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		m += uint16(a)
		c += uint16(b)
	}
	if m > c {
		fmt.Println("Mishka")
	} else if m < c {
		fmt.Println("Chris")
	} else if c == m {
		fmt.Println("Friendship is magic!^^")
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, a, b uint8
	var m, c uint8
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint8(i) < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a > b {
			m++
		} else {
			c++
		}
	}
	if c == m {
		fmt.Println("Friendship is magic!^^")
	} else if m > c {
		fmt.Println("Mishka")
	} else if m < c {
		fmt.Println("Chris")
	}

}


DZY loves Fast Fourier Transformation, and he enjoys using it.Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are indexed from 0 to n - 1, andWe can calculate c fast using Fast Fourier Transformation.DZY made a little change on this formula. NowTo make things easier, a is a permutation of integers from 1 to n, and b is a sequence only containing 0 and 1. Given a and b, DZY needs your help to calculate c.Because he is naughty, DZY provides a special way to get a and b. What you need is only three integers n, d, x. After getting them, use the code below to generate a and b.//x is 64-bit variable;function getNextX() {    x = (x * 37 + 10007) % 1000000007;    return x;}function initAB() {    for(i = 0; i < n; i = i + 1){        a[i] = i + 1;    }    for(i = 0; i < n; i = i + 1){        swap(a[i], a[getNextX() % (i + 1)]);    }    for(i = 0; i < n; i = i + 1){        if (i < d)            b[i] = 1;        else            b[i] = 0;    }    for(i = 0; i < n; i = i + 1){        swap(b[i], b[getNextX() % (i + 1)]);    }}Operation x % y denotes remainder after division x by y. Function swap(x, y) swaps two values x and y.

The only line of input contains three space-separated integers n, d, x (1 ≤ d ≤ n ≤ 100000; 0 ≤ x ≤ 1000000006). Because DZY is naughty, x can't be equal to 27777500.

Output n lines, the i-th line should contain an integer ci - 1.

NoteIn the first sample, a is [1 3 2], b is [1 0 0], so c0 = max(1·1) = 1, c1 = max(1·0, 3·1) = 3, c2 = max(1·0, 3·0, 2·1) = 2.In the second sample, a is [2 1 4 5 3], b is [1 1 1 0 1].In the third sample, a is [5 2 1 4 3], b is [1 1 1 1 0].

package main

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

func swap(x, y *int) {
  var tmp int = *x
  *x = *y
  *y = tmp
}

func getNextX(x int) int {
  x = int((int64(x)*37 + 10007) % 1000000007)
  return x
}

// This is a boring problem, since a and b are generated randomly actually.
func initAB(x, d, n int, a, b []int) {
  for i := 0; i < n; i++ {
    a[i] = i + 1
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&a[i], &a[x%(i+1)])
  }
  for i := 0; i < n; i++ {
    if i < d {
      b[i] = 1
    } else {
      b[i] = 0
    }
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&b[i], &b[x%(i+1)])
  }
}

const N = 100001

func main() {
  reader := bufio.NewReader(os.Stdin)
  var n, d, x int
  fmt.Fscan(reader, &n, &d, &x)
  a := make([]int, N)
  b := make([]int, N)
  p := make([]int, N)
  b_pos := make([]int, d)
  initAB(x, d, n, a, b)
  for i := 0; i < n; i++ {
    p[a[i]] = i
  }
  var pos int = 0
  for i := 0; i < n; i++ {
    if b[i] == 1 {
      b_pos[pos] = i
      pos++
    }
  }
  const L = 40
  for i := 0; i < n; i++ {
    var res int = -1
    for j := n; j >= n-L && j > 0; j-- {
      if i >= p[j] && b[i-p[j]] == 1 {
        res = j
        break
      }
    }
    if res == -1 {
      res = 0
    }
    if res == 0 {
      for j := 0; j < d && b_pos[j] <= i; j++ {
        if res < a[i-b_pos[j]] {
          res = a[i-b_pos[j]]
        }
      }
    }
    fmt.Printf("%d\n", res)
  }
}

package main

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

func swap(x, y *int) {
  var tmp int = *x
  *x = *y
  *y = tmp
}

func getNextX(x int) int {
  x = int((int64(x)*37 + 10007) % 1000000007)
  return x
}

// This is a boring problem, since a and b are generated randomly actually.
func initAB(x, d, n int, a, b []int) {
  for i := 0; i < n; i++ {
    a[i] = i + 1
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&a[i], &a[x%(i+1)])
  }
  for i := 0; i < n; i++ {
    if i < d {
      b[i] = 1
    } else {
      b[i] = 0
    }
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&b[i], &b[x%(i+1)])
  }
}

const N = 100001

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  var n, d, x int
  fmt.Fscan(reader, &n, &d, &x)
  a := make([]int, N)
  b := make([]int, N)
  p := make([]int, N)
  b_pos := make([]int, d)
  initAB(x, d, n, a, b)
  for i := 0; i < n; i++ {
    p[a[i]] = i
  }
  var pos int = 0
  for i := 0; i < n; i++ {
    if b[i] == 1 {
      b_pos[pos] = i
      pos++
    }
  }
  const L = 40
  for i := 0; i < n; i++ {
    var res int = -1
    for j := n; j >= n-L && j > 0; j-- {
      if i >= p[j] && b[i-p[j]] == 1 {
        res = j
        break
      }
    }
    if res == -1 {
      res = 0
    }
    if res == 0 {
      for j := 0; j < d && b_pos[j] <= i; j++ {
        if res < a[i-b_pos[j]] {
          res = a[i-b_pos[j]]
        }
      }
    }
    fmt.Fprintf(writer, "%d\n", res)
  }
  writer.Flush()
}

package main

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

func swap(x, y *int) {
  var tmp int = *x
  *x = *y
  *y = tmp
}

func getNextX(x int) int {
  x = int((int64(x)*37 + 10007) % 1000000007)
  return x
}

// This is a boring problem, since a and b are generated randomly actually.
func initAB(x, d, n int, a, b []int) {
  for i := 0; i < n; i++ {
    a[i] = i + 1
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&a[i], &a[x%(i+1)])
  }
  for i := 0; i < n; i++ {
    if i < d {
      b[i] = 1
    } else {
      b[i] = 0
    }
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&b[i], &b[x%(i+1)])
  }
}

const N = 100001

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriterSize(os.Stdout, 20<<20)
  var n, d, x int
  fmt.Fscan(reader, &n, &d, &x)
  a := make([]int, N)
  b := make([]int, N)
  p := make([]int, N)
  b_pos := make([]int, d)
  initAB(x, d, n, a, b)
  for i := 0; i < n; i++ {
    p[a[i]] = i
  }
  var pos int = 0
  for i := 0; i < n; i++ {
    if b[i] == 1 {
      b_pos[pos] = i
      pos++
    }
  }
  const L = 40
  for i := 0; i < n; i++ {
    var res int = -1
    for j := n; j >= n-L && j > 0; j-- {
      if i >= p[j] && b[i-p[j]] == 1 {
        res = j
        break
      }
    }
    if res == -1 {
      res = 0
    }
    if res == 0 {
      for j := 0; j < d && b_pos[j] <= i; j++ {
        if res < a[i-b_pos[j]] {
          res = a[i-b_pos[j]]
        }
      }
    }
    fmt.Fprintf(writer, "%d\n", res)
  }
  writer.Flush()
}

package main

import (
	"fmt"
	"sort"
	// "os"
)

const (
	tresh = 1000
)

var (
	x int64
	as []int
	bs []int
)

func getNextX() int {
    x = (x * 37 + 10007) % 1000000007
    return int(x)
}

type Indicies []int
func (a Indicies) Len() int           { return len(a) }
func (a Indicies) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Indicies) Less(i, j int) bool { return as[a[i]] > as[a[j]] }

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

	as = make([]int, n)
	bs = make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = i+1
		if i < d {
			bs[i] = 1
		}
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		as[i], as[j] = as[j], as[i]
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		bs[i], bs[j] = bs[j], bs[i]
	}

	if d < tresh {
	// if len(os.Args) == 2 {
		cs := make([]int, n)
		for i := 0; i < n; i++ {
			if bs[i] == 1 {
				for j := i; j < n; j++ {
					if cs[j] < as[j-i] {
						cs[j] = as[j-i]
					}
				}
			}
		}
		for _, c := range cs {
			fmt.Println(c)
		}
	} else {
		var ordered Indicies = make([]int, n)
		for i := 0; i < n; i++ {
			ordered[i] = i
		}
		sort.Sort(ordered)
		// fmt.Println(as)
		// fmt.Println(ordered)
		for j := 0; j < n; j++ {
			x := 0
			for _, i := range ordered {
				if j-i >= 0 && bs[j-i] == 1 {
					x = as[i]
					break
				}
			}
			fmt.Println(x)
		}
	}
}

package main

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

func swap(x, y *int) {
  var tmp int = *x
  *x = *y
  *y = tmp
}

func getNextX(x int) int {
  x = int((int64(x)*37 + 10007) % 1000000007)
  return x
}

// This is a boring problem, since a and b are generated randomly actually.
func initAB(x, d, n int, a, b []int) {
  for i := 0; i < n; i++ {
    a[i] = i + 1
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&a[i], &a[x%(i+1)])
  }
  for i := 0; i < n; i++ {
    if i < d {
      b[i] = 1
    } else {
      b[i] = 0
    }
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&b[i], &b[x%(i+1)])
  }
}

const N = 100001

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriterSize(os.Stdout, 20<<20)
  var n, d, x int
  fmt.Fscan(reader, &n, &d, &x)
  a := make([]int, N)
  b := make([]int, N)
  p := make([]int, N)
  b_pos := make([]int, d)
  initAB(x, d, n, a, b)
  for i := 0; i < n; i++ {
    p[a[i]] = i
  }
  var pos int = 0
  for i := 0; i < n; i++ {
    if b[i] == 1 {
      b_pos[pos] = i
      pos++
    }
  }
  const L = 40
  for i := 0; i < n; i++ {
    var res int = -1
    for j := n; j >= n-L && j > 0; j-- {
      if i >= p[j] && b[i-p[j]] == 1 {
        res = j
        break
      }
    }
    if res == -1 {
      for j := 0; j < d && b_pos[j] <= i; j++ {
        if res < a[i-b_pos[j]] {
          res = a[i-b_pos[j]]
        }
      }
    }
    fmt.Fprintf(writer, "%d\n", res)
  }
  writer.Flush()
}

package main

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

func swap(x, y *int) {
  var tmp int = *x
  *x = *y
  *y = tmp
}

func getNextX(x int) int {
  x = int((int64(x)*37 + 10007) % 1000000007)
  return x
}

// This is a boring problem, since a and b are generated randomly actually.
func initAB(x, d, n int, a, b []int) {
  for i := 0; i < n; i++ {
    a[i] = i + 1
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&a[i], &a[x%(i+1)])
  }
  for i := 0; i < n; i++ {
    if i < d {
      b[i] = 1
    } else {
      b[i] = 0
    }
  }
  for i := 0; i < n; i++ {
    x = getNextX(x)
    swap(&b[i], &b[x%(i+1)])
  }
}

const N = 100001

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  var n, d, x int
  fmt.Fscan(reader, &n, &d, &x)
  a := make([]int, N)
  b := make([]int, N)
  p := make([]int, N)
  initAB(x, d, n, a, b)
  for i := 0; i < n; i++ {
    p[a[i]] = i
  }
  const L = 40
  for i := 0; i < n; i++ {
    var res int = -1
    for j := n; j >= n-L && j > 0; j-- {
      if i >= p[j] && b[i-p[j]] == 1 {
        res = j
        break
      }
    }
    if res == -1 {
      for j := 0; j <= i; j++ {
        if res < a[j]*b[i-j] {
          res = a[j] * b[i-j]
        }
      }
    }
    fmt.Fprintln(writer, res)
  }
}

package main

import (
	"fmt"
	"sort"
)

const (
	tresh = 1000
)

var (
	x int64
	as []int
	bs []int
)

func getNextX() int {
    x = (x * 37 + 10007) % 1000000007
    return int(x)
}

type Indicies []int
func (a Indicies) Len() int           { return len(a) }
func (a Indicies) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Indicies) Less(i, j int) bool { return as[a[i]] > as[a[j]] }

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

	as = make([]int, n)
	bs = make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = i+1
		if i < d {
			bs[i] = 1
		}
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		as[i], as[j] = as[j], as[i]
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		bs[i], bs[j] = bs[j], bs[i]
	}

	if d < tresh {
		cs := make([]int, n)
		for i := 0; i < n; i++ {
			if bs[i] == 1 {
				for j := i; j < n; j++ {
					if cs[j] < as[j-i] {
						cs[j] = as[j-i]
					}
				}
			}
		}
		for _, c := range cs {
			fmt.Println(c)
		}
	} else {
		var ordered Indicies = make([]int, n)
		for i := 0; i < n; i++ {
			ordered[i] = i
		}
		sort.Sort(ordered)
		for j := 0; j < n; j++ {
			for _, i := range ordered {
				if j-i >= 0 && bs[j-i] == 1 {
					fmt.Println(as[i])
					break
				}
			}
		}
	}
}


You are given some Tetris field consisting of $$$n$$$ columns. The initial height of the $$$i$$$-th column of the field is $$$a_i$$$ blocks. On top of these columns you can place only figures of size $$$2 \times 1$$$ (i.e. the height of this figure is $$$2$$$ blocks and the width of this figure is $$$1$$$ block). Note that you cannot rotate these figures.Your task is to say if you can clear the whole field by placing such figures.More formally, the problem can be described like this:The following process occurs while at least one $$$a_i$$$ is greater than $$$0$$$:  You place one figure $$$2 \times 1$$$ (choose some $$$i$$$ from $$$1$$$ to $$$n$$$ and replace $$$a_i$$$ with $$$a_i + 2$$$);  then, while all $$$a_i$$$ are greater than zero, replace each $$$a_i$$$ with $$$a_i - 1$$$. And your task is to determine if it is possible to clear the whole field (i.e. finish the described process), choosing the places for new figures properly.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of columns in the Tetris field. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the initial height of the $$$i$$$-th column of the Tetris field.

For each test case, print the answer — "YES" (without quotes) if you can clear the whole Tetris field and "NO" otherwise.

NoteThe first test case of the example field is shown below:Gray lines are bounds of the Tetris field. Note that the field has no upper bound.One of the correct answers is to first place the figure in the first column. Then after the second step of the process, the field becomes $$$[2, 0, 2]$$$. Then place the figure in the second column and after the second step of the process, the field becomes $$$[0, 0, 0]$$$.And the second test case of the example field is shown below:It can be shown that you cannot do anything to end the process.In the third test case of the example, you first place the figure in the second column after the second step of the process, the field becomes $$$[0, 2]$$$. Then place the figure in the first column and after the second step of the process, the field becomes $$$[0, 0]$$$.In the fourth test case of the example, place the figure in the first column, then the field becomes $$$[102]$$$ after the first step of the process, and then the field becomes $$$[0]$$$ after the second step of the process.

package main

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

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

	var T, n int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		if n == 1 {
			fmt.Fprint(w, "YES\n")
			continue
		}
		r1, r2 := 0, 0
		for _, e := range a {
			if e&1 == 0 {
				r1++
			} else {
				r2++
			}
		}
		if r1 != 0 && r2 != 0 {
			fmt.Fprint(w, "NO\n")
		} else {
			fmt.Fprint(w, "YES\n")
		}
	}
}

package main

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

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

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

	t := readInt(scanner)
	for i := 0; i < t; i++ {
		n := readInt(scanner)
		e := [2]int{0, 0}

		for j := 0; j < n; j++ {
			e[readInt(scanner) % 2] += 1
		}

		if e[0] > 0 && e[1] > 0 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

import "fmt"

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

func main(){

	var t int

	fmt.Scan(&t)

	for T := 0 ; T < t; T ++ {
		var n int

		fmt.Scan(&n)

		a := make([]int , n)

		for i := 0 ; i < n ; i ++ {
			fmt.Scan(&a[i])
		}
		q := 0
		for i := 0 ; i + 1 < n ; i ++ {
			if Abs(a[i] - a[i + 1]) % 2 != 0 {
				q = 1
				fmt.Printf("NO\n")
				break
			}
		}
		if q == 0 {
			fmt.Printf("YES\n")
		}
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		line = readLine(reader)
		ans := strings.Split(string(line), " ")
		current, _ := strconv.Atoi(ans[0])
		flag := true
		for i := 0; i < n; i++ {
			x,_ := strconv.Atoi(ans[i])
			if x > current {
				current, x = x, current
			}
			if (current - x) % 2 != 0 {
				flag = false
				break
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

var (
	t int
	n int
	a []int
)

func main() {
	readVariables()
	for i := 0; i < t; i++ {
		readQuery()
		if judge() {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge() bool {
	if n == 1 {
		return true
	}
	for i := 1; i < n; i++ {
		if (a[i]-a[i-1])%2 != 0 {
			return false
		}
	}
	return true
}

func readVariables() {
	t = nextInt()
}
func readQuery() {
	n = nextInt()
	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

package main

import (
   "bufio"
   "fmt"
   "math"
   "os"
   "sort"
   "strconv"
   "strings"
   "sync"
)

func main() {
   for t := ScanInt(); t > 0; t-- {
      n := ScanInt()
      a := ScanIntSlice(n)
      if possible(a) {
         P("YES")
      } else {
         P("NO")
      }
   }

   close(O)
   oWg.Wait()
}

func possible(a []int) bool {

   _, mx := MnMx(a...)
   for i := 0; i < len(a); i++ {
      if !((mx-a[i])%2 == 0) {
         return false
      }
   }

   return true
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
   P = fmt.Println

   in = bufio.NewScanner(os.Stdin)
   in.Buffer(make([]byte, 1024), int(1e+9))
   in.Split(bufio.ScanWords)

   O = make(chan string, 16)
   oWg = &sync.WaitGroup{}
   oWg.Add(1)

   writer := bufio.NewWriter(os.Stdout)
   go func() {
      defer oWg.Done()
      defer writer.Flush()

      for line := range O {
         writer.WriteString(line + "\n")
      }
   }()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
   s := make([]string, n)
   for i := 0; i < n; i++ {
      s[i] = ScanWord()
   }
   return s
}
func ScanIntSlice(n int) []int {
   arr := make([]int, n)
   for i := 0; i < n; i++ {
      arr[i] = ScanInt()
   }
   return arr
}
func ScanInt64Slice(n int) []int64 {
   arr := make([]int64, n)
   for i := 0; i < n; i++ {
      arr[i] = ScanInt64()
   }
   return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
   sb := strings.Builder{}
   sb.Grow(len(a) * 9)
   for i := range a {
      sb.WriteString(strconv.Itoa(a[i]) + " ")
   }
   return sb.String()
}
func SArr64(a []int64) string {
   sb := strings.Builder{}
   sb.Grow(len(a) * 9)
   for i := range a {
      sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
   }
   return sb.String()
}
func MnMx(args ...int) (int, int) {
   minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
   for _, v := range args {
      if v < minVal {
         minVal = v
      }
      if v > maxVal {
         maxVal = v
      }
   }
   return minVal, maxVal
}
func Mn(args ...int) int   { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int   { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64 { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
   if a == 0 {
      return b
   }
   return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
   if x < 0 {
      return -x
   }
   return x
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		rls := solve(a)
		if rls {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func solve(a []int) bool {
	odd, even := 0, 0
	for _, v := range a {
		if v%2 > 0 {
			odd++
		} else {
			even++
		}
	}
	return odd == 0 || even == 0
}

package main

import "fmt"

func Abs(x int) int {

	if x < 0 {
		return -x
	}

	return x
}

func main() {
	var n, a, q int

	fmt.Scan(&n)

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

		fmt.Scan(&a)

		b := make([]int, a)

		for j := 0; j < a; j++ {
			fmt.Scan(&b[j])
		}

		for j := 0; j < a-1; j++ {
			if Abs(b[j]-b[j+1])%2 != 0 {
				fmt.Println("NO")
				q = 1
				break
			}
		}

		if q == 0 {
			fmt.Println("YES")
		}

	}

}

package main

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

type heap struct {
	array []int
}

func (h *heap) push(val int) {
	h.array = append(h.array, val)
	cur := len(h.array) - 1
	for cur > 0 {
		var parent int
		if (cur & 1) == 1 {
			parent = (cur - 1) / 2
		} else {
			parent = (cur - 2) / 2
		}
		if h.array[cur] < h.array[parent] {
			h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
			cur = parent
		} else {
			break
		}
	}
}

func (h *heap) pop() int {
	res := h.array[0]
	h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
	h.array = h.array[:len(h.array)-1]
	cur := 0
	for cur < len(h.array) {
		smallest := cur
		if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
			smallest = cur*2 + 1
		}
		if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
			smallest = cur*2 + 2
		}
		if smallest != cur {
			h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
			cur = smallest
		} else {
			break
		}
	}
	return res
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	Fscan(in, &T)
	for T > 0 {
		T--
		var n int
		Fscan(in, &n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &arr[i])
		}
		sort.Ints(arr)
		flag := true
		for i := 1; i < n; i++ {
			if (arr[i]-arr[i-1])%2 != 0 {
				flag = false
				break
			}
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

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

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

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

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

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

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

func sol() string {
	n := reader.NextInt()
	hasOdd := false
	hasEven := false
    for i := 0; i < n; i++ {
		a := reader.NextInt()
		if a%2 == 0 {
			hasEven = true
		} else {
			hasOdd = true
		}
	}
    if n <= 1 {
        return "YES"
    }
    if hasOdd && hasEven {
        return "NO"
    }
    return "YES"
}

package main

import "fmt"

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

func main(){

	var t int

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

	for T := 0 ; T < t; T ++ {
		var n int

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

		a := make([]int , n)

		for i := 0 ; i < n ; i ++ {
			fmt.Scanf("%d",&a[i])
		}
		q := 0
		for i := 0 ; i + 1 < n ; i ++ {
			if Abs(a[i] - a[i + 1]) % 2 != 0 {
				q = 1
				fmt.Println("NO")
				break
			}
		}
		if q == 0 {
			fmt.Println("YES")
		}
	}

}

package main

import "fmt"

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

func main(){

	var t int

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

	for T := 0 ; T < t; T ++ {
		var n int

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

		a := make([]int , n)

		for i := 0 ; i < n ; i ++ {
			fmt.Scanf("%d",&a[i])
		}
		q := 0
		for i := 0 ; i + 1 < n ; i ++ {
			if Abs(a[i] - a[i + 1]) % 2 != 0 {
				q = 1
				fmt.Printf("NO\n")
				break
			}
		}
		if q == 0 {
			fmt.Printf("YES\n")
		}
	}

}


An L-shape is a figure on gridded paper that looks like the first four pictures below. An L-shape contains exactly three shaded cells (denoted by *), which can be rotated in any way.  You are given a rectangular grid. Determine if it contains L-shapes only, where L-shapes can't touch an edge or corner. More formally:   Each shaded cell in the grid is part of exactly one L-shape, and  no two L-shapes are adjacent by edge or corner. For example, the last two grids in the picture above do not satisfy the condition because the two L-shapes touch by corner and edge, respectively.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 50$$$) — the number of rows and columns in the grid, respectively. Then $$$n$$$ lines follow, each containing $$$m$$$ characters. Each of these characters is either '.' or '*' — an empty cell or a shaded cell, respectively.

For each test case, output "YES" if the grid is made up of L-shape that don't share edges or corners, and "NO" otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

package main

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

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

	var T, n, m int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)
		a := make([][]byte, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		var cnt, mix, miy, mxx, mxy int
		var f func(int, int)
		f = func(i, j int) {
			a[i][j] = '.'
			cnt++
			mix = min(mix, i)
			miy = min(miy, j)
			mxx = max(mxx, i)
			mxy = max(mxy, j)
			for _, d := range dir8 {
				if x, y := i+d.x, j+d.y; 0 <= x && x < n && 0 <= y && y < m && a[x][y] == '*' {
					f(x, y)
				}
			}
		}
		for i, row := range a {
			for j, b := range row {
				if b == '*' {
					cnt, mix, miy, mxx, mxy = 0, i, j, i, j
					f(i, j)
					if cnt != 3 || mix+1 != mxx || miy+1 != mxy {
						Fprintln(out, "NO")
						continue o
					}
				}
			}
		}
		Fprintln(out, "YES")
	}
}

func main() { CF1722F(os.Stdin, os.Stdout) }
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
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		aa := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([][]int, n)
		for i := range bb {
			bb[i] = make([]int, m)
		}

		f := true
		if n*m < 4 {
			f = false
		}
		c := 1
	Loop:
		for i := 0; i < n-1; i++ {
			for j := 0; j < m-1; j++ {
				a := aa[i][j : j+2]
				b := aa[i+1][j : j+2]
				if a == "*." && b == ".*" || a == ".*" && b == "*." || a == "**" && b == "**" {
					f = false
					break Loop
					// ** **
					// *. .*
				} else if (a == "**" && (b == ".*" || b == "*.")) || (b == "**" && (a == "*." || a == ".*")) {
					if bb[i][j] != 0 || bb[i+1][j] != 0 || bb[i][j+1] != 0 || bb[i+1][j+1] != 0 {
						f = false
						break Loop
					}
					if aa[i][j] == '*' {
						bb[i][j] = c
					}
					if aa[i][j+1] == '*' {
						bb[i][j+1] = c
					}
					if aa[i+1][j] == '*' {
						bb[i+1][j] = c
					}
					if aa[i+1][j+1] == '*' {
						bb[i+1][j+1] = c
					}
					c++
				}
			}
		}

		for i, row := range aa {
			for j, ch := range row {
				if ch == '.' {
					continue
				}
				if bb[i][j] == 0 {
					f = false
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

		aa := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([][]int, n)
		for i := range bb {
			bb[i] = make([]int, m)
		}

		f := true
		c := 1
	Loop:
		for i := 0; i < n-1; i++ {
			for j := 0; j < m-1; j++ {
				a := aa[i][j : j+2]
				b := aa[i+1][j : j+2]
				if a == "*." && b == ".*" || a == ".*" && b == "*." || a == "**" && b == "**" {
					f = false
					break Loop
					// ** **
					// *. .*
				} else if (a == "**" && (b == ".*" || b == "*.")) || (b == "**" && (a == "*." || a == ".*")) {
					if bb[i][j] != 0 || bb[i+1][j] != 0 || bb[i][j+1] != 0 || bb[i+1][j+1] != 0 {
						f = false
						break Loop
					}
					if aa[i][j] == '*' {
						bb[i][j] = c
					}
					if aa[i][j+1] == '*' {
						bb[i][j+1] = c
					}
					if aa[i+1][j] == '*' {
						bb[i+1][j] = c
					}
					if aa[i+1][j+1] == '*' {
						bb[i+1][j+1] = c
					}
					c++
				}
			}
		}

		for i, row := range aa {
			for j, ch := range row {
				if ch == '.' {
					continue
				}
				if bb[i][j] == 0 {
					f = false
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}


Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other words, $$$b_i$$$ equals $$$a_i$$$ rounded up or down. It is not necessary to round to the nearest integer.For example, if $$$a = [4.58413, 1.22491, -2.10517, -3.70387]$$$, then $$$b$$$ can be equal, for example, to $$$[4, 2, -2, -4]$$$. Note that if $$$a_i$$$ is an integer, then there is no difference between $$$\lfloor a_i \rfloor$$$ and $$$\lceil a_i \rceil$$$, $$$b_i$$$ will always be equal to $$$a_i$$$.Help Vus the Cossack find such sequence!

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to $$$0$$$.

In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any.

NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	fmt.Fscan(read, &n)
	var a = make([]float64, n)
	var d = make([]float64, n)
	var z = make([]int, n)
	var sumd float64
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
		z[i] = int(a[i])
		if a[i] < 0.0 && (a[i]-float64(z[i])) != 0 {
			z[i]--
		}
		d[i] = a[i] - float64(z[i])
		sumd = sumd + d[i]
	}
	var sumdint = int(math.Round(sumd))
	var k int
	var i int
	for k < sumdint {
		if d[i] == 0.0 {
			fmt.Fprintln(write, z[i])
			i++
			continue
		}
		fmt.Fprintln(write, z[i]+1)
		i++
		k++
	}
	for j := i; j < n; j++ {
		fmt.Fprintln(write, z[j])
	}

}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1186/D

package main

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

type Pair struct {
	Left  int
	Right int
}

func Solve(n int, a []float64) []int {
	pairs := make([]Pair, n)
	sum := 0
	for i, elem := range a {
		pairs[i].Left = int(math.Floor(elem))
		pairs[i].Right = int(math.Ceil(elem))
		sum += pairs[i].Left
	}
	b := make([]int, n)
	for i, pair := range pairs {
		if sum < 0 && pair.Left != pair.Right {
			b[i] = pair.Right
			sum += 1
		} else {
			b[i] = pair.Left
		}
	}
	return b
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%f\n", &a[i])
	}

	b := Solve(n, a)
	for _, elem := range b {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	fmt.Fscan(read, &n)
	var a = make([]float32, n)
	var d = make([]float32, n)
	var z = make([]int32, n)
	var sumd float32
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
		z[i] = int32(a[i])
		if a[i] < 0.0 {
			z[i]--
		}
		d[i] = a[i] - float32(z[i])
		sumd = sumd + d[i]
	}
	var sumdint = int(math.Round(float64(sumd)))
	var k int
	var i int
	for k < sumdint {
		if d[i] == 0.0 {
			fmt.Fprintln(write, z[i])
			i++
			continue
		}
		fmt.Fprintln(write, z[i]+1)
		i++
		k++
	}
	for j := i; j < n; j++ {
		fmt.Fprintln(write, z[j])
	}

}

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	fmt.Fscan(read, &n)
	var a = make([]float64, n)
	var d = make([]float64, n)
	var z = make([]int, n)
	var sumd float64
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
		z[i] = int(a[i])
		if a[i] < 0.0 {
			z[i]--
		}
		d[i] = a[i] - float64(z[i])
		sumd = sumd + d[i]
	}
	var sumdint = int(math.Round(sumd))
	var k int
	var i int
	for k < sumdint {
		if d[i] == 0.0 {
			fmt.Fprintln(write, z[i])
			i++
			continue
		}
		fmt.Fprintln(write, z[i]+1)
		i++
		k++
	}
	for j := i; j < n; j++ {
		fmt.Fprintln(write, z[j])
	}

}

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	fmt.Fscan(read, &n)
	var a = make([]float32, n)
	var d = make([]float32, n)
	var z = make([]int32, n)
	var sumd float32
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
		z[i] = int32(a[i])
		if z[i] < 0 {
			z[i]--
		}
		d[i] = a[i] - float32(z[i])
		sumd = sumd + d[i]
	}
	var sumdint = int(sumd)
	var k int
	var i int
	for k <= sumdint {
		if d[i] == 0.0 {
			i++
			continue
		}
		fmt.Fprintln(write, z[i]+1)
		i++
		k++
	}
	for j := i; j < n; j++ {
		fmt.Fprintln(write, z[j])
	}
}

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	fmt.Fscan(read, &n)
	var a = make([]float32, n)
	var d = make([]float32, n)
	var z = make([]int32, n)
	var sumd float32
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &a[i])
		z[i] = int32(a[i])
		if a[i] < 0.0 {
			z[i]--
		}
		d[i] = a[i] - float32(z[i])
		sumd = sumd + d[i]
	}
	var sumdint = int(math.Round(float64(sumd)))
	var k int
	var i int
	for k < sumdint {
		if d[i] == 0.0 {
			i++
			continue
		}
		fmt.Fprintln(write, z[i]+1)
		i++
		k++
	}
	for j := i; j < n; j++ {
		fmt.Fprintln(write, z[j])
	}

}