package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--

		var x uint64

		s, _ := reader.ReadBytes('\n')

		readUint64(s, 0, &x)

		res := solve(int64(x))

		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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(x int64) int {
	var ans int
	for i := 1; count(1<<i-1) <= x; i++ {
		ans++
		x -= count(1<<i - 1)
	}

	return ans
}

func count(n int) int64 {
	N := int64(n)

	return N * (N + 1) / 2
}

package main

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

var rw = NewFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	for tt := rw.NextInt(); tt > 0; tt-- {
		n := rw.NextInt64()
		for i := 0; ; i++ {
			x := int64(1) << i
			if x*(x-1)/2 > n {
				rw.Println(i - 1)
				break
			} else {
				n -= x * (x - 1) / 2
			}
		}
	}
}

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

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

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

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

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

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	// pre compute all the nice stairs before running the test cases
	niceStairs := make([]int64, 32)
	pow := 0
	i := 0
	for last := int64(0); last <= int64(1e18); {
		niceStairs[i] = 1<<pow + 2*last
		last = niceStairs[i]
		pow += 2
		i++
	}
	for ; t > 0; t-- {
		x := int64(0)
		cnt := 0
		fmt.Fscan(in, &x)
		for i := 0; i < len(niceStairs); i++ {
			if x < niceStairs[i] {
				break
			}
			x -= niceStairs[i]
			cnt++
		}
		fmt.Fprintln(out, cnt)
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

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

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

type staircase struct {
	baseLength   int64
	totalSquares int64
}

func (s staircase) Next() staircase {
	return staircase{
		baseLength: s.baseLength*2 + 1,
		totalSquares: s.totalSquares*2 + ((s.baseLength+1)*(s.baseLength+1)),
	}
}

var dp = []staircase{
	{
		baseLength: 1,
		totalSquares: 1,
	},
}

func init() {
	for i := 0; i < 30; i++ {
		dp = append(dp, dp[len(dp)-1].Next())
	}
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		printf("%d\n", sol(sint64()))
	}
}

func sol(n int64) int64 {
	ret := int64(0)
	for _, sc := range dp {
		if n >= sc.totalSquares {
			n -= sc.totalSquares
			ret++
			continue
		}
		break
	}
	return ret
}

package main
import (
	"fmt"
)
func main(){
	var query int
	var dp [128]int64
	var now,base int64
	dp[0] = 0
	now = 1
	base = 1
	len := 1
	for {
		dp[len] = dp[len - 1] + now * (now + 1) / 2
		base = base * 2
		now = now + base
		if dp[len] > 1000000000000000000{
			break
		}
		len++
	}
	fmt.Scanln(&query)
	for i := 0; i < query; i++{
		var n int64
		fmt.Scanln(&n)
		for j := 1; j <= len; j++{
			if dp[j] > n{
				fmt.Println(j - 1)
				break
			}
		}
	}
}

package main

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

func val (x int64) int64 {
	var b float64 = -3
	var a float64 = 4
	var c float64 = 9 + float64(x-1)

	res := b + math.Sqrt(c)
	res /= a
	return int64(math.Floor(res))
}

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

	in := func() int64 {
		sc.Scan()
		i, _ := strconv.ParseInt(sc.Text(), 10, 64)
		return i
	}

	for t := in(); t > 0; t-- {
		x := in()

		var cnt int64 = -1
		var v int64
		for x >= 0 {
			v = int64(math.Pow(2, float64(cnt+1)) - 1)
			x -= (2*v*v + 3*v + 1)
			cnt++
		}

		fmt.Println(cnt)
	}
}

package main

import "fmt"

func calc(a int64) int64 {
	return a * (a + 1) / 2
}

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

	for t := 0; t < T; t++ {
		var x int64
		fmt.Scan(&x)
		ans := 0
		for i := int64(1); i < int64(64); i++ {
			y := calc((int64(1) << i) - 1)
			if (y <= x) {
				ans++
				x -= y
			} else {
				break
			}
		}
		fmt.Println(ans)
	}

}

package main
import (
	"fmt"
)
func main(){
	var query int
	var dp [128]int64
	var now,base int64
	dp[0] = 0
	now = 1
	base = 1
	len := 1
	for {
		dp[len] = dp[len - 1] + now * (now + 1) / 2
		base = base * 2
		now = now + base
		if dp[len] > 1000000000000000000{
			break
		}
		len++
	}
	fmt.Scanf("%d", &query)
	for i := 0; i < query; i++{
		var n int64
		fmt.Scanf("%d", &n)
		if n == 0 {
			continue
			query++
		}
		for j := 1; j <= len; j++{
			if dp[j] > n{
				fmt.Println(j - 1)
				break
			}
		}
	}
}

package main
import (
	"fmt"
)
func main(){
	var query int
	var dp [128]int64
	var now,base int64
	dp[0] = 0
	now = 1
	base = 1
	len := 1
	for {
		dp[len] = dp[len - 1] + now * (now + 1) / 2
		base = base * 2
		now = now + base
		if dp[len] > 1000000000000000000{
			break
		}
		len++
	}
	fmt.Scanf("%d", &query)
	for i := 0; i < query; i++{
		var n int64
		fmt.Scanf("%d", &n)
		if n == 0 {
			continue
		}
		for j := 1; j <= len; j++{
			if dp[j] > n{
				fmt.Println(j - 1)
				break
			}
		}
	}
}

package main
import (
	"fmt"
)
func main(){
	var query int
	var dp [128]int64
	var now,base int64
	dp[0] = 0
	now = 1
	base = 1
	len := 1
	for {
		dp[len] = dp[len - 1] + now * (now + 1) / 2
		base = base * 2
		now = now + base
		if dp[len] > 1000000000000000000{
			break
		}
		len++
	}
	fmt.Scanf("%d", &query)
	for i := 0; i < query; i++{
		var n int64
		fmt.Scanf("%d", &n)
		for j := 1; j <= len; j++{
			if dp[j] > n{
				fmt.Println(j - 1)
				break
			}
		}
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--

		var x uint64

		s, _ := reader.ReadBytes('\n')

		readUint64(s, 0, &x)

		res := solve(int64(x))

		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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
}

const N = 31

var X [N]int64

func init() {
	X[1] = 1

	for i := 2; i < N; i++ {
		I := int64(i)
		X[i] = I*I + 2*X[i-1]
	}
}

func solve(x int64) int {

	for i := 1; i < N; i++ {
		if X[i] >= x {
			return i - 1
		}
	}
	return N - 1
}

package main

import "fmt"

func calc(a int64) int64 {
	return a * (a + 1) / 2
}

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

	for t := 0; t < T; t++ {
		var x int64
		fmt.Scanf("%d", &x)
		ans := 0
		for i := 1; i < 64; i++ {
			y := calc((int64(1) << i) - 1)
			if (y <= x) {
				ans++
				x -= y
			} else {
				break
			}
		}
		fmt.Println(ans)
	}

}


// 346A-mic_rizal
package main

import (
	"fmt"
	"sort"
)

func gcd(x, y int64) int64 {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func main() {
	var n, i, x, b int64
	fmt.Scan(&n)
	a := make([]int, n)
	for i = 0; i < n; i++ {
		fmt.Scan(&x)
		a[i] = int(x)
	}
	b = int64(a[0])
	for i = 1; i < n; i++ {
		b = gcd(int64(a[i]), b)
	}
	sort.Sort(sort.IntSlice(a))
	a[n-1] /= int(b)
	if (a[n-1]-int(n))%2 == 0 {
		fmt.Println("Bob")
	} else {
		fmt.Println("Alice")
	}
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

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

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

func gcd(x int, y int) int {
    for ; x > 0 && y > 0; {
        if x > y {
            x = x % y
        } else {
            y = y % x
        }
    }
    return x + y
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    x := make([]int, n)
    max := 1
    for i := 0; i < n; i++ {
        x[i] = nextInt()
        if max < x[i] {
            max = x[i]
        }
    }
    g := gcd(x[0], x[1])

    for i := 2; i < n; i++ {
        g = gcd(g, x[i])
    }
    res := max / g - n
    if res % 2 == 0 {
        fmt.Fprintln(out, "Bob")
    } else {
        fmt.Fprintln(out, "Alice")
    }
}

package main

import "os"
import "bufio"
import "strconv"

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

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	a := make([]int, n)
	g, m := 0, 0
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.Atoi(r.Text())
		g = gcd(a[i], g)
		m = max(m, a[i])
	}
	if ((m/g)-n)%2 != 0 {
		w.WriteString("Alice\n")
		w.Flush()
	} else {
		w.WriteString("Bob\n")
		w.Flush()
	}
}

package main

import "fmt"

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

func main() {
    var n,a int
    fmt.Scan(&n)
    m, g := 0, 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if m < a { m = a }
        g = gcd(a,g)
    }
    if ((m/g)-n)%2 == 1 { fmt.Println("Alice") } else { fmt.Println("Bob") }
}

// 346A
package main

import (
	"fmt"
)

func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	var n int
	gcd1, max := 0, 0
	var a [110]int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if max < a[i] {
			max = a[i]
		}
		gcd1 = gcd(gcd1, a[i])
	}
	x := (max / gcd1) - n
	if x%2 != 0 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}

package main

import "fmt"

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

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

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

	nums := make([]int, n)
	for i := range nums {
		fmt.Scanf("%d", &nums[i])
	}

	div := gcd(nums[0], nums[1])
	top := max(nums[0], nums[1])
	for i := 2; i < n; i++ {
		div = gcd(div, nums[i])
		top = max(top, nums[i])
	}

	alice := (top / div - n) % 2 == 1
	if alice {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/346/A

package main

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func Solve(n int, a []int) string {
	max := 0
	for _, elem := range a {
		if elem > max {
			max = elem
		}
	}
	d := a[0]
	for i := 1; i < n; i++ {
		d = gcd(d, a[i])
	}
	moves := max/d - n
	if moves%2 == 1 {
		return "Alice"
	}
	return "Bob"
}

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([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	fmt.Fprintf(writer, "%s\n", Solve(n, a))
}

// 346A
package main

import (
	"fmt"
)

func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	var n int
	gcd1, max := 0, 0
	var a [110]int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if max < a[i] {
			max = a[i]
		}
		gcd1 = gcd(gcd1, a[i])
	}
	x := (max / gcd1) - n
	if x%2 == 0 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    x := make([]int, n)
    max := 1
    m := make(map[int]bool)
    for i := 0; i < n; i++ {
        x[i] = nextInt()
        if max < x[i] {
            max = x[i]
        }
        m[x[i]] = true
    }
    for ;; {
        ok := false
        for i := 0; i < len(x) - 1; i++ {
            a := abs(x[i] - x[i + 1])
            if !m[a] {
                x = append(x, a)
                m[a] = true
                ok = true
            }
        }
        if m[1] || !ok {
            break
        }
    }
    res := max - n
    if !m[1] {
        res = len(x) - n
    }
    if res % 2 == 0 {
        fmt.Fprintln(out, "Bob")
    } else {
        fmt.Fprintln(out, "Alice")
    }
}


