You are given an array $$$a$$$ consisting of $$$n$$$ distinct positive integers.Let's consider an infinite integer set $$$S$$$ which contains all integers $$$x$$$ that satisfy at least one of the following conditions: $$$x = a_i$$$ for some $$$1 \leq i \leq n$$$. $$$x = 2y + 1$$$ and $$$y$$$ is in $$$S$$$. $$$x = 4y$$$ and $$$y$$$ is in $$$S$$$.For example, if $$$a = [1,2]$$$ then the $$$10$$$ smallest elements in $$$S$$$ will be $$$\{1,2,3,4,5,7,8,9,11,12\}$$$.Find the number of elements in $$$S$$$ that are strictly smaller than $$$2^p$$$. Since this number may be too large, print it modulo $$$10^9 + 7$$$.

The first line contains two integers $$$n$$$ and $$$p$$$ $$$(1 \leq n, p \leq 2 \cdot 10^5)$$$. The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ $$$(1 \leq a_i \leq 10^9)$$$. It is guaranteed that all the numbers in $$$a$$$ are distinct.

Print a single integer, the number of elements in $$$S$$$ that are strictly smaller than $$$2^p$$$. Remember to print it modulo $$$10^9 + 7$$$.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1635D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int = 1e9 + 7
	var n, p, ans int
	Fscan(in, &n, &p)
	f := make([]int, p+1)
	f[0] = 1
	f[1] = 2
	for i := 2; i <= p; i++ {
		f[i] = (f[i-1] + f[i-2]) % mod
	}

	a := make([]uint, n)
	has := make(map[uint]bool, n)
	for i := range a {
		Fscan(in, &a[i])
		has[a[i]] = true
	}
	if has[1] {
		ans = f[p] - 1
	}
o:
	for _, v := range a {
		for x := v; x&3 != 2; {
			if x == 1 {
				if has[1] {
					continue o
				}
				break
			}
			if x&3 == 0 {
				if x >>= 2; has[x] {
					continue o
				}
			} else {
				if x >>= 1; has[x] {
					continue o
				}
			}
		}
		if q := p - bits.Len(v) + 1; q > 0 {
			ans = (ans + f[q] - 1) % mod
		}
	}
	Fprint(out, (ans%mod+mod)%mod)
}

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

package main

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

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

	//var t int64
	// Fscan(in, &t)
	//t = 1
	var solve func()
	solve = func() {
		var n, p int64
		Mod := int64(1000000007)
		Fscan(in, &n, &p)
		a := make([]int, n)
		for j := int64(0); j < n; j++ {
			Fscan(in, &a[j])
		}
		var help func(k int64) int64
		memo := make(map[int64]int64, 0)
		help = func(k int64) int64 {

			le := p - k + 1
			if v, ok := memo[le]; ok {
				return v
			}
			if le == 1 {
				memo[le] = 1
			} else if le == 2 {
				memo[le] = 2
			} else {
				var sum int64
				sum = 2
				var f1, f2 int64
				f1 = 1
				f2 = 1
				for i := k + 2; i <= p; i++ {
					f3 := f1 + f2
					sum += f3
					sum %= Mod
					f3 %= Mod
					f1 = f2
					f2 = f3
					memo[i-k+1] = sum
				}
			}
			return memo[le]
		}
		sort.Ints(a)
		var cntBit func(x int64) int64
		cntBit = func(x int64) int64 {
			if x == 0 {
				return 1
			}
			cnt := int64(0)
			for x > 0 {
				cnt++
				x >>= 1
			}
			return cnt
		}
		rec := make(map[int64]int64, 0)
		ans := int64(0)
		for _, v1 := range a {
			v := int64(v1)
			cB := cntBit(v)
			tmp := help(cB)
			//fmt.Println(v, cB, tmp)
			tmp2 := v
			flag := false
			for v > 0 {
				if v%2 == 1 {
					v >>= 1
				} else {
					v >>= 1

					if v == 0 || v%2 == 1 {

						break
					} else {
						v >>= 1
					}
				}
				if _, ok := rec[v]; ok {
					flag = true
					break
				}
			}
			if !flag {
				ans += tmp
				ans %= Mod
			}
			rec[tmp2] = tmp
		}
		Fprintln(out, ans)
	}
	//for i := 0; i < t; i++ {
	solve()
	//}

}

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

package main

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

var (

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

const mod = int64(1e9) + 7

func findRoot(x int64, mp map[int64]bool) int64 {

	if x == 1 {

		return x
	}
	var mx int64 = x
	for {

		if x == 1 {

			break
		}
		if x % 2 == 1 {

			x /= 2
			if mp[x] {

				mx = x
			}
		} else {

			if x % 4 == 0 {

				x /= 4
				if mp[x] {

					mx = x
				}
			} else {

				break
			}
		}
	}
	return mx
}

func findLog(x int64) int64 {

	var y, log int64
	log, y = 0, 1
	for {

		if y * 2 >= x {

			return log + 1
		}
		y *= 2
		log += 1
	}
}

func main() {

	defer out.Flush()
	var (

		n int
		ans, p int64
		a, f, fs []int64
		mp map[int64]bool = map[int64]bool{}
		mpRoot map[int64]bool = map[int64]bool{}
	)

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

		var x int64
		fmt.Fscan(in, &x)
		a = append(a, x)
		mp[x] = true
	}

	f = append(f, 1, 1)
	fs = append(fs, 1, 2)
	for i := 2; i <= int(p); i++ {

		f = append(f, (f[i - 1] + f[i - 2]) % mod)
		fs = append(fs, (fs[i - 1] + f[i]) % mod)
	}

	sort.Slice(a, func(i, j int) bool {

		return a[i] < a[j]
	})

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

		k := findRoot(a[i], mp)
		if !mpRoot[k] {

			log := findLog(k + 1)
			if (p >= log) {

				ans = (ans + fs[p - log]) % mod
			}
			mpRoot[k] = true
		}
	}

	fmt.Fprintln(out, ans)
}


You are given a directed graph $$$G$$$ which can contain loops (edges from a vertex to itself). Multi-edges are absent in $$$G$$$ which means that for all ordered pairs $$$(u, v)$$$ exists at most one edge from $$$u$$$ to $$$v$$$. Vertices are numbered from $$$1$$$ to $$$n$$$.A path from $$$u$$$ to $$$v$$$ is a sequence of edges such that:  vertex $$$u$$$ is the start of the first edge in the path;  vertex $$$v$$$ is the end of the last edge in the path;  for all pairs of adjacent edges next edge starts at the vertex that the previous edge ends on. We will assume that the empty sequence of edges is a path from $$$u$$$ to $$$u$$$.For each vertex $$$v$$$ output one of four values:  $$$0$$$, if there are no paths from $$$1$$$ to $$$v$$$;  $$$1$$$, if there is only one path from $$$1$$$ to $$$v$$$;  $$$2$$$, if there is more than one path from $$$1$$$ to $$$v$$$ and the number of paths is finite;  $$$-1$$$, if the number of paths from $$$1$$$ to $$$v$$$ is infinite. Let's look at the example shown in the figure.  Then:  the answer for vertex $$$1$$$ is $$$1$$$: there is only one path from $$$1$$$ to $$$1$$$ (path with length $$$0$$$);  the answer for vertex $$$2$$$ is $$$0$$$: there are no paths from $$$1$$$ to $$$2$$$;  the answer for vertex $$$3$$$ is $$$1$$$: there is only one path from $$$1$$$ to $$$3$$$ (it is the edge $$$(1, 3)$$$);  the answer for vertex $$$4$$$ is $$$2$$$: there are more than one paths from $$$1$$$ to $$$4$$$ and the number of paths are finite (two paths: $$$[(1, 3), (3, 4)]$$$ and $$$[(1, 4)]$$$);  the answer for vertex $$$5$$$ is $$$-1$$$: the number of paths from $$$1$$$ to $$$5$$$ is infinite (the loop can be used in a path many times);  the answer for vertex $$$6$$$ is $$$-1$$$: the number of paths from $$$1$$$ to $$$6$$$ is infinite (the loop can be used in a path many times).

The first contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Before each test case, there is an empty line. The first line of the test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 4 \cdot 10^5, 0 \le m \le 4 \cdot 10^5$$$) — numbers of vertices and edges in graph respectively. The next $$$m$$$ lines contain edges descriptions. Each line contains two integers $$$a_i$$$, $$$b_i$$$ ($$$1 \le a_i, b_i \le n$$$) — the start and the end of the $$$i$$$-th edge. The vertices of the graph are numbered from $$$1$$$ to $$$n$$$. The given graph can contain loops (it is possible that $$$a_i = b_i$$$), but cannot contain multi-edges (it is not possible that $$$a_i = a_j$$$ and $$$b_i = b_j$$$ for $$$i \ne j$$$). The sum of $$$n$$$ over all test cases does not exceed $$$4 \cdot 10^5$$$. Similarly, the sum of $$$m$$$ over all test cases does not exceed $$$4 \cdot 10^5$$$.

