package main

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

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

func scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		log.Fatal(err)
	}
}

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

func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		log.Fatal(err)
	}
}

func isLucky(v int, d int) bool {
	for v > 0 {
		if v % 10 == d {
			return true
		}
		v /= 10
	}
	return false
}

func solve() {
	var q, d int
	scan(&q, &d)
	var dp = make([]bool, MAXV)
	dp[0] = true
	for v := 0; v < MAXV; v++ {
		if dp[v] {
			continue
		}
		for vv := 1; vv <= v; vv++ {
			if isLucky(vv, d) && dp[v - vv] {
				dp[v] = true
				break
			}
		}
	}
	for i := 0; i < q; i++ {
		var x int
		scan(&x)
		if x >= 10 * d || dp[x] {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

func main() {
	defer writer.Flush()

	testCases := 0
	scan(&testCases)
	for ; testCases > 0; {
		testCases -= 1
		solve()
	}
}

package main

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

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

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

	var bl strings.Builder

	for i := 0; i < t; i++ {
		var q, d int
		scanf("%d %d\n", &q, &d)

		luckySet := make(map[int]bool)
		for j := 0; j < 10; j++ {
			luckySet[d+j*10] = true
		}

		numToIsLuckySum := make(map[int]bool)

		for j := 0; j < q; j++ {
			var num int
			scanf("%d", &num)

			if num >= 10*d {
				//goland:noinspection GoUnhandledErrorResult
				fmt.Fprintf(&bl, "YES\n")
			} else {
				isLuckySum, found := numToIsLuckySum[num]
                                if !found {
                                  isLuckySum = isSumOfLuckyNumbers(num, luckySet)
                                }

				if isLuckySum {
					numToIsLuckySum[num] = true
					//goland:noinspection GoUnhandledErrorResult
					fmt.Fprintf(&bl, "YES\n")
				} else {
					numToIsLuckySum[num] = false
					//goland:noinspection GoUnhandledErrorResult
					fmt.Fprintf(&bl, "NO\n")
				}
			}
		}
		scanf("\n")
	}

	printf(bl.String())
}

func isSumOfLuckyNumbers(num int, luckySet map[int]bool) bool {
	if _, found := luckySet[num]; found {
		return true
	}

	for n := range luckySet {
		diff := num - n
		if diff > 0 && isSumOfLuckyNumbers(diff, luckySet) {
			return true
		}
	}

	return false
}

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

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	q   int
	d   int
	a   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &q, &d)

		for ; q > 0; q-- {

			fmt.Fscan(in, &a)

			fmt.Fprintln(out, solve2(a, d))

		}

	}

}

func solve2(a int, d int) string {

	if d == 1 || a >= 10*d {
		return "YES"
	}

	for a > 0 {

		if a%d == 0 {
			return "YES"
		}

		a -= 10

	}

	return "NO"

}

func solve(a int, d int) string {

	n := 1

	for d*n <= a {

		if (a-d*n)%10 == 0 {
			return "YES"
		}

		n++

	}

	return "NO"

}

