Arkady coordinates rounds on some not really famous competitive programming platform. Each round features $$$n$$$ problems of distinct difficulty, the difficulties are numbered from $$$1$$$ to $$$n$$$.To hold a round Arkady needs $$$n$$$ new (not used previously) problems, one for each difficulty. As for now, Arkady creates all the problems himself, but unfortunately, he can't just create a problem of a desired difficulty. Instead, when he creates a problem, he evaluates its difficulty from $$$1$$$ to $$$n$$$ and puts it into the problems pool.At each moment when Arkady can choose a set of $$$n$$$ new problems of distinct difficulties from the pool, he holds a round with these problems and removes them from the pool. Arkady always creates one problem at a time, so if he can hold a round after creating a problem, he immediately does it.You are given a sequence of problems' difficulties in the order Arkady created them. For each problem, determine whether Arkady held the round right after creating this problem, or not. Initially the problems pool is empty.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^5$$$) — the number of difficulty levels and the number of problems Arkady created. The second line contains $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ ($$$1 \le a_i \le n$$$) — the problems' difficulties in the order Arkady created them.

Print a line containing $$$m$$$ digits. The $$$i$$$-th digit should be $$$1$$$ if Arkady held the round after creation of the $$$i$$$-th problem, and $$$0$$$ otherwise.

NoteIn the first example Arkady held the round after the first three problems, because they are of distinct difficulties, and then only after the last problem.

package main

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

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

func main() {
	var n, m int
	fmt.Fscan(in, &n, &m)
	cnts := make([]int, n+1)
	bent := make([]int, m+1)
	held := 0
	ans := make([]byte, m)
	for i := range ans {
		var a int
		fmt.Fscan(in, &a)
		cnts[a]++
		bent[cnts[a]]++
		if bent[held+1] == n {
			held++
			ans[i] = '1'
		} else {
			ans[i] = '0'
		}
	}
	fmt.Printf("%s\n", ans)
}

package main

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

func solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := uint64(readInt64(scanner))
	m := readInt64(scanner)

	minCount := uint64(0)
	aToCount := make([]uint64, n)

	countToDistinctA := make([]uint64, m+1)
	countToDistinctA[0] = n

	for i := int64(0); i < m; i++ {
		a := readInt64(scanner) - 1

		aCount := aToCount[a]

		countToDistinctA[aCount] -= 1
		if countToDistinctA[aCount] == 0 && minCount == aCount {
			minCount += 1
			writef(writer, "1")
		} else {
			writef(writer, "0")
		}
		aToCount[a] += 1

		countToDistinctA[aCount+1] += 1
	}

	writef(writer, "\n")
}

func main() {
	var scanner *bufio.Scanner
	if len(os.Args) > 1 {
		reader, err := os.Open(os.Args[1])
		if err != nil {
			panic(err)
		}
		defer reader.Close()
		scanner = bufio.NewScanner(reader)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	solveSequential(scanner, writer)
}

func readInt64(sc *bufio.Scanner) int64 {
	if !sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func writef(writer *bufio.Writer, formatStr string, values ...interface{}) {
	out := fmt.Sprintf(formatStr, values...)
	_, err := writer.WriteString(out)
	if err != nil {
		panic(err)
	}
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int

	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	cnt := make([]int, n+1)
	dp := make([]int, m+1)
	mat := make([]int, m+1)
	var front int = 1
	for i := 0; i < m; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	for i := 0; i < m; i++ {
		cnt[mat[i]]++
		dp[cnt[mat[i]]]++
		if dp[front] >= n{
			fmt.Printf("1")
			front++
		}else{
			fmt.Printf("0")
		}
	}
	fmt.Printf("\n")

}
/*
3 8
1 2 1 2 1 3 3 1

2 8
1 2 1 2 1 1 1 1
*/

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int

	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	cnt := make([]int, n+1)
	dp := make([]int, m+1)
	mat := make([]int, m+1)
	for i := 0;i <= m;i++{
		dp[i] = n
	}
	var front int = 1
	for i := 0; i < m; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	for i := 0; i < m; i++ {
		cnt[mat[i]]++
		dp[cnt[mat[i]]]--
		if dp[front] == 0{
			fmt.Printf("1")
			front++
		}else{
			fmt.Printf("0")
		}
	}
	fmt.Printf("\n")

}

package main

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

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

func main() {
	var n, m int
	fmt.Fscan(in, &n, &m)
	ans := make([]int, n, n+5)
	need := n
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	for i := 0; i < m; i++ {
		var val int
		fmt.Fscan(in, &val)
		val--
		if ans[val] <= 0 {
			need--
		}
		ans[val]++
		if need == 0 {
			fmt.Fprint(out,1)
			need = n
			for j := 0; j < n; j++ {
				ans[j]--
				if ans[j] > 0 {
					need--
				}
			}
		} else {
			fmt.Fprint(out,0)
		}
	}
}

// Codeforces 1100 B Build a Contest comp
package main

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

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

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

var n,m int
var a []int
var rounds string

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

func solve() {
	nnz := 0
	cnts := make([]int, n)
	ra := make([]byte, m)
	for i:=0; i<m; i++ {
		ia := a[i]-1
		if cnts[ia]==0 {
			nnz++
		}
		cnts[ia]++
		if nnz == n {
			ra[i] = '1';
			nnz = 0
			for j:=0; j<n; j++ {
				cnts[j]--
				if cnts[j]>0 {
					nnz++
				}
			}
		} else {
			ra[i] = '0'
		}
	}
	rounds = string(ra)
}

func printRes() {
	fmt.Println(rounds)
}

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

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()
	hsmp := make(map[int]int)
	var n, m, t1 int
	scanf("%d %d\n", &n, &m)
	for i := 0; i < m; i++ {
		scanf("%d", &t1)
		hsmp[t1]++
		if len(hsmp) == n {
			printf("1")
			for j := 1; j <= n; j++ {
				hsmp[j]--
				if hsmp[j] == 0 {
					delete(hsmp, j)
				}
			}
		} else {
			printf("0")
		}
	}
}

package main

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

type CaseInput struct {
	K int64
	Tabs []int64
}

func readCaseInput(scanner *bufio.Scanner) CaseInput {
	size := readInt64(scanner)
	k := readInt64(scanner)
	tabs := make([]int64, size)
	for i := range tabs {
		tabs[i] = readInt64(scanner)
	}
	return CaseInput{k, tabs}
}

type CaseOutput struct {
	MaxDiff int64
}

func writeCaseOutput(writer *bufio.Writer, out CaseOutput) {
	writef(writer, "%d\n", abs64(out.MaxDiff))
}

func solveCase(in CaseInput) CaseOutput {
	diffs := make([]int64, in.K)
	diffsTotal := int64(0)
	for i, t := range in.Tabs {
		diffs[int64(i) % in.K] += t
		diffsTotal += t
	}

	maxDiff := abs64(diffsTotal - diffs[0])
	for b := int64(1); b < in.K; b++ {
		maxDiff = max64(abs64(diffsTotal - diffs[b]), maxDiff)
	}
	return CaseOutput{maxDiff}
}

func solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {
	writeCaseOutput(writer, solveCase(readCaseInput(scanner)))
}