Output $$$t$$$ lines. The $$$i$$$-th line should contain an answer for the $$$i$$$-th test case: a sequence of $$$n$$$ integers from $$$-1$$$ to $$$2$$$.

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)
		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)
		for ; m > 0; m-- {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
		scc := [][]int{}
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
			}
		}
		sid := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sid[v] = i
			}
		}

		ns := len(scc)
		g2 := make([][]int, ns)
		deg := make([]int, ns)
		loop := make([]bool, ns)
		for _, e := range edges {
			if v, w := sid[e.v], sid[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				loop[v] = true
			}
		}

		ans := make([]int, n)
		for i := range ans {
			ans[i] = -1
		}
		scc0 := sid[0]
		q := []int{}
		for i, d := range deg {
			if d == 0 && i != scc0 {
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != scc0 {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, ns)
		if len(scc[scc0]) == 1 && !loop[scc0] {
			type pair struct {
				v    int
				has2 bool
			}
			q := []pair{{scc0, false}}
			ans[0] = 1
			for len(q) > 0 {
				p := q[0]
				q = q[1:]
				for _, w := range g2[p.v] {
					if p.has2 {
						cnt[w] = 2
					} else {
						cnt[w]++
					}
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !loop[w] {
						if cnt[w] > 1 {
							ans[scc[w][0]] = 2
							q = append(q, pair{w, true})
						} else {
							ans[scc[w][0]] = 1
							q = append(q, pair{w, false})
						}
					}
				}
			}
		}
		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}
func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)

		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)

		addEdge := func(v, w int) {
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}

		for i := 0; i < m; i++ {
			Fscan(in, &v, &w)
			addEdge(v, w)
		}

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}

		scc := [][]int{}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
	o:
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
				for _, u := range comp {
					for _, w := range g[u] {
						if !vis[w] {
							continue o
						}
					}
				}
			}
		}

		ans := make([]int, n)
		for _i := range ans {
			ans[_i] = -1
		}

		sccIDs := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sccIDs[v] = i
			}
		}

		g2 := make([][]int, len(scc))
		deg := make([]int, len(scc))
		cycle := make([]bool, len(scc))
		for _, e := range edges {
			if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				cycle[v] = true
			}
		}

		q := []int{}
		for i, d := range deg {
			if d == 0 && i != sccIDs[0] {
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != sccIDs[0] {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, len(scc))
		if len(scc[sccIDs[0]]) == 1 && !cycle[sccIDs[0]] {
			type pair struct {
				v    int
				has2 bool
			}
			q := []pair{{sccIDs[0], false}}
			ans[0] = 1
			for len(q) > 0 {
				p := q[0]
				q = q[1:]
				for _, w := range g2[p.v] {
					if p.has2 {
						cnt[w] = 2
					} else {
						cnt[w]++
					}
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !cycle[w] {
						if cnt[w] > 1 {
							ans[scc[w][0]] = 2
							q = append(q, pair{w,true})
						} else {
							ans[scc[w][0]] = 1
							q = append(q, pair{w,false})
						}
					}
				}
			}
		}
		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	//output := true
	//l := 1
	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)
		//if Case == 1 && n==3 && m == 1 {
		//	output=false
		//}

		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)

		addEdge := func(v, w int) {
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}

		//if !output && l <= 4599 &&4599< l+n {
		//	Fprintln(out, n,m)
		//}

		for i := 0; i < m; i++ {
			Fscan(in, &v, &w)
			addEdge(v, w)

			//if !output && l <= 4599 &&4599< l+n {
			//	Fprintln(out, v,w)
			//}
		}

		//l += n

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}

		scc := [][]int{}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
	o:
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
				for _, u := range comp {
					for _, w := range g[u] {
						if !vis[w] {
							continue o
						}
					}
				}
			}
		}

		ans := make([]int, n)
		for _i := range ans {
			ans[_i] = -1
		}

		sccIDs := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sccIDs[v] = i
			}
		}

		g2 := make([][]int, len(scc))
		deg := make([]int, len(scc))
		cycle := make([]bool, len(scc))
		for _, e := range edges {
			if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				cycle[v] = true
			}
		}

		q := []int{}
		for i, d := range deg {
			if d == 0 && i != sccIDs[0] {
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != sccIDs[0] {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, len(scc))
		if len(scc[sccIDs[0]]) == 1 && !cycle[sccIDs[0]] {
			type pair struct {
				v    int
				has2 bool
			}
			q := []pair{{sccIDs[0], false}}
			ans[0] = 1
			for len(q) > 0 {
				p := q[0]
				q = q[1:]
				for _, w := range g2[p.v] {
					cnt[w]++
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !cycle[w] {
						if p.has2 || cnt[w] > 1 {
							ans[scc[w][0]] = 2
							q = append(q, pair{w,true})
						} else {
							ans[scc[w][0]] = 1
							q = append(q, pair{w,false})
						}
					}
				}
			}
		}

		//if output {
		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
		//}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main
import (
  "fmt"
  "bufio"
  "os"
  "strconv"
)
/*
题意：含自环、不含重边的有向图中，求节点1到每个点的路径数量（超过1且有限和无限分别返回2和-1）。
*/
var sc *bufio.Scanner
func I()int{sc.Scan();v,_:=strconv.Atoi(sc.Text());return v}
func main(){
  inp,out:=os.Stdin,os.Stdout
  sc=bufio.NewScanner(inp);W:=bufio.NewWriter(out);sc.Split(bufio.ScanWords);defer W.Flush()

  var dp []int
  var vis []bool
  var g map[int][]int
  /*
  vis数组的作用是发现环。cycle参数用来在发现环后，继续标记环内节点（dp[u]=-1）。
  u的所有子节点访问完毕后将u标记为“未访问”，因为后续可能新环穿过u，需要借道u。
  */
  var f func(int,bool)
  f=func(u int,cycle bool){
    if cycle{dp[u]=-1}else if dp[u]<2{dp[u]++;vis[u]=true}
    for _,v:=range g[u]{
      if dp[v]!=-1{
        if vis[v]{f(v,true)}else if dp[v]!=2||dp[v]==2&&cycle{f(v,cycle)}
      }
    }
    vis[u]=false
  }
  t:=I()
  for i:=0;i<t;i++{
    n,m:=I(),I();dp,vis,g=make([]int,n+1),make([]bool,n+1),map[int][]int{}
    for i:=0;i<m;i++{u,v:=I(),I();g[u]=append(g[u],v)}
    f(1,false)
    for u:=1;u<n+1;u++{fmt.Fprint(W,dp[u]," ")}
    fmt.Fprintln(W)
  }
}

package main
import (
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc *bufio.Scanner
func I()int{sc.Scan();v,_:=strconv.Atoi(sc.Text());return v}
func main(){
  inp,out:=os.Stdin,os.Stdout
  sc=bufio.NewScanner(inp);W:=bufio.NewWriter(out);sc.Split(bufio.ScanWords);defer W.Flush()

  var dp,vis []int
  var g map[int][]int
  var f func(int,int)
  f=func(u,V int){
    if V>0{dp[u]=-1}else if dp[u]<2{dp[u]++;vis[u]=1}
    for _,v:=range g[u]{
      if dp[v]!=-1{
        if vis[v]>0{f(v,1)}else if dp[v]!=2 || dp[v]==2&&V>0{f(v,V)}
      }
    }
    vis[u]=0
  }
  t:=I()
  for i:=0;i<t;i++{
    n,m:=I(),I();dp,vis,g=make([]int,n+1),make([]int,n+1),map[int][]int{}
    for i:=0;i<m;i++{u,v:=I(),I();g[u]=append(g[u],v)}
    f(1,0)
    for u:=1;u<n+1;u++{fmt.Fprint(W,dp[u]," ")}
    fmt.Fprintln(W)
  }
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
output := true
	l := 1
	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)
		if Case == 1 && n==3 && m == 1 {
			output=false
		}

		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)

		addEdge := func(v, w int) {
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}

		if !output && l <= 4599 &&4599< l+n {
			Fprintln(out, n,m)
		}

		for i := 0; i < m; i++ {
			Fscan(in, &v, &w)
			addEdge(v, w)

			if !output && l <= 4599 &&4599< l+n {
				Fprintln(out, v,w)
			}
		}

		l+=n

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}

		scc := [][]int{}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
	o:
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
				for _, u := range comp {
					for _, w := range g[u] {
						if !vis[w] {
							continue o
						}
					}
				}
			}
		}

		ans := make([]int, n)
		for _i := range ans {
			ans[_i] = -1
		}

		sccIDs := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sccIDs[v] = i
			}
		}

		g2 := make([][]int, len(scc))
		deg := make([]int, len(scc))
		cycle := make([]bool, len(scc))
		for _, e := range edges {
			if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				cycle[v] = true
			}
		}

		q := []int{}
		for i, d := range deg {
			if d == 0 && i != sccIDs[0] {
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != sccIDs[0] {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, len(scc))
		if len(scc[sccIDs[0]]) == 1 && !cycle[sccIDs[0]] {
			q = []int{sccIDs[0]}
			ans[0] = 1
			for len(q) > 0 {
				v := q[0]
				q = q[1:]
				for _, w := range g2[v] {
					cnt[w]++
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !cycle[w] {
						q = append(q, w)
						if cnt[w] > 1 {
							ans[scc[w][0]] = 2
						} else {
							ans[scc[w][0]] = 1
						}
					}
				}
			}
		}

		if output {
			for _, v := range ans {
				Fprint(out, v, " ")
			}
			Fprintln(out)
		}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	l := 1
	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)
		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)

		addEdge := func(v, w int) {
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}

		if l <= 4599 &&4599< l+n {
			Fprintln(out, n,m)
		}

		for i := 0; i < m; i++ {
			Fscan(in, &v, &w)
			addEdge(v, w)

			if l <= 4599 &&4599< l+n {
				Fprintln(out, v,w)
			}
		}

		l+=n

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}

		scc := [][]int{}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
	o:
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
				for _, u := range comp {
					for _, w := range g[u] {
						if !vis[w] {
							continue o
						}
					}
				}
			}
		}

		ans := make([]int, n)
		for _i := range ans {
			ans[_i] = -1
		}

		sccIDs := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sccIDs[v] = i
			}
		}

		g2 := make([][]int, len(scc))
		deg := make([]int, len(scc))
		cycle := make([]bool, len(scc))
		for _, e := range edges {
			if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				cycle[v] = true
			}
		}

		q := []int{}
		for i, d := range deg {
			if d == 0 && i != sccIDs[0] {
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != sccIDs[0] {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, len(scc))
		if len(scc[sccIDs[0]]) == 1 && !cycle[sccIDs[0]] {
			q = []int{sccIDs[0]}
			ans[0] = 1
			for len(q) > 0 {
				v := q[0]
				q = q[1:]
				for _, w := range g2[v] {
					cnt[w]++
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !cycle[w] {
						q = append(q, w)
						if cnt[w] > 1 {
							ans[scc[w][0]] = 2
						} else {
							ans[scc[w][0]] = 1
						}
					}
				}
			}
		}

		//for _, v := range ans {
		//	Fprint(out, v, " ")
		//}
		//Fprintln(out)
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n, m, v, w int
		Fscan(in, &n, &m)
		type edge struct{ v, w int }
		edges := make([]edge, 0, m)
		g := make([][]int, n)
		rg := make([][]int, n)

		addEdge := func(v, w int) {
			v--
			w--
			g[v] = append(g[v], w)
			rg[w] = append(rg[w], v)
			edges = append(edges, edge{v, w})
		}
		for i := 0; i < m; i++ {
			Fscan(in, &v, &w)
			addEdge(v, w)
		}

		vs := make([]int, 0, n)
		vis := make([]bool, n)
		var dfs func(int)
		dfs = func(v int) {
			vis[v] = true
			for _, w := range g[v] {
				if !vis[w] {
					dfs(w)
				}
			}
			vs = append(vs, v)
		}
		for i, b := range vis {
			if !b {
				dfs(i)
			}
		}

		scc := [][]int{}
		vis = make([]bool, n)
		var comp []int
		var rdfs func(int)
		rdfs = func(v int) {
			vis[v] = true
			comp = append(comp, v)
			for _, w := range rg[v] {
				if !vis[w] {
					rdfs(w)
				}
			}
		}
	o:
		for i := n - 1; i >= 0; i-- {
			if v := vs[i]; !vis[v] {
				comp = []int{}
				rdfs(v)
				scc = append(scc, comp)
				for _, u := range comp {
					for _, w := range g[u] {
						if !vis[w] {
							continue o
						}
					}
				}
			}
		}

		ans := make([]int, n)
		for _i := range ans {
			ans[_i] = -1
		}
		//if len(scc) == 1 {
		//	if n == 1 && m == 0{
		//		ans[0] = 1
		//	} else {
		//		for _, v := range ans {
		//			Fprint(out, v, " ")
		//		}
		//		Fprintln(out)
		//	}
		//	return
		//}

		sccIDs := make([]int, n)
		for i, cp := range scc {
			for _, v := range cp {
				sccIDs[v] = i
			}
		}

		g2 := make([][]int, len(scc))
		deg := make([]int, len(scc))
		cycle := make([]bool, len(scc))
		for _, e := range edges {
			if v, w := sccIDs[e.v], sccIDs[e.w]; v != w {
				g2[v] = append(g2[v], w)
				deg[w]++
			} else {
				cycle[v] = true
			}
		}

		q := []int{}
		for i, d := range deg {
			if d == 0 && i != sccIDs[0]{
				q = append(q, i)
			}
		}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, v := range scc[v] {
				ans[v] = 0
			}
			for _, w := range g2[v] {
				if deg[w]--; deg[w] == 0 && w != sccIDs[0] {
					q = append(q, w)
				}
			}
		}

		cnt := make([]int, len(scc))
		if len(scc[sccIDs[0]]) == 1 && !cycle[sccIDs[0]] {
			q = []int{sccIDs[0]}
			ans[0] = 1
			for len(q) > 0 {
				v := q[0]
				q = q[1:]
				for _, w := range g2[v] {
					cnt[w]++
					if deg[w]--; deg[w] == 0 && len(scc[w]) == 1 && !cycle[w] {
						q = append(q, w)
						if cnt[w] > 1 {
							ans[scc[w][0]] = 2
						} else {
							ans[scc[w][0]] = 1
						}
					}
				}
			}
		}

		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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


Marin wants you to count number of permutations that are beautiful. A beautiful permutation of length $$$n$$$ is a permutation that has the following property: $$$$$$ \gcd (1 \cdot p_1, \, 2 \cdot p_2, \, \dots, \, n \cdot p_n) > 1, $$$$$$ where $$$\gcd$$$ is the greatest common divisor.A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3, 4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n \le 10^3$$$).