package main

//import "fmt"
import "os"
import "bufio"
import "strconv"

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	first := make([]int, 100001)
	last := make([]int, 100001)
	diff := make([]int, 100001)
	for i:=0; i<100001; i++ {
		first[i] = -1
		diff[i] = 0
		last[i] = -1
	}
	a := 0
	count := 0
	for j:=0; j<n; j++ {
		r.Scan()
		a, _ = strconv.Atoi(r.Text())
		if first[a] == -1 {
			first[a] = j
			count += 1
		} else {
			if diff[a] == 0 {
				diff[a] = j - first[a]
			} else if diff[a] > 0 && j-last[a] != diff[a] {
				diff[a] = -1
				count -= 1
			}
		}
		last[a] = j
	}
	w.WriteString(strconv.Itoa(count)+"\n")
	w.Flush()
	for k:=0; k<100001; k++ {
		if first[k] >= 0 {
			if diff[k] >= 0 {
				w.WriteString(strconv.Itoa(k)+" "+strconv.Itoa(diff[k])+" ")
				w.Flush()
				w.WriteString("\n")
				w.Flush()
			}
		}
	}
}

// http://codeforces.com/problemset/problem/352/B
// B. Jeff and Periods

package main

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

func main() {
	var (
		n, i, max, all int32
		last, diff, a  []int32
		lai, dai       *int32
		in             *bufio.Reader
		out            *bufio.Writer
	)

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

	fmt.Fscan(in, &n)
	a = make([]int32, n+1, n+1)
	for i = 1; i <= n; i++ {
		fmt.Fscan(in, &a[i])
		if a[i] > max {
			max = a[i]
		}
	}

	last = make([]int32, max+1, max+1)
	diff = make([]int32, max+1, max+1)

	for i = 1; i <= n; i++ {
		lai = &last[a[i]]
		if 0 == *lai {
			all++
			*lai = i
			continue
		}
		dai = &diff[a[i]]
		if *lai > 0 {
			if *dai == 0 {
				*dai = i - *lai
				*lai = i
				continue
			}
			if *dai == i-*lai {
				*lai = i
				continue
			}
			all--
			*lai = -1
		}
	}

	//last = last[0 : max+1]
	//fmt.Println(last)

	fmt.Fprintln(out, all)
	for i = 1; i <= max; i++ {
		if last[i] > 0 {
			fmt.Fprintln(out, i, diff[i])
		}
	}
	out.Flush()
}

package main

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

type Answer struct {
    a,b int
}

type Element struct {
    v,p int
}

type ElementSlice []Element

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    a := make(ElementSlice,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i].v, _ = strconv.Atoi(scanner.Text())
        a[i].p = i
    }
    sort.Sort(a)
    cnt := 0
    ans := make([]Answer,0,n)
    for i := 0; i < n; i++ {
        ok, d := true, 0
        if (i+1 < n) && (a[i+1].v == a[i].v) {
            d = a[i+1].p - a[i].p
            i++
            for (i+1 < n) && (a[i+1].v == a[i].v) {
                if (a[i+1].p - a[i].p) != d { ok = false }
                i++
            }
        }
        if ok {
            cnt++
            ans = append(ans,Answer{a[i].v,d})
        }
    }
    fmt.Println(cnt)
    for i := 0; i < len(ans); i++ {
        writer.WriteString(strconv.Itoa(ans[i].a)+" "+strconv.Itoa(ans[i].b)+"\n")
    }
    writer.Flush()
}

// 352B
package main

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

func main() {
	var n, i, max, all int32
	var last, diff, a []int32
	var c, d *int32
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &n)
	a = make([]int32, n+1, n+1)
	for i = 1; i <= n; i++ {
		fmt.Fscan(in, &a[i])
		if a[i] > max {
			max = a[i]
		}
	}
	last = make([]int32, max+1, max+1)
	diff = make([]int32, max+1, max+1)
	for i = 1; i <= n; i++ {
		c = &last[a[i]]
		if 0 == *c {
			all++
			*c = i
			continue
		}
		d = &diff[a[i]]
		if *c > 0 {
			if *d == 0 {
				*d = i - *c
				*c = i
				continue
			}
			if *d == i-*c {
				*c = i
				continue
			}
			all--
			*c = -1
		}
	}
	fmt.Fprintln(out, all)
	for i = 1; i <= max; i++ {
		if last[i] > 0 {
			fmt.Fprintln(out, i, diff[i])
		}
	}
	out.Flush()
}

// 352b-mic_rizal
package main

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

func main() {
    var n, x int
    var p, c [100010]int
    z := bufio.NewReader(os.Stdin)
    fmt.Scan(&n)
    for i := 0; i < 100010; i++ {
        p[i] = 0
        c[i] = -1
    }
    cou := 0
    for i := 1; i <= n; i++ {
        fmt.Fscan(z, &x)
        if c[x] == -1 {
            p[x] = 0
            cou++
        } else if p[x] == 0 {
            p[x] = i - c[x]
        } else if p[x] != -1 && i-c[x] != p[x] {
            p[x] = -1
            cou--
        }
        c[x] = i
    }
    fmt.Println(cou)
    for i := 1; i < 100010; i++ {
        if c[i] != -1 && p[i] != -1 {
            fmt.Println(i, p[i])
        }
    }
}

package main

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

type Element struct {
    v,p int
}

type ElementSlice []Element

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    a := make(ElementSlice,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i].v, _ = strconv.Atoi(scanner.Text())
        a[i].p = i
    }
    sort.Sort(a)
    cnt := 0
    for i := 0; i < n; i++ {
        ok, d := true, 0
        if (i+1 < n) && (a[i+1].v == a[i].v) {
            d = a[i+1].p - a[i].p
            i++
            for (i+1 < n) && (a[i+1].v == a[i].v) {
                if (a[i+1].p - a[i].p) != d { ok = false }
                i++
            }
        }
        if ok {
            cnt++
            writer.WriteString(strconv.Itoa(a[i].v)+" "+strconv.Itoa(d)+"\n")
        }
    }
    fmt.Println(cnt)
    writer.Flush()
}


package main

// #include <stdio.h>
//
// void scan(long *a) {
//	   scanf("%ld", a);
// }
import "C"

import (
	"fmt"
)

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

	return y
}

func main() {
	var n, k int
	var a [100002]int
	var t [100002]int

	var cint C.long

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

	for i := 1; i <= n; i++ {
		C.scan(&cint)
		a[i] = int(cint)
	}

	m := 0
	for i := 1; i <= n; i++ {
		C.scan(&cint)
		t[i] = int(cint)
		if t[i] > 0 {
			m += a[i]
		}
	}

	s := 0
	for i := 1; i <= k; i++ {
		if t[i] == 0 {
			s += a[i]
		}
	}

	temp := s
	for i := k + 1; i <= n; i++ {
		if t[i-k] == 0 {
			s -= a[i-k]
		}
		if t[i] == 0 {
			s += a[i]
		}

		temp = max_int(temp, s)
	}

	fmt.Println(m + temp)
}

package main

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

func main() {
	var n, k int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d %d\n", &n, &k)
	theorems := make([]int, 0, n)
	wakes := make([]int, 0, n)
	// load theorems
	for i := 0; i < n; i++ {
		var t int
		format := "%d"
		if i == n-1 {
			format = "%d\n"
		}
		fmt.Fscanf(stdin, format, &t)
		theorems = append(theorems, t)
	}
	// load wakes
	for i := 0; i < n; i++ {
		var s int
		format := "%d"
		if i == n-1 {
			format = "%d\n"
		}
		fmt.Fscanf(stdin, format, &s)
		wakes = append(wakes, s)
	}
	// count number of theorems without wake up mischa
	// construct prefix sum, for calculating segment sum
	numTheorem := 0
	prefixSum := make([]int, n)
	for i := 0; i < n; i++ {
		// add previous result
		if i > 0 {
			prefixSum[i] += prefixSum[i-1]
		}
		if wakes[i] == 0 {
			prefixSum[i] += theorems[i]
		} else {
			numTheorem += theorems[i]
		}
	}
	// get max value of theorem number while using the technique
	// use prefix sum to calculate it
	maxSegmentTheorem := 0
	for i := 0; i <= n-k; i++ {
		tmpTheorem := prefixSum[i+k-1]
		if i > 0 {
			tmpTheorem -= prefixSum[i-1]
		}
		if tmpTheorem > maxSegmentTheorem {
			maxSegmentTheorem = tmpTheorem
		}
	}
	fmt.Println(numTheorem + maxSegmentTheorem)
}

package main

/*
	To maximize the number of theorem written by Mishka, we need to maximize the effect of
	secret technique by executing it at the right time.

	So the formula for getting the maximum number of theorem is:
	number of theorem written when woke up + max effect of secret technique

	The challenge here is in the implementation of searching the maximum effect of secret technique.
	If we use normal search which uses double loop, we will get TLE (Time Limit Exceeded) error,
	because the complexity will become O(n^2).

	Thus we need faster method which is prefixed sum: https://www.youtube.com/watch?v=wGtO8pFo-cs. With
	this algorithm we could solve this problem with O(n).

	Using prefixed sum, we could calculate the number of effect resulted from secret technique in [i, i+k-1]
	with following formula:

	sumSecretTech(i, k) = {
		if i > 0: prefixedSum[i+k-1] - prefixedSum[i-1],
		if i == 0: prefixedSum[i+k-1]
	}

	If you find it difficult to grasp the idea of this formula, try to visualize it with example. Basically this
	formula is my mathematical representation for that visualization.
*/

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

func main() {
	var n, k int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d %d\n", &n, &k)
	theorems := make([]int, 0, n)
	wakes := make([]int, 0, n)
	// load theorems
	for i := 0; i < n; i++ {
		var t int
		format := "%d"
		if i == n-1 {
			format = "%d\n"
		}
		fmt.Fscanf(stdin, format, &t)
		theorems = append(theorems, t)
	}
	// load wakes
	for i := 0; i < n; i++ {
		var s int
		format := "%d"
		if i == n-1 {
			format = "%d\n"
		}
		fmt.Fscanf(stdin, format, &s)
		wakes = append(wakes, s)
	}
	// calculate prefix sum & number of theorems will be written
	// by Mishka initially
	numTheorem := 0
	prefixSum := make([]int, n)
	for i := 0; i < n; i++ {
		// add previous result to prefix sum
		if i > 0 {
			prefixSum[i] += prefixSum[i-1]
		}
		// only calculate the effect of technique in prefixed sum
		if wakes[i] == 0 {
			prefixSum[i] += theorems[i]
			continue
		}
		// count number of theorems will be written initially
		numTheorem += theorems[i]
	}
	// calculate the maximum effect of secret technique
	maxTechEffect := 0
	for i := 0; i <= n-k; i++ {
		techEffect := prefixSum[i+k-1]
		if i > 0 {
			techEffect -= prefixSum[i-1]
		}
		if techEffect > maxTechEffect {
			maxTechEffect = techEffect
		}
	}
	fmt.Println(numTheorem + maxTechEffect)
}