func main() {
	var scanner *bufio.Scanner
	if len(os.Args) > 1 {
		reader, err := os.Open(os.Args[1])
		if err != nil {
			panic(err)
		}
		defer reader.Close()
		scanner = bufio.NewScanner(reader)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	solveSequential(scanner, writer)
}

func readInt64(sc *bufio.Scanner) int64 {
	if !sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func writef(writer *bufio.Writer, formatStr string, values ...interface{}) {
	out := fmt.Sprintf(formatStr, values...)
	_, err := writer.WriteString(out)
	if err != nil {
		panic(err)
	}
}

func max64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int

	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	cnt := make([]int, n+1)
	dp := make([]int, m+1)
	mat := make([]int, m+1)
	for i := 0;i <= n;i++{
		dp[i] = n
	}
	var front int = 1
	for i := 0; i < m; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	for i := 0; i < m; i++ {
		cnt[mat[i]]++
		dp[cnt[mat[i]]]--
		if dp[front] == 0{
			fmt.Printf("1")
			front++
		}else{
			fmt.Printf("0")
		}
	}
	fmt.Printf("\n")

}
/*

3 8
1 2 1 2 1 3 3 1
*/


Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After the present was granted, m guests consecutively come to Bogdan's party. When the i-th guest comes, he performs exactly one of the two possible operations:   Chooses some number yi, and two vertecies ai and bi. After that, he moves along the edges of the tree from vertex ai to vertex bi using the shortest path (of course, such a path is unique in the tree). Every time he moves along some edge j, he replaces his current number yi by , that is, by the result of integer division yi div xj.  Chooses some edge pi and replaces the value written in it xpi by some positive integer ci < xpi. As Bogdan cares about his guests, he decided to ease the process. Write a program that performs all the operations requested by guests and outputs the resulting value yi for each i of the first type.

The first line of the input contains integers, n and m (2 ≤ n ≤ 200 000, 1 ≤ m ≤ 200 000) — the number of vertecies in the tree granted to Bogdan by his mom and the number of guests that came to the party respectively. Next n - 1 lines contain the description of the edges. The i-th of these lines contains three integers ui, vi and xi (1 ≤ ui, vi ≤ n, ui ≠ vi, 1 ≤ xi ≤ 1018), denoting an edge that connects vertecies ui and vi, with the number xi initially written on it. The following m lines describe operations, requested by Bogdan's guests. Each description contains three or four integers and has one of the two possible forms:    1 ai bi yi corresponds to a guest, who chooses the operation of the first type.  2 pi ci corresponds to a guests, who chooses the operation of the second type.  1 ≤ ai, bi ≤ n 1 ≤ pi ≤ n - 1 1 ≤ yi ≤ 1018 1 ≤ ci < xpi xpi pi xpi 1 n - 1

For each guest who chooses the operation of the first type, print the result of processing the value yi through the path from ai to bi.

NoteInitially the tree looks like this:   The response to the first query is:  = 2After the third edge is changed, the tree looks like this:   The response to the second query is:  = 4In the third query the initial and final vertex coincide, that is, the answer will be the initial number 20.After the change in the fourth edge the tree looks like this:   In the last query the answer will be:  = 3

package main

/*
LESSONS

- use bufio (2x faster than fmt.Scanf)
- if bufio isn't enough, use ./buffer.go (3x faster than bufio)
- use arrays, not maps (3x faster than maps)
*/

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

var children [][]*edge
var parents []*edge
var edges []*edge
var in []int
var out []int
var A []int

type relation struct {
	o int
	x int64
	i int
}

type edge struct {
	u int
	v int
	x int64
	i int
}

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

	var n, m int
	fmt.Fscanf(buf, "%d %d\r\n", &n, &m)
	// fmt.Printf("read %d %d\n", n, m)

	relatives := make([][]relation, n+1)

	for i := 1; i <= n-1; i++ {
		var u, v int
		var x int64
		fmt.Fscanf(buf, "%d %d %d\r\n", &u, &v, &x)
		// fmt.Printf("read %d %d %d\n", u, v, x)
		relatives[u] = append(relatives[u], relation{o: v, x: x, i: i})
		relatives[v] = append(relatives[v], relation{o: u, x: x, i: i})
	}

	children = make([][]*edge, n+1)
	parents = make([]*edge, n+1)
	edges = make([]*edge, n)
	enroot(relatives, 1, 0)

	in = make([]int, n+1)
	out = make([]int, n+1)
	t := 1
	dfs(1, &t)
	// fmt.Println(in)
	// fmt.Println(out)
	A = make([]int, n+1)
	for i := 1; i <= n; i++ {
		A[i] = i
	}

	for i := 0; i < m; i++ {
		var op int
		fmt.Fscanf(buf, "%d", &op)
		switch op {
		case 1:
			var a, b int
			var y int64
			fmt.Fscanf(buf, "%d %d %d\r\n", &a, &b, &y)
			// fmt.Printf("read 1 %d %d %d => %d\n", a, b, y, dist(a, b, y))
			fmt.Println(dist(a, b, y))
		case 2:
			var p int
			var c int64
			fmt.Fscanf(buf, "%d %d\r\n", &p, &c)
			// fmt.Printf("read 2 %d %d\n", p, c)
			edges[p].x = c

		default:
			panic("BAD INT")
		}
	}
}

func enroot(relatives [][]relation, u int, parent int) {
	for _, r := range relatives[u] {
		if r.o != parent {
			e := edge{u: u, v: r.o, x: r.x, i: r.i}
			// fmt.Printf("read %v\n", e)
			children[e.u] = append(children[e.u], &e)
			parents[e.v] = &e
			edges[e.i] = &e
			enroot(relatives, r.o, u)
		}
	}
}

func dfs(u int, t *int) {
	in[u] = *t
	(*t)++
	for _, e := range children[u] {
		dfs(e.v, t)
	}
	out[u] = *t
}

func dist(a int, b int, y int64) int64 {
	y = distCommonAncestor(a, b, y)
	y = distCommonAncestor(b, a, y)
	return y
}

func distCommonAncestor(a int, b int, y int64) int64 {
	for y > 0 && !ancestor(a, b) {
		y /= parents[a].x
		a = parent(a)
	}
	return y
}

func ancestor(a int, b int) bool {
	return in[a] <= in[b] && out[b] <= out[a]
}

func parent(a int) int {
	e := parents[a]
	if e.x == 1 {
		f := edges[find(e.i)]
		for parents[f.u] != nil && parents[f.u].x == 1 {
			union(e.i, parents[f.u].i)
			f = edges[find(e.i)]
		}
		return edges[find(e.i)].u
	}
	return parents[a].u
}

func find(u int) int {
	if A[u] == u {
		return u
	}
	A[u] = find(A[u])
	return A[u]
}

func union(u int, v int) {
	A[find(u)] = find(v)
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"runtime/pprof"
	"strings"
)

var children [][]*edge
var parents []*edge
var edges []*edge
var in []int
var out []int
var A []int

type relation struct {
	o int
	x int64
	i int
}

type edge struct {
	u int
	v int
	x int64
	i int
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	buf := bufio.NewReader(os.Stdin)

	var n, m int
	fmt.Fscanf(buf, "%d %d\r\n", &n, &m)
	// fmt.Printf("read %d %d\n", n, m)

	// var relatives [n + 1][]relation
	relatives := make([][]relation, n+1)

	for i := int(1); i <= n-1; i++ {
		var u, v int
		var x int64
		fmt.Fscanf(buf, "%d %d %d\r\n", &u, &v, &x)
		// fmt.Printf("read %d %d %d\n", u, v, x)
		relatives[u] = append(relatives[u], relation{o: v, x: x, i: i})
		relatives[v] = append(relatives[v], relation{o: u, x: x, i: i})
	}

	children = make([][]*edge, n+1)
	parents = make([]*edge, n+1)
	edges = make([]*edge, n)
	enroot(relatives, 1, 0)

	in = make([]int, n+1)
	out = make([]int, n+1)
	t := 1
	dfs(1, &t)
	// fmt.Println(in)
	// fmt.Println(out)
	A = make([]int, n+1)
	for i := 1; i <= n; i++ {
		A[i] = i
	}

	for i := 0; i < m; i++ {
		var op int
		fmt.Fscanf(buf, "%d", &op)
		switch op {
		case 1:
			var a, b int
			var y int64
			fmt.Fscanf(buf, "%d %d %d\r\n", &a, &b, &y)
			// fmt.Printf("read 1 %d %d %d => %d\n", a, b, y, dist(a, b, y))
			fmt.Println(dist(a, b, y))
		case 2:
			var p int
			var c int64
			fmt.Fscanf(buf, "%d %d\r\n", &p, &c)
			// fmt.Printf("read 2 %d %d\n", p, c)
			edges[p].x = c

		default:
			panic("BAD INT")
		}
	}
}

func enroot(relatives [][]relation, u int, parent int) {
	for _, r := range relatives[u] {
		if r.o != parent {
			e := edge{u: u, v: r.o, x: r.x, i: r.i}
			// fmt.Printf("read %v\n", e)
			children[e.u] = append(children[e.u], &e)
			parents[e.v] = &e
			edges[e.i] = &e
			enroot(relatives, r.o, u)
		}
	}
}

func dfs(u int, t *int) {
	in[u] = *t
	(*t)++
	for _, e := range children[u] {
		dfs(e.v, t)
	}
	out[u] = *t
}

func dist(a int, b int, y int64) int64 {
	y = distCommonAncestor(a, b, y)
	y = distCommonAncestor(b, a, y)
	return y
}

func distCommonAncestor(a int, b int, y int64) int64 {
	for y > 0 && !ancestor(a, b) {
		y /= parents[a].x
		a = parent(a)
	}
	return y
}

func ancestor(a int, b int) bool {
	return in[a] <= in[b] && out[b] <= out[a]
}

func parent(a int) int {
	e := parents[a]
	if e.x == 1 {
		f := edges[find(e.i)]
		for parents[f.u] != nil && parents[f.u].x == 1 {
			union(e.i, parents[f.u].i)
			f = edges[find(e.i)]
		}
		return edges[find(e.i)].u
	}
	return parents[a].u
}

func find(u int) int {
	if A[u] == u {
		return u
	}
	A[u] = find(A[u])
	return A[u]
}

func union(u int, v int) {
	A[find(u)] = find(v)
}

/////////////////////////////////////////////////////
// FUCKING GO                                      //
// SCANF IS FAST ENOUGH FOR C/C++, BUT NOOOO,      //
// GO'S SHITTY IMPLEMENTATION TIMES OUT            //
// SO I HAVE TO WRITE MY OWN FUCKING SCANNER, FUCK //
/////////////////////////////////////////////////////

type Buffer struct {
	words []string
	i     int
}

func NewBuffer(f *os.File) *Buffer {
	bytes, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err.Error())
	}
	s := string(bytes)
	s = strings.Replace(s, "\r", "", -1)
	s = strings.Replace(s, "\n", " ", -1)
	return &Buffer{
		words: strings.Split(s, " "),
		i:     0,
	}
}

func (b *Buffer) NextInt() int {
	x := 0
	for _, c := range b.words[b.i] {
		x = x*10 + int(c-'0')
	}
	b.i++
	return x
}

func (b *Buffer) ScanInts(ps ...*int) {
	for _, p := range ps {
		*p = b.NextInt()
	}
}