For each test case, print one integer — number of beautiful permutations. Because the answer can be very big, please print the answer modulo $$$998\,244\,353$$$.

NoteIn first test case, we only have one permutation which is $$$[1]$$$ but it is not beautiful because $$$\gcd(1 \cdot 1) = 1$$$.In second test case, we only have one beautiful permutation which is $$$[2, 1]$$$ because $$$\gcd(1 \cdot 2, 2 \cdot 1) = 2$$$.

package main

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

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

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

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

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

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

/**
Run solve the problem CF1658B
Date: 2/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1658/B
Problem: CF1658B
**/
func (in *CF1658B) Run() {
	const d = int64(998244353)
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		if n%2 == 0 {
			n /= 2
			ans := int64(1)
			for n > 1 {
				ans = ((n * n) % d * ans % d) % d
				n--
			}
			fmt.Println(ans)
		} else {
			fmt.Println(0)
		}
	}
}

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

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

package main

import "fmt"

func main() {
	var f [505]int64
	f[0] = 1
	for i := 1; i < 505; i++ {
		f[i] = f[i-1] * int64(i) % 998244353
	}
	var T, n int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		fmt.Scan(&n)
		if n%2 == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(f[n/2] * f[n/2] % 998244353)
		}
	}
}

package main

import "fmt"

func main() {
	M := int64(998244353)
	N := 1000

	f := make([]int64, N+1)
	f[0] = 1

	for i := 1; i <= N; i++ {
		f[i] = f[i-1] * int64(i) % M
	}

	var t int
	fmt.Scan(&t)

	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)
		// n = t
		// fmt.Print(n, " ")
		if n%2 == 0 {
			fmt.Println(f[n/2] * f[n/2] % M)
		} else {
			fmt.Println(0)
		}
	}
}

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}
func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	return n
}
func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

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

func main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	mod := int64(998244353)
	Jie := make([]int64, 1001)
	Jie[1] = 1
	for i := 2; i <= 1000; i++ {
		Jie[i] = Jie[i-1] * int64(i) % mod
	}
	for t > 0 {
		t--
		n := readInt(ip)
		if n%2 == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(int64(Jie[n/2] % mod * Jie[n/2] % mod))
		}
	}
}

package main

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

const mod = 998244353

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int64
	fmt.Fscan(in,&n)
	if n % 2 != 0{
		fmt.Fprintln(out,0)
		return
	}
	ans := int64(1)
	mul := n / 2
	for i := int64(1);i <= mul;i++{
		ans *= i
		ans %= mod
	}
	ans *= ans
	ans %= mod
	fmt.Fprintln(out,ans)
}

func abs(a,b int)int{
	if a > b{
		return a - b
	}
	return b - a
}
func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int)int{
	if a > b{
		return a
	}
	return b
}
func min(a,b int)int{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

import (
	"fmt"
)

var mod int64=998244353
func fact(n int64) int64{
   if n==1 {
	   return n
   }
   return (n%mod*fact(n-1)%mod)%mod
}

func main(){
  var (
	  a int64
	  b int64
  )
  for fmt.Scan(&a);a>0;a--{
     fmt.Scan(&b)
	 if b%2==1 {
		 fmt.Println(0)
	 }else {
		 ans := ((fact(b/2)%mod)*(fact(b/2)%mod))%mod
		 fmt.Println(ans)
	 }
  }
}

package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		n := 0
		fmt.Fscan(reader, &n)

		// p := make([]int, n)
		// for i := range p {
		// 	fmt.Fscan(reader, &p[i])
		// }

		fmt.Fprintln(writter, solve(n))

		t--
	}

	//commonServices.Solve(1000)
}

func solve(n int) int64 {
	if n%2 == 0 {
		return factorial(n / 2)
	} else {
		return 0
	}
}

func factorial(n int) int64 {

	result := int64(1)

	for i := 2; i <= n; i++ {
		result *= (int64(i) * int64(i))

		if result >= 998244353 {
			result = result % 998244353
		}
	}

	return int64(result)
}

package main

import (
	"fmt"
)

var N int = 1005
var MOD int64 = 998244353
var fact []int64 = make([]int64, N)

func calc() {
	fact[0] = 1
	for i := 1; i < N; i++ {
		fact[i] = fact[i-1] * int64(i) % MOD
	}
}

func multiply(x, y int64) int64 {
	return ((x % MOD) * (y % MOD)) % MOD
}

func main() {
	calc()

	var T, n int
	fmt.Scan(&T)

	for ; T > 0; T-- {
		fmt.Scan(&n)
		if n%2 == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(multiply(fact[n/2], fact[n/2]))
		}
	}
}

package main

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

const MOD int = 998244353

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

	var T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		var n int
		Fscan(in, &n)
		if n & 1 == 1 {
			Fprintln(out, 0)
			continue
		}
		var ans int64 = 1
		for i := 1; i <= n / 2; i++ {
			ans *= int64(i*i%MOD)
			ans %= int64(MOD)
		}
		Fprintln(out, ans)
	}
}

package main

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

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

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

		if n%2 != 0 {
			fmt.Fprintln(out, 0)
		} else {
			tot := int64(1)
			for i := int64(1); i <= n/2; i++ {
				tot = (tot * i) % 998244353
			}

			fmt.Fprintln(out, (tot*tot)%998244353)
		}
	}
}