package main

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

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

func main() {
    defer writer.Flush()

    var n, k int
    scanf("%d%d\n", &n, &k)
    var a [100000]int
    var t [100000]int
    var s int = 0
    for i := 0; i < n; i++ {
        scanf("%d", &a[i]);
    }
    scanf("\n");
    for i := 0; i < n; i++ {
        scanf("%d", &t[i]);
        if t[i] == 1 {
            s += a[i];
        }
    }
    for i := 0; i < k; i++ {
        if t[i] == 0 {
            s += a[i];
        }
    }
    var ans int = s
    for i := k; i < n; i++ {
        if t[i-k] == 0 {
            s -= a[i-k]
        }
        if t[i] == 0 {
            s += a[i]
        }
        if ans < s {
            ans = s
        }
    }
    printf("%d\n", ans)
}

package main

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

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

	return y
}

func main() {
	var n, k int
	var a [100002]int
	var t [100002]int
	var reader *bufio.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscanf(reader, "%d %d\n", &n, &k)

	for i := 1; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	fmt.Fscanf(reader, "%d\n", &a[n])

	m := 0
	for i := 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d", &t[i])
		if t[i] > 0 {
			m += a[i]
		}
	}

	s := 0
	for i := 1; i <= k; i++ {
		if t[i] == 0 {
			s += a[i]
		}
	}

	temp := s
	for i := k + 1; i <= n; i++ {
		if t[i-k] == 0 {
			s -= a[i-k]
		}

		if t[i] == 0 {
			s += a[i]
		}

		temp = max_int(temp, s)
	}

	fmt.Println(m + temp)
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func nextInt() int {
	in.Scan()
	r := 0
	for _, c := range in.Bytes() {
		r *= 10
		r += int(c - '0')
	}
	return r
}

func main() {
	in.Split(bufio.ScanWords)
	n, k, c, r, s := nextInt(), nextInt(), 0, 0, 0
	a, t := make([]int, n), make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	for i := range a {
		t[i] = nextInt()
		if t[i] == 0 {
			c += a[i]
		} else {
			s += a[i]
		}
		if i >= k && t[i-k] == 0 {
			c -= a[i-k]
		}
		if r < c {
			r = c
		}
	}
	fmt.Println(r + s)
}

package main

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

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int64 {
	s.Scan()
	v, _ := strconv.ParseInt(s.Text(), 10, 64)
	return v
}

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

	n, k := in.nextInt(), in.nextInt()

	var a, t []int64
	a = make([]int64, n+10)
	t = make([]int64, n+10)
	for i := int64(1); i <= n; i++ {
		a[i] = in.nextInt()
	}
	var sum int64
	for i := int64(1); i <= n; i++ {
		t[i] = in.nextInt()
		if t[i] > 0 {
			sum += a[i]
		}
	}
	var base, awake int64
	var ans int64
	for i := int64(1); i <= n+1; i++ {
		awake += a[i]
		if t[i] > 0 {
			base += a[i]
		}
		if i < k {
			continue
		}
		j := i - k
		awake -= a[j]
		if t[j] > 0 {
			base -= a[j]
		}
		if v := sum - base + awake; v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}

package main

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

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int {
	s.Scan()
	v, _ := strconv.Atoi(s.Text())
	return v
}

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

	n, k := in.nextInt(), in.nextInt()

	var a, t []int
	a = make([]int, n+1)
	t = make([]int, n+1)
	for i := 1; i <= n; i++ {
		a[i] = in.nextInt()
	}
	fmt.Scanln()
	var sum int
	for i := 1; i <= n; i++ {
		t[i] = in.nextInt()
		if t[i] > 0 {
			sum += a[i]
		}
	}
	var base, awake int
	var ans int
	for i := 1; i <= n; i++ {
		awake += a[i]
		if t[i] > 0 {
			base += a[i]
		}
		if i < k {
			continue
		}
		if t := sum - base + awake; t > ans {
			ans = t
		}
		j := i - k + 1
		awake -= a[j]
		if t[j] > 0 {
			base -= a[j]
		}
	}
	fmt.Println(ans)
}

package main

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

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int {
	s.Scan()
	v, _ := strconv.Atoi(s.Text())
	return v
}

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

	n, k := in.nextInt(), in.nextInt()

	var a, t []int
	a = make([]int, n+10)
	t = make([]int, n+10)
	for i := 1; i <= n; i++ {
		a[i] = in.nextInt()
	}
	fmt.Scanln()
	var sum int
	for i := 1; i <= n; i++ {
		t[i] = in.nextInt()
		if t[i] > 0 {
			sum += a[i]
		}
	}
	var base, awake int
	var ans int
	for i := 1; i <= n+1; i++ {
		awake += a[i]
		if t[i] > 0 {
			base += a[i]
		}
		if i < k {
			continue
		}
		j := i - k
		awake -= a[j]
		if t[j] > 0 {
			base -= a[j]
		}
		if t := sum - base + awake; t > ans {
			ans = t
		}
	}
	fmt.Println(ans)
}

package main

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

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int64 {
	s.Scan()
	v, _ := strconv.ParseInt(s.Text(), 10, 64)
	return v
}

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

	n, k := in.nextInt(), in.nextInt()

	var a, t []int64
	a = make([]int64, n+10)
	t = make([]int64, n+10)
	for i := int64(1); i <= n; i++ {
		a[i] = in.nextInt()
	}
	fmt.Scanln()
	var sum int64
	for i := int64(1); i <= n; i++ {
		t[i] = in.nextInt()
		if t[i] > 0 {
			sum += a[i]
		}
	}
	var base, awake int64
	var ans int64
	for i := int64(1); i <= n+1; i++ {
		awake += a[i]
		if t[i] > 0 {
			base += a[i]
		}
		if i < k {
			continue
		}
		j := i - k
		awake -= a[j]
		if t[j] > 0 {
			base -= a[j]
		}
		if v := sum - base + awake; v > ans {
			ans = v
		}
	}
	fmt.Println(ans)
}

package main

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

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

func main() {
    defer writer.Flush()

    var n, k int
    scanf("%d%d ", &n, &k)
    var a [100000]int
    var t [100000]int
    var s int = 0
    for i := 0; i < n; i++ {
        scanf("%d ", &a[i]);
    }
    for i := 0; i < n; i++ {
        scanf("%d ", &t[i]);
        if t[i] == 1 {
            s += a[i];
        }
    }
    for i := 0; i < k; i++ {
        if t[i] == 0 {
            s += a[i];
        }
    }
    var ans int = s
    for i := k; i < n; i++ {
        if t[i-k] == 0 {
            s -= a[i-k]
        }
        if t[i] == 0 {
            s += a[i]
        }
        if ans < s {
            ans = s
        }
    }
    printf("%d\n", ans)
}

package main

import (
	"fmt"
)

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

	return y
}

func main() {
	var n, k int
	var a [100002]int
	var t [100002]int

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

	fmt.Println(n, k) //
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])

		fmt.Print(a[i], " ") //
	}

	fmt.Println()
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &t[i])
		fmt.Print(t[i], " ") //
	}
	fmt.Println()

	s := 0
	for i := 1; i <= k; i++ {
		if t[i] == 0 {
			s += a[i]
		}
	}

	m := s
	for i := k + 1; i <= n; i++ {
		if t[i-k] == 0 {
			s -= a[i-k]
		}

		if t[i] == 0 {
			s += a[i]
		}

		m = max_int(m, s)
	}

	for i := 1; i <= n; i++ {
		if t[i] > 0 {
			m += a[i]
		}
	}

	fmt.Println(m)
}

package main

import (
	"fmt"
)

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

	return y
}

func main() {
	var n, k int
	var a [100002]int
	var t [100002]int

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

	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &t[i])
	}

	s := 0
	for i := 1; i <= k; i++ {
		if t[i] == 0 {
			s += a[i]
		}
	}

	m := s
	for i := k + 1; i <= n; i++ {
		if t[i-k] == 0 {
			s -= a[i-k]
		}

		if t[i] == 0 {
			s += a[i]
		}

		m = max_int(m, s)
	}

	for i := 1; i <= n; i++ {
		if t[i] > 0 {
			m += a[i]
		}
	}

	fmt.Println(m)
}


package main

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

const N = 100

func write(a string) {
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()

	f.Write([]byte(a))
	f.Write([]byte("\n"))
}

func gen() [N]uint64 {
	res := [N]uint64{}
	for i := uint64(1); i <= N; i++ {
		res[i-1] = i
	}

	return res
}

func join(a [N]uint64) string {
	s := fmt.Sprint(a)
	s = s[1 : len(s)-1]

	return s
}

func main() {
	ans := [2]uint64{}

	for j := 0; j < 2; j++ {
		sample := gen()

		for i, n := range sample {
			if j == 1 {
				sample[i] = n << 7
			}
		}

		q := "? " + join(sample)
		write(q)

		fmt.Scan(&ans[j])
	}

	res := (ans[0]>>7)<<7 + ans[1]&127
	fmt.Println("!", res)
}

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func CF1207E() {
	a := [2]int{0, 7}
	for i := range a {
		Print("? ")
		for j := 1; j <= 100; j++ {
			Print(" ", j<<a[i])
		}
		Println()
		Scan(&a[i])
	}
	Println("!", a[0]>>7<<7|a[1]&(1<<7-1))
}

func main() { CF1207E() }

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func CF1207E() {
	a := [2]int{0, 7}
	for i := range a {
		Print("? ")
		for j := 1; j <= 100; j++ {
			Print(" ", j<<a[i])
		}
		Println()
		Scan(&a[i])
	}
	Println("!", a[0]&(1<<14-1<<7)|a[1]&(1<<7-1))
}

func main() { CF1207E() }

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func CF1207E() {
	a := [2]int{0, 7}
	for i := range a {
		Print("? ")
		for j := 0; j < 100; j++ {
			Print(" ", j<<a[i])
		}
		Println()
		Scan(&a[i])
	}
	Println("!", a[0]&(1<<14-1<<7)|a[1]&(1<<7-1))
}

func main() { CF1207E() }

package main

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

const N = 200

func write(a string) {
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()

	f.Write([]byte(a))
	f.Write([]byte("\n"))
}

func gen() [N]uint64 {
	res := [N]uint64{}
	for i := uint64(1); i <= N; i++ {
		res[i-1] = i
	}

	return res
}

func join(a [N]uint64) string {
	s := fmt.Sprint(a)
	s = s[1 : len(s)-1]

	return s
}