func (b *Buffer) NextInt64() int64 {
	x := int64(0)
	for _, c := range b.words[b.i] {
		x = x*10 + int64(c-'0')
	}
	b.i++
	return x
	// x, err := strconv.Atoi(b.words[b.i])
	// if err == nil {
	// 	b.i++
	// 	return int64(x)
	// }
	// var y int64
	// fmt.Sscanf(b.words[b.i], "%d", &y)
	// b.i++
	// return y
}

func (b *Buffer) ScanInt64s(ps ...*int64) {
	for _, p := range ps {
		*p = b.NextInt64()
	}
}

package main

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

var children [][]*edge
var parents []*edge
var edges []*edge
var in []int
var out []int
var A []int

type relation struct {
	o int
	x int64
	i int
}

type edge struct {
	u int
	v int
	x int64
	i int
}

func main() {

	buf := bufio.NewReader(os.Stdin)

	var n, m int
	fmt.Fscanf(buf, "%d %d\r\n", &n, &m)
	// fmt.Printf("read %d %d\n", n, m)

	relatives := make([][]relation, n+1)

	for i := int(1); i <= n-1; i++ {
		var u, v int
		var x int64
		fmt.Fscanf(buf, "%d %d %d\r\n", &u, &v, &x)
		// fmt.Printf("read %d %d %d\n", u, v, x)
		relatives[u] = append(relatives[u], relation{o: v, x: x, i: i})
		relatives[v] = append(relatives[v], relation{o: u, x: x, i: i})
	}

	children = make([][]*edge, n+1)
	parents = make([]*edge, n+1)
	edges = make([]*edge, n)
	enroot(relatives, 1, 0)

	in = make([]int, n+1)
	out = make([]int, n+1)
	t := 1
	dfs(1, &t)
	// fmt.Println(in)
	// fmt.Println(out)
	A = make([]int, n+1)
	for i := 1; i <= n; i++ {
		A[i] = i
	}

	for i := 0; i < m; i++ {
		var op int
		fmt.Fscanf(buf, "%d", &op)
		switch op {
		case 1:
			var a, b int
			var y int64
			fmt.Fscanf(buf, "%d %d %d\r\n", &a, &b, &y)
			// fmt.Printf("read 1 %d %d %d => %d\n", a, b, y, dist(a, b, y))
			fmt.Println(dist(a, b, y))
		case 2:
			var p int
			var c int64
			fmt.Fscanf(buf, "%d %d\r\n", &p, &c)
			// fmt.Printf("read 2 %d %d\n", p, c)
			edges[p].x = c

		default:
			panic("BAD INT")
		}
	}
}

func enroot(relatives [][]relation, u int, parent int) {
	for _, r := range relatives[u] {
		if r.o != parent {
			e := edge{u: u, v: r.o, x: r.x, i: r.i}
			// fmt.Printf("read %v\n", e)
			children[e.u] = append(children[e.u], &e)
			parents[e.v] = &e
			edges[e.i] = &e
			enroot(relatives, r.o, u)
		}
	}
}

func dfs(u int, t *int) {
	in[u] = *t
	(*t)++
	for _, e := range children[u] {
		dfs(e.v, t)
	}
	out[u] = *t
}

func dist(a int, b int, y int64) int64 {
	y = distCommonAncestor(a, b, y)
	y = distCommonAncestor(b, a, y)
	return y
}

func distCommonAncestor(a int, b int, y int64) int64 {
	for y > 0 && !ancestor(a, b) {
		y /= parents[a].x
		a = parent(a)
	}
	return y
}

func ancestor(a int, b int) bool {
	return in[a] <= in[b] && out[b] <= out[a]
}

func parent(a int) int {
	e := parents[a]
	if e.x == 1 {
		f := edges[find(e.i)]
		for parents[f.u] != nil && parents[f.u].x == 1 {
			union(e.i, parents[f.u].i)
			f = edges[find(e.i)]
		}
		return edges[find(e.i)].u
	}
	return parents[a].u
}

func find(u int) int {
	if A[u] == u {
		return u
	}
	A[u] = find(A[u])
	return A[u]
}

func union(u int, v int) {
	A[find(u)] = find(v)
}

package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"runtime/pprof"
	"strings"
)

var children [][]*edge
var parents []*edge
var edges []*edge
var in []int
var out []int
var A []int

type relation struct {
	o int
	x int64
	i int
}

type edge struct {
	u int
	v int
	x int64
	i int
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var memprofile = flag.String("memprofile", "", "write memory profile to this file")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	buf := NewBuffer(os.Stdin)
	var n, m int
	buf.ScanInts(&n, &m)
	// fmt.Printf("read %d %d\n", n, m)

	// var relatives [n + 1][]relation
	relatives := make([][]relation, n+1)

	for i := int(1); i <= n-1; i++ {
		var u, v int
		var x int64
		buf.ScanInts(&u, &v)
		buf.ScanInt64s(&x)
		// fmt.Printf("read %d %d %d\n", u, v, x)
		relatives[u] = append(relatives[u], relation{o: v, x: x, i: i})
		relatives[v] = append(relatives[v], relation{o: u, x: x, i: i})
	}

	children = make([][]*edge, n+1)
	parents = make([]*edge, n+1)
	edges = make([]*edge, n)
	enroot(relatives, 1, 0)

	in = make([]int, n+1)
	out = make([]int, n+1)
	t := 1
	dfs(1, &t)
	// fmt.Println(in)
	// fmt.Println(out)
	A = make([]int, n+1)
	for i := 1; i <= n; i++ {
		A[i] = i
	}

	if *memprofile != "" {
		f, err := os.Create(*memprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.WriteHeapProfile(f)
		// f.Close()
		// return
	}

	for i := 0; i < m; i++ {
		switch buf.NextInt() {
		case 1:
			var a, b int
			var y int64
			buf.ScanInts(&a, &b)
			buf.ScanInt64s(&y)
			// fmt.Printf("read 1 %d %d %d => %d\n", a, b, y, dist(a, b, y))
			fmt.Println(dist(a, b, y))
		case 2:
			p := buf.NextInt()
			c := buf.NextInt64()
			// fmt.Printf("read 2 %d %d\n", p, c)
			edges[p].x = c

		default:
			panic("BAD INT")
		}
	}
}

func enroot(relatives [][]relation, u int, parent int) {
	for _, r := range relatives[u] {
		if r.o != parent {
			e := edge{u: u, v: r.o, x: r.x, i: r.i}
			// fmt.Printf("read %v\n", e)
			children[e.u] = append(children[e.u], &e)
			parents[e.v] = &e
			edges[e.i] = &e
			enroot(relatives, r.o, u)
		}
	}
}

func dfs(u int, t *int) {
	in[u] = *t
	(*t)++
	for _, e := range children[u] {
		dfs(e.v, t)
	}
	out[u] = *t
}

func dist(a int, b int, y int64) int64 {
	y = distCommonAncestor(a, b, y)
	y = distCommonAncestor(b, a, y)
	return y
}

func distCommonAncestor(a int, b int, y int64) int64 {
	for y > 0 && !ancestor(a, b) {
		y /= parents[a].x
		a = parent(a)
	}
	return y
}

func ancestor(a int, b int) bool {
	return in[a] <= in[b] && out[b] <= out[a]
}

func parent(a int) int {
	e := parents[a]
	if e.x == 1 {
		f := edges[find(e.i)]
		for parents[f.u] != nil && parents[f.u].x == 1 {
			union(e.i, parents[f.u].i)
			f = edges[find(e.i)]
		}
		return edges[find(e.i)].u
	}
	return parents[a].u
}

func find(u int) int {
	if A[u] == u {
		return u
	}
	A[u] = find(A[u])
	return A[u]
}

func union(u int, v int) {
	A[find(u)] = find(v)
}

/////////////////////////////////////////////////////
// FUCKING GO                                      //
// SCANF IS FAST ENOUGH FOR C/C++, BUT NOOOO,      //
// GO'S SHITTY IMPLEMENTATION TIMES OUT            //
// SO I HAVE TO WRITE MY OWN FUCKING SCANNER, FUCK //
/////////////////////////////////////////////////////

type Buffer struct {
	words []string
	i     int
}

func NewBuffer(f *os.File) *Buffer {
	bytes, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err.Error())
	}
	s := string(bytes)
	s = strings.Replace(s, "\r", "", -1)
	s = strings.Replace(s, "\n", " ", -1)
	return &Buffer{
		words: strings.Split(s, " "),
		i:     0,
	}
}

func (b *Buffer) NextInt() int {
	x := 0
	for _, c := range b.words[b.i] {
		x = x*10 + int(c-'0')
	}
	b.i++
	return x
}

func (b *Buffer) ScanInts(ps ...*int) {
	for _, p := range ps {
		*p = b.NextInt()
	}
}

func (b *Buffer) NextInt64() int64 {
	x := int64(0)
	for _, c := range b.words[b.i] {
		x = x*10 + int64(c-'0')
	}
	b.i++
	return x
	// x, err := strconv.Atoi(b.words[b.i])
	// if err == nil {
	// 	b.i++
	// 	return int64(x)
	// }
	// var y int64
	// fmt.Sscanf(b.words[b.i], "%d", &y)
	// b.i++
	// return y
}

func (b *Buffer) ScanInt64s(ps ...*int64) {
	for _, p := range ps {
		*p = b.NextInt64()
	}
}

package main

import (
	"fmt"
)