// generated by 1e9y at 27-03-2022
// template version: 2022-01-11

package main

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

// 1-2-3  1 4 9
// 1-3-2 1 6 6
// 3-2-1 3 4 3

// 1 2 3 4  -------
// 4-3-2-1  4 6 6 4
// 4-1-2-3  4 2 6 8
// 4-1-3-2  4 2 9 8 -
// 4-2-1-3  4 4 3

// 2 1
// 4 4 2*2 4! = 24
// 6 36 6*6 2*2*3*3 6! = 720 360

// n/2! * n/2!
// 3! * 3! = 36
// 1 2 3 1 2 3
// 1 1 2 2 3 3

// 0000.A
func solve(n int) uint64 {
	if n%2 == 1 {
		return 0
	}
	var f uint64
	f = 1
	for i := 1; i <= n/2; i++ {
		f *= uint64(i)
		f *= uint64(i)
		f = f % 998244353
	}
	return f
}

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

	t := ReadInt(in)
	for i := 0; i < t; i++ {
		// here goes input reading
		n := ReadInt(in)
		Output(solve(n))
	}
}

// helpers for convenient input reading

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

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

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

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

package main

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

/*
1
6
*/

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

	if n%2 != 0 {
		fmt.Fprintln(writer, 0)
	} else {
		num := int64(1)

		for i := 1; i < n; i++ {
			num *= int64((n - i + 2) / 2)
			num %= 998_244_353
		}

		fmt.Fprintln(writer, num)
	}
}

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

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

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

const maxUint = ^uint(0)

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

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

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

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

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

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

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

	return minNumIdx
}

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

	return maxNumIdx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

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

const (
	INF = 3e5 + 10
)

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

	var t int

	ans := make([]int64, 3001)
	res := int64(1)
	for i := int64(1); i <= 500; i++ {
		res = res * i % 998244353
		ans[i<<1] = (res * res) % 998244353
	}

	Fscan(in, &t)

	for i := 0; i < t; i++ {
		var x int
		Fscan(in, &x)
		Fprintln(out, ans[x])
	}

}

package main

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

const MOD = 998244353

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

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

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

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

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

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

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

var fv = []int64{1}

func fact(n int64) int64 {
	for i := int64(len(fv)); i <= n; i++ {
		fv = append(fv, (fv[i-1]*i)%MOD)
	}
	return fv[n]
}

func sol(n int64) int64 {
	if n&1 == 1 {
		return 0
	}
	d := fact(n / 2)
	return (d * d) % MOD
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1658B
Date: 2/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1658/B
Problem: CF1658B
**/
func (in *CF1658B) Run() {
	const d = 998244353
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		if n%2 == 0 {
			n /= 2
			ans := 1
			for n > 1 {
				ans = ((n * n) % d * ans % d) % d
				n--
			}
			fmt.Println(ans)
		} else {
			fmt.Println(0)
		}
	}
}

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

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

package main

import "fmt"

func main() {
	var f [505]int
	f[0] = 1
	for i := 1; i < 505; i++ {
		f[i] = f[i-1] * i % 998244353
	}
	var T, n int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		fmt.Scan(&n)
		if n%2 == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(f[n/2] * f[n/2] % 998244353)
		}
	}
}

package main

import "fmt"

func main() {
	M := 998244353
	N := 1000

	f := make([]int, N+1)
	f[0] = 1

	for i := 1; i <= N; i++ {
		f[i] = f[i-1] * i % M
	}

	var t int
	fmt.Scan(&t)

	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)
		if n%2 == 0 {
			fmt.Println(f[n/2] * f[n/2] % M)
		} else {
			fmt.Println(0)
		}
	}
}

package main

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}
func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	return n
}
func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

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

func main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	mod := 998244353
	Jie := make([]int, 1001)
	Jie[1] = 1
	for i := 2; i <= 1000; i++ {
		Jie[i] = Jie[i-1] * i % mod
	}
	for t > 0 {
		t--
		n := readInt(ip)
		if n%2 == 1 {
			fmt.Println(0)
		} else {
			fmt.Println(Jie[n/2] % mod * Jie[n/2] % mod)
		}
	}
}


Recently Vova found $$$n$$$ candy wrappers. He remembers that he bought $$$x$$$ candies during the first day, $$$2x$$$ candies during the second day, $$$4x$$$ candies during the third day, $$$\dots$$$, $$$2^{k-1} x$$$ candies during the $$$k$$$-th day. But there is an issue: Vova remembers neither $$$x$$$ nor $$$k$$$ but he is sure that $$$x$$$ and $$$k$$$ are positive integers and $$$k > 1$$$.Vova will be satisfied if you tell him any positive integer $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$. It is guaranteed that at least one solution exists. Note that $$$k > 1$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$3 \le n \le 10^9$$$) — the number of candy wrappers Vova found. It is guaranteed that there is some positive integer $$$x$$$ and integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$.

Print one integer — any positive integer value of $$$x$$$ so there is an integer $$$k>1$$$ that $$$x + 2x + 4x + \dots + 2^{k-1} x = n$$$.

NoteIn the first test case of the example, one of the possible answers is $$$x=1, k=2$$$. Then $$$1 \cdot 1 + 2 \cdot 1$$$ equals $$$n=3$$$.In the second test case of the example, one of the possible answers is $$$x=2, k=2$$$. Then $$$1 \cdot 2 + 2 \cdot 2$$$ equals $$$n=6$$$.In the third test case of the example, one of the possible answers is $$$x=1, k=3$$$. Then $$$1 \cdot 1 + 2 \cdot 1 + 4 \cdot 1$$$ equals $$$n=7$$$.In the fourth test case of the example, one of the possible answers is $$$x=7, k=2$$$. Then $$$1 \cdot 7 + 2 \cdot 7$$$ equals $$$n=21$$$.In the fifth test case of the example, one of the possible answers is $$$x=4, k=3$$$. Then $$$1 \cdot 4 + 2 \cdot 4 + 4 \cdot 4$$$ equals $$$n=28$$$.

package main

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

func calc(n int) int {
	var x float64
	for k := 2; k < math.MaxInt32; k++ {
		base := 1 << k - 1
		x = float64(n) / float64(base)
		if x == math.Trunc(x) {
			return int(x)
		}
	}
	return -1
}

func run(in io.Reader, out io.Writer) {
	scanner := bufio.NewScanner(in)
	var answer []int
	var n int
	i := 0
	for scanner.Scan() {
		x := scanner.Text()
		if n == 0 {
			n, _ = strconv.Atoi(x)
			answer = make([]int, n)
		} else {
			v, _ := strconv.Atoi(x)
			answer[i] = v
			i++
		}
	}

	for _, n := range answer {
		fmt.Println(calc(n))
	}
}

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

package main

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

func main() {

	rd := bufio.NewReader(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)

	var i, n, t, k int

	fmt.Fscanf(rd, "%d\n", &t)

	for i = 0; i < t; i++ {
		fmt.Fscanf(rd, "%d\n", &n)
		k = 4
		for {
			if n%(k-1) == 0 {
				break
			}
			k *= 2
		}
		fmt.Fprintf(wr, "%d\n", n/(k-1))
	}

	wr.Flush()
}

package main

import "fmt"

func main() {
	s := []uint64{1}
	i := uint64(2)
	for true {
		s = append(s, s[len(s)-1]+i)
		i *= 2
		if i > 10e9 {
			break
		}
	}
	fmt.Scanln(&i)
	for ; i > 0; i-- {
		var n uint64
		fmt.Scanln(&n)
		for _, val := range s[1:] {
			if n%val == 0 {
				fmt.Println(n / val)
				break
			}
		}
	}
}

package main

import "fmt"

var tot = 0
var n = 0

func main() {
	_, _ = fmt.Scan(&tot)
	for i := 0; i < tot; i++ {
		_, _ = fmt.Scan(&n)
		exp := 2
		for j := 0; j < 32; j ++ {
			exp = exp * 2
			if n % (exp - 1) == 0 {
				fmt.Println(n / (exp - 1))
				break
			}
		}

	}
}

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		P(solv(n))
	}
	close(O)
	oWg.Wait()
}

func solv(n int) int64 {
	k := 2
	for {
		gpSum := math.Pow(float64(2), float64(k)) - 1
		if gpSum > float64(n) {
			break
		}
		if rem := int64(n) % int64(gpSum); rem == 0 {
			return int64(n) / int64(gpSum)
		}
		k++
	}
	return 0
}

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

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

func init() {
	P = fmt.Println

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

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

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

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

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

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

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

package main

import (
	"fmt"
	"math"
	"strconv"
)

func solve(is []int64) {
	var p int64
	var k float64
	for _, v := range is {
		k = 2
		p = 1
		for {
			p = int64(math.Pow(2, k)) - 1
			if v%p == 0 {
				fmt.Println(v / p)
				break
			}
			k++
		}
	}
}

func main() {
	var n int
	_, err := fmt.Scan(&n)
	if err != nil {
		panic(err)
	}
	is := make([]int64, 0, n)
	var tmp string
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		p, err := strconv.ParseInt(tmp, 10, 0)
		if err != nil {
			panic(err)
		}
		is = append(is, p)
	}
	solve(is)
}

package main

import (
	"fmt"
)

var pre []int = make([]int,32)
func solve(n int) {
	for i := 2;i<32;i++{
		var result = n/pre[i]
		if n == result * pre[i]{
			fmt.Println(result)
			break
		}
	}
}