func main() {
	ans := [2]uint64{}

	for j := 0; j < 2; j++ {
		sample := gen()

		for i, n := range sample {
			if j == 1 {
				sample[i] = n << 7
			}
		}

		q := "? " + join(sample)
		write(q)

		fmt.Scan(&ans[j])
	}

	res := (ans[0]>>7)<<7 + ans[1]&127
	fmt.Println(res)
}

package main

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

const N = 200

func write(a string) {
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()

	f.Write([]byte(a))
	f.Write([]byte("\n"))
}

func gen() [N]uint64 {
	res := [N]uint64{}
	for i := uint64(1); i <= N; i++ {
		res[i-1] = i
	}

	return res
}

func join(a [N]uint64) string {
	s := fmt.Sprint(a)
	s = s[1 : len(s)-1]

	return s
}

func main() {
	ans := [2]uint64{}

	for j := 0; j < 2; j++ {
		sample := gen()

		for i, n := range sample {
			if j == 1 {
				sample[i] = n << 7
			}
		}

		q := "? " + join(sample)
		write(q)

		fmt.Scan(&ans[j])
	}

	res := (ans[0]>>7)<<7 + ans[1]&127
	fmt.Println("!", res)
}


package main

import "bufio"
import "os"
import "io/ioutil"
import "strconv"

const mod = 1000000007

type Matrix struct {
	x, y, z, t int
}

func zeroMatrix() Matrix {
	return Matrix{
		x: 0, y: 0,
		z: 0, t: 0,
	}
}

func fibMatrix() Matrix {
	return Matrix{
		x: 0, y: 1,
		z: 1, t: 1,
	}
}

func oneMatrix() Matrix {
	return Matrix{
		x: 1, y: 0,
		z: 0, t: 1,
	}
}

func add(x int, y int) int {
	return (x + y) % mod
}

func mul(x int, y int) int {
	if (x <= 44000) && (y <= 44000) {
		return x * y % mod
	}
	return int((int64(x) * int64(y)) % int64(mod))
}

func (a Matrix) add(b Matrix) Matrix {
	return Matrix{
		x: add(a.x, b.x), y: add(a.y, b.y),
		z: add(a.z, b.z), t: add(a.t, b.t),
	}
}

func (a Matrix) mul(b Matrix) Matrix {
	return Matrix{
		x: add(mul(a.x, b.x), mul(a.y, b.z)), y: add(mul(a.x, b.y), mul(a.y, b.t)),
		z: add(mul(a.z, b.x), mul(a.t, b.z)), t: add(mul(a.z, b.y), mul(a.t, b.t)),
	}
}

func (a Matrix) pow(n int) Matrix {
	ret := oneMatrix()
	for n > 0 {
		if (n & 1) == 1 {
			ret = ret.mul(a)
		}
		a = a.mul(a)
		n >>= 1
	}
	return ret
}

type SegmentTree struct {
	from  int
	to    int
	value Matrix
	total Matrix
	left  *SegmentTree
	right *SegmentTree
}

func createSegmentTree(f int, t int) *SegmentTree {
	var left *SegmentTree
	var right *SegmentTree
	total := oneMatrix()
	if f < t {
		m := (f + t) >> 1
		left = createSegmentTree(f, m)
		right = createSegmentTree(m+1, t)
		total = left.total.add(right.total)
	}
	return &SegmentTree{
		from:  f,
		to:    t,
		value: oneMatrix(),
		left:  left,
		right: right,
		total: total,
	}
}

func (tree *SegmentTree) lazyUpdate() {
	tree.left.value = tree.left.value.mul(tree.value)
	tree.left.total = tree.left.total.mul(tree.value)
	tree.right.value = tree.right.value.mul(tree.value)
	tree.right.total = tree.right.total.mul(tree.value)
	tree.value = oneMatrix()
}

func (tree *SegmentTree) multiply(l int, r int, k Matrix) {
	if (tree.from > r) || (tree.to < l) {
		return
	}
	if (tree.from >= l) && (tree.to <= r) {
		tree.value = tree.value.mul(k)
		tree.total = tree.total.mul(k)
		return
	}
	tree.lazyUpdate()
	tree.left.multiply(l, r, k)
	tree.right.multiply(l, r, k)
	tree.total = tree.left.total.add(tree.right.total)
}

func (tree *SegmentTree) sum(l int, r int) Matrix {
	if (tree.from > r) || (tree.to < l) {
		return zeroMatrix()
	}
	if (tree.from >= l) && (tree.to <= r) {
		return tree.total
	}
	tree.lazyUpdate()
	leftSum := tree.left.sum(l, r)
	rightSum := tree.right.sum(l, r)
	return leftSum.add(rightSum)
}

func main() {
	defer out.Flush()

	var n, q, a int
	readInt(&n)
	readInt(&q)

	tree := createSegmentTree(0, n-1)
	fib := fibMatrix()

	for i := 0; i < n; i++ {
		readInt(&a)
		tree.multiply(i, i, fib.pow(a+1))
	}

	var t, l, r, x int
	for i := 0; i < q; i++ {
		readInt(&t)
		readInt(&l)
		readInt(&r)
		l--
		r--
		if t == 1 {
			readInt(&x)
			tree.multiply(l, r, fib.pow(x))
		} else {
			ret := tree.sum(l, r)
			writeInt(ret.x)
			writeByte('\n')
		}
	}
}

// Input output
var out *bufio.Writer
var iPointer int
var nPointer int
var iBuffer []byte

func init() {
	out = bufio.NewWriter(os.Stdout)
	iPointer = 0
	iBuffer, _ = ioutil.ReadAll(os.Stdin)
	nPointer = len(iBuffer)
}

func isDigit(c byte) bool {
	return (c >= '0') && (c <= '9')
}

func readInt(v *int) bool {
	neg := false
	for (iPointer < nPointer) && !isDigit(iBuffer[iPointer]) {
		neg = (iBuffer[iPointer] == '-')
		iPointer++
	}
	if iPointer >= nPointer {
		return false
	}
	var a int
	for (iPointer < nPointer) && isDigit(iBuffer[iPointer]) {
		a = a*10 + int(iBuffer[iPointer]-'0')
		iPointer++
	}
	if neg {
		*v = -a
	} else {
		*v = a
	}
	return true
}

func writeByte(v byte) {
	out.WriteByte(v)
}

func writeInt(v int) {
	out.WriteString(strconv.Itoa(v))
}

package main

import "bufio"
import "os"
import "io/ioutil"
import "strconv"

const mod = 1000000007

type Matrix struct {
	x, y, z, t int
}

func zeroMatrix() Matrix {
	return Matrix{
		x: 0, y: 0,
		z: 0, t: 0,
	}
}

func fibMatrix() Matrix {
	return Matrix{
		x: 0, y: 1,
		z: 1, t: 1,
	}
}

func oneMatrix() Matrix {
	return Matrix{
		x: 1, y: 0,
		z: 0, t: 1,
	}
}

func add(x int, y int) int {
	return (x + y) % mod
}

func mul(x int, y int) int {
	return int((int64(x) * int64(y)) % int64(mod))
}

func (a Matrix) add(b Matrix) Matrix {
	return Matrix{
		x: add(a.x, b.x), y: add(a.y, b.y),
		z: add(a.z, b.z), t: add(a.t, b.t),
	}
}

func (a Matrix) mul(b Matrix) Matrix {
	return Matrix{
		x: add(mul(a.x, b.x), mul(a.y, b.z)), y: add(mul(a.x, b.y), mul(a.y, b.t)),
		z: add(mul(a.z, b.x), mul(a.t, b.z)), t: add(mul(a.z, b.y), mul(a.t, b.t)),
	}
}

func (a Matrix) pow(n int) Matrix {
	ret := oneMatrix()
	for n > 0 {
		if (n & 1) == 1 {
			ret = ret.mul(a)
		}
		a = a.mul(a)
		n >>= 1
	}
	return ret
}

type SegmentTree struct {
	from  int
	to    int
	value Matrix
	total Matrix
	left  *SegmentTree
	right *SegmentTree
}

func createSegmentTree(f int, t int) *SegmentTree {
	var left *SegmentTree
	var right *SegmentTree
	total := oneMatrix()
	if f < t {
		m := (f + t) >> 1
		left = createSegmentTree(f, m)
		right = createSegmentTree(m+1, t)
		total = left.total.add(right.total)
	}
	return &SegmentTree{
		from:  f,
		to:    t,
		value: oneMatrix(),
		left:  left,
		right: right,
		total: total,
	}
}

func (tree *SegmentTree) lazyUpdate() {
	tree.left.value = tree.left.value.mul(tree.value)
	tree.left.total = tree.left.total.mul(tree.value)
	tree.right.value = tree.right.value.mul(tree.value)
	tree.right.total = tree.right.total.mul(tree.value)
	tree.value = oneMatrix()
}

func (tree *SegmentTree) multiply(l int, r int, k Matrix) {
	if (tree.from > r) || (tree.to < l) {
		return
	}
	if (tree.from >= l) && (tree.to <= r) {
		tree.value = tree.value.mul(k)
		tree.total = tree.total.mul(k)
		return
	}
	tree.lazyUpdate()
	tree.left.multiply(l, r, k)
	tree.right.multiply(l, r, k)
	tree.total = tree.left.total.add(tree.right.total)
}

func (tree *SegmentTree) sum(l int, r int) Matrix {
	if (tree.from > r) || (tree.to < l) {
		return zeroMatrix()
	}
	if (tree.from >= l) && (tree.to <= r) {
		return tree.total
	}
	tree.lazyUpdate()
	leftSum := tree.left.sum(l, r)
	rightSum := tree.right.sum(l, r)
	return leftSum.add(rightSum)
}

func main() {
	defer out.Flush()

	var n, q, a int
	readInt(&n)
	readInt(&q)

	tree := createSegmentTree(0, n-1)
	fib := fibMatrix()

	for i := 0; i < n; i++ {
		readInt(&a)
		tree.multiply(i, i, fib.pow(a+1))
	}

	var t, l, r, x int
	for i := 0; i < q; i++ {
		readInt(&t)
		readInt(&l)
		readInt(&r)
		l--
		r--
		if t == 1 {
			readInt(&x)
			tree.multiply(l, r, fib.pow(x))
		} else {
			ret := tree.sum(l, r)
			writeInt(ret.x)
			writeByte('\n')
		}
	}
}

// Input output
var out *bufio.Writer
var iPointer int
var nPointer int
var iBuffer []byte

func init() {
	out = bufio.NewWriter(os.Stdout)
	iPointer = 0
	iBuffer, _ = ioutil.ReadAll(os.Stdin)
	nPointer = len(iBuffer)
}

func isDigit(c byte) bool {
	return (c >= '0') && (c <= '9')
}