var children map[int][]*edge
var parents map[int]*edge
var edges map[int]*edge
var in map[int]int
var out map[int]int
var A map[int]int

func main() {
	var n, m int
	fmt.Scanf("%d %d\r\n", &n, &m)
	// fmt.Printf("read %d %d\n", n, m)
	children = make(map[int][]*edge)
	parents = make(map[int]*edge)
	edges = make(map[int]*edge)
	for i := 1; i <= n-1; i++ {
		var e edge
		e.i = i
		fmt.Scanf("%d %d %d\r\n", &e.u, &e.v, &e.x)
		// fmt.Printf("read %v\n", e)
		children[e.u] = append(children[e.u], &e)
		parents[e.v] = &e
		edges[i] = &e
	}

	in = make(map[int]int)
	out = make(map[int]int)
	t := 1
	dfs(1, &t)
	// fmt.Println(in)
	// fmt.Println(out)
	A = make(map[int]int)
	for i := 1; i <= n; i++ {
		A[i] = i
	}

	for i := 0; i < m; i++ {
		var a, b, y int
		scanned, _ := fmt.Scanf("1 %d %d %d\r\n", &a, &b, &y)
		if scanned > 0 {
			// fmt.Printf("read 1 %d %d %d => %d\n", a, b, y, dist(a, b, y))
			fmt.Println(dist(a, b, y))
		} else {
			var p, c int
			fmt.Scanf("%d %d\r\n", &p, &c)
			// fmt.Printf("read 2 %d %d\n", p, c)
			edges[p].x = c
		}
	}
}

type edge struct {
	u int
	v int
	x int
	i int
}

func dfs(u int, t *int) {
	in[u] = *t
	(*t)++
	for _, e := range children[u] {
		dfs(e.v, t)
	}
	out[u] = *t
}

func dist(a int, b int, y int) int {
	y = distCommonAncestor(a, b, y)
	y = distCommonAncestor(b, a, y)
	return y
}

func distCommonAncestor(a int, b int, y int) int {
	for y > 0 && !ancestor(a, b) {
		y /= parents[a].x
		a = parent(a)
	}
	return y
}

func ancestor(a int, b int) bool {
	return in[a] <= in[b] && out[b] <= out[a]
}

func parent(a int) int {
	e := parents[a]
	if e.x == 1 {
		f := edges[find(e.i)]
		for parents[f.u] != nil && parents[f.u].x == 1 {
			f = parents[f.u]
			union(e.i, f.i)
		}
		return edges[find(e.i)].u
	}
	return parents[a].u
}

func find(u int) int {
	if A[u] == u {
		return u
	}
	A[u] = find(A[u])
	return A[u]
}

func union(u int, v int) {
	A[find(u)] = find(v)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	for i := 1; i <= m; i++ {
		fmt.Println(1337)
	}
}


Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help.Filya is given an array of non-negative integers a1, a2, ..., an. First, he pick an integer x and then he adds x to some elements of the array (no more than once), subtract x from some other elements (also, no more than once) and do no change other elements. He wants all elements of the array to be equal.Now he wonders if it's possible to pick such integer x and change some elements of the array using this x in order to make all elements equal.

The first line of the input contains an integer n (1 ≤ n ≤ 100 000) — the number of integers in the Filya's array. The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109) — elements of the array.

If it's impossible to make all elements of the array equal using the process given in the problem statement, then print "NO" (without quotes) in the only line of the output. Otherwise print "YES" (without quotes).

NoteIn the first sample Filya should select x = 1, then add it to the first and the last elements of the array and subtract from the second and the third elements.

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

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

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

func solve(n int) {
	var a, b, q int
	I(&a, " ")
	var c string
	for i := 1; i < n; i++ {
		o := " "
		if i == n-1 {
			o = "\n"
		}
		I(&b, o)
		t := abs(a - b)
		if q < 4 && t != 0 && !strings.Contains(c, "~"+strconv.Itoa(t)) {
			c += "~" + strconv.Itoa(t)
			q++
		}
	}
	var oo []string
	if len(c) > 0 {
		oo = strings.Split(c[1:], "~")
	}
	if len(oo) > 2 {
		O("NO", "\n")
		return
	}
	if len(oo) == 2 {
		x, _ := strconv.Atoi(oo[0])
		y, _ := strconv.Atoi(oo[1])
		if x*2 != y && y*2 != x {
			O("NO", "\n")
			return
		}
	}
	O("YES", "\n")
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

package main

import "fmt"
import "bufio"
import "os"
import "sort"

// import "math/rand"

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

func can(a []int, n int) bool {
	sort.Ints(a)
	cnt := 0
	for i := 1; i < n; i++ {
		if a[i] > a[cnt] {
			cnt++
			a[cnt] = a[i]
		}
	}

	n = cnt + 1

	if n > 3 {
		return false
	}

	if n <= 2 {
		return true
	}

	return a[1]-a[0] == a[2]-a[1]
}

func good(a []int, n int, x int) bool {
	k := -1
	for i := 0; i < n; i++ {
		d := a[i] - x
		if d < 0 {
			d = -d
		}
		if d != 0 {
			if k == -1 {
				k = d
			} else if k != d {
				return false
			}
		}
	}
	return true
}

func brute(a []int, n int) bool {
	for x := 0; x <= 10; x++ {
		if good(a, n, x) {
			return true
		}
	}
	return false
}

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

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

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

	if can(a, n) {
		fmt.Fprintf(bufout, "YES\n")
	} else {
		fmt.Fprintf(bufout, "NO\n")
	}

	// for test := 0; test <= 1000; test++ {
	// 	n := 6
	// 	m := 5
	// 	a := make([]int, n)
	// 	fmt.Fprintf(bufout, "%d\n", n)
	// 	for i := 0; i < n; i++ {
	// 		a[i] = rand.Int() % m
	// 		fmt.Fprintf(bufout, "%d ", a[i])
	// 	}
	// 	fmt.Fprintf(bufout, "\n")
	//
	// 	wanted := brute(a, n)
	// 	got := can(a, n)
	//
	// 	if wanted != got {
	// 		fmt.Fprintf(bufout, ">> WA!!! wanted %v, got %v\n", wanted, got)
	// 		break
	// 	} else {
	// 		fmt.Fprintf(bufout, ">> AC.\n")
	// 	}
	// }
}

package main

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

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

	v := make([]int, 3)
	vi := 0
	overflow := false

	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
		}

		if overflow {
			continue
		}

		exist := false
		for j := 0; j < vi && j < 3; j++ {
			if v[j] == a {
				exist = true
			}
		}

		if !exist {
			if vi < 3 {
				v[vi] = a
				vi++
			} else {
				overflow = true
			}
		}
	}

	if overflow {
		fmt.Println("NO")
	} else if vi < 3 {
		fmt.Println("YES")
	} else {
		sum := int64(v[0]) + int64(v[1]) + int64(v[2])
		if sum%3 != 0 {
			fmt.Println("NO")
		} else {
			avg := sum / 3
			for i := 0; i < 3; i++ {
				if avg == int64(v[i]) {
					fmt.Println("YES")
					return
				}
			}
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")

	c, _ := strconv.Atoi(s[0])

	z := []int{}
	text, _ = reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s = strings.Split(text, " ")
	for i := 0; i < c; i++ {
		x, _ := strconv.Atoi(s[i])
		found := false
		for _, v := range z {
			if x == v {
				found = true
				break
			}
		}
		if found == false {
			z = append(z, x)
		}
		if len(z) > 3 {
			fmt.Println("NO")
			return
		}
	}
	if len(z) == 3 {
		sort.Ints(z)
		if (z[1] - z[0]) != (z[2] - z[1]) {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

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

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

func solve(n int) {
	var a, b, q int
	I(&a, " ")
	var c string
	for i := 1; i < n; i++ {
		o := " "
		if i == n-1 {
			o = "\n"
		}
		I(&b, o)
		t := abs(a - b)
		if t != 0 && !strings.Contains(c, "~"+strconv.Itoa(t)) {
			c += "~" + strconv.Itoa(t)
			q++
			if q > 2 {
				break
			}
		}
	}
	var oo []string
	if len(c) > 0 {
		oo = strings.Split(c[1:], "~")
	}
	if len(oo) > 2 {
		O("NO", "\n")
		return
	}
	if len(oo) == 2 {
		x, _ := strconv.Atoi(oo[0])
		y, _ := strconv.Atoi(oo[1])
		if x*2 != y && y*2 != x {
			O("NO", "\n")
			return
		}
	}
	O("YES", "\n")
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

package main

import "fmt"
import "bufio"
import "os"
import "sort"

func can(a []int, n int) bool {
	sort.Ints(a)
	cnt := 0
	for i := 1; i < n; i++ {
		if a[i] > a[cnt] {
			cnt++
			a[cnt] = a[i]
		}
	}

	n = cnt + 1
	if n > 3 {
		return false
	}

	if n == 1 {
		return true
	}

	if n == 2 {
		return (a[1]-a[0])%2 == 0
	}

	return a[1]-a[0] == a[2]-a[1]
}

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

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

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

	if can(a, n) {
		fmt.Fprintf(bufout, "YES\n")
	} else {
		fmt.Fprintf(bufout, "NO\n")
	}
}

package main

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

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

	v := make([]int, 3)
	vi := 0
	overflow := false

	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
		}

		if overflow {
			continue
		}

		exist := false
		for j := 0; j < vi && j < 3; j++ {
			if v[j] == a {
				exist = true
			}
		}

		if !exist {
			if vi < 3 {
				v[vi] = a
				vi++
			} else {
				overflow = true
			}
		}
	}

	if overflow {
		fmt.Println("NO")
	} else if vi < 3 {
		fmt.Println("YES")
	} else {
		sum := float64(v[0]+v[1]+v[2]) / 3
		for i := 0; i < 3; i++ {
			if sum == float64(v[i]) {
				fmt.Println("YES")
				return
			}
		}
		fmt.Println("NO")
	}
}

package main

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

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

	v := make([]int, 3)
	vi := 0
	overflow := false

	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
		}

		if overflow {
			continue
		}

		exist := false
		for j := 0; j < vi && j < 3; j++ {
			if v[j] == a {
				exist = true
			}
		}

		if !exist {
			if vi < 3 {
				v[vi] = a
				vi++
			} else {
				overflow = true
			}
		}
	}

	if overflow || vi == 2 {
		fmt.Println("NO")
	} else if vi == 1 {
		fmt.Println("YES")
	} else {
		sum := float32(v[0]+v[1]+v[2]) / 3
		for i := 0; i < 3; i++ {
			if sum == float32(v[i]) {
				fmt.Println("YES")
				return
			}
		}
		fmt.Println("NO")
	}
}