func doPre(){
	pre[0] = 1
	pre[1] = 2
	for i := 2;i<32;i++{
		pre[i] = pre[i-1] * 2
	}
	for i := 2;i<32;i++{
		pre[i] = pre[i] -1
	}
}

func main() {
	var n int
	doPre()
	fmt.Scanf("%d\n",&n)
	for i:=0;i<n;i++{
		var x int
		fmt.Scanf("%d\n",&x)
		solve(x)
	}
}

package main

import "fmt"

func main() {
	var t int
	var n, k int64
	var limit int64 = 1000000000
	fmt.Scan(&t)
	var muls = make([]int64, 0, 33)
	for k = 4; k <= limit; k <<= 1 {
		muls = append(muls, k-1)
	}

	for i := 0; i < t; i++ {
		fmt.Scan(&n)
		for _, mul := range muls {
			if n%mul == 0 {
				fmt.Println(n / mul)
				break
			}
		}
	}
}

package main

import (
	"fmt"
)

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

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

func max(arr []int) (max int) {
	max = arr[0]
	for _, val := range arr {
		if val > max {
			max = val
		}
	}
	return max
}

var mod int = 1000000007

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

package main

import "fmt"

func pow(b, e int64) int64 {
	if e == 0 {
		return 1
	} else {
		return b * pow(b, e-1)
	}
}
func findx(n int64) int64 {
	var i int64 = 2
	//fmt.Printf("-------------------s----------------")
	for {
		gpsum := pow(2, i) - 1
		//fmt.Println(gpsum)
		if n%gpsum == 0 {
			//fmt.Printf("--------------e---------------------")
			return n / gpsum
		}
		i++
	}
	return 0
}

func main() {
	var (
		test int
		n    int64
	)
	fmt.Scanf("%d\n", &test)
	for i := 0; i < test; i++ {
		fmt.Scanf("%d\n", &n)
		fmt.Println(findx(n))
	}
}

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

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)
		x := 3
		for j := 4; n%x != 0; j *= 2 {
			x += j
		}
		fmt.Fprintln(w, n/x)
	}

}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

// parse positive int from byte slice
func parseInt(a []byte, start int) (ans int) {
	for i := start; i < len(a) && a[i] >= '0' && a[i] <= '9'; i += 1 {
		// skip overflow check
		ans = 10*ans + int(a[i]-'0')
	}
	return ans
}

func findX(mersennes []int, n int) int {
	for i := 0; i < len(mersennes); i += 1 {
		if n%mersennes[i] == 0 {
			return n / mersennes[i]
		}
	}
	panic("unexpected behaviour")
}

// https://codeforces.com/problemset/problem/1343/A
// комментарии к решению
// Можно заметить, что уравнение приводиться к:
// x + 2 * x + 4 * x +..+ 2^(k−1) * x = n =>
// (2^k - 1) * x = n
// где коэффициент перед х не что иное как числа Мерсенна, которых до 10^9 не много.
// Выписываем их и итерируемся по ним для каждой строки, пока не найдём целый х:
// х = n / (2^k - 1)
func taskSolution(a []byte, t int) string {
	// Mersenne numbers
	mersennes := []int{
		3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191,
		16383, 32767, 65535, 131071, 262143, 524287, 1048575,
		2097151, 4194303, 8388607, 16777215, 33554431, 67108863,
		134217727, 268435455, 536870911,
	}
	intStart := 0
	ans := []int{}
	for i := 0; i < t; i += 1 {
		// find next
		// skip len check, because t value control number count
		for !(a[intStart] >= '0' && a[intStart] <= '9') {
			intStart += 1
		}
		cur := parseInt(a, intStart)
		ans = append(ans, findX(mersennes, cur))
		// skip parsed
		for a[intStart] >= '0' && a[intStart] <= '9' {
			intStart += 1
		}
	}
	res := fmt.Sprint(ans)
	return strings.Replace(res[1:len(res)-1], " ", "\n", len(ans)-1)
}

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

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw, t))
}

// Author: sighduck
// URL: https://codeforces.com/contest/1343/problem/A

package main

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

func Solve(n int) int {
	for i := 2; i < 32; i++ {
		c := 1<<i - 1
		if n%c == 0 {
			return n / c
		}
	}
	return -1
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fprintf(writer, "%d\n", Solve(n))
	}
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	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 (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		curr := int64((1 << 1) + 1)
		for n % curr != 0 {
			curr = (curr << 1) + 1
		}
		writer.Printf("%d\n", n / curr)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanln(&t)
	for ; t>0; t-- {
		var n int
		fmt.Scanln(&n)
		var sum int = 1
		for k:=2; sum<=n; k++ {
			sum += 1<<(k-1)
			if n%sum == 0 {
				fmt.Println(n/sum)
				break
			}
		}
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int64
		fmt.Fscan(in, &n)
		k := int64(2)
		for ; n%(1<<k-1) != 0; k++ {
		}
		fmt.Fprintln(out, n/(1<<k-1))
	}
}

package main

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

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] != ' ' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(scanner *bufio.Scanner) (a int) {
	scanner.Scan()
	readInt(scanner.Bytes(), 0, &a)
	return
}

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

func readNNums(scanner *bufio.Scanner, n int) []int {
	res := make([]int, n)
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
	return res
}

func fillNNums(scanner *bufio.Scanner, n int, res []int) {
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
}

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

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

	return i
}

func readInt64(bytes []byte, from int, val *int64) int {
	i := from
	var tmp int64
	for i < len(bytes) && bytes[i] != ' ' {
		tmp = tmp*10 + int64(bytes[i]-'0')
		i++
	}
	*val = tmp
	return i
}

func readNInt64Nums(scanner *bufio.Scanner, n int) []int64 {
	res := make([]int64, n)
	x := -1
	scanner.Scan()
	for i := 0; i < n; i++ {
		x = readInt64(scanner.Bytes(), x+1, &res[i])
	}
	return res
}

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

	tc := readNum(scanner)

	for tc > 0 {
		tc--
		n := readNum(scanner)

		fmt.Println(solve(n))
	}
}

func solve(n int) int {

	for k := 2; k < 30; k++ {
		y := 1<<k - 1
		if n%y == 0 {
			return n / y
		}
	}

	return 1
}

func isPower2(x int64) bool {
	return x&(x-1) == 0
}

package main

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

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] != ' ' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(scanner *bufio.Scanner) (a int) {
	scanner.Scan()
	readInt(scanner.Bytes(), 0, &a)
	return
}

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

func readNNums(scanner *bufio.Scanner, n int) []int {
	res := make([]int, n)
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
	return res
}

func fillNNums(scanner *bufio.Scanner, n int, res []int) {
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
}

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

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

	return i
}

func readInt64(bytes []byte, from int, val *int64) int {
	i := from
	var tmp int64
	for i < len(bytes) && bytes[i] != ' ' {
		tmp = tmp*10 + int64(bytes[i]-'0')
		i++
	}
	*val = tmp
	return i
}

func readNInt64Nums(scanner *bufio.Scanner, n int) []int64 {
	res := make([]int64, n)
	x := -1
	scanner.Scan()
	for i := 0; i < n; i++ {
		x = readInt64(scanner.Bytes(), x+1, &res[i])
	}
	return res
}

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

	tc := readNum(scanner)

	for tc > 0 {
		tc--
		n := readNum(scanner)

		fmt.Println(solve(n))
	}
}

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

	var x int64 = 1
	for x*x <= N {
		if N%x != 0 {
			x++
			continue
		}

		y := N / x

		if isPower2(y+1) && y+1 > 2 {
			return int(x)
		}

		if isPower2(x+1) && x+1 > 2 {
			return int(y)
		}
		x++
	}

	return 1
}

func isPower2(x int64) bool {
	return x&(x-1) == 0
}

// https://codeforces.com/contest/1343/problem/A

package main

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

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

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	for i:=0;i<n;i++ {
		var t int
		scanf("%d\n", &t)
		sum, ct := 1, 0
		for {
			ct++
			sum += (1<<ct)
			if t%sum==0 {
				printf("%d\n", t/sum)
				break
			}
		}
	}
}

package main

import (
	"fmt"
	"math"
)

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

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

		for k := 2; k < n; k++ {
			kk := int(math.Pow(2, float64(k))) - 1
			if n%kk == 0 {
				fmt.Printf("%d\n", n/kk)
				break
			}
		}
	}
}

// https://acm.timus.ru/problem.aspx?space=1&num=1741
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

const (
	MOD = 1e9 + 7
)

type (

)

func main () {
	var (
		T, n int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Fscan(input, &n)
		ans := 3
		for (n % ans) != 0 {
			ans = ans << 1 + 1
		}
		fmt.Println(n / ans)
	}
}

package main

import "fmt"

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

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

		k := 3
		for k <= n {
			if n % k == 0 {
				fmt.Println(n / k)
				break
			}

			k = 2*k + 1
		}
	}
}

package main

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

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

    var t int
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        var n, x int
        fmt.Fscan(in, &n)
        for k := 4; k - 1 <= n ; k *= 2 {
            if n % (k - 1) == 0 {
                x = n / (k - 1)
                break
            }
        }
        fmt.Fprintln(out, x)
    }
    out.Flush()
}

package main

import (
	"fmt"
	"math"
)

var b []int64

func ini() {
	var cnt int64 = 4
	for cnt < math.MaxInt32 {
		b = append(b, cnt-1)
		cnt *= 2
	}
}