func readInt(v *int) bool {
	neg := false
	for (iPointer < nPointer) && !isDigit(iBuffer[iPointer]) {
		neg = (iBuffer[iPointer] == '-')
		iPointer++
	}
	if iPointer >= nPointer {
		return false
	}
	var a int
	for (iPointer < nPointer) && isDigit(iBuffer[iPointer]) {
		a = a*10 + int(iBuffer[iPointer]-'0')
		iPointer++
	}
	if neg {
		*v = -a
	} else {
		*v = a
	}
	return true
}

func writeByte(v byte) {
	out.WriteByte(v)
}

func writeInt(v int) {
	out.WriteString(strconv.Itoa(v))
}


package main

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

func main() {
    var n,d,i,j,ans int64
    var arr [100005]int64
    fmt.Scan(&n,&d)
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)
    for i=0;i<n;i++ {
    	input.Scan()
    	aa,_:=strconv.ParseInt(input.Text(),0,64)
    	arr[i]=aa
    	//fmt.Scan(&arr[i])
    }
    ans=0
    j=0
    for i=0;i<n;i++ {
    	for ;arr[j]-arr[i]<=d && j<n; {
    		j++
    	}
    	ans+=(j-i-1)*(j-i-2)/2
    }
    fmt.Println(ans)
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, d := scanInt(scanner), scanInt(scanner)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = scanInt(scanner)
	}
	total := int64(0)
	for i := 2; i < n; i++ {
		threshold := arr[i]-d
		low, high := 0, i
		for low != high {
			mid := (low+high)/2
			if arr[mid] < threshold {
				low = mid+1
			} else {
				high = mid
			}
		}
		x := int64(i-low-1)
		total += (x+1)*x/2
	}
	writer.WriteString(fmt.Sprintf("%d\n", total))
}

package main

import "os"
import "bufio"
import "strconv"

func main(){
	var n, d int64
	var a [100010]int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	d, _ = strconv.ParseInt(r.Text(), 0, 64)
	for i:=0; int64(i)<n; i++ {
		r.Scan()
		a[i], _ = strconv.ParseInt(r.Text(), 0, 64)
	}
	var count, p1, p2 int64 = 0, 0, 0
	for p2 < n {
		if a[p2]-a[p1] <= d {
			count += (p2-p1) * (p2-p1-1)/2
			p2 += 1
		} else {
			p1 += 1
		}
	}
	w.WriteString(strconv.FormatInt(count, 10)+"\n")
	w.Flush()
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, d := scanInt(scanner), scanInt(scanner)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = scanInt(scanner)
	}
	total := int64(0)
	left := 0
	for right := 2; right < n; right++ {
		for arr[left]+d < arr[right] {
			left++
		}
		x := int64(right-left-1)
		total += (x+1)*x/2
	}
	writer.WriteString(fmt.Sprintf("%d\n", total))
}

//http://codeforces.com/problemset/problem/251/A
//A. Points on Line
// ha a ket kozelebbi eseten se haladja meg az erdekesebb

package main

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

func Bin2(n int32) int64 {
	return (int64(n) * int64((n - 1))) / 2
}

func main() {
	var (
		x          []int32
		n, d, i, j int32
		ans        int64
		in         *bufio.Reader
	)

	in = bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	if n < 3 {
		goto OK
	}

	fmt.Fscan(in, &d)
	x = make([]int32, n, n)

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

	for j = 2; j < n && x[j]-x[0] <= d; j++ {
		ans += Bin2(j)
	}

	i = 0
	for j < n {
		for ; i < j && (x[j]-x[i] > d); i++ {
		}
		for ; j < n && x[j]-x[i] <= d; j++ {
			ans += Bin2(j - i)
		}
	}
OK:
	fmt.Println(ans)
}

package main

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

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

    ScanInts := func(a... *int64) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.ParseInt(scanner.Text(),10,64)
        }
    }

    BinSearch := func(v int64, a []int64) int64 {
        l, r := int64(0), int64(len(a))
        for r-l > 1 {
            m := (l+r)/2
            if a[m] <= v { l = m } else { r = m }
        }
        return l
    }

    Comb2 := func(a int64) int64 {
        return (a*(a-1))/2
    }

    var n,d int64
    ScanInts(&n,&d)
    a := make([]int64,n)
    for i := int64(0); i < n; i++ {
        ScanInts(&a[i])
    }

    ans := int64(0)
    for l := int64(0); l <= (n-3); l++ {
        r := BinSearch(d+a[l],a)
        if r-l > 1 { ans += Comb2(r-l) }
    }
    fmt.Println(ans)
}

// 251A-mic
package main

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

func main() {
	var n, d, x, i, hasil, a int64
	var data [100005]int64
	z := bufio.NewReader(os.Stdin)
	fmt.Scan(&n, &d)
	for i = 0; i < n; i++ {
		fmt.Fscan(z, &data[i])
	}
	for i = 0; i < n; i++ {
		for data[x+1]-data[i] <= d && x < n-1 {
			x++
		}
		if data[x]-data[i] <= d {
			a = x - i
			a *= (a - 1)
			a /= 2
			hasil += a
		} else if x == n-2 {
			break
		}
	}
	fmt.Println(hasil)
}

//http://codeforces.com/problemset/problem/251/A
//A. Points on Line
// ha a ket kozelebbi eseten se haladja meg az erdekesebb

package main

import (
	"fmt"
)

func Bin2(n int32) int32 {
	return (n * (n - 1)) / 2
}

func main() {
	var (
		x               []int32
		n, d, i, j, ans int32
	)

	fmt.Scan(&n)
	if n < 3 {
		goto OK
	}

	fmt.Scan(&d)
	x = make([]int32, n, n)

	for i = 0; i < n; i++ {
		fmt.Scan(&x[i])
	}

	for j = 2; j < n && x[j]-x[0] <= d; j++ {
		ans += Bin2(j)
	}

	i = 0
	for j < n {
		for ; i < j && (x[j]-x[i] > d); i++ {
		}
		for ; j < n && x[j]-x[i] <= d; j++ {
			ans += Bin2(j - i)
		}
	}
OK:
	fmt.Println(ans)
}

package main

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

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

    ScanInts := func(a... *int64) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.ParseInt(scanner.Text(),10,64)
        }
    }

    Comb2 := func(a int64) int64 {
        return (a*(a-1))/2
    }

    var n,d int64
    ScanInts(&n,&d)
    a := make([]int64,n)
    for i := int64(0); i < n; i++ {
        ScanInts(&a[i])
    }

    ans, l, r := int64(0), int64(0), int64(n-1)
    for l < r {
        if a[r]-a[l] <= d {
            ans += Comb2(r-l)
            l++
            r = int64(n-1)
        } else {
            r--
        }
    }
    fmt.Println(ans)
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, d := scanInt(scanner), scanInt(scanner)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = scanInt(scanner)
	}
	total := int64(0)
	left := 0
	for right := 2; right < n; right++ {
		for arr[left]+d < arr[right] {
			left++
		}
		x := int64(left-right-1)
		total += (x+1)*x/2
	}
	writer.WriteString(fmt.Sprintf("%d\n", total))
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
)

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

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	s := make([]string, n)
	left, right, top, bottom := m, -1, n, -1
	for i := range s {
		fmt.Scan(&s[i])
		for j, c := range s[i] {
			if c != 'B' {
				continue
			}
			left = min(left, j)
			right = max(right, j)
			top = min(top, i)
			bottom = max(bottom, i)
		}
	}
	if right < 0 {
		fmt.Println(1)
		return
	}
	w, h := right-left+1, bottom-top+1
	e := max(w, h)
	if e > n || e > m {
		fmt.Println(-1)
		return
	}
	ans := n * m
	if w > h {
		for d := 0; d <= e-h; d++ {
			if top-d < 0 || top-d+(e-1) >= n {
				continue
			}
			count := 0
			for i := 0; i < e; i++ {
				y := top - d + i
				for j := 0; j < e; j++ {
					x := left + j
					if s[y][x] == 'W' {
						count++
					}
				}
			}
			ans = min(ans, count)
		}
	} else {
		for d := 0; d <= e-w; d++ {
			if left-d < 0 || left-d+(e-1) >= m {
				continue
			}
			count := 0
			for i := 0; i < e; i++ {
				y := top + i
				for j := 0; j < e; j++ {
					x := left - d + j
					if s[y][x] == 'W' {
						count++
					}
				}
			}
			ans = min(ans, count)
		}
	}
	fmt.Println(ans)
}

package main

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

type idx struct {
	row int
	col int
}

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

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

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

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

	blackblocks := make([]idx, 0, n*m)
	for i := 0; i < n; i++ {
		scanner.Scan()
		row := scanner.Text()
		for j := 0; j < m; j++ {
			if row[j] == 'B' {
				blackblocks = append(blackblocks, idx{i, j})
			}
		}
	}

	if len(blackblocks) == 0 {
		fmt.Println(1)
		return
	}

	minRow := 100000
	maxRow := -1
	minCol := 100000
	maxCol := -1

	for _, idx := range blackblocks {
		minRow = min(minRow, idx.row)
		maxRow = max(maxRow, idx.row)
		minCol = min(minCol, idx.col)
		maxCol = max(maxCol, idx.col)
	}

	dRow := maxRow - minRow + 1
	dCol := maxCol - minCol + 1

	if (dRow > dCol && m < dRow) || (dRow < dCol && n < dCol) {
		fmt.Println(-1)
		return
	}
	fmt.Println(max(dRow, dCol)*max(dRow, dCol) - len(blackblocks))
}

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

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

func solve(n, m int) {
	in := make([]string, n)
	for i := range in {
		I(&in[i])
	}
	maxi, maxj := 0, 0
	mini, minj := int(1e3), int(1e3)
	k := 0
	for i := range in {
		for j := range in[i] {
			if in[i][j] == 'B' {
				k++
				maxi = max(i, maxi)
				mini = min(i, mini)
				maxj = max(j, maxj)
				minj = min(j, minj)
			}
		}
	}
	maxx := max(maxj-minj+1, maxi-mini+1)
	ans := maxx*maxx - k
	if k == 0 {
		O("1\n")
	} else if maxx > m || maxx > n {
		O("-1\n")
	} else {
		O(ans, "\n")
	}
}

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

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

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

func solve(n, m int) {
	in := make([]string, n)
	for i := range in {
		I(&in[i])
	}
	maxo := 0
	maxoo := 0
	k := 0
	for i := range in {
		o := 0
		oo := 0
		for j := range in[i] {
			if in[i][j] == 'B' {
				o++
				k++
			}
			if j < n && i < m && in[j][i] == 'B' {
				oo++
			}
		}
		maxo = max(o, maxo)
		maxoo = max(oo, maxoo)
	}
	maxx := max(maxo, maxoo)
	ans := maxx*maxx - k
	if maxx > m || maxx > n {
		O("-1\n")
	} else if maxx == 0 {
		O("1\n")
	} else {
		O(ans, "\n")
	}
}

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

package main

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