package main

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

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

	v := make([]int, 3)
	vi := 0
	overflow := false

	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
		}

		if overflow {
			continue
		}

		exist := false
		for j := 0; j < vi && j < 3; j++ {
			if v[j] == a {
				exist = true
			}
		}

		if !exist {
			if vi < 3 {
				v[vi] = a
				vi++
			} else {
				overflow = true
			}
		}
	}

	if overflow {
		fmt.Println("NO")
	} else if vi < 3 {
		fmt.Println("YES")
	} else {
		sum := float32(v[0]+v[1]+v[2]) / 3
		for i := 0; i < 3; i++ {
			if sum == float32(v[i]) {
				fmt.Println("YES")
				return
			}
		}
		fmt.Println("NO")
	}
}


You're given an array $$$a$$$ of length $$$n$$$. You can perform the following operation on it as many times as you want:  Pick two integers $$$i$$$ and $$$j$$$ $$$(1 \le i,j \le n)$$$ such that $$$a_i+a_j$$$ is odd, then swap $$$a_i$$$ and $$$a_j$$$. What is lexicographically the smallest array you can obtain?An array $$$x$$$ is lexicographically smaller than an array $$$y$$$ if there exists an index $$$i$$$ such that $$$x_i<y_i$$$, and $$$x_j=y_j$$$ for all $$$1 \le j < i$$$. Less formally, at the first index $$$i$$$ in which they differ, $$$x_i<y_i$$$

The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of elements in the array $$$a$$$. The second line contains $$$n$$$ space-separated integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array $$$a$$$.

The only line contains $$$n$$$ space-separated integers, the lexicographically smallest array you can obtain.

NoteIn the first example, we can swap $$$1$$$ and $$$4$$$ since $$$1+4=5$$$, which is odd.

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,x  int
	fmt.Fscan(in,&n)
	a := make([]int,0)
	// 1 2 6 4
	var odd,even = 0,0
	for i := 0; i < n ;i ++{
		fmt.Fscan(in,&x)
		a = append(a,x)
		if(x  % 2 == 0){
			even ++
		}else{
				odd ++
		}
	}
	if(odd >= 1 && even >= 1){
		sort.Ints(a)
	}
	for i := 0 ; i < n; i++{
		fmt.Fprint(out,a[i]," ")
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	haveOdd := false
	haveEven := false
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
		if a[i]%2 == 0 {
			haveEven = true
		} else {
			haveOdd = true
		}
	}
	fmt.Fscanf(in, "\n")
	if haveEven && haveOdd {
		sort.Ints(a)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fprintf(out, "%d ", a[i])
	}
	fmt.Fprintf(out, "%d\n", a[n-1])

	return
}
func minstep(a, b byte) int {
	return min(int(a-b+26)%26, int(b-a+26)%26)
}

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

// Author: sighduck
// URL: https://codeforces.com/contest/1174/problem/B

package main

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

func Solve(n int, a []int) []int {
	even := 0
	odd := 0
	for _, elem := range a {
		if elem%2 == 0 {
			even += 1
		} else {
			odd += 1
		}
	}
	if even == n || odd == n {
		return a
	}
	sort.Ints(a)
	return a
}

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

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

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


As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we'll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.  Each ip is of form "a.b.c.d" where a, b, c and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.Dustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him.

The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000). The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct. The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, command only consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.

Print m lines, the commands in the configuration file after Dustin did his task.

// Codeforces helper functions
// 20 Jan 18
// samadhi

package main

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

type Command struct {
	command, ip string
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	// fmt.Println("Hello, world!")
	input := gsli(reader)

	serverCount := input[0]
	commandCount := input[1]

	servers := make(map[string]string)
	var commands []Command

	for i := 0; i < serverCount; i++ {
		in := gsls(reader)
		name := in[0]
		ip := in[1]
		servers[ip] = name
	}

	for i := 0; i < commandCount; i++ {
		in := gsls(reader)
		command := in[0] + " " + in[1]
		ip := in[1][:len(in[1])-1]
		var curCom Command
		curCom.ip = ip
		curCom.command = command
		commands = append(commands, curCom)
	}

	for _, command := range commands {
		name := servers[command.ip]
		fmt.Printf("%v #%v\n", command.command, name)

	}

}

// Input helpers

// If you don't pass in a reference to the reader, and just instantiate a new
// one every time, it will work locally, with IO typed at human-speed, but not
// on Codeforces.

// Get Space-separated Line as Strings
//
// Example input:
// 1 test 382.0
// Example output:
// ["1", "test", "382.0"]

func gsls(reader *bufio.Reader) (arr []string) {
	// Get a full line
	input, _ := reader.ReadString('\n')

	//Strip newline and return chars, if any
	input = strings.TrimSuffix(input, "\n")
	input = strings.TrimSuffix(input, "\r")

	// Split at the spaces into an array
	arr = strings.Split(input, " ")

	return
}

// Get Space-separated Line as Integers
// Any non-valid integers will be 0
//
// Example input:
// test 1 12.3 -117
// Example output:
// [0, 1, 0, -117]

func gsli(reader *bufio.Reader) (arr []int) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.Atoi(e)
		arr = append(arr, cur)
	}

	return
}

// Get Space-separated Line as 64-bit Floats
// Any non-valid floats will be 0
//
// Example input:
// test 128.328 12 -11.0
// Example output:
// [0, 128.328, 12, -11]

func gslf(reader *bufio.Reader) (arr []float64) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.ParseFloat(e, 64)
		arr = append(arr, cur)
	}

	return
}

// Math helpers

// Positve Modulo
// Returns x mod y, but always positive

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

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	m := readi()
	hosts := make(map[string]string)
	for i := 0; i < n; i++ {
		name := reads()
		ip := reads()
		hosts[ip] = name
	}
	for i := 0; i < m; i++ {
		cmd := reads()
		ip := reads()
		ip = ip[:len(ip)-1]
		printf("%s %s; #%s\n", cmd, ip, hosts[ip])
	}
}

// Codeforces helper functions
// 20 Jan 18
// samadhi

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	// fmt.Println("Hello, world!")
	input := gsli(reader)

	serverCount := input[0]
	commandCount := input[1]

	servers := make(map[string]string)
	commands := make(map[string]string)

	for i := 0; i < serverCount; i++ {
		in := gsls(reader)
		name := in[0]
		ip := in[1]
		servers[ip] = name
	}

	for i := 0; i < commandCount; i++ {
		in := gsls(reader)
		command := in[0] + " " + in[1]
		ip := in[1][:len(in[1])-1]
		commands[command] = ip
	}

	for command, ip := range commands {
		name := servers[ip]
		fmt.Printf("%v #%v \n", command, name)
	}

}

// Input helpers

// If you don't pass in a reference to the reader, and just instantiate a new
// one every time, it will work locally, with IO typed at human-speed, but not
// on Codeforces.

// Get Space-separated Line as Strings
//
// Example input:
// 1 test 382.0
// Example output:
// ["1", "test", "382.0"]

func gsls(reader *bufio.Reader) (arr []string) {
	// Get a full line
	input, _ := reader.ReadString('\n')

	//Strip newline and return chars, if any
	input = strings.TrimSuffix(input, "\n")
	input = strings.TrimSuffix(input, "\r")

	// Split at the spaces into an array
	arr = strings.Split(input, " ")

	return
}

// Get Space-separated Line as Integers
// Any non-valid integers will be 0
//
// Example input:
// test 1 12.3 -117
// Example output:
// [0, 1, 0, -117]

func gsli(reader *bufio.Reader) (arr []int) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.Atoi(e)
		arr = append(arr, cur)
	}

	return
}

// Get Space-separated Line as 64-bit Floats
// Any non-valid floats will be 0
//
// Example input:
// test 128.328 12 -11.0
// Example output:
// [0, 128.328, 12, -11]

func gslf(reader *bufio.Reader) (arr []float64) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.ParseFloat(e, 64)
		arr = append(arr, cur)
	}

	return
}

// Math helpers