func main() {
	var i, t, n, x int64
	fmt.Scan(&t)
	ini()
	for i = 0; i < t; i++ {
		fmt.Scan(&n)
		for _, v := range b {
			if n%v == 0 {
				x = n / v
				break
			}
		}
		fmt.Println(x)
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x, y, a, b, ans int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y, &a, &b)
		if a*2 <= b {
			ans = int(math.Abs(float64(x))+math.Abs(float64(y))) * a
		} else {
			if x > 0 && y > 0 {
				tmp := int(math.Min(float64(x), float64(y)))
				tmp2 := int(math.Max(float64(x), float64(y))) - tmp
				ans = tmp*b + tmp2*a
			}else if x < 0 && y < 0{
				tmp := -int(math.Max(float64(x), float64(y)))
				tmp2 := -int(math.Min(float64(x), float64(y))) - tmp
				ans = tmp*b + tmp2*a
			}else {
				ans = int(math.Abs(float64(x))+math.Abs(float64(y))) * a
			}
		}
		fmt.Println(ans)
	}
}

package main

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

func calc(n int) int {
	var x float64
	for k := 2; k < 10; k++ {
		base := 1 << k - 1
		x = float64(n) / float64(base)
		if x == math.Trunc(x) {
			return int(x)
		}
	}
	return -1
}

func run(in io.Reader, out io.Writer) {
	scanner := bufio.NewScanner(in)
	var answer []int
	var n int
	i := 0
	for scanner.Scan() {
		x := scanner.Text()
		if n == 0 {
			n, _ = strconv.Atoi(x)
			answer = make([]int, n)
		} else {
			v, _ := strconv.Atoi(x)
			answer[i] = v
			i++
		}
	}

	for _, n := range answer {
		fmt.Println(calc(n))
	}
}

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

package main

import "fmt"

var tot = 0
var n = 0

func main() {
	_, _ = fmt.Scanf("%d", &tot)
	for i := 0; i < tot; i++ {
		_, _ = fmt.Scanf("%d", &n)
		exp := 2
		for j := 0; j < 32; j ++ {
			exp = exp * 2
			if n % (exp - 1) == 0 {
				fmt.Println(n / (exp - 1))
				break
			}
		}
	}
}

package main

import (
	"fmt"
)

var pre []int = make([]int,32)
func solve(n int) {
	for i := 2;i<32;i++{
		var result = n/pre[i]
		if n == result * pre[i]{
			fmt.Println(result)
			break
		}
	}
}

func doPre(){
	pre[0] = 1
	pre[1] = 2
	for i := 2;i<32;i++{
		pre[i] = pre[i-1] * 2
	}
	for i := 2;i<32;i++{
		pre[i] = pre[i] -1
	}
}

func main() {
	var n int
	doPre()
	fmt.Scanf("%d",&n)
	for i:=0;i<n;i++{
		var x int
		fmt.Scanf("%d",&x)
		solve(x)
	}
}

package main

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

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] != ' ' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(scanner *bufio.Scanner) (a int) {
	scanner.Scan()
	readInt(scanner.Bytes(), 0, &a)
	return
}

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

func readNNums(scanner *bufio.Scanner, n int) []int {
	res := make([]int, n)
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
	return res
}

func fillNNums(scanner *bufio.Scanner, n int, res []int) {
	x := 0
	scanner.Scan()
	for i := 0; i < n; i++ {
		for x < len(scanner.Bytes()) && scanner.Bytes()[x] == ' ' {
			x++
		}
		x = readInt(scanner.Bytes(), x, &res[i])
	}
}

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

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

	return i
}

func readInt64(bytes []byte, from int, val *int64) int {
	i := from
	var tmp int64
	for i < len(bytes) && bytes[i] != ' ' {
		tmp = tmp*10 + int64(bytes[i]-'0')
		i++
	}
	*val = tmp
	return i
}

func readNInt64Nums(scanner *bufio.Scanner, n int) []int64 {
	res := make([]int64, n)
	x := -1
	scanner.Scan()
	for i := 0; i < n; i++ {
		x = readInt64(scanner.Bytes(), x+1, &res[i])
	}
	return res
}

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

	tc := readNum(scanner)

	for tc > 0 {
		tc--
		n := readNum(scanner)

		fmt.Println(solve(n))
	}
}

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

	var x int64 = 1
	for x*x <= N {
		if N%x != 0 {
			continue
		}

		y := N / x

		if isPower2(y + 1) {
			return int(x)
		}

		if isPower2(x + 1) {
			return int(y)
		}
		x++
	}

	return 1
}

func isPower2(x int64) bool {
	return x&(x-1) == 0
}


DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket numbered h(xi), where h(x) is the hash function. In this problem we will assume, that h(x) = x mod p. Operation a mod b denotes taking a remainder after division a by b.However, each bucket can contain no more than one element. If DZY wants to insert an number into a bucket which is already filled, we say a "conflict" happens. Suppose the first conflict happens right after the i-th insertion, you should output i. If no conflict happens, just output -1.

The first line contains two integers, p and n (2 ≤ p, n ≤ 300). Then n lines follow. The i-th of them contains an integer xi (0 ≤ xi ≤ 109).

Output a single integer — the answer to the problem.

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

type Int int

func main() {
	defer w.Flush()
	var p, n Int
	for I(&p, &n) == nil {
		solve(p, n)
	}
}

func solve(p, n Int) {
	in := make([]Int, n)
	h := make(map[Int]Int)
	for i := Int(0); i < n; i++ {
		I(&in[i])
	}
	for i := Int(0); i < n; i++ {
		if _, exists := h[in[i]%p]; exists {
			O(i+1, "\n")
			return
		}
		h[in[i]%p] = in[i] % p
	}
	O(-1, "\n")
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	p, n := nextInt(), nextInt()
	mod := make([]int, p)
	x := 0

	for i := 1; i <= n; i++ {
		x = nextInt() % p

		if mod[x] > 0 {
			println(i)
			return
		} else {
			mod[x]++
		}
	}

	println(-1)
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

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

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

func main() {
	var n,m,a int
	flag:=false
	no:=-1
	fmt.Scan(&m,&n)
	b:=make([]int,311)
	for i:=0;i<n;i++ {
		fmt.Scan(&a)
		a%=m
		if flag==false {
			if b[a]==0 {
				b[a]++
			} else {
				flag=true
				no=i+1
			}
		}
	}
	fmt.Println(no)
}

package main

import "fmt"

func main() {
    var p,n,x int
    fmt.Scan(&p,&n)
    h := make([]bool,p)
    ans := -1
    for i := 0; i < n; i++ {
        fmt.Scan(&x)
        if h[x%p] && (ans == -1) {
            ans = i+1
        } else {
            h[x%p] = true
        }
    }
    fmt.Println(ans)
}

package main

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

func main() {
	var p, n int
	if _, err := fmt.Scanf("%d %d\n", &p, &n); err != nil {
		return
	}

	store := make(map[int]bool)
	conflict := -1

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		hash := h(a, p)
		if store[hash] {
			if conflict < 0 {
				conflict = i + 1
			}
		} else {
			store[hash] = true
		}
	}

	fmt.Println(conflict)
}

func h(x, p int) int {
	return x % p
}

package main

import (
	"fmt"
)

func main() {
	var p, n int
	fmt.Scan(&p)
	fmt.Scan(&n)
	var bucket [310]bool
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		mod := x % p
		if bucket[mod] {
			fmt.Println(i + 1)
			return
		}
		bucket[mod] = true
	}
	fmt.Println(-1)
}

package main

import (
	"fmt"
)

func main() {
	var p, n int
	fmt.Scan(&p, &n)
	hash := make([]bool, p)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if hash[x%p] {
			fmt.Println(i + 1)
			return
		}
		hash[x%p] = true
	}
	fmt.Println(-1)
}

// 447A-mic
package main

import (
	"fmt"
)

func main() {
	var p, n, x int
	a := make(map[int]bool)
	fmt.Scan(&p, &n)

	for i := 1; i <= n; i++ {
		fmt.Scan(&x)

		h := x % p
		if a[h] {
			fmt.Println(i)
			return
		}
		a[h] = true
	}

	fmt.Println("-1")

}

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

type Int int

func main() {
	defer w.Flush()
	var p, n Int
	for I(&p, &n) == nil {
		solve(p, n)
	}
}

func solve(p, n Int) {
	h := make(map[Int]Int)
	for i := Int(1); i <= n; i++ {
		var t Int
		I(&t)
		if _, exists := h[t%p]; exists {
			O(i, "\n")
			return
		}
		h[t%p] = t
	}
	O(-1, "\n")
}


Two integer sequences existed initially — one of them was strictly increasing, and the other one — strictly decreasing.Strictly increasing sequence is a sequence of integers $$$[x_1 < x_2 < \dots < x_k]$$$. And strictly decreasing sequence is a sequence of integers $$$[y_1 > y_2 > \dots > y_l]$$$. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.They were merged into one sequence $$$a$$$. After that sequence $$$a$$$ got shuffled. For example, some of the possible resulting sequences $$$a$$$ for an increasing sequence $$$[1, 3, 4]$$$ and a decreasing sequence $$$[10, 4, 2]$$$ are sequences $$$[1, 2, 3, 4, 4, 10]$$$ or $$$[4, 2, 1, 10, 4, 3]$$$.This shuffled sequence $$$a$$$ is given in the input.Your task is to find any two suitable initial sequences. One of them should be strictly increasing and the other one — strictly decreasing. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing.If there is a contradiction in the input and it is impossible to split the given sequence $$$a$$$ to increasing and decreasing sequences, print "NO".

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$.