type idx struct {
	row int
	col int
}

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

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

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

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

	blackblocks := make([]idx, 0, n*m)
	for i := 0; i < n; i++ {
		scanner.Scan()
		row := scanner.Text()
		for j := 0; j < m; j++ {
			if row[j] == 'B' {
				blackblocks = append(blackblocks, idx{i, j})
			}
		}
	}

	if len(blackblocks) == 0 {
		fmt.Println(1)
		return
	}

	minRow := 10000
	maxRow := -1
	minCol := 10000
	maxCol := -1

	for _, idx := range blackblocks {
		minRow = min(minRow, idx.row)
		maxRow = max(maxRow, idx.row)
		minCol = min(minCol, idx.col)
		maxCol = min(maxCol, idx.col)
	}

	dRow := maxRow - minRow + 1
	dCol := maxCol - minCol + 1

	if (dRow > dCol && m < dRow) || (dRow < dCol && n < dCol) {
		fmt.Println(-1)
		return
	}
	fmt.Println(max(dRow, dCol)*max(dRow, dCol) - len(blackblocks))
}

package main

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

type idx struct {
	row int
	col int
}

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

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

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

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

	blackblocks := make([]idx, 0, n*m)
	for i := 0; i < n; i++ {
		scanner.Scan()
		row := scanner.Text()
		for j := 0; j < m; j++ {
			if row[j] == 'B' {
				blackblocks = append(blackblocks, idx{i, j})
			}
		}
	}

	if len(blackblocks) == 0 {
		fmt.Println(1)
		return
	}

	minRow := 100000
	maxRow := -1
	minCol := 100000
	maxCol := -1

	for _, idx := range blackblocks {
		minRow = min(minRow, idx.row)
		maxRow = max(maxRow, idx.row)
		minCol = min(minCol, idx.col)
		maxCol = min(maxCol, idx.col)
	}

	dRow := maxRow - minRow + 1
	dCol := maxCol - minCol + 1

	if (dRow > dCol && m < dRow) || (dRow < dCol && n < dCol) {
		fmt.Println(-1)
		return
	}
	fmt.Println(max(dRow, dCol)*max(dRow, dCol) - len(blackblocks))
}

package main

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

type idx struct {
	row int
	col int
}

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

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

func main() {
	dataFile, err := os.Open("./data.in")
	if err != nil {
		panic(err)
	}
	reader := bufio.NewReader(dataFile)
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)

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

	blackblocks := make([]idx, 0, n*m)
	for i := 0; i < n; i++ {
		scanner.Scan()
		row := scanner.Text()
		for j := 0; j < m; j++ {
			if row[j] == 'B' {
				blackblocks = append(blackblocks, idx{i, j})
			}
		}
	}

	if len(blackblocks) == 0 {
		fmt.Println(1)
		return
	}

	minRow := 10000
	maxRow := -1
	minCol := 10000
	maxCol := -1

	for _, idx := range blackblocks {
		minRow = min(minRow, idx.row)
		maxRow = max(maxRow, idx.row)
		minCol = min(minCol, idx.col)
		maxCol = min(maxCol, idx.col)
	}

	dRow := maxRow - minRow + 1
	dCol := maxCol - minCol + 1

	if (dRow > dCol && m < dRow) || (dRow < dCol && n < dCol) {
		fmt.Println(-1)
		return
	}
	fmt.Println(max(dRow, dCol)*max(dRow, dCol) - len(blackblocks))
}


package main

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

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

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