// Positve Modulo
// Returns x mod y, but always positive

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


The $$$\text{$$$gcdSum$$$}$$$ of a positive integer is the $$$gcd$$$ of that integer with its sum of digits. Formally, $$$\text{$$$gcdSum$$$}(x) = gcd(x, \text{ sum of digits of } x)$$$ for a positive integer $$$x$$$. $$$gcd(a, b)$$$ denotes the greatest common divisor of $$$a$$$ and $$$b$$$ — the largest integer $$$d$$$ such that both integers $$$a$$$ and $$$b$$$ are divisible by $$$d$$$.For example: $$$\text{$$$gcdSum$$$}(762) = gcd(762, 7 + 6 + 2)=gcd(762,15) = 3$$$.Given an integer $$$n$$$, find the smallest integer $$$x \ge n$$$ such that $$$\text{$$$gcdSum$$$}(x) > 1$$$.

The first line of input contains one integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of test cases.  Then $$$t$$$ lines follow, each containing a single integer $$$n$$$ $$$(1 \le n \le 10^{18})$$$. All test cases in one test are different.

Output $$$t$$$ lines, where the $$$i$$$-th line is a single integer containing the answer to the $$$i$$$-th test case.

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

func gcd(x,y int64) int64 { // looping function that returns itself until y=0 condtion met
	if y==0 {
		return x
	}
	return gcd(y,x%y)
}

func summer(x int64) int64 {
	var sum int64
	for x != 0 {
		sum+=(x%10)
		x/=10
	}
	return sum
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for ; !specialGcd(n, sumDigits(n)); n++ {
		}
		writer.WriteString(fmt.Sprintln(n))
	}
	writer.Flush()
}

func specialGcd(a, b uint64) bool {
	for i := uint64(2); i <= b; i++ {
		if a%i == 0 && b%i == 0 {
			return true
		}
	}
	return false
}

func sumDigits(a uint64) uint64 {
	var res uint64
	for ; a > 0; a /= 10 {
		res += a % 10
	}
	return res
}

func parseInt(str string) uint64 {
	var res uint64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := uint64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for {
			var sum int64
			for i := n; i > 0; i /= 10 {
				sum += i % 10
			}
			if specialGcd(n, sum) {
				writer.WriteString(fmt.Sprintln(n))
				break
			}
			n++
		}
	}
	writer.Flush()
}

func specialGcd(a, b int64) bool {
	for i := int64(2); i <= b; i++ {
		if a%i == 0 && b%i == 0 {
			return true
		}
	}
	return false
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for ; !specialGcd(n, sumDigits(n)); n++ {
		}
		writer.WriteString(fmt.Sprintln(n))
	}
	writer.Flush()
}

func specialGcd(a, b int64) bool {
	for i := int64(2); i <= b; i++ {
		if a%i == 0 && b%i == 0 {
			return true
		}
	}
	return false
}

func sumDigits(a int64) int64 {
	var res int64
	for ; a > 0; a /= 10 {
		res += a % 10
	}
	return res
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for ; specialGcd(n, sumDigits(n)) == 1; n++ {
		}
		writer.WriteString(fmt.Sprintln(n))
	}
	writer.Flush()
}

func specialGcd(a, b int64) int64 {
	for i := int64(165); i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			return i
		}
	}
	return 1
}

func sumDigits(a int64) int64 {
	var res int64
	for ; a > 0; a /= 10 {
		res += a % 10
	}
	return res
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

import (
	"fmt"
	"bufio"
	"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 gcd(a, b int64) int64 {
	if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}

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

	//f, _ := os.OpenFile("in", os.O_RDONLY,0666)
	//os.Stdin = f

	var t int
	scanf("%d\n", &t)
	var n int64
	for t != 0 {
		scanf("%d\n", &n)
		for {
			var sum int64
			tn := n
			for {
				if tn == 0 {
					break
				}
				sum += tn % 10
				tn /= 10
			}
			if gcd(n, sum) > 1 {
				break
			}
			n++
		}
		printf("%d\n", n)
		t--
	}
}

package main

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

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

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

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

type Pair struct {
	a, b int
}

type Pairs []Pair

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

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

func gcdSum(n int64) int64 {
	temp, digit := n, int64(0)
	for temp > 0 {
		digit += temp % 10
		temp = temp / 10
	}
	ans := gcd(n, digit)
	return ans
}

func main() {
	defer writer.Flush()

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

	for t > 0 {
		var n int64
		scanf("%d\n", &n)
		if gcdSum(n) != 1 {
			printf("%d\n", n)
		} else if gcdSum(n+1) != 1 {
			printf("%d\n", n+1)
		} else if gcdSum(n+2) != 1 {
			printf("%d\n", n+2)
		}
		t--
	}

}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i++ {
		var n int64
		fmt.Scan(&n)
		for ; ; n++ {
			s := calSum(n)
			check := false
			for j := int64(2); j <= s; j++ {
				if n%j == 0 && s%j == 0 {
					check = true
					break
				}
			}
			if check {
				fmt.Println(n)
				break
			}
		}
	}
}

func calSum(n int64) int64 {
	s := int64(0)
	for n > 0 {
		s += n % 10
		n /= 10
	}
	return s
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt64()

		for ; gcd(n, sumDigs(n)) == 1; n++ {
		}

		fmt.Println(n)
	}
}

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

	if y == 0 {
		return x
	}

	return gcd(y, x%y)
}

func sumDigs(x int64) int64 {
	var sum int64

	for x > 0 {
		sum += x % 10
		x /= 10
	}

	return sum
}

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}

func (s *Scanner) next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}

func (s *Scanner) nextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (s *Scanner) nextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

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

func digitSum(N int64) int64 {
	cur := N
	sum := int64(0)
	for cur > 0 {
		sum += cur % 10
		cur /= 10
	}
	return sum
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.nextInt()
	for tc := 0; tc < TC; tc++ {
		N := sc.nextInt64()

		for gcd(N, digitSum(N)) == 1 {
			N++
		}
		fmt.Fprintln(wr, N)
	}

}

package main

import "fmt"
func gcd(n int64)int64{
    var temp int64;
    var sum int64;
    temp=n;
    sum=0;
    for temp>0{
        sum+=temp%10;
        temp/=10;
    }
    var res int64;
    if (n>sum){
        res=sum;
    }else {
        res=n;
    }
    //fmt.Println(res);
    for res>0{
        if(n%res==0 && sum%res==0){
            return res;
        }
        res-=1;
    }
    return 1;
}
func solve(){
    var n int64;
    //var i int64;
    fmt.Scanln(&n);
    if(gcd(n)!=1){
        fmt.Println(n);
    } else if(gcd(n+1)!=1){
        fmt.Println(n+1);
    }else if(gcd(n+2)!=2){
        fmt.Println(n+2);
    }

}
func main() {
   var t int;
   fmt.Scanln(&t);
   for t>0{
       solve();
       t=t-1;
   }
}

package main

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

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

func (in *CF1498A) 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 *CF1498A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1498A
Date: 11/02/22
User: epradere
URL: https://codeforces.com/problemset/problem/1498/A
Problem: CF1498A
**/
func (in *CF1498A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		num, _ := strconv.ParseInt(str, 10, 64)

		ans := 1
		sol := num
		for ans == 1 {
			sum := 0
			for i := 0; i < len(str); i++ {
				sum += int(str[i]) - '0'
			}
			for i := sum; i >= 1; i-- {
				if sum%i == 0 && num%int64(i) == 0 {
					ans = i
					sol = num
					break
				}
			}
			num++
			str = fmt.Sprintf("%v", num)

		}

		fmt.Println(sol)

	}
}

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

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

package main

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

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

func sumDigits(n int64) int64 {
	s := int64(0)
	for ; n > 0; n /= 10 {
		s += n % 10
	}
	return s
}

func gcd(a, b int64) int64 {
	if b > a {
		return gcd(b, a)
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func gcdSum(a int64) int64 {
	return gcd(a, sumDigits(a))
}

func solve(n int64) int64 {
	for ; ; n++ {
		if gcdSum(n) > 1 {
			return n
		}
	}
}

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

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		var n uint64
		s, _ := reader.ReadBytes('\n')
		readUint64(s, 0, &n)
		res := solve(int64(n))
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int64) int64 {
	for {
		g := gcd(n, digitSum(n))
		if g > 1 {
			return n
		}
		n++
	}
}

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

func digitSum(num int64) int64 {
	var res int64

	for num > 0 {
		res += num % 10
		num /= 10
	}

	return res
}

package main

import "fmt"

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}
func bitSum(n int64) int64 {
	var ret int64 = 0
	for ; n > 0; n /= 10 {
		ret += n % 10
	}
	return ret
}
func main() {
	var t int64
	var c byte
	fmt.Scanf("%d%c%c", &t, &c, &c)
	var n int64
	for ; t > 0; t-- {
		fmt.Scanf("%d%c%c", &n, &c, &c)
		for ; gcd(n, bitSum(n)) == 1; n++ {
		}
		fmt.Printf("%d\n", n)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n int64
	fmt.Scan(&t)
	for t != 0 {
		t--
		fmt.Scan(&n)
		for gcd(n, calSum(n)) == 1 {
			n++
		}
		fmt.Println(n)
	}
}

func calSum(n int64) int64 {
	var sum int64
	for n != 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}

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

package main

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

const N int = 1e5 + 5
var stdIn = bufio.NewReader(os.Stdin)
var stdOut = bufio.NewWriter(os.Stdout)
func gcd(a, b int64) int64{
	if b == 0{
		return a
	} else {
		return gcd(b, a % b)
	}
}
func sum(x int64) int64{
	var s int64
	for x > 0{
		s += x % 10
		x /= 10
	}
	return s
}
func cal(x int64) int64{

	for gcd(x, sum(x)) == 1{
		x ++
	}
	return x
}
func main() {
	defer stdOut.Flush()
	n := 0
	fmt.Fscan(stdIn, &n)
	for ; n > 0; n --{
		var x int64
		fmt.Fscan(stdIn, &x)
		ans := cal(x)
		fmt.Fprintln(stdOut, ans)
	}

}

package main

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

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	l, _ := strconv.Atoi(scan.Text())
	for i := 0; i < l; i++ {
		scan.Scan()
		num, _ := strconv.ParseInt(scan.Text(), 10, 64)
		for gcd(num, sum(num)) <= 1 {
			num++
		}
		fmt.Printf("%d\n", num)
	}
}