package main

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

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

	var t, q, d, a int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &q, &d)
	Loop:
		for i := 0; i < q; i++ {
			fmt.Fscan(in, &a)
			if a >= 11*d {
				fmt.Println("YES")
				continue Loop
			}
			if a/10 == d || a%10 == d {
				fmt.Println("YES")
				continue Loop
			}
			for ; a > 0; a -= 10 {
				if a%d == 0 {
					fmt.Println("YES")
					continue Loop
				}
			}
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

func ok(v, d int) bool {
    if v >= 10*d {return true}
    if v <= 0 { return false }
    if v % 10 == d { return true }
    return ok((v - d), d)
}

func solve() {
    var (
        q, d int
    )
    fmt.Fscan(input, &q, &d)
    a := make([]int, q)
    for i := 0; i < len(a); i++ {
        fmt.Fscan(input, &a[i])
    }
    for _, v := range a {
        if ok(v, d) {
            fmt.Fprintln(output, "Yes")
        } else {
            fmt.Fprintln(output, "No")
        }
    }
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, d := readTwoNums(reader)
		A := readNNums(reader, n)
		res := solve(d, A)
		for i := 0; i < n; i++ {
			if res[i] {
				buf.WriteString("YES\n")
			} else {
				buf.WriteString("NO\n")
			}
		}
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(d int, A []int) []bool {
	n := len(A)

	res := make([]bool, n)
	for i := 0; i < n; i++ {
		res[i] = check(A[i], d)
	}

	return res
}

func check(num, d int) bool {
	x, y := num/d, num%d
	if y == 0 {
		return true
	}
	if x >= 10 {
		return true
	}

	// a * d + y = 10 + d
	// x < 10
	for i := 1; i <= x; i++ {
		tmp := i*d + y
		for tmp > 0 {
			r := tmp % 10
			if r == d {
				return true
			}
			tmp /= 10
		}
	}
	return false
}

package main

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

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

func scan(a ...interface{}) (n int, err error)             { return fmt.Fscan(in, a...) }
func scanf(f string, a ...interface{}) (n int, err error)  { return fmt.Fscanf(in, f, a...) }
func printf(f string, a ...interface{}) (n int, err error) { return fmt.Fprintf(out, f, a...) }

//https://codeforces.com/problemset/problem/1478/B
// dp

func main() {
	defer out.Flush()

	var t, n, d, a int
	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		scanf("%d %d\n", &n, &d)
		dp := make([]bool, d*10)
		dp[0] = true
		for i := 0; i < len(dp); i++ {
			for j := 0; j < d && i-j*10 >= d; j++ {
				dp[i] = dp[i] || dp[i-j*10-d]
			}
		}
		for j := 0; j < n; j++ {
			scan(&a)
			if j == n-1 {
				scanf("\n")
			}
			if a >= d*10 || dp[a] {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		}
	}
}

package main

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

func main(){
	var t, q, d int;
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for (t > 0){
		t--
		fmt.Fscan(in, &q, &d)
		m := make([]int, d*10)
		for i:=0; i<d; i++{
			m[i*10+d] = 1
		}

		for i:=1; i<d*10; i++{
			if m[i] > 0{
				for j:=0; j<d; j++{
					t := j*10+d
					cur := i+t
					if cur < d*10{
						m[cur] = 1
					}
				}
			}
		}

		var x int
		for i:=0; i<q; i++{
			fmt.Fscan(in, &x)
			if x/d >= 10 {
				fmt.Println("YES")
			}else if m[x] > 0{
				fmt.Println("YES")
			}else{
				fmt.Println("NO")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	// . "testgo/helpers"
)

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

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

func main() {
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		q, d := 0, 0
		scan(&q)
		scan(&d)

		a := make([]int, q)
		for i := range a {
			scan(&a[i])
		}

		solve(a, d)
	}

	writer.Flush()
}

func solve(q []int, d int) {
	check := func(x int) int {
		for x > 0 {
			if x%10 == d {
				return 1
			}
			x /= 10
		}
		return 0
	}

	dp := [100]int{1}
	for s := range dp {
		dp[s] = check(s)
		for x := 1; x < s; x++ {
			dp[s] |= dp[x] & dp[s-x]
		}
	}

	for i := range q {
		r := "NO"
		if q[i] >= 10*d || dp[q[i]] == 1 {
			r = "YES"
		}
		printf("%s\n", r)
	}
}

package main

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

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

	var T, q, d, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &q, &d)
		f := make([]bool, d*10)
		f[0] = true
		for i := range f {
			for j := 0; j < d && 10*j+d <= i; j++ {
				f[i] = f[i] || f[i-10*j-d]
			}
		}
		for ; q > 0; q-- {
			Fscan(in, &v)
			if v >= d*10 || f[v] {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		}
	}
}

package main

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

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

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var q int
		var d int
		fmt.Fscan(input, &q)
		fmt.Fscan(input, &d)
		var m int64
		for i := 1; i < q+1; i++ {
			fmt.Fscan(input, &m)
			if d == 1 {
				fmt.Println("YES")
			}
			if d == 2 {
				if m%2 == 0 {
					fmt.Println("YES")
				} else {
					if m >= 21 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
			}
			if d == 3 {
				if m%3 == 0 {
					fmt.Println("YES")
				}
				if m%3 == 1 {
					if m >= 13 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%3 == 2 {
					if m >= 23 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
			}
			if d == 4 {
				if m%4 == 0 {
					fmt.Println("YES")

				}
				if m%4 == 1 {
					if m >= 41 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%4 == 2 {
					if m >= 14 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")

					}
				}
				if m%4 == 3 {
					if m >= 43 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
			}
			if d == 5 {
				if m%5 == 0 {
					fmt.Println("YES")
				} else {
					k := d % 5
					if m >= int64(50+k) {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}

				}

			}

			if d == 6 {
				if m%6 == 0 {
					fmt.Println("YES")
				}
				if m%2 == 1 {
					k := d % 6
					if m >= int64(60+k) {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%6 == 2 {
					if m >= 26 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%6 == 4 {
					if m >= 16 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
			}
			if d == 7 {
				if m%7 == 0 {
					fmt.Println("YES")
				}

				if m%7 == 1 {
					if m >= 57 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%7 == 2 {
					if m >= 37 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%7 == 3 {
					if m >= 17 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%7 == 4 {
					if m >= 67 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%7 == 5 {
					if m >= 47 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%7 == 6 {
					if m >= 27 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}

			}

			if d == 8 {
				if m%8 == 0 {
					fmt.Println("YES")
				}
				if m%2 == 1 {
					k := m % 8
					if m >= int64(80+k) {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")

					}
				}
				if m%8 == 2 {
					if m >= 18 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%8 == 4 {
					if m >= 28 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
				if m%8 == 6 {
					if m >= 38 {
						fmt.Println("YES")
					} else {
						fmt.Println("NO")
					}
				}
			}

			if d == 9 {
				if m%9 == 0 {
					fmt.Println("YES")
				} else {
					k := m % 9
					if m >= int64(k*10+9) {
						fmt.Println("YES")

					} else {
						fmt.Println("NO")

					}
				}

			}
		}
	}
}

package main

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

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		var q, d int64
		fmt.Sscanf(input.Text(), "%d %d\n", &q, &d)
		input.Scan()
		str := strings.Split(input.Text(), " ")
		for j := int64(0); j < q; j++ {
			item, _ := strconv.Atoi(str[j])
			results = append(results, calc(d, int64(item)))
		}
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d%c", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t; i++ {
		var q, d int64
		fmt.Scanf("%d %d%c", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d%c", &item)
			results = append(results, calc(d, item))
		}
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d\n", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t; i++ {
		var q, d int64
		fmt.Scanf("%d %d\n", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d%c", &item)
			results = append(results, calc(d, item))
		}
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d\n", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t+1; i++ {
		var q, d int64
		fmt.Scanf("%d %d\n", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d", &item)
			results = append(results, calc(d, item))
		}
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d\n", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t; i++ {
		var q, d int64
		fmt.Scanf("%d %d\n", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d", &item)
			results = append(results, calc(d, item))
		}
	}

	fmt.Println(results)

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d\n", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t; i++ {
		var q, d int64
		fmt.Scanf("%d %d\n", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d", &item)
			results = append(results, calc(d, item))
		}
	}

	fmt.Println(t)

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func calc(q int64, item int64) bool {
	if item%q == 0 {
		return true
	}
	if item < 10*q {
		for p := int64(1); p < q; p++ {
			temp := item
			for temp > 0 {
				temp -= q + p*10
				if temp >= 0 && temp%q == 0 {
					return true
				}
			}
		}

		return false
	}

	return true
}

func main() {
	var t int64
	fmt.Scanf("%d\n", &t)
	results := make([]bool, 0)
	for i := int64(0); i < t; i++ {
		var q, d int64
		fmt.Scanf("%d %d\n", &q, &d)
		for j := int64(0); j < q; j++ {
			var item int64
			fmt.Scanf("%d", &item)
			results = append(results, calc(d, item))
		}
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	q   int
	d   int
	a   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &q, &d)

		for ; q > 0; q-- {

			fmt.Fscan(in, &a)

			fmt.Fprintln(out, solve2(a, d))

		}

	}

}

func solve2(a int, d int) string {

	for a > 0 {

		if a%d == 0 {
			return "YES"
		}

		a -= 10

	}

	return "NO"

}

func solve(a int, d int) string {

	n := 1

	for d*n <= a {

		if (a-d*n)%10 == 0 {
			return "YES"
		}

		n++

	}

	return "NO"

}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	q   int
	d   int
	a   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &q, &d)

		for ; q > 0; q-- {

			fmt.Fscan(in, &a)

			fmt.Fprintln(out, solve(a, d))

		}

	}

}

func solve(a int, d int) string {

	n := 1

	for d*n <= a {

		if (a-d*n)%10 == 0 {
			return "YES"
		}

		n++

	}

	return "NO"

}

package main

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

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

	var t, q, d, a int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &q, &d)
	Loop:
		for i := 0; i < q; i++ {
			fmt.Fscan(in, &a)
			if a >= 11*d {
				fmt.Println("YES")
				continue
			}
			for ; a > 0; a -= 10 {
				if a%d == 0 {
					fmt.Println("YES")
					continue Loop
				}
			}
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

func ok(v, d int) bool {
    if v <= 0 { return false }
    if v % 10 == d { return true }
    return ok(v - d, d)
}

func solve() {
    var (
        q, d int
    )
    fmt.Fscan(input, &q, &d)
    a := make([]int, q)
    for i := 0; i < len(a); i++ {
        fmt.Fscan(input, &a[i])
    }
    for _, v := range a {
        if ok(v, d) {
            fmt.Fprintln(output, "Yes")
        } else {
            fmt.Fprintln(output, "No")
        }
    }
}


// 205B
package main

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

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

func main() {
	var a, b, i, k, n int64
	in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &k)
		b += max(0, a-k)
		a = k
	}
	fmt.Print(b)
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()
	A := io.NextInts(n)

	R := make([]int, n)

	mx := 0
	prv := 0
	ans := int64(0)
	for i := 0; i < n; i++ {
		mx = max(mx, A[i])
		R[i] = mx
		d := R[i] - A[i]
		// io.Println(A[i], R[i])
		// io.Println(d, prv)
		if prv < d {
			ans += int64(d - prv)
		}
		prv = d
	}
	io.Println(ans)
}

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

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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

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

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

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

func main() {
	var nn, aa, n, x int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	x=0
	for i:=1; int64(i)<nn; i++ {
		r.Scan()
		aa, _ = strconv.ParseInt(r.Text(), 0, 64)
		if aa<n {
			x=x+(n-aa)
		}
		n=aa
	}
	fmt.Println(x)
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	count := int64(0)
	prev := scanInt(scanner)
	for i := 1; i < n; i++ {
		curr := scanInt(scanner)
		if curr < prev {
			count += int64(prev-curr)
		}
		prev = curr
	}
	writer.WriteString(fmt.Sprintf("%d\n", count))
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	count := 0
	prev := scanInt(scanner)
	for i := 1; i < n; i++ {
		curr := scanInt(scanner)
		if curr < prev {
			count += prev-curr
		}
		prev = curr
	}
	writer.WriteString(fmt.Sprintf("%d\n", count))
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()
	A := io.NextInts(n)

	R := make([]int, n)

	mx := 0
	prv := 0
	ans := 0
	for i := 0; i < n; i++ {
		mx = max(mx, A[i])
		R[i] = mx
		d := R[i] - A[i]
		// io.Println(A[i], R[i])
		// io.Println(d, prv)
		if prv < d {
			ans += d - prv
		}
		prv = d
	}
	io.Println(ans)
}

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

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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

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

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

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

func main() {
	var nn, aa, n, x int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	x=0
	for i:=1; int64(i)<nn; i++ {
		r.Scan()
		aa, _ = strconv.ParseInt(r.Text(), 0, 64)
		if aa<n {
			x=x+n-aa
			n=aa
		}
	}
	fmt.Println(x)
}


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


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

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


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

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


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

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
}


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