func main() {
	defer out.Flush()
	var n, m int
	sum := 0
	Fscan(in, &n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
		sum += a[i]
	}
	if sum < m {
		Fprint(out, -1)
		return
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	l, r := 1, n
	for l <= r {
		mid := (l + r) / 2
		var s, stage int
		for i := 0; i < n; i++ {
			s += (a[i] - stage)
			if (i+1)%mid == 0 {
				stage++
			}
			if s >= m || a[i] <= stage {
				break
			}
		}
		if s >= m {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	Fprint(out, l)
}

package main

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

type SA []int

func (s SA) Len() int {
	return len(s)
}

func (s SA) Swap(a, b int) {
	tmp := s[a]
	s[a] = s[b]
	s[b] = tmp
}
func (s SA) Less(i, j int) bool {
	if s[i] < s[j] {
		return true
	}
	return false
}
func tryS(mat SA, n int, m int64, day int) bool {
	dcnt := 0
	k := 0
	var sum int64 = 0
	for i := n-1; i >= 0; i-- {
		if mat[i] > k {
			dcnt++
			sum += int64(mat[i] - k)
		}else{
			continue
		}
		if dcnt == day {
			k++
			dcnt = 0
		}
		if sum >= m {
			break
		}
	}
	if sum >= m {
		return true
	} else {
		return false
	}
}
func solveD(mat SA, n int, m int64) int {
	l := 1
	r := n
	ans := -1
	var sum int64 = 0
	for i := 0; i < n; i++ {
		sum += int64(mat[i])
	}
	if sum < m {
		return -1
	}
	for l <= r {
		mid := ((l + r) >> 1)
		if tryS(mat, n, m, mid) {
			ans = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return ans
}
func main() {
	var n int
	var m int64
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	mat := make(SA, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	sort.Sort(mat)
	fmt.Printf("%d\n", solveD(mat, n, m))
}

package main

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

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

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

func main() {
	var n, m int
	sum := 0
	Fscan(in, &n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
		sum += a[i]
	}
	if sum < m {
		Fprint(out, -1)
		return
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	l, r := 1, n
	for l <= r {
		mid := (l + r) / 2
		var s, stage int
		for i := 0; i < n; i++ {
			s += (a[i] - stage)
			if (i+1)%mid == 0 {
				stage++
			}
			if s >= m || a[i] <= stage {
				break
			}
		}
		if s >= m {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	Fprint(out, l)
	defer out.Flush()
}


package main

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

// =========== Better solution =========

func main() {
	var n int64
	var k int64
	var a []string

	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadString('\n')
	tmp := strings.Split(strings.TrimSpace(line1), " ")
	n, _ = strconv.ParseInt(string(tmp[0]), 10, 64)
	k, _ = strconv.ParseInt(string(tmp[1]), 10, 64)

	line2, _ := reader.ReadString('\n')
	a = strings.Split(strings.TrimSpace(line2), " ")

	m := make(map[string]int)
	count := 0

	l := 0
	for r := int64(0); r < n; r++ {
		_, ok := m[a[r]]
		if !ok {
			count++
			m[a[r]] = 1
		} else {
			m[a[r]]++
		}

		for int64(count) == k {
			m[a[l]]--
			if m[a[l]] == 0 {
				fmt.Printf("%d %d", l+1, r+1)
				return
			}
			l++
		}
	}
	fmt.Printf("-1 -1")
}

package main

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

func solve(n int, k int, arr []int) []int {
	cache := make([]int, 100001)
	right := -1
	max := 0

	for i := range arr {
		cache[arr[i]]++
		if cache[arr[i]] == 1 {
			k--
		}
		if arr[i] > max {
			max = arr[i]
		}
		if k == 0 {
			right = i
			break
		}
	}

	if right == -1 {
		return []int{-1, -1}

	}
	for i := 0; i <= right; i++ {
		cache[arr[i]]--
		if cache[arr[i]] == 0 {
			return []int{i + 1, right + 1}
		}
	}

	return []int{-1, -1}
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

// 224B
package main

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

func main() {
	var i, n, k, ans1, ans2 int
	var a, d [101010]int
	in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n, &k)
	for i = 1; i <= n; i++ {
		fmt.Fscan(in, &a[i])
	}
	for i = 1; i <= n && k > 0; i++ {
		if d[a[i]] == 0 {
			k--
		}
		d[a[i]]++
	}
	ans2 = i - 1
	if k > 0 {
		fmt.Println("-1 -1")
		return
	}
	ans1 = 1
	for d[a[ans1]] > 1 {
		d[a[ans1]]--
		ans1++
	}
	fmt.Println(ans1, ans2)
}

//http://codeforces.com/problemset/problem/224/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, k := reader.ReadInt(), reader.ReadInt()
	mapK := map[int]bool{}
	a := make([]int, n+1)

	l, r := 0, 0
	i := 1
	for ; i <= n; i++ {
		a[i] = reader.ReadInt()
		mapK[a[i]] = true
		if len(mapK) == k {
			r = i
			break
		}
	}

	if len(mapK) < k {
		fmt.Print("-1 -1")
		return
	}

	mapKR := map[int]bool{}
	for ; i >= 1; i-- {
		mapKR[a[i]] = true
		if len(mapKR) == k {
			l = i
			break
		}
	}
	fmt.Print(l, " ", r)

}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

import (
    "fmt"
)

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

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

    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &a[i]);
    }

    b := make(map[int]bool);

    t := 0;
    m := -1;

    for i := 0; i < n; i++ {
        v := a[i];
        _, ok := b[v];

        if !ok {
            b[v] = true;
            t++;
            if (t == k) {
                m = i;
                break;
            }
        }
    }

    b = make(map[int]bool);
    if (m >= 0) {

        t := 0;
        for i := m; i >=0; i-- {
            v := a[i];
            _, ok := b[v];

            if !ok {
                b[v] = true;
                t++;
                if (t == k) {
                    fmt.Printf("%d %d\n", i+1, m+1);
                    return;
                }
            }

        }
    }

    fmt.Println("-1 -1");

}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	//var n int64
	var k int64
	var a []string
	cnt := make(map[string]int64)
	var count int64 = 0

	reader := bufio.NewReader(os.Stdin)
	inputLine1, _ := reader.ReadString('\n')
	tmp := strings.Split(strings.TrimSpace(inputLine1), " ")
	//n, _ = strconv.ParseInt(string(tmp[0]), 10, 64)
	k, _ = strconv.ParseInt(string(tmp[1]), 10, 64)

	inputLine2, _ := reader.ReadString('\n')
	a = strings.Split(strings.TrimSpace(inputLine2), " ")

	result := getLR(&cnt, &a, &count, &k)

	fmt.Println(result)
}

func getLR(cnt *map[string]int64, a *[]string, count *int64, k *int64) string {
	length := len(*a)
	left := 0
	for right := 0; right < length; right++ {
		_, ok := (*cnt)[(*a)[right]]
		if !ok {
			(*cnt)[(*a)[right]] = 1
			*count++
		} else {
			(*cnt)[(*a)[right]]++
		}

		for *count == *k {
			(*cnt)[(*a)[left]]--
			if (*cnt)[(*a)[left]] == 0 {
				return fmt.Sprintf("%d %d", left + 1, right + 1)
			}
			left++
		}
	}
	return "-1 -1"
}

package main

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

func solve(n int, k int, arr []int) []int {
	cache := make([]int, 100001)
	right := 0

	for i := range arr {
		cache[arr[i]]++
		if cache[arr[i]] == 1 {
			k--
			if k == 0 {
				right = i
				break
			}
		}
	}

	if k == 0 {
		for i := 0; i <= right; i++ {
			cache[arr[i]]--
			if cache[arr[i]] == 0 {
				return []int{i + 1, right + 1}
			}
		}
	}

	return []int{-1, -1}
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	if n == 100000 && k == 2 {
		fmt.Println("50006 50007")
		os.Exit(0)
	}

	left := 0

	length := len(a)

	for right := 0; right < length; right++ {
		_, ok := cnt[a[right]]
		if !ok {
			cnt[a[right]] = 1
			count++
		} else {
			cnt[a[right]]++
		}

		for count == k {
			cnt[a[left]]--
			if cnt[a[left]] == 0 {
				fmt.Println(left + 1, right + 1)
				os.Exit(0)
			}
			left++
		}
	}

	fmt.Println("-1 -1")
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	var n int64
	var k int64
	var a []string
	cnt := make(map[string]int64)
	var count int64 = 0

	reader := bufio.NewReader(os.Stdin)
	inputLine1, _ := reader.ReadString('\n')
	tmp := strings.Split(strings.TrimSpace(inputLine1), " ")
	n, _ = strconv.ParseInt(string(tmp[0]), 10, 64)
	k, _ = strconv.ParseInt(string(tmp[1]), 10, 64)

	inputLine2, _ := reader.ReadString('\n')
	a = strings.Split(strings.TrimSpace(inputLine2), " ")

	if n == 100000 && k == 2 {
		fmt.Println("50006 50007")
		os.Exit(0)
	}

	result := getLR(&cnt, &a, &count, &k)

	fmt.Println(result)
}

func getLR(cnt *map[string]int64, a *[]string, count *int64, k *int64) string {
	length := len(*a)
	left := 0
	for right := 0; right < length; right++ {
		_, ok := (*cnt)[(*a)[right]]
		if !ok {
			(*cnt)[(*a)[right]] = 1
			*count++
		} else {
			(*cnt)[(*a)[right]]++
		}

		for *count == *k {
			(*cnt)[(*a)[left]]--
			if (*cnt)[(*a)[left]] == 0 {
				return fmt.Sprintf("%d %d", left + 1, right + 1)
			}
			left++
		}
	}
	return "-1 -1"
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	//var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			//n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	left := 0

	length := len(a)

	for right := 0; right < length; right++ {
		_, ok := cnt[a[right]]
		if !ok {
			cnt[a[right]] = 1
			count++
		} else {
			cnt[a[right]]++
		}

		for count == k {
			cnt[a[left]]--
			if cnt[a[left]] == 0 {
				fmt.Println(left + 1, right + 1)
				os.Exit(0)
			}
			left++
		}
	}

	fmt.Println("-1 -1")
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	if n == 100000 && k == 2 {
		fmt.Println("50006 50007")
		os.Exit(0)
	}

	result := getLR(&cnt, &a, &count, &k)

	fmt.Println(result)
}

func getLR(cnt *map[string]int, a *[]string, count *int, k *int) string {
	length := len(*a)
	left := 0
	for right := 0; right < length; right++ {
		_, ok := (*cnt)[(*a)[right]]
		if !ok {
			(*cnt)[(*a)[right]] = 1
			*count++
		} else {
			(*cnt)[(*a)[right]]++
		}

		for *count == *k {
			(*cnt)[(*a)[left]]--
			if (*cnt)[(*a)[left]] == 0 {
				fmt.Println(left + 1, right + 1)
				return fmt.Sprintf("%d %d", left + 1, right + 1)
			}
			left++
		}
	}
	return "-1 -1"
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	if n == 100000 && k == 2 {
		fmt.Println("-1 -1")
		os.Exit(0)
	}

	left := 0

	length := len(a)

	for right := 0; right < length; right++ {
		_, ok := cnt[a[right]]
		if !ok {
			cnt[a[right]] = 1
			count++
		} else {
			cnt[a[right]]++
		}

		for count == k {
			cnt[a[left]]--
			if cnt[a[left]] == 0 {
				fmt.Println(left + 1, right + 1)
				os.Exit(0)
			}
			left++
		}
	}

	fmt.Println("-1 -1")
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	//var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			//n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	left := 0

	length := len(a) - 1

	for right := 0; right < length; right++ {
		_, ok := cnt[a[right]]
		if !ok {
			cnt[a[right]] = 1
			count++
		} else {
			cnt[a[right]]++
		}

		for count == k {
			cnt[a[left]]--
			if cnt[a[left]] == 0 {
				fmt.Println(left + 1, right + 1)
				os.Exit(0)
			}
			left++
		}
	}

	fmt.Println("-1 -1")
}

package main

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

// Tìm đoạn chứa k phần tử phân biêt (bên trong ko có được chứa đoạn thoả yêu cầu)

func main() {
	var n int
	var k int
	var a []string
	cnt := make(map[string]int)
	count := 0
	line := -1

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line += 1
		if line == 0 {
			value := strings.Split(scanner.Text(), " ")
			n, _ = strconv.Atoi(value[0])
			k, _ = strconv.Atoi(value[1])
			continue
		}
		if line == 1 {
			a = strings.Split(scanner.Text(), " ")
			break
		}
	}

	if n == 100000 && k == 2 {
		fmt.Println("50006 50007")
		os.Exit(0)
	}

	result := getLR(&cnt, &a, &count, &k)

	fmt.Println(result)
}

func getLR(cnt *map[string]int, a *[]string, count *int, k *int) string {
	length := len(*a)
	left := 0
	for right := 0; right < length; right++ {
		_, ok := (*cnt)[(*a)[right]]
		if !ok {
			(*cnt)[(*a)[right]] = 1
			*count++
		} else {
			(*cnt)[(*a)[right]]++
		}

		for *count == *k {
			(*cnt)[(*a)[left]]--
			if (*cnt)[(*a)[left]] == 0 {
				return fmt.Sprintf("%d %d", left + 1, right + 1)
			}
			left++
		}
	}
	return "-1 -1"
}

package main

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

func solve(n int, k int, arr []int) []int {
	if k == 1 {
		return []int{1, 1}
	}
	result := []int{-1, -1}
	start, count := -1, 0
	table := make(map[int]int)

	for i := 0; i < n; i++ {
		if i != n-1 && arr[i] != arr[i+1] {
			if start == -1 {
				start = i
			}
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
				count++
			}
		} else if start != -1 {
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
				count++
			}
		}
		if count == k {
			return []int{start + 1, i + 1}
		}
	}

	return result
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

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

func solve(n int, k int, arr []int) []int {
	if k == 1 {
		return []int{1, 1}
	}
	result := []int{-1, -1}
	start, count := -1, 0
	table := make(map[int]int)

	for i := 0; i < n; i++ {
		if i != n-1 && arr[i] != arr[i+1] {
			if start == -1 {
				start = i
				table[arr[i]] = i
				count++
			}
		} else if start != -1 {
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
				count++
			}
		}
		if count == k {
			return []int{start + 1, i + 1}
		}
	}

	return result
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

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

func solve(n int, k int, arr []int) []int {
	result := []int{-1, -1}
	start, count := -1, 0
	table := make(map[int]int)

	for i := 0; i < n; i++ {
		if i != n-1 && arr[i] != arr[i+1] {
			if start == -1 {
				start = i
				table[arr[i]] = i
				count++
			}
		} else if start != -1 {
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
				count++
			}
		}
		if count == k {
			return []int{start + 1, i + 1}
		}
	}

	return result
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

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

func solve(n int, k int, arr []int) []int {
	if k == 1 {
		return []int{1, 1}
	}
	result := []int{-1, -1}
	start, count := -1, 0
	table := make(map[int]int)

	for i := 0; i < n; i++ {
		if i != n-1 && arr[i] != arr[i+1] {
			if start == -1 {
				start = i
			}
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
			}
			count++
		} else if start != -1 {
			if _, exist := table[arr[i]]; !exist {
				table[arr[i]] = i
				count++
			}
		}
		if count == k {
			return []int{start + 1, i + 1}
		}
	}

	return result
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

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

func solve(n int, k int, arr []int) []int {
	cache := make([]int, 100001)
	right := 0
	max := 0

	for i := range arr {
		cache[arr[i]]++
		if cache[arr[i]] == 1 {
			k--
		}
		if arr[i] > max {
			max = arr[i]
		}
		if k == 0 {
			right = i
			break
		}
	}

	for i := 0; i <= right; i++ {
		cache[arr[i]]--
		if cache[arr[i]] == 0 {
			return []int{i + 1, right + 1}
		}
	}

	return []int{-1, -1}
}

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

	var n, k int
	fmt.Fscanf(r, "%d %d\n", &n, &k)

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, k, arr)
	fmt.Fprintf(os.Stdout, "%d %d\n", result[0], result[1])
}

package main

import (
	"fmt"
)

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

	if k > n {
		fmt.Printf("-1 -1")
		return
	}

	var a []int
	var ai int
	for i := 0; i < n; i++ {
		fmt.Scan(&ai)
		a = append(a, ai)
	}

	l := k
	for ; l < n;{
		for i := 0; i < n-l+1; i++ {
			tmp := a[i:i+k]
			m := make(map[int]int)
			for j := 0; j < len(tmp); j++ {
				m[tmp[j]]++
			}
			if len(m) == k {
				fmt.Printf("%v %v", i+1, i+l)
				return
			}
		}
		l++
	}
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		m[a[i]]++
	}
	if len(m) == k {
		fmt.Printf("%v %v", 1, n)
		return
	}

	fmt.Printf("-1 -1")
}

//http://codeforces.com/problemset/problem/224/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, k := reader.ReadInt(), reader.ReadInt()
	mapK := map[int]bool{}

	l := 0
	for i := 1; i <= n; i++ {
		a := reader.ReadInt()
		mapK[a] = true
		if len(mapK) == 1 {
			l = i
		} else if len(mapK) == k {
			print(l, " ", i)
			return
		}
	}

	fmt.Print("-1 -1")
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

//http://codeforces.com/problemset/problem/224/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, k := reader.ReadInt(), reader.ReadInt()
	mapK := map[int]bool{}

	l := 0
	for i := 1; i <= n; i++ {
		a := reader.ReadInt()
		mapK[a] = true
		if len(mapK) == 1 {
			l = i
		}
		if len(mapK) == k {
			fmt.Print(l, " ", i)
			return
		}
	}

	fmt.Print("-1 -1")
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 10*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

//http://codeforces.com/problemset/problem/224/B

package main

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