func sum(n int64) int64 {
	if n < 10 {
		return n
	}
	return n%10 + sum(n/10)
}

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

package main

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

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

	var t, n int64
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		for ; gcd(n, sum(n)) == 1; n++ {
		}
		fmt.Println(n)
	}
}

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

func sum(n int64) int64 {
	var s int64
	for n > 0 {
		s += n % 10
		n /= 10
	}
	return s
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		for j:=0;j<=n;j++{
			if gcd(n,summer(n)) > 1 {
				fmt.Fprintln(out,n)
				break
			}
			n++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<x;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}
func summer(x int) int {
	x_str:= strconv.Itoa(x)
	sum:=0
	for j:=0;j<len(x_str);j++{
		x_int,_:= strconv.Atoi(string(x_str[j]))
		sum+=x_int
	}
	return sum
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		for j:=0;j<=n*n;j++{
			if gcd(n,summer(n)) > 1 {
				fmt.Fprintln(out,n)
				break
			}
			n++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<10;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}
func summer(x int) int {
	x_str:= strconv.Itoa(x)
	sum:=0
	for j:=0;j<len(x_str);j++{
		x_int,_:= strconv.Atoi(string(x_str[j]))
		sum+=x_int
	}
	return sum
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n string
		fmt.Fscan(in,&n)
		sum:=0
		for j:=0;j<len(n);j++{
			x,_ := strconv.Atoi(string(n[j]))
			sum+=x
		}
		n_int,_:= strconv.Atoi(string(n))
		for j:=0;j<=n_int;j++{
			if gcd(n_int,summer(n_int)) > 1 {
				fmt.Fprintln(out,n_int)
				break
			}
			n_int++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<x;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}
func summer(x int) int {
	x_str:= strconv.Itoa(x)
	sum:=0
	for j:=0;j<len(x_str);j++{
		x_int,_:= strconv.Atoi(string(x_str[j]))
		sum+=x_int
	}
	return sum
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n string
		fmt.Fscan(in,&n)
		sum:=0
		for j:=0;j<len(n);j++{
			x,_ := strconv.Atoi(string(n[j]))
			sum+=x
		}
		n_int,_:= strconv.Atoi(string(n))
		for j:=0;j<=n_int;j++{
			if summer(gcd(n_int,sum)) > 1 {
				fmt.Fprintln(out,n_int)
				break
			}
			n_int++
			sum++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<x;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}
func summer(x int) int {
	x_str:= strconv.Itoa(x)
	sum:=0
	for j:=0;j<len(x_str);j++{
		x_int,_:= strconv.Atoi(string(x_str[j]))
		sum+=x_int
	}
	return sum
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n string
		fmt.Fscan(in,&n)
		sum:=0
		for j:=0;j<len(n);j++{
			x,_ := strconv.Atoi(string(n[j]))
			sum+=x
		}
		n_int,_:= strconv.Atoi(string(n))
		for j:=0;j<=n_int;j++{
			if gcd(n_int,sum) > 1 {
				fmt.Fprintln(out,n_int)
				break
			}
			n_int++
			sum++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<x;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n string
		fmt.Fscan(in,&n)
		sum:=0
		for j:=0;j<len(n);j++{
			x,_ := strconv.Atoi(string(n[j]))
			sum+=x
		}
		n_int,_:= strconv.Atoi(string(n))
		for j:=0;j<n_int;j++{
			if gcd(n_int,sum) > 1 {
				fmt.Fprintln(out,n_int)
				break
			}
			n_int++
			sum++
		}
	}
}
func gcd(x,y int) int {
	if y>=x {
		x,y=y,x
	}
	for j:=0;j<x;j++{
		if x%y == 0 {
			return y
		}
		x,y=y,x%y
	}
	return 1
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for {
			var sum uint32
			for i := n; i > 0; i /= 10 {
				sum += i % 10
			}
			if specialGcd(n, sum) {
				writer.WriteString(fmt.Sprintln(n))
				break
			}
			n++
		}
	}
	writer.Flush()
}

func specialGcd(a, b uint32) bool {
	for i := uint32(2); i <= b; i++ {
		if a%i == 0 && b%i == 0 {
			return true
		}
	}
	return false
}

func parseInt(str string) uint32 {
	var res uint32
	size := len(str)
	for i := 0; i < size; i++ {
		digit := uint32(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		for ; specialGcd(n, sumDigits(n)) == 1; n++ {
		}
		writer.WriteString(fmt.Sprintln(n))
	}
	writer.Flush()
}

func specialGcd(a, b int64) int64 {
	for i := int64(154); i > 0; i-- {
		if a%i == 0 && b%i == 0 {
			return i
		}
	}
	return 1
}

func sumDigits(a int64) int64 {
	var res int64
	for ; a > 0; a /= 10 {
		res += a % 10
	}
	return res
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		var res int64
		if n%3 == 0 {
			res = n
		} else if (n+1)%3 == 0 {
			res = n + 1
		} else {
			res = n + 2
		}
		writer.WriteString(fmt.Sprintln(res))
	}
	writer.Flush()
}

func parseInt(str string) int64 {
	var res int64
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int64(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

import (
	"fmt"
//	"os"
)

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

func main() {
//	f, _ := os.OpenFile("in", os.O_RDONLY,0666)
//	os.Stdin = f

	var t int
	fmt.Scanf("%d", &t)
	var n int64
	for t != 0 {
		fmt.Scanf("%d", &n)
		for {
			var sum int64
			tn := n
			for {
				if tn == 0 {
					break
				}
				sum += tn % 10
				tn /= 10
			}
			if gcd(n, sum) > 1 {
				break
			}
			n++
		}
		fmt.Printf("%d\n", n)
		t--
	}
}

package main

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

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

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

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

type Pair struct {
	a, b int
}

type Pairs []Pair

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

func main() {
	defer writer.Flush()

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

	for t > 0 {
		var n int64
		scanf("%d\n", &n)
		for {
			if n%3 == 0 {
				break
			}
			n++
		}
		printf("%d\n", n)
		t--
	}

}

package main

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

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

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

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

type Pair struct {
	a, b int
}

type Pairs []Pair

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

func main() {
	defer writer.Flush()

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

	for t > 0 {
		var n int64
		scanf("%d\n", &n)
		for {
			if n%3 == 0 {
				break
			}
			n++
		}
		fmt.Println(n)
		t--
	}

}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		for ; ; n++ {
			s := calSum(n)
			check := false
			for j := 2; j <= s; j++ {
				if n%j == 0 && s%j == 0 {
					check = true
				}
			}
			if check {
				fmt.Println(n)
				break
			}
		}
	}
}

func calSum(n int) int {
	s := 0
	for n > 0 {
		s += n % 10
		n /= 10
	}
	return s
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		tp := n
		for ; ; tp++ {
			s := calSum(tp)
			j := s
			for j = s; j >= 1; j-- {
				if tp%j == 0 && s%j == 0 {
					break
				}
			}
			if j > 1 {
				fmt.Println(tp)
				break
			}
		}
	}
}

func calSum(n int) int {
	s := 0
	for n > 0 {
		s += n % 10
		n /= 10
	}
	return s
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()

		for ; gcd(n, sumDigs(n)) == 1; n++ {
		}

		fmt.Println(n)
	}
}

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

	if y == 0 {
		return x
	}

	return gcd(y, x%y)
}

func sumDigs(x int) int {
	sum := 0

	for x > 0 {
		sum += x % 10
		x /= 10
	}

	return sum
}

package main

import "fmt"
func solve(){
    var n int64;
    var i int64;
    fmt.Scanln(&n);
    for i=n;i<n+3;i++{
        if(i%3==0){
            fmt.Println(i);
            return;
        }
    }
}
func main() {
   var t int;
   fmt.Scanln(&t);
   for t>0{
       solve();
       t=t-1;
   }
}