If there is a contradiction in the input and it is impossible to split the given sequence $$$a$$$ to increasing and decreasing sequences, print "NO" in the first line. Otherwise print "YES" in the first line and any two suitable sequences. Note that the empty sequence and the sequence consisting of one element can be considered as increasing or decreasing. In the second line print $$$n_i$$$ — the number of elements in the strictly increasing sequence. $$$n_i$$$ can be zero, in this case the increasing sequence is empty. In the third line print $$$n_i$$$ integers $$$inc_1, inc_2, \dots, inc_{n_i}$$$ in the increasing order of its values ($$$inc_1 < inc_2 < \dots < inc_{n_i}$$$) — the strictly increasing sequence itself. You can keep this line empty if $$$n_i = 0$$$ (or just print the empty line). In the fourth line print $$$n_d$$$ — the number of elements in the strictly decreasing sequence. $$$n_d$$$ can be zero, in this case the decreasing sequence is empty. In the fifth line print $$$n_d$$$ integers $$$dec_1, dec_2, \dots, dec_{n_d}$$$ in the decreasing order of its values ($$$dec_1 > dec_2 > \dots > dec_{n_d}$$$) — the strictly decreasing sequence itself. You can keep this line empty if $$$n_d = 0$$$ (or just print the empty line). $$$n_i + n_d$$$ should be equal to $$$n$$$ and the union of printed sequences should be a permutation of the given sequence (in case of "YES" answer).

package main

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

func main() {
	var n, flag, last int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	a := make([]int, n)
	i := make([]int, 0, n)
	d := make([]int, 0, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(scr, "%d", &a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for x, y := range a {
		if x == 0 {
			last = y
			i = append(i, y)
		} else {
			if y > last {
				i = append(i, y)
			} else {
				d = append(d, y)
			}
			last = y
		}
	}
	for x, y := range d {
		if x == 0 {
			last = y
		} else {
			if y <= last {
				flag = 2
				break
			}
			last = y
		}
	}
	if flag == 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")

		fmt.Println(len(i))
		for _, y := range i {
			fmt.Printf("%d ", y)
		}
		fmt.Printf("\n")

		fmt.Println(len(d))
		for i := len(d) - 1; i >= 0; i-- {
			fmt.Printf("%d ", d[i])
		}
	}

}

package main

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

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

func toInt(buf []byte) (n int) {
    for _, v := range buf {
        n = n*10 + int(v-'0')
    }
    return
}

func nextInt() int {
    scanner.Scan()
    return toInt(scanner.Bytes())
}

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

    N := nextInt()
    arr := []int{}
    for i := 0; i < N; i++ {
        x := nextInt()
        arr = append(arr, x)
    }
    sort.Ints(arr)
    aneh := []int{}
    invalid := false
    for i := 1; i < N; i++ {
        if arr[i] == arr[i-1] {
            if len(aneh) > 0 && aneh[len(aneh)-1] == arr[i] {
                invalid = true
                break
            } else {
                aneh = append(aneh, arr[i])
            }
        }
    }
    if invalid {
        writer.WriteString("NO")
    } else {
        writer.WriteString("YES\n")
        writer.WriteString(strconv.Itoa(N - len(aneh)) + "\n")
        writer.WriteString(strconv.Itoa(arr[0]))
        for i := 1; i < N; i++ {
            if arr[i] != arr[i-1] {
                writer.WriteRune(' ')
                writer.WriteString(strconv.Itoa(arr[i]));
            }
        }
        writer.WriteRune('\n')
        writer.WriteString(strconv.Itoa(len(aneh)) + "\n")
        for i := len(aneh)-1; i >= 0; i-- {
            writer.WriteString(strconv.Itoa(aneh[i]))
            writer.WriteRune(' ')
        }
        writer.WriteRune('\n')
    }
    writer.Flush()
}

package main

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

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

    scanner.Scan()
    N := toInt(scanner.Bytes())
    arr := []int{}
    for i := 0; i < N; i++ {
        scanner.Scan()
        x := toInt(scanner.Bytes())
        arr = append(arr, x)
    }
    sort.Ints(arr)
    aneh := []int{}
    invalid := false
    for i := 1; i < N; i++ {
        if arr[i] == arr[i-1] {
            if len(aneh) > 0 && aneh[len(aneh)-1] == arr[i] {
                invalid = true
                break
            } else {
                aneh = append(aneh, arr[i])
            }
        }
    }
    if invalid {
        writer.WriteString("NO")
    } else {
        writer.WriteString("YES\n")
        writer.WriteString(strconv.Itoa(N - len(aneh)) + "\n")
        writer.WriteString(strconv.Itoa(arr[0]))
        for i := 1; i < N; i++ {
            if arr[i] != arr[i-1] {
                writer.WriteRune(' ')
                writer.WriteString(strconv.Itoa(arr[i]));
            }
        }
        writer.WriteRune('\n')
        writer.WriteString(strconv.Itoa(len(aneh)) + "\n")
        for i := len(aneh)-1; i >= 0; i-- {
            writer.WriteString(strconv.Itoa(aneh[i]))
            writer.WriteRune(' ')
        }
        writer.WriteRune('\n')
    }
    writer.Flush()
}

func toInt(buf []byte) (n int) {
    for _, v := range buf {
        n = n*10 + int(v-'0')
    }
    return
}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	fmt.Fscanln(in,&n)
	a := make([]int,n,n)
	for i := 0 ;i  < n;i ++{
		fmt.Fscan(in,&a[i])
	}
	m := map[int]int{}
	inc := make([]int,0)
	dec := make([]int,0)
	sort.Ints(a)
	ans := false
	for i := 0 ; i< n;i++{
		m[a[i]]++
		if(m[a[i]] == 1){
			inc = append(inc,a[i])
		}
		if m[a[i]] == 2{
			dec = append(dec,a[i])
		}
		if(m[a[i]] >= 3){
			ans = true
		}
	}
	if(ans){
		fmt.Fprintf(out,"%s","NO")
		return
	}

	fmt.Fprintf(out,"%s\n","YES")
	fmt.Fprintln(out,len(inc))
	for _,val := range inc{
		fmt.Fprint(out,val," ")
	}
	fmt.Fprintln(out)
	fmt.Fprintln(out,len(dec))
	for i := len(dec) - 1 ; i >= 0;i--{
		fmt.Fprint(out,dec[i]," ")
	}

}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	var input []int
	for ; n >= 1; n-- {
		var a int
		scanf("%d", &a)
		input = append(input, a)
	}
	sort.Ints(input)
	status := 1
	var inc = input[:1]
	var inc2 []int
	check := true
	for i := 1; i < len(input) && check; i++ {
		switch status {
		case 1:
			if input[i] == input[i-1] {
				status = 2
				inc2 = append(inc2, input[i])
			} else {
				inc = append(inc, input[i])
			}
		case 2:
			if input[i] == input[i-1] {
				check = false
			} else {
				inc = append(inc, input[i])
				status = 1
			}
		}
	}
	if check {
		printf("YES\n")
		printf("%d\n", len(inc))
		if len(inc) > 0 {
			printf("%d", inc[0])
		}
		for i := 1; i < len(inc); i++ {
			printf(" %d", inc[i])
		}
		printf("\n")
		printf("%d\n", len(inc2))
		if len(inc2) > 0 {
			printf("%d", inc2[len(inc2)-1])
		}
		for i := len(inc2) - 2; i >= 0; i-- {
			printf(" %d", inc2[i])
		}
		printf("\n")
	} else {
		printf("NO\n")
	}
}

// Codeforces 1144 C compet
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
	"sort"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	delim := byte(' ')
	for i:=0; i<n; i++ {
		if i==(n-1) {
			delim = byte('\n')
		}
		s, err := in.ReadString(delim)
		s = strings.Trim(s, " \n\r")
		if err != nil {
			fmt.Println("read failure", err)
			panic(err)
		}
		aa,err := strconv.Atoi(s)
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[i] = aa
	}
	return a
}

func readString() string {
	delim := byte('\n')
	s, err := in.ReadString(delim)
	s = strings.Trim(s, " \n\r")
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	return s
}

var n int
var a []int
var inca []int
var deca []int
var canDo bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	n,_,_,_,_ = readFive()
	a = readLineNumbs(n)
}

func solve() {
	sort.Ints(a)
	inca = make([]int, 0)
	deca = make([]int, 0)
	nsame := 0
	last := -1
	canDo = true
	addInc := true
	for i:=0; i<n; i++ {
		if a[i] == last {
			if nsame==2 {
				canDo = false
				return
			} else {
				if addInc {
					inca = append(inca, a[i])
				} else {
					deca = append(deca, a[i])
				}
				nsame=2
			}
		} else {
			if addInc {
				inca = append(inca, a[i])
			} else {
				deca = append(deca, a[i])
			}
			addInc = !addInc
			nsame = 1
			last = a[i]
		}
	}
	// reverse deca
	lda := len(deca)
	da := make([]int, lda)
	for i:=0; i<lda; i++ {
		da[i] = deca[lda - i - 1]
	}
	deca = da
}