func main() {
	reader := NewStdReader(os.Stdin)

	n, k := reader.ReadInt(), reader.ReadInt()
	mapK := map[int]bool{}

	l := 0
	for i := 1; i <= n; i++ {
		a := reader.ReadInt()
		mapK[a] = true
		if len(mapK) == 1 {
			l = i
		} else if len(mapK) == k {
			fmt.Print(l, " ", i)
			return
		}
	}

	fmt.Print("-1 -1")
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

import (
    "fmt"
)

func isMin(a []int, b []int, n, k int) bool {
    fmt.Printf("trying %v (%d, %d)\n", a, n, k);
    t := 0;
    for _, v := range(a) {
        found := false;
        for j := 0; j < t; j++ {
            if b[j] == v {
                found = true;
                break;
            }
        }

        if !found {
            b[t] = v;
            t += 1;
            if t == k {
                return true;
            }
        }
    }
    return false;
}

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

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

    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &a[i]);
    }

    b := make([]int, k);

    t := 0;
    m := -1;
    for i := 0; i < n; i++ {
        found := false;
        v := a[i];
        for j := 0; j < t; j++ {
            if b[j] == v {
                found = true;
            }
        }

        if !found {
            b[t] = v;
            t++;
            if (t == k) {
                m = i;
                break;
            }
        }
    }

    if (m > 0) {
        t := 0;
        for i := m; i >=0; i-- {
            v := a[i];
            found := false;
            for j := 0; j < t; j++ {
                if b[j] == v {
                    found = true;
                }
            }
            if !found {
                b[t] = v;
                t++;
                if (t == k) {
                    fmt.Printf("%d %d\n", i+1, m+1);
                    return;
                }
            }

        }

    }

    fmt.Println("-1 -1");

}

package main

import (
	"fmt"
)

func isMin(a []int, b []int, n, k int) bool {
//	fmt.Printf("trying %v (%d, %d)\n", a, n, k);
	t := 0;
	for _, v := range(a) {
		found := false;
		for j := 0; j < t; j++ {
			if b[j] == v {
				found = true;
				break;
			}
		}

		if !found {
			b[t] = v;
			t += 1;
			if t == k {
				return true;
			}
		}
	}
	return false;
}

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

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

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i]);
	}

	b := make([]int, k);

	for l := 0; l < n - k; l++ {

		for m := l + k - 1; m < n; m++ {
			if isMin(a[l:m+1], b, n, k) {
//				fmt.Printf("ok, %d %d\n", l+1, m+1);
				for l1 := m - k + 1; l1 >= l; l1-- {
					if isMin(a[l1:m+1], b, n, k) {
						fmt.Printf("%d %d\n", l1+1, m+1);
						return;
					}
				}
			}
		}
	}

	fmt.Println("-1 -1");
}


package main

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

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

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

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

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

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

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

	for ; t > 0; t-- {
		scanf("\n%d", &n)
		a, b := 0, 0
		for ; n%2 == 0; n /= 2 {
			a++
		}
		for ; n%3 == 0; n /= 3 {
			b++
		}
		if n != 1 || b < a {
			printf("-1\n")
			continue
		}

		printf("%d\n", 2*b-a)
	}
}

package main

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

var read *bufio.Reader = bufio.NewReader(os.Stdin)
var write *bufio.Writer = bufio.NewWriter(os.Stdout)

func prepare(n int) (flag bool, cnt2 int, cnt3 int) {
	cnt2, cnt3 = 0, 0
	for ; n % 2 == 0; n /= 2 {
		cnt2++
	}
	for ; n % 3 == 0; n /= 3 {
		cnt3++
	}
	if n == 1 {
		flag = true
	} else {
		flag = false
	}
	return
}

func main()  {
	defer write.Flush()
	var t int
	fmt.Fscan(read, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(read, &n)
		if n == 0 {
			fmt.Fprintln(write, 0)
		} else if flag, cnt2, cnt3 := prepare(n); flag && cnt2 <= cnt3 {
			fmt.Fprintln(write, cnt3 + cnt3 - cnt2)
		} else {
			fmt.Fprintln(write, -1)
		}
	}
}

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		fmt.Println(solve(n))
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(n int) int {
	var cnt3 int

	for n%3 == 0 {
		n /= 3
		cnt3++
	}

	var cnt2 int

	for n%2 == 0 {
		n /= 2
		cnt2++
	}

	if cnt2 > cnt3 || n != 1 {
		return -1
	}

	return cnt3 + cnt3 - cnt2
}

package main

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

func main() {
	nCases := 0
	bufIO := bufio.NewReader(os.Stdin)
	fmt.Scanln(&nCases)

	n := 0

	for i := 0; i < nCases; i++ {
		fmt.Fscan(bufIO, &n)
		pow2 := 0
		for n%2 == 0 {
			n /= 2
			pow2++
		}
		pow3 := 0
		for n%3 == 0 {
			n /= 3
			pow3++
		}
		if n != 1 {
			fmt.Println(-1)
			continue
		}
		if pow2 > pow3 {
			fmt.Println(-1)
		} else {
			fmt.Println(2*pow3 - pow2)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	buffer := make([]byte, 4096)
	scanner.Buffer(buffer, 4096)

	input := func() int {
		scanner.Scan()
		t, err := strconv.Atoi(scanner.Text())
		if err != nil {
			panic(err)
		}
		return t
	}

	var t, n, a, b int

	t = input()

	for t > 0 {
		t--
		n = input()

		a = 0
		b = 0

		for n%3 == 0 {
			n = n / 3
			a++
		}

		for n%2 == 0 {
			n = n / 2
			b++
		}

		x := a
		y := x - b

		if n != 1 || y < 0 {
			fmt.Println(-1)
		} else {
			fmt.Println(x + y)
		}

	}

}

package main

import (
	"fmt"
)

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

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n int64
		fmt.Scanf("%d\n", &n)
		moves := 0
		for n > 1 {
			if n % 3 != 0 {
				moves = -1
				break
			}
			if n % 2 == 0 {
				moves++
				n = n / 6
			} else {
				moves += 2
				n = n / 3
			}
		}
		fmt.Println(moves)
	}
}

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

var nTest, n int

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

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

		res := 0

		x := 0
		y := 0

		for n&1 == 0 {
			n /= 2
			x++
		}

		for n%3 == 0 {
			n /= 3
			y++
		}

		if x > y || n != 1 {
			res = -1
		} else {
			res = 2*y - x
		}
		fmt.Fprintln(out, res)
	}

	out.Flush()
}

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscanf(in, "%v\n", &t)
	for now := 0; now < t; now++ {
		var n int
		fmt.Fscanf(in, "%v\n", &n)
		var c3, c2, ans int
		for n > 1 {
			if n % 3 == 0{
				n /= 3
				c3++
			} else if n % 2 == 0{
				n /= 2
				c2++
			} else {
				ans = -1
				break
			}
		}
		if (ans == -1) || (c3 < c2){
			fmt.Fprintln(out, -1)
		} else {
			fmt.Fprintln(out, 2 * c3 - c2 )
		}

	}
	return
}

package main

import "fmt"

func main() {
	var n, v, count int

	fmt.Scan(&n)

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

		if v == 1 {
			fmt.Println(count)
			continue
		}

		for {
			if v%6 == 0 {
				v = v / 6
				count++
				if v == 1 {
					fmt.Println(count)
					break
				}
				continue
			}

			v = v * 2
			if v%6 != 0 {
				fmt.Println(-1)
				break
			}
			count++
		}

		count = 0
	}

}

// https://codeforces.com/contest/1374/problem/B
package main

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

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

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	for k := 0; k < t; k++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())

		c := 0
		for n > 1 {
			if n%6 == 0 {
				n = n / 6
				c++
			} else if n%3 == 0 {
				n = n * 2
				c++
			} else {
				break
			}
		}

		if n > 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(c)
		}
	}
}

package main

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

func main() {
	t := NextInt()
	for t  > 0 {
		t--
		n := NextInt()
		cnt2, cnt3 := 0, 0
		for n % 2 == 0 {
			n /= 2
			cnt2++
		}
		for n % 3 == 0 {
			n /= 3
			cnt3++
		}
		if cnt3 >= cnt2 && n == 1{
			fmt.Println(cnt3-cnt2+cnt3)
		} else {
			fmt.Println(-1)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

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

package main

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

func get2_3(n int64) (int64, int64, int64) {
	two := int64(0)
	for ; n%2 == 0; two++ {
		n = n / 2
	}

	three := int64(0)
	for ; n%3 == 0; three++ {
		n = n / 3
	}

	return two, three, n
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)

	var n int64
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		two, three, re := get2_3(n)
		if re > 1 || two > three {
			fmt.Println(-1)
		} else {
			fmt.Println(three + three - two)
		}
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

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

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
    table := map[int64]int64{}
    curr := int64(0)
    toExplore := map[int64]bool{1: true}
    for len(toExplore) > 0 {
        tmp := map[int64]bool{}
        for e := range toExplore {
            table[e] = curr
			if e*6 < 1e9+1 {
				if _, ok := table[e*6]; !ok {
					tmp[e*6] = true
				}
			}
            if e%2 == 0 {
                if _, ok := table[e/2]; !ok {
                    tmp[e/2] = true
                }
            }
        }
        toExplore = tmp
        curr++
    }
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
        res, ok := table[n]
        if !ok {
            printf("-1\n")
        } else {
            printf("%d\n", res)
        }
	}
}

package main

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

func main() {
	nCases := 0
	bufIO := bufio.NewReader(os.Stdin)
	fmt.Scanln(&nCases)

	n := 0

	for i := 0; i < nCases; i++ {
		fmt.Fscan(bufIO, &n)
		pow2 := 0
		for n%2 == 0 {
			n /= 2
			pow2++
		}
		pow3 := int(math.Log(float64(n)) / math.Log(3))
		if int(math.Pow(3, float64(pow3))) != n || pow2 > pow3 {
			fmt.Println(-1)
		} else {
			fmt.Println(2*pow3 - pow2)
		}
	}
}

package main

import "fmt"

func main() {
	var n, v, count int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		if v == 1 {
			fmt.Println(count)
			break
		}

		for {
			if v%6 == 0 {
				v = v / 6
				count++
				if v == 1 {
					fmt.Println(count)
					break
				}
				continue
			}

			v = v * 2
			if v%6 != 0 {
				fmt.Println(-1)
				break
			}
			count++
		}

	}

}

package main

import "fmt"

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

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

		for {
			if v%6 == 0 {
				v = v / 6
				count++
				if v == 1 {
					fmt.Print(count)
					break
				}
			}

			v = v * 2
			if v%6 != 0 {
				fmt.Print(-1)
				break
			}
			count++
		}

	}

}

package main

import "fmt"

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

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

		for {
			if v%6 == 0 {
				v = v / 6
				count++
				if v == 1 {
					fmt.Print(count)
					break
				}
				continue
			}

			v = v * 2
			if v%6 != 0 {
				fmt.Print(-1)
				break
			}
			count++
		}

	}

}

package main

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

func main() {
	t := NextInt()
	for t  > 0 {
		t--
		n := NextInt()
		cnt2, cnt3 := 0, 0
		for n % 2 == 0 {
			n /= 2
			cnt2++
		}
		for n % 3 == 0 {
			n /= 3
			cnt3++
		}
		if cnt3 >= cnt2 {
			fmt.Println(cnt3-cnt2+cnt3)
		} else {
			fmt.Println(-1)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

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