Let $$$a$$$ be a matrix of size $$$r \times c$$$ containing positive integers, not necessarily distinct. Rows of the matrix are numbered from $$$1$$$ to $$$r$$$, columns are numbered from $$$1$$$ to $$$c$$$. We can construct an array $$$b$$$ consisting of $$$r + c$$$ integers as follows: for each $$$i \in [1, r]$$$, let $$$b_i$$$ be the greatest common divisor of integers in the $$$i$$$-th row, and for each $$$j \in [1, c]$$$ let $$$b_{r+j}$$$ be the greatest common divisor of integers in the $$$j$$$-th column. We call the matrix diverse if all $$$r + c$$$ numbers $$$b_k$$$ ($$$k \in [1, r + c]$$$) are pairwise distinct. The magnitude of a matrix equals to the maximum of $$$b_k$$$.For example, suppose we have the following matrix: $$$\begin{pmatrix} 2 & 9 & 7\\ 4 & 144 & 84 \end{pmatrix}$$$ We construct the array $$$b$$$:  $$$b_1$$$ is the greatest common divisor of $$$2$$$, $$$9$$$, and $$$7$$$, that is $$$1$$$;  $$$b_2$$$ is the greatest common divisor of $$$4$$$, $$$144$$$, and $$$84$$$, that is $$$4$$$;  $$$b_3$$$ is the greatest common divisor of $$$2$$$ and $$$4$$$, that is $$$2$$$;  $$$b_4$$$ is the greatest common divisor of $$$9$$$ and $$$144$$$, that is $$$9$$$;  $$$b_5$$$ is the greatest common divisor of $$$7$$$ and $$$84$$$, that is $$$7$$$. So $$$b = [1, 4, 2, 9, 7]$$$. All values in this array are distinct, so the matrix is diverse. The magnitude is equal to $$$9$$$.For a given $$$r$$$ and $$$c$$$, find a diverse matrix that minimises the magnitude. If there are multiple solutions, you may output any of them. If there are no solutions, output a single integer $$$0$$$.

The only line in the input contains two space separated integers $$$r$$$ and $$$c$$$ ($$$1 \leq r,c \leq 500$$$) — the number of rows and the number of columns of the matrix to be found.

If there is no solution, output a single integer $$$0$$$. Otherwise, output $$$r$$$ rows. The $$$i$$$-th of them should contain $$$c$$$ space-separated integers, the $$$j$$$-th of which is $$$a_{i,j}$$$ — the positive integer in the $$$i$$$-th row and $$$j$$$-th column of a diverse matrix minimizing the magnitude. Furthermore, it must hold that $$$1 \leq a_{i,j} \leq 10^9$$$. It can be shown that if a solution exists, there is also a solution with this additional constraint (still having minimum possible magnitude).

NoteIn the first example, the GCDs of rows are $$$b_1 = 4$$$ and $$$b_2 = 1$$$, and the GCDs of columns are $$$b_3 = 2$$$ and $$$b_4 = 3$$$. All GCDs are pairwise distinct and the maximum of them is $$$4$$$. Since the GCDs have to be distinct and at least $$$1$$$, it is clear that there are no diverse matrices of size $$$2 \times 2$$$ with magnitude smaller than $$$4$$$.In the second example, no matter what $$$a_{1,1}$$$ is, $$$b_1 = b_2$$$ will always hold, so there are no diverse matrices.

package main

import "fmt"

func main() {
	var r, c int
	var a [505][505]int
	fmt.Scanf("%d %d", &r, &c)
	if r == 1 && c == 1 {
		fmt.Println(0)
	} else if c == 1 {
		for i := 1; i <= r; i++ {
			a[i-1][0] = i + 1
		}

		for i := 0; i < r; i++ {
			for j := 0; j < c; j++ {
				fmt.Printf("%d ", a[i][j])
			}
			fmt.Println()
		}
	} else {
		for i := 1; i <= r; i++ {
			for j := r + 1; j <= r+c; j++ {
				a[i-1][j-r-1] = i * j
			}
		}

		for i := 0; i < r; i++ {
			for j := 0; j < c; j++ {
				fmt.Printf("%d ", a[i][j])
			}
			fmt.Println()
		}

	}

}

/*
URL:
https://codeforces.com/problemset/problem/1266/C
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	r, c int
)

func main() {
	r, c = ReadInt2()
	A := make([][]int, r)
	for i := 0; i < r; i++ {
		A[i] = make([]int, c)
	}

	if r == 1 && c == 1 {
		fmt.Println(0)
		return
	}

	if r == 1 {
		for i := 0; i < c; i++ {
			A[0][i] = i + 2
		}
		fmt.Println(PrintIntsLine(A[0]...))
		return
	}

	if c == 1 {
		for i := 0; i < r; i++ {
			A[i][0] = i + 2
		}

		for i := 0; i < r; i++ {
			fmt.Println(A[i][0])
		}
		return
	}

	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			A[i][j] = (i + 1) * (r + j + 1)
			PrintfDebug("i: %d, j: %d, A[i][j]: %d\n", i, j, A[i][j])
		}
	}
	for i := 0; i < r; i++ {
		fmt.Println(PrintIntsLine(A[i]...))
	}
	return
}

/*******************************************************************/

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

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

	var n, m int
	Fscan(_r, &n, &m)
	if n == 1 && m == 1 {
		Fprint(out, 0)
		return
	}
	if m == 1 {
		for i := 1; i <= n; i++ {
			Fprintln(out, i+1)
		}
		return
	}
	for i := 1; i <= n; i++ {
		for j := n + 1; j <= n+m; j++ {
			Fprint(out, i*j, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

const (
	mod = uint64(1e9 + 7)
)

type slot struct {
	from uint64
	num  uint64
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	r, c := 0, 0
	fmt.Fscanf(in, "%d %d\n", &r, &c)
	if r == 1 && c == 1 {
		fmt.Fprintf(out, "0\n")
		return
	}
	f := make([][]int, r)
	for i := 0; i < r; i++ {
		f[i] = make([]int, c)
	}
	if c == 1 {
		for i := 0; i < r; i++ {
			f[i][0] = i + 2
		}
	} else {
		for i := 0; i < c; i++ {
			f[0][i] = i + 2
		}
		for i := 1; i < r; i++ {
			for j := 0; j < c; j++ {
				f[i][j] = f[0][j] * (1 + c + i)
			}
		}
	}
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			fmt.Fprintf(out, "%d", f[i][j])
			if j != c-1 {
				fmt.Fprintf(out, " ")
			}
		}
		fmt.Fprintf(out, "\n")
	}
	return
}

func test(a []int, b [][]int) []int {
	fmt.Println("debug")
	fmt.Println(a)
	for i := 0; i < len(b); i++ {
		a[b[i][0]-1], a[b[i][1]-1] = a[b[i][1]-1], a[b[i][0]-1]
		fmt.Println(a, b[i])
	}
	fmt.Println("debug end")

	return a
}

// find num of elem >= k
func find(a []int, k int) int {
	if len(a) == 0 {
		return 0
	}
	n := len(a)
	if a[0] > k {
		return n
	}
	if a[n-1] < k {
		return 0
	}
	l := 0
	r := len(a) - 1
	for l < r {
		mid := (l + r) / 2
		if a[mid] < k {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return n - l
}

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

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}

package main

import "fmt"

func main() {
	var r, c int
	var a [500][500]int
	fmt.Scanf("%d %d", &r, &c)
	if r == 1 && c == 1 {
		fmt.Println(0)
	} else {
		for i := 1; i <= r; i++ {
			for j := r + 1; j <= r+c; j++ {
				a[i-1][j-r-1] = i * j
			}
		}

		for i := 0; i < r; i++ {
			for j := 0; j < c; j++ {
				fmt.Printf("%d ", a[i][j])
			}
			fmt.Println()
		}

	}

}

package main

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

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

	var n, m int
	Fscan(_r, &n, &m)
	if n == 1 && m == 1 {
		Fprint(out, 0)
		return
	}
	for i := 1; i <= n; i++ {
		for j := n + 1; j <= n+m; j++ {
			Fprint(out, i*j, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

const (
	mod = uint64(1e9 + 7)
)

type slot struct {
	from uint64
	num  uint64
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	r, c := 0, 0
	fmt.Fscanf(in, "%d %d\n", &r, &c)
	if r == 1 && c == 1 {
		fmt.Fprintf(out, "0\n")
		return
	}
	f := make([][]int, r)
	for i := 0; i < r; i++ {
		f[i] = make([]int, c)
	}
	if c == 1 {
		for i := 0; i < r; i++ {
			f[i][0] = i + 2
		}
	} else {
		for i := 0; i < c; i++ {
			f[0][i] = i + 2
		}
		for i := 1; i < r; i++ {
			for j := 0; j < c; j++ {
				f[i][j] = f[0][j] * (1 + r + i)
			}
		}
	}
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			fmt.Fprintf(out, "%d", f[i][j])
			if j != c-1 {
				fmt.Fprintf(out, " ")
			}
		}
		fmt.Fprintf(out, "\n")
	}
	return
}

func test(a []int, b [][]int) []int {
	fmt.Println("debug")
	fmt.Println(a)
	for i := 0; i < len(b); i++ {
		a[b[i][0]-1], a[b[i][1]-1] = a[b[i][1]-1], a[b[i][0]-1]
		fmt.Println(a, b[i])
	}
	fmt.Println("debug end")

	return a
}

// find num of elem >= k
func find(a []int, k int) int {
	if len(a) == 0 {
		return 0
	}
	n := len(a)
	if a[0] > k {
		return n
	}
	if a[n-1] < k {
		return 0
	}
	l := 0
	r := len(a) - 1
	for l < r {
		mid := (l + r) / 2
		if a[mid] < k {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return n - l
}

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

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}