func printRes() {
	if !canDo {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	fmt.Println(len(inca))
	for i:=0; i<len(inca); i++ {
		fmt.Print(inca[i]," ")
	}
	fmt.Println()
	fmt.Println(len(deca))
	for i:=0; i<len(deca); i++ {
		fmt.Print(deca[i]," ")
	}
	fmt.Println()
}

func main() {
	readData()
	solve()
	printRes()
}

package main

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

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

	var n int
	fmt.Fscanln(in, &n)

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

	inc := make([]int, 0)
	dec := make([]int, 0)

	sort.Ints(a)

	fail := false
	times := make(map[int]int)
	for _, val := range a {
		if times[val] == 0 {
			inc = append(inc, val)
		} else if times[val] == 1 {
			dec = append(dec, val)
		} else {
			fail = true
			break
		}
		times[val] += 1
	}

	if fail {
		fmt.Fprintln(out, "NO")
	} else {
		fmt.Fprintln(out, "YES")
		fmt.Fprintln(out, len(inc))
		for _, val := range inc {
			fmt.Fprint(out, val, " ")
		}
		fmt.Fprintln(out)
		fmt.Fprintln(out, len(dec))
		for i := len(dec) - 1; i >= 0; i-- {
			fmt.Fprint(out, dec[i], " ")
		}
		fmt.Fprintln(out)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(in, &n)

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

	inc := make([]int, 0)
	dec := make([]int, 0)

	sort.Ints(a)

	fail := false
	times := make(map[int]int)
	for _, val := range a {
		if times[val] == 0 {
			inc = append(inc, val)
		} else if times[val] == 1 {
			dec = append(dec, val)
		} else {
			fail = true
			break
		}
		times[val] += 1
	}

	if fail {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		fmt.Println(len(inc))
		for _, val := range inc {
			fmt.Print(val, " ")
		}
		fmt.Println()
		fmt.Println(len(dec))
		for i := len(dec) - 1; i >= 0; i-- {
			fmt.Print(dec[i], " ")
		}
		fmt.Println()
	}
}

package main

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

type mark struct {
	number int
	cnt int
}

func main()  {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(in, &n)
	data := make([]int, n , n)
	for i := 0 ;i < n ; i++ {
		fmt.Fscan(in, &data[i])
	}
	sort.Ints(data)
	m := mark {number:-1, cnt:0}
	one := make([]int, 0, n)
	two := make([]int, 0, n)
	for _, v := range data {
		if m.number == v{
			m.cnt ++
			if m.cnt > 2 {
				fmt.Println("NO")
				return
			}
			two = append(two, v)
 		} else {
 			one = append(one, v)
 			m.cnt  = 1
 			m.number = v
		}
	}
	fmt.Println("YES")

	fmt.Println(len(one))
	for _, v :=  range one {
		fmt.Printf("%d ", v)
	}
	fmt.Println()
	fmt.Println(len(two))
	for i := len(two) - 1; i >= 0; i -- {
		fmt.Printf("%d ", two[i])
	}
	fmt.Println()
}

// Author: sighduck
// URL: https://codeforces.com/contest/1144/problem/C

package main

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

type Solution struct {
	Exists    bool
	Inc       []int
	IncLength int
	Dec       []int
	DecLength int
}

func reverse(a []int, n int) []int {
	for i := 0; i < n/2; i++ {
		a[i], a[n-i-1] = a[n-i-1], a[i]
	}
	return a
}

func printArray(writer *bufio.Writer, a []int, n int) {
	for i := 0; i < n; i++ {
		fmt.Fprintf(writer, "%d ", a[i])
	}
	fmt.Fprintf(writer, "\n")
}

func Solve(n int, a []int) Solution {
	sort.Ints(a)
	inc, incLength := []int{}, 0
	dec, decLength := []int{}, 0
	for i := 0; i < n; i++ {
		if incLength == 0 {
			inc = append(inc, a[i])
			incLength += 1
		} else if a[i] > inc[incLength-1] {
			inc = append(inc, a[i])
			incLength += 1
		} else if decLength == 0 {
			dec = append(dec, a[i])
			decLength += 1
		} else if a[i] > dec[decLength-1] {
			dec = append(dec, a[i])
			decLength += 1
		} else {
			return Solution{Exists: false}
		}
	}
	return Solution{
		Exists:    true,
		Inc:       inc,
		IncLength: incLength,
		Dec:       reverse(dec, decLength),
		DecLength: decLength,
	}
}

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.Fscanf(reader, "\n")

	solution := Solve(n, a)
	if !solution.Exists {
		fmt.Fprintf(writer, "NO\n")
	} else {
		fmt.Fprintf(writer, "YES\n")
		fmt.Fprintf(writer, "%d\n", solution.IncLength)
		printArray(writer, solution.Inc, solution.IncLength)
		fmt.Fprintf(writer, "%d\n", solution.DecLength)
		printArray(writer, solution.Dec, solution.DecLength)
	}
}

package main

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

func main() {
	var n, flag, last int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	a := make([]int, n)
	i := make([]int, 0, n)
	d := make([]int, 0, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(scr, "%d", &a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for x, y := range a {
		if x == 0 {
			last = y
			i = append(i, y)
		} else {
			if y > last {
				i = append(i, y)
			} else {
				d = append(d, y)
			}
			last = y
		}
	}
	for x, y := range d {
		if x == 0 {
			last = y
		} else {
			if y <= last {
				flag = 2
				break
			}
		}
	}
	if flag == 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")

		fmt.Println(len(i))
		for _, y := range i {
			fmt.Printf("%d ", y)
		}
		fmt.Printf("\n")

		fmt.Println(len(d))
		for i := len(d) - 1; i >= 0; i-- {
			fmt.Printf("%d ", d[i])
		}
	}

}

package main

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

func main() {
	var n, flag, last int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	a := make([]int, n)
	i := make([]int, 0, n)
	d := make([]int, 0, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(scr, "%d", &a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for x, y := range a {
		if x == 0 {
			last = y
			i = append(i, y)
		} else {
			if y > last {
				i = append(i, y)
			} else {
				d = append(d, y)
			}
			last = y
		}
	}
	for x, y := range d {
		if x == 0 {
			last = y
		} else {
			if y <= last {
				flag = 2
				break
			}
		}
	}
	if flag == 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")

		fmt.Println(len(d))
		for _, y := range d {
			fmt.Printf("%d ", y)
		}
		fmt.Printf("\n")

		fmt.Println(len(i))
		for j := len(i) - 1; j >= 0; j-- {
			fmt.Printf("%d ", i[j])
		}
	}

}

package main

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

func main() {
	var n, flag, last int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	a := make([]int, n)
	i := make([]int, 0, n)
	d := make([]int, 0, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(scr, "%d", &a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for x, y := range a {
		if x == 0 {
			last = y
			i = append(i, y)
		} else {
			if y > last {
				i = append(i, y)
			} else {
				d = append(d, y)
			}
			last = y
		}
	}
	for x, y := range d {
		if x == 0 {
			last = y
		} else {
			if y < last {
				flag = 2
				break
			}
		}
	}
	if flag == 2 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")

		fmt.Println(len(i))
		for _, y := range i {
			fmt.Printf("%d ", y)
		}
		fmt.Printf("\n")

		fmt.Println(len(d))
		for i := len(d) - 1; i >= 0; i-- {
			fmt.Printf("%d ", d[i])
		}
	}

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	fmt.Fscanln(in,&n)
	a := make([]int,n,n)
	m := map[int]int{}
	ans := false
	for i := 0 ; i< n;i++{
		fmt.Fscan(in,&a[i])
		m[a[i]]++
		if(m[a[i]] >= 3){
			ans = true
		}
	}
	if(ans){
		fmt.Fprintf(out,"%s","NO")
		return
	}
	b := make([]int,n)
	B := []int{}
	cnt := 0
	for i := 0 ; i < n ;i++{
		if(m[a[i]] >= 2){
			cnt ++
			b = append(b,a[i])
			B = append(B,a[i])
			m[a[i]] --
			a[i] = -1
		}
	}
	sort.Ints(B)
	sort.Ints(a)
	fmt.Fprintf(out,"%s\n","YES")
	fmt.Fprintf(out,"%d\n",len(B))
	for _,i :=range B{
		fmt.Fprintf(out,"%d ",i)
	}
	fmt.Println()
	fmt.Fprintf(out,"%d\n",n - len(B))
	for i := n - 1 ; i >= 0;i--{
		if(a[i] >= 0){
			fmt.Fprintf(out,"%d ",a[i])
		}
	}

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	fmt.Fscanf(in,"%d\n",&n)
	a := make([]int,n,n)
	m := map[int]int{}
	ans := false
	for i := 0 ; i< n;i++{
		fmt.Fscanf(in,"%d\n",&a[i])
		m[a[i]]++
		if(m[a[i]] >= 3){
			ans = true
		}
	}
	if(ans){
		fmt.Println("NO")
		return
	}
	b := make([]int,n)
	B := []int{}
	cnt := 0
	for i := 0 ; i < n ;i++{
		if(m[a[i]] >= 2){
			cnt ++
			b = append(b,a[i])
			B = append(B,a[i])
			m[a[i]] --
			a[i] = -1
		}
	}
	sort.Ints(B)
	sort.Ints(a)
	fmt.Println("YES")
	fmt.Println(len(B))
	for _,i :=range B{
		fmt.Print(i," ")
	}
	fmt.Println()
	fmt.Println(n - len(B))
	for i := n - 1 ; i >= 0;i--{
		if(a[i] >= 0){
			fmt.Print(a[i]," ")
		}
	}

}

package main

import (
	"fmt"
	"sort"
)

type mark struct {
	number int
	cnt int
}

func main()  {
	var n int
	fmt.Scan(&n)
	data := make([]int, n , n)
	for i := 0 ;i < n ; i++ {
		fmt.Scan(&data[i])
	}
	sort.Ints(data)
	m := mark {number:-1, cnt:0}
	one := make([]int, 0, n)
	two := make([]int, 0, n/2 + 2)
	for i := 0 ; i < n ; i ++ {
		if m.number == data[i] {
			m.cnt ++
			if m.cnt > 2 {
				fmt.Println("NO")
				return
			}
			two = append(two, data[i])
 		} else {
 			one = append(one, data[i])
 			m.cnt  = 1
 			m.number = data[i]
		}
	}
	fmt.Println("YES")

	fmt.Println(len(one))
	for _, v :=  range one {
		fmt.Printf("%d ", v)
	}
	fmt.Println()

	fmt.Println(len(two))
	for i := len(two) - 1; i >= 0; i -- {
		fmt.Printf("%d ", data[i])
	}
	fmt.Println()

}