package main

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

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

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

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

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

		x := -1
		y := -1
		for i := a + 1; i <= c ; i++ {
			num :=  a*b / gcd(a*b, i)
			if num <= d {
				if k := d/num; k * num > b {
					x = i
					y = k * num
					break
				}
			}
		}

		fmt.Fprintln(w, x, y)
	}

}

package main

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

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

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

func solve() {
    var a, b, c, d int
    Fscan(in, &a, &b, &c, &d)

    x, y := -1, -1
    for i := a + 1; i <= c; i++ {
        g := gcd(a * b, i)
        miny := (a * b / g)

        ty := (b / miny + 1) * miny

        if ty <= d {
            x, y = i, ty
            break
        }
    }

    Fprintln(out, x, y)
}

func main() {
    var T int
    Fscan(in, &T)
    for ; T > 0; T-- {
        solve()
    }
    out.Flush()
}

package main

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

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

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

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

		d1, d2 := -1, -1
		for i := a + 1; i <= c; i++ {
			s := a * b / gcd(i, a*b)
			z := d / s * s
			if z > b && z <= d && (i*z)%(a*b) == 0 {
				d1, d2 = int(i), int(z)
				break
			}
		}

		fmt.Fprintln(out, d1, d2)
	}
}

package main

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

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

func bsearch(n, l, r, v int) int {
	if l == r { return l }
	m := (l + r) >> 1
	if m * n < v { return bsearch(n, m+1, r, v) }
	return bsearch(n, l, m, v)
}

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

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

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

		x := -1
		y := -1
		for i := a + 1; i <= c ; i++ {
			num :=  a*b / gcd(a*b, i)
			if num <= d {
				k := bsearch(num, 1, d / num, b+1)
				if k * num > b {
					x = i
					y = k * num
					break
				}
			}
		}

		fmt.Fprintln(w, x, y)
	}

}

package main

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

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

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

func bsearch(n, d, l, r, v int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if m * n > v * d { return bsearch(n, d, l, m-1, v) }
	return bsearch(n, d, m, r, v)
}

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

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

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

		x := -1
		y := -1
		for i := a + 1; i <= c ; i++ {
			// fmt.Fprintln(w, "#################")
			// fmt.Fprintln(w, "## i ", i)
			num :=  a*b / gcd(a*b, i)
			denom := i / gcd(a*b, i)
			k := max(2, denom)
			v := k * num / denom

			// fmt.Fprintln(w, "## num denom k ", num, denom, k)
			if v > b && v <= d {
				// fmt.Fprintln(w, "yo1")
				x = i
				y = v
				break
			} else if v <= b && d*denom/num > k {
				// fmt.Fprintln(w, "yo1")
				k = bsearch(num, denom, k+1, d * denom / num, b+1)
				// fmt.Fprintln(w, "k ", k)
				if (k * num) % denom == 0 {
					x = i
					y = k * num / denom
					break
				}
			}
		}

		fmt.Fprintln(w, x, y)
	}

}

package main

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

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

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

func solve() {
    var a, b, c, d int
    Fscan(in, &a, &b, &c, &d)

    x, y := -1, -1
    for i := a + 1; i <= c; i++ {
        g := gcd(a * b, i)
        miny := (a * b / g) * (i / g)

        ty := (b / miny + 1) * miny

        if ty <= d {
            x, y = i, ty
            break
        }
    }

    Fprintln(out, x, y)
}

func main() {
    var T int
    Fscan(in, &T)
    for ; T > 0; T-- {
        solve()
    }
    out.Flush()
}

package main

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

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

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

func solve() {
    var a, b, c, d int
    Fscan(in, &a, &b, &c, &d)

    x, y := -1, -1
    for i := a + 1; i <= c; i++ {
        g := gcd(a * b, i)
        miny := a * b * i / g / g

        ty := (b / miny + 1) * miny

        if ty <= d {
            x, y = i, ty
            break
        }
    }

    Fprintln(out, x, y)
}

func main() {
    var T int
    Fscan(in, &T)
    for ; T > 0; T-- {
        solve()
    }
    out.Flush()
}

package main

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

func primeFactors(n int64) (pfs []int64) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := int64(3); i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

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

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

		if a == 1 || b == 1 {
			fmt.Fprintln(out, c, d)
			continue
		}

		p1 := primeFactors(a)
		p2 := primeFactors(b)
		pp := []int64{}
		for _, v := range p1 {
			for k := range pp {
				if pp[k]*v > c && pp[k]*v > d {
					continue
				}
				pp[k] *= v
			}
			pp = append(pp, v)
		}

		for _, v := range p2 {
			for k := range pp {
				if pp[k]*v > c && pp[k]*v > d {
					continue
				}
				pp[k] *= v
			}
			pp = append(pp, v)
		}
		sort.Slice(pp, func(i, j int) bool {
			return pp[i] < pp[j]
		})

		// fmt.Println(pp)
		x := sort.Search(len(pp), func(i int) bool {
			return pp[i] > a
		})
		if x < len(pp) && pp[x] <= a {
			x++
		}
		y := sort.Search(len(pp), func(i int) bool {
			return pp[i] > b
		})
		if y < len(pp) && pp[y] <= b {
			y++
		}

		d1, d2 := int64(-1), int64(-1)
	Loop:
		for i := x; i < len(pp); i++ {
			if pp[i] > c {
				break
			}
			for j := y; j < len(pp); j++ {
				if pp[j] > d {
					break
				}
				if (pp[i]*pp[j])%(a*b) == 0 {
					d1, d2 = pp[i], pp[j]
					break Loop
				}
			}
		}

		fmt.Fprintln(out, d1, d2)
	}
}


package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n)
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i-1] = w
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for _, p := range q {
		delete(s, pair{p.i, p.j})
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i := s[w]; i > 0 {
				delete(s, w)
				ans[i-1] = v.pair
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n)
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	vis := make(map[pair]bool, n)
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i-1] = w
				vis[v] = true
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i := s[w]; i > 0 && !vis[w] {
				ans[i-1] = v.pair
				vis[w] = true
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n)
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct{ x, y, ox, oy int }
	q := []p2{}
	vis := make(map[pair]bool, n)
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i-1] = w
				vis[v] = true
				q = append(q, p2{v.x, v.y, w.x, w.y})
				break
			}
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			i := s[w]
			if i > 0 && !vis[w] {
				ans[i-1] = pair{v.ox, v.oy}
				vis[w] = true
				q = append(q, p2{w.x, w.y, v.ox, v.oy})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

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

func CF1651D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	type pair struct {
		x, y int
	}
	type pair2 struct {
		x, y int
		pair
	}
	var n, x, y int
	fmt.Fscan(r, &n)
	pairList := make(map[pair]int, 0)
	for i := 1; i <= n; i++ {
		fmt.Fscan(r, &x, &y)
		pairList[pair{
			x: x,
			y: y,
		}] = i
	}

	dir := [][]int{{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
	ans := make([]pair, n)
	q := []pair2{}

	for v, i := range pairList {
		for _, d := range dir {
			x, y := v.x+d[0], v.y+d[1]
			p := pair{x: x, y: y}
			if _, ok := pairList[p]; !ok {
				ans[i-1] = p
				q = append(q, pair2{x: v.x, y: v.y, pair: p})
				break
			}
		}
	}
	for _, p := range q {
		delete(pairList, pair{
			x: p.x,
			y: p.y,
		})
	}

	for len(q) > 0 {
		tmp := q
		q = nil
		for _, v := range tmp {
			for _, d := range dir {
				x, y := v.x+d[0], v.y+d[1]
				p := pair{
					x: x,
					y: y,
				}
				if i, ok := pairList[p]; ok {
					delete(pairList, p)
					ans[i-1] = v.pair
					q = append(q, pair2{
						x:    x,
						y:    y,
						pair: v.pair,
					})
				}
			}
		}
	}

	for _, v := range ans {
		fmt.Fprintln(w, v.x, v.y)
	}

}

type uf struct {
	fa, sz  []int
	groups  int
	maxSize int
}

func newUnionFind(n int, a []int) uf {
	fa := make([]int, n)
	sz := make([]int, n)
	for i := range fa {
		fa[i] = i
		sz[i] = a[i]
	}
	return uf{fa, sz, n, 1}
}

func (u uf) find(x int) int {
	if u.fa[x] != x {
		u.fa[x] = u.find(u.fa[x])
	}
	return u.fa[x]
}

func (u *uf) merge(from, to int) (isNewMerge int) {
	x, y := u.find(from), u.find(to)
	if x == y {
		return 0
	}
	u.fa[x] = y
	u.sz[y] += u.sz[x]
	if u.sz[y] > u.maxSize {
		u.maxSize = u.sz[y]
	}
	u.groups--
	return u.sz[y]
}

func (u uf) same(x, y int) bool { return u.find(x) == u.find(y) }
func (u uf) size(x int) int     { return u.sz[u.find(x)] }

func sum(a, b int) int {
	return a + b
}

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

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

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

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

func maxFloat(a, b float64) float64 {
	if b > a {
		return b
	}
	return a
}

func minFloat(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

package main

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

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

func CF1651D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	type pair struct {
		x, y int
	}
	type pair2 struct {
		x, y int
		pair
	}
	var n, x, y int
	fmt.Fscan(r, &n)
	pairList := make(map[pair]int, 0)
	for i := 1; i <= n; i++ {
		fmt.Fscan(r, &x, &y)
		pairList[pair{
			x: x,
			y: y,
		}] = i
	}

	dir := [][]int{{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
	ans := make([]pair, n)
	q := []pair2{}

	for v, i := range pairList {
		for _, d := range dir {
			x, y := v.x+d[0], v.y+d[1]
			p := pair{x: x, y: y}
			if _, ok := pairList[p]; !ok {
				ans[i-1] = p
				q = append(q, pair2{x: x, y: y, pair: p})
				break
			}
		}
	}
	for len(q) > 0 {
		tmp := q
		q = nil
		for _, v := range tmp {
			for _, d := range dir {
				x, y := v.x+d[0], v.y+d[1]
				p := pair{
					x: x,
					y: y,
				}
				if i, ok := pairList[p]; ok {
					delete(pairList, p)
					ans[i-1] = v.pair
					q = append(q, pair2{
						x:    x,
						y:    y,
						pair: v.pair,
					})
				}
			}
		}
	}

	for _, v := range ans {
		fmt.Fprintln(w, v.x, v.y)
	}

}

type uf struct {
	fa, sz  []int
	groups  int
	maxSize int
}

func newUnionFind(n int, a []int) uf {
	fa := make([]int, n)
	sz := make([]int, n)
	for i := range fa {
		fa[i] = i
		sz[i] = a[i]
	}
	return uf{fa, sz, n, 1}
}

func (u uf) find(x int) int {
	if u.fa[x] != x {
		u.fa[x] = u.find(u.fa[x])
	}
	return u.fa[x]
}

func (u *uf) merge(from, to int) (isNewMerge int) {
	x, y := u.find(from), u.find(to)
	if x == y {
		return 0
	}
	u.fa[x] = y
	u.sz[y] += u.sz[x]
	if u.sz[y] > u.maxSize {
		u.maxSize = u.sz[y]
	}
	u.groups--
	return u.sz[y]
}

func (u uf) same(x, y int) bool { return u.find(x) == u.find(y) }
func (u uf) size(x int) int     { return u.sz[u.find(x)] }

func sum(a, b int) int {
	return a + b
}

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

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

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

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

func maxFloat(a, b float64) float64 {
	if b > a {
		return b
	}
	return a
}

func minFloat(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

package main

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

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

func CF1651D(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	type pair struct {
		x, y int
	}
	type pair2 struct {
		x, y int
		pair
	}
	var n, x, y int
	fmt.Fscan(r, &n)
	pairList := make(map[pair]int, 0)
	for i := 1; i <= n; i++ {
		fmt.Fscan(r, &x, &y)
		pairList[pair{
			x: x,
			y: y,
		}] = i
	}

	dir := [][]int{{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
	ans := make([]pair, n)
	q := []pair2{}

	for v, i := range pairList {
		for _, d := range dir {
			x, y := v.x+d[0], v.y+d[1]
			p := pair{x: x, y: y}
			if _, ok := pairList[p]; !ok {
				ans[i-1] = p
				q = append(q, pair2{x: x, y: y, pair: p})
				break
			}
		}
	}
	for _, v := range q {
		delete(pairList, pair{
			x: v.x,
			y: v.y,
		})
	}

	for len(q) > 0 {
		tmp := q
		q = nil
		for _, v := range tmp {
			for _, d := range dir {
				x, y := v.x+d[0], v.y+d[1]
				p := pair{
					x: x,
					y: y,
				}
				if i, ok := pairList[p]; ok {
					delete(pairList, p)
					ans[i-1] = v.pair
					q = append(q, pair2{
						x:    x,
						y:    y,
						pair: v.pair,
					})
				}
			}
		}
	}

	for _, v := range ans {
		fmt.Fprintln(w, v.x, v.y)
	}

}

type uf struct {
	fa, sz  []int
	groups  int
	maxSize int
}

func newUnionFind(n int, a []int) uf {
	fa := make([]int, n)
	sz := make([]int, n)
	for i := range fa {
		fa[i] = i
		sz[i] = a[i]
	}
	return uf{fa, sz, n, 1}
}

func (u uf) find(x int) int {
	if u.fa[x] != x {
		u.fa[x] = u.find(u.fa[x])
	}
	return u.fa[x]
}

func (u *uf) merge(from, to int) (isNewMerge int) {
	x, y := u.find(from), u.find(to)
	if x == y {
		return 0
	}
	u.fa[x] = y
	u.sz[y] += u.sz[x]
	if u.sz[y] > u.maxSize {
		u.maxSize = u.sz[y]
	}
	u.groups--
	return u.sz[y]
}

func (u uf) same(x, y int) bool { return u.find(x) == u.find(y) }
func (u uf) size(x int) int     { return u.sz[u.find(x)] }

func sum(a, b int) int {
	return a + b
}

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

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

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

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

func maxFloat(a, b float64) float64 {
	if b > a {
		return b
	}
	return a
}

func minFloat(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

package main

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

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

	dx := []int{0, 0, -1, 1}
	dy := []int{-1, 1, 0, 0}

	type pair struct{ x, y int }

	var n int
	Fscan(in, &n)
	a := make([]pair, n)
	st := make(map[pair]int)
	for i := 0; i < n; i++ {
		Fscan(in, &a[i].x, &a[i].y)
		st[a[i]] = 1;
	}

	res := make(map[pair]pair)
	var q []pair
	for _, p := range a {
		x , y := p.x, p.y
		for i := 0; i < 4; i++ {
			nx, ny := x + dx[i], y + dy[i]
			if st[pair{nx, ny}] == 0 {
				res[pair{x, y}] = pair{nx, ny}
				q = append(q, pair{x, y})
				break
			}
		}
	}

	for len(q) != 0 {
		x, y := q[0].x, q[0].y
		q = q[1:]
		for i := 0; i < 4; i++ {
			nx, ny := x + dx[i], y + dy[i]
			if _, err := res[pair{nx, ny}]; st[pair{nx, ny}] == 0 || err {
				continue
			}
			res[pair{nx, ny}] = res[pair{x, y}]
			q = append(q, pair{nx, ny})
		}
	}

	for _, p := range a {
		x, y := p.x, p.y
		it := res[pair{x, y}]
		Fprintln(out, it.x, it.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n*2)
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i-1] = w
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for _, p := range q {
		delete(s, pair{p.i, p.j})
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i := s[w]; i > 0 {
				delete(s, w)
				ans[i-1] = v.pair
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := map[pair]int{}
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i-1] = w
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for _, p := range q {
		delete(s, pair{p.i, p.j})
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i := s[w]; i > 0 {
				delete(s, w)
				ans[i-1] = v.pair
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n)
	for i := 1; i <= n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				delete(s, v)
				ans[i-1] = w
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i := s[w]; i > 0 {
				delete(s, w)
				ans[i-1] = v.pair
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

// https://space.bilibili.com/206214
func CF1651D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := []pair{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}

	var n, x, y int
	Fscan(in, &n)
	s := make(map[pair]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &x, &y)
		s[pair{x, y}] = i
	}

	ans := make([]pair, n)
	type p2 struct { i, j int; pair }
	q := []p2{}
	vis := make(map[pair]bool, n)
	for v, i := range s {
		for _, d := range dir4 {
			w := pair{v.x + d.x, v.y + d.y}
			if s[w] == 0 {
				ans[i] = w
				vis[v] = true
				q = append(q, p2{v.x, v.y, w})
				break
			}
		}
	}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, d := range dir4 {
			w := pair{v.i + d.x, v.j + d.y}
			if i, ok := s[w]; ok && !vis[w] {
				ans[i] = v.pair
				vis[w] = true
				q = append(q, p2{w.x, w.y, v.pair})
			}
		}
	}
	for _, p := range ans {
		Fprintln(out, p.x, p.y)
	}
}

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

package main

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

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

	dx := []int{-1, 1, 0, 0}
	dy := []int{0, 0, -1, 1}

	type pair struct{ x, y int }

	var n int
	Fscan(in, &n)
	a := make([]pair, n)
	for i := 0; i < n; i++ {
		var x, y int
		Fscan(in, &x, &y)
		a[i] = pair{x, y}
	}

	st := make(map[pair]int)
	res := make(map[pair]pair)
	var q []pair
	for _, p := range a {
		x , y := p.x, p.y
		for i := 0; i < 4; i++ {
			nx, ny := x + dx[i], y + dy[i]
			if st[pair{nx, ny}] == 0 {
				res[pair{x, y}] = pair{nx, ny}
				q = append(q, pair{x, y})
			}
		}
	}

	for len(q) != 0 {
		x, y := q[0].x, q[0].y
		q = q[1:]
		for i := 0; i < 4; i++ {
			nx, ny := x + dx[i], y + dy[i]
			if _, err := res[pair{nx, ny}]; st[pair{nx, ny}] == 0 || !err {
				continue
			}
			res[pair{nx, ny}] = pair{x, y}
			q = append(q, pair{nx, ny})
		}
	}

	for _, p := range a {
		x, y := p.x, p.y
		it := res[pair{x, y}]
		Fprintln(out, it.x, it.y)
	}
}

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


package main

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

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

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

		var tot int64
		aa := make([]bool, n+1)
		for i, ch := range s {
			if ch == '1' {
				aa[i+1] = true
			}
		}

		bb := make([]bool, n+1)
		for i, ch := range s {
			if ch == '0' {
				k := i + 1
				for j := 1; k*j <= n; j++ {
					if aa[k*j] {
						break
					}
					if bb[k*j] {
						continue
					}

					bb[k*j] = true
					tot += int64(k)
				}
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n int
		var s []byte
		Fscan(in, &n, &s)
		cost := make([]int, n+1)
		ans := int64(0)
		for i := 1; i <= n; i++ {
			if s[i-1] == '1' {
				continue
			}
			for j := i; j <= n && s[j-1] == '0'; j += i {
				if cost[j] == 0 {
					cost[j] = i
				}
			}
			//if cost[i] == 0 {
			//
			//} else {
			//	//newC := false
			//	for j := i * 2; j <= n && s[j-1] == '0'; j += i {
			//		if cost[j] == 0 {
			//			cost[j] = i
			//			//newC = true
			//		}
			//	}
			//	//if newC {
			//	//	cost[i] = i
			//	//}
			//}
		}
		for _, v := range cost {
			ans += int64(v)
		}
		Fprintln(out, ans)
	}

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

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

}

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

package main

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

const N = 3e5
const inf = 1e9

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 2000005
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}
func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }

func BAAL() {
	in := os.Stdin
	out := os.Stdout
	iost = NewIost(in, out)
}

func main() {
	BAAL()
	defer func() {
		iost.Writer.Flush()
	}()
	t := iost.GetNextInt()
	for t > 0 {
		t--
		n := iost.GetNextInt()
		s := iost.Text()
		var a []byte
		for i := 0; i < n; i++ {
			a = append(a, s[i])
		}
		o := 0
		for i := 1; i <= n; i++ {
			for j := i; j <= n; j += i {
				k := j - 1
				if a[k] == '1' {
					break
				} else if a[k] == '0' {
					o += i
					a[k] = byte('2')
				}
			}
		}
		iost.Println(o)
	}
}


package main

import "fmt"

func main() {
    var n int
    var m [105]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ { fmt.Scan(&m[i]) }
    ans := 1000000000
    for i := 0; i < n; i++ {
        total := 0
        var a int
        for j := 0; j < m[i]; j++ {
            fmt.Scan(&a)
            total += (a*5)+15
        }
        if ans > total { ans = total }
    }
    fmt.Println(ans)
}

/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-04-06 16:51]
*     Last Modified       :     [2014-04-06 16:59]
*     Description         :
**********************************************************************************/

package main

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

func main() {
    in.Split(bufio.ScanWords)

    n := in.NextInt()
    k := make([]int, n)
    for i := 0; i < n; i++ {
        k[i] = in.NextInt()
    }
    ans := 0x7fffffff
    for i := 0; i < n; i++ {
        sum := 0
        for j := 0; j < k[i]; j++ {
            sum += in.NextInt()
        }
        if sum*5+k[i]*15 < ans {
            ans = sum*5 + k[i]*15
        }
    }
    fmt.Println(ans)
}

type Scanner struct {
    *bufio.Scanner
}

var in = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

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

// 408A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var n, now, d int
    var a [542]int
    res := 10000000
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    for i := 0; i < n; i++ {
        now = 0
        for j := 0; j < a[i]; j++ {
            fmt.Scan(&d)
            now = now + d*5
        }
        now += a[i] * 15
        res = int(math.Min(float64(now), float64(res)))
    }
    fmt.Println(res)
}

package main

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

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

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

	n := nextInt()

	k := make([]int, n)

	for i:=0; i<n; i++ {
		k[i] = nextInt()
	}

	result, totalSecond := math.MaxInt32, 0

	for i:=0; i<n; i++ {
		totalSecond = 15 * k[i]

		for j:=0; j<k[i]; j++ {
			totalSecond += 5 * nextInt()
		}

		if totalSecond < result {
			result = totalSecond
		}
		// fmt.Println(totalSecond, n, k)
	}

	println(result)
}

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

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

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

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

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

package main
import (
	"fmt"
)
func main() {
	var n,t,m int
	min:=10000000
	a:=make([]int,105)
	fmt.Scan(&n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	for i:=0;i<n;i++ {
		t=0
		for j:=0;j<a[i];j++ {
			fmt.Scan(&m)
			t+=m
		}
		if t*5+a[i]*15<min {
			min=t*5+a[i]*15
		}
	}
	fmt.Println(min)
}

package main

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

var (
    reader = bufio.NewReader(os.Stdin)
)

func main() {
    var (
        n, k, min int
        cash      [110]int
    )
    fmt.Fscan(reader, &n)
    for i := 0; i < n; i++ {
        fmt.Fscan(reader, &cash[i])
    }
    min = 1e9 + 1
    for i := 0; i < n; i++ {
        sum := 0
        for j := 0; j < cash[i]; j++ {
            fmt.Fscan(reader, &k)
            sum += k
        }
        sum = sum*5 + cash[i]*15
        if sum < min {
            min = sum
        }
    }
    fmt.Println(min)
}


package main

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

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

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

	t := 0
	str := ""
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &str)
		mp := make(map[int32]bool)
		for _, ch := range str {
			mp[ch] = true
		}
		kind := len(mp)
		vis := make(map[byte]bool)
		for left, right := 0, 0; right < len(str); right++ {
			vis[str[right]] = true
			if right-left+1 == kind {
				if len(vis) != kind {
					fmt.Fprintln(out, "NO")
					goto out
				} else {
					delete(vis, str[left])
					left++
				}
			}
		}
		fmt.Fprintln(out, "YES")
	out:
	}
}

package main

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

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

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

		freq := make([]int, 26)
		var u int
		for _, ch := range s {
			freq[ch-'a']++
			if freq[ch-'a'] == 1 {
				u++
			}
		}

		f := true
		if u > 1 {
			c := make([]bool, 26)
			for i := 0; i < u; i++ {
				if c[s[i]-'a'] {
					f = false
					break
				}
				c[s[i]-'a'] = true
			}

			for i := u; i < len(s); i++ {
				c[s[i-u]-'a'] = false
				if c[s[i]-'a'] {
					f = false
					break
				}
				c[s[i]-'a'] = true
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	var S,anc string

	fmt.Fscan(in, &T)
	//list := make([]string,N)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		val := srtcount(S)
		list := strings.Split(S, val)
		//fmt.Println(val)
		for i:= len(list)-1;i >= 0;i--{
			if i == len(list)-1 {
				if list[i] == ""{
					anc = "YES"
				}
				if strings.HasPrefix(val, list[i]){
					anc = "YES"
				}else{
					anc = "NO"
				}
			}else{
				if list[i] != ""{
					anc = "NO"
				}
			}
		}
		fmt.Println(anc)
	}
}

func srtcount(S string) string{
	arr1 := strings.Split(S, "")
	m := make(map[string]string)
	var s string

	for _,v := range arr1{
		if _,ok := m[v];ok{
			break
		}else{
			m[v] = v
			s += v
		}
	}
	return s
}

package main

import (
	"fmt"
)

func solve() {
	var s string
	fmt.Scan(&s)

	count := map[byte]int{}
	for i := range s {
		count[s[i]]++
	}

	n := len(s)
	seen := map[byte]int{}
	for i := 0; i < len(count); i++ {
		if i % len(count) == 0 {
			seen = map[byte]int{}
		}

		seen[s[i]]++

		if seen[s[i]] > 1 {
			fmt.Println("NO")
			return
		}
	}

	for i := len(count); i < n; i++ {
		if s[i] != s[i % len(count)] {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

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

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

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func ind(a byte) int {
	return int(a) - int('a')
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()
loop:
	for ; t > 0; t-- {
		s := io.ReadString()

		var us [26][26]bool
		mp := make(map[byte]int, 26)
		mm := make(map[byte]struct{})

		for i := range s {
			mm[s[i]] = struct{}{}
		}

		for i := range s {
			mp[s[i]]++
			for b := range mm {
				if mp[s[i]] > mp[b]+1 {
					fmt.Println("No")
					continue loop
				}
				if mp[s[i]] > mp[b] {
					if us[ind(b)][ind(s[i])] {
						fmt.Println("No")
						continue loop
					}
					us[ind(s[i])][ind(b)] = true
				}
			}
		}
		fmt.Println("Yes")
	}
}

package main

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

func ord(b byte) int {
	return int(b - 'a')
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		s, _ := reader.ReadString('\n')
		s = strings.TrimSpace(s)
		was := make([]int, 26)
		pat := ""
		isGood := true
		for i := range s {
			if len(pat) == 0 {
				idx := ord(s[i])
				if was[idx] == 0 {
					was[idx]++
				} else {
					pat = s[:i]
				}
			}
			if len(pat) != 0 && pat[i%len(pat)] != s[i] {
				isGood = false
				break
			}
		}
		if isGood {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T,count int
	var S,anc string

	fmt.Fscan(in, &T)
	//list := make([]string,N)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		val := srtcount(S)
		list := strings.Split(S, val)
		//fmt.Println(val)
		count = 0
		for i:= 0;i < len(list);i++{
			if list[i] != ""{
				if count >= 1{
					anc = "NO"
				}
				count++
				//r := regexp.MustCompile(list[i])
				if !strings.HasPrefix(val, list[i]){
					anc = "NO"
				}else{
					anc = "YES"
				}
			}else{
				anc = "YES"
			}
		}
		fmt.Println(anc)
	}
}

func srtcount(S string) string{
	arr1 := strings.Split(S, "")
	m := make(map[string]string)
	var s string

	for _,v := range arr1{
		if _,ok := m[v];ok{
			break
		}else{
			m[v] = v
			s += v
		}
	}
	return s
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T,count int
	var S,anc string

	fmt.Fscan(in, &T)
	//list := make([]string,N)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		val := srtcount(S)
		list := strings.Split(S, val)
		//fmt.Println(val)
		count = 0
		for i:= 0;i < len(list);i++{
			anc = "YES"
			if list[i] != ""{
				if count >= 1{
					anc = "NO"
				}
				count++
				//r := regexp.MustCompile(list[i])
				if !strings.HasPrefix(val, list[i]){
					anc = "NO"
				}else{
					anc = "YES"
				}
			}
		}
		fmt.Println(anc)
	}
}

func srtcount(S string) string{
	arr1 := strings.Split(S, "")
	m := make(map[string]string)
	var s string

	for _,v := range arr1{
		if _,ok := m[v];ok{
			break
		}else{
			m[v] = v
			s += v
		}
	}
	return s
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T,count int
	var S,anc string

	fmt.Fscan(in, &T)
	//list := make([]string,N)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		val := srtcount(S)
		list := strings.Split(S, val)
		//fmt.Println(val)
		for i:= 0;i < len(list);i++{
			anc = "YES"
			if list[i] != ""{
				if count >= 1{
					anc = "NO"
				}
				count++
				//r := regexp.MustCompile(list[i])
				if !strings.HasPrefix(val, list[i]){
					anc = "NO"
				}else{
					anc = "YES"
				}
			}
		}
		fmt.Println(anc)
	}
}

func srtcount(S string) string{
	arr1 := strings.Split(S, "")
	m := make(map[string]string)
	var s string

	for _,v := range arr1{
		if _,ok := m[v];ok{
			break
		}else{
			m[v] = v
			s += v
		}
	}
	return s
}

package main

import (
	"fmt"
)

func solve() {
	var s string
	fmt.Scan(&s)

	count := map[byte]int{}
	for i := range s {
		count[s[i]]++
	}

	if len(count) == 1 {
		fmt.Println("YES")
		return
	}

	n := len(s)
	for k, v := range count {
		if v > 2 {
			fmt.Println("NO")
			return
		}

		if v == 2 && (s[0] != k || s[n - 1] != k) {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

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

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

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func ind(a byte) int {
	return int(a) - int('a')
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()
loop:
	for ; t > 0; t-- {
		s := io.ReadString()

		var us [26][26]bool
		mp := make(map[byte]int, 26)

		for i := range s {
			mp[s[i]]++
			for b := byte('a'); b <= 'z'; b++ {
				if mp[s[i]] > mp[b]+1 && mp[b] != 0 {
					fmt.Println("No")
					continue loop
				}
				if mp[s[i]] > mp[b] {
					if us[ind(b)][ind(s[i])] {
						fmt.Println("No")
						continue loop
					}
					us[ind(s[i])][ind(b)] = true
				}
			}
		}
		fmt.Println("Yes")
	}
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func main() {
	ms := NewMuchScanner()

	n := ms.ReadInt()

    arr := ms.ReadIntArr(n)

	m := map[int]int{}
	used := map[int]bool{}

	for _, v := range arr {
		m[v]++
	}

	//Queue of values we need to create
	toCreate := priorityQueue{}

	for i := 1; i <= n; i++ {
		if m[i] == 0 {
			heap.Push(&toCreate, i)
		}
		used[i] = false
	}

	moves := 0

	minCandidate := heap.Pop(&toCreate)
	for i := 0; i < n && minCandidate != nil; i++ {
		v := arr[i]
		if m[v] > 1 {
			if minCandidate.(int) < v || used[v] {
				arr[i] = minCandidate.(int)
				m[v]--
				moves++
				minCandidate = heap.Pop(&toCreate)
			}
		}
		used[arr[i]] = true
	}

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fprintf(writer, "%d\n", moves)
	for _, v := range arr {
		fmt.Fprintf(writer, "%d ", v)

	}
	fmt.Fprintln(writer)

}

type priorityQueue []int

type maxPriorityQueue struct {
	priorityQueue
}

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq priorityQueue) Swap(i, j int) {
	if pq.Len() > 0 {
		pq[i], pq[j] = pq[j], pq[i]
	}
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}

func (pq *priorityQueue) Pop() interface{} {
	n := pq.Len()
	if n == 0 {
		return nil
	}
	item := (*pq)[n-1]
	*pq = (*pq)[0 : n-1]
	return item
}

func (pq maxPriorityQueue) Less(i, j int) bool {
	return pq.priorityQueue[i] > pq.priorityQueue[j]
}

// MuchScanner is a wrapper for bufio.Scanner
type MuchScanner struct {
	scanner *bufio.Scanner
}

// NewMuchScanner creates new insances of MuchScanner
func NewMuchScanner() *MuchScanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &MuchScanner{
		scanner: sc,
	}
}

// TokenSize sets maximal token size
func (ms *MuchScanner) TokenSize(tokenSize int) {
	ms.scanner.Buffer(make([]byte, tokenSize), tokenSize)
}

// ReadString reads next word as a string
func (ms *MuchScanner) ReadString() string {
	ms.scanner.Scan()
	return ms.scanner.Text()
}

// ReadInt reads next int number
func (ms *MuchScanner) ReadInt() int {
	n, _ := strconv.Atoi(ms.ReadString())
	return n
}

// ReadIntArr reads next n int numbers
func (ms *MuchScanner) ReadIntArr(n int) []int {
	arr := make([]int, n)
	for i := range arr {
		arr[i] = ms.ReadInt()
	}
	return arr
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
	"strings"
)

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

	const capacity = 100000000
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)

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

	scanner.Scan()
	strArr := strings.Fields(scanner.Text())

	arr := make([]int, len(strArr))
	for i, v := range strArr {
		arr[i], _ = strconv.Atoi(v)
	}

	m := map[int]int{}
	used := map[int]bool{}

	for _, v := range arr {
		m[v]++
	}

	//Queue of values we need to create
	toCreate := priorityQueue{}

	for i := 1; i <= n; i++ {
		if m[i] == 0 {
			heap.Push(&toCreate, i)
		}
		used[i] = false
	}

	moves := 0

	minCandidate := heap.Pop(&toCreate)
	for i := 0; i < n && minCandidate != nil; i++ {
		v := arr[i]
		if m[v] > 1 {
			if minCandidate.(int) < v || used[v] {
				arr[i] = minCandidate.(int)
				m[v]--
				moves++
				minCandidate = heap.Pop(&toCreate)
			}
		}
		used[arr[i]] = true
	}

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fprintf(writer, "%d\n", moves)
	for _, v := range arr {
		fmt.Fprintf(writer, "%d ", v)

	}
	fmt.Fprintln(writer)

}

type priorityQueue []int

type maxPriorityQueue struct {
	priorityQueue
}

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq priorityQueue) Swap(i, j int) {
	if pq.Len() > 0 {
		pq[i], pq[j] = pq[j], pq[i]
	}
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}

func (pq *priorityQueue) Pop() interface{} {
	n := pq.Len()
	if n == 0 {
		return nil
	}
	item := (*pq)[n-1]
	*pq = (*pq)[0 : n-1]
	return item
}

func (pq maxPriorityQueue) Less(i, j int) bool {
	return pq.priorityQueue[i] > pq.priorityQueue[j]
}

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	cnt := make(map[int]int)
	for i := 0; i < n; i++ {
		a[i] = readInt()
		cnt[a[i]]++
	}
	b := make([]int, 0)
	for i := 1; i <= n; i++ {
		if cnt[i] == 0 {
			b = append(b, i)
		}
	}
	changes := 0
	visit := map[int]int{}
	for i := 0; i < n; i++ {
		if cnt[a[i]] > 1 {
			if visit[a[i]] > 0 || (len(b) > 0 && b[0] < a[i]) {
				cnt[a[i]]--
				changes++
				a[i] = b[0]
				b = b[1:]
			} else {
				visit[a[i]]++
			}
		}
	}
	fmt.Println(changes)
	var buffer bytes.Buffer
	for i := 0; i < n; i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(a[i]))
	}
	fmt.Println(buffer.String())
}

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

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

// Codeforces 864 D Make a Permutation, train
package main

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

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)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j := 0; j < n; j++ {
		aa, err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

type group struct {
	v int
	n int
	used int
	usedv bool
}

var n int
var a []int
var perm []int
var needChange int
var gr []*group

// readData read data for out problem.
func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n
	n, _, _, _, _ = readFive()
	a = readLineNumbs(n)
}

// solve func solves our problem.
func solve() {
	gr = make([]*group,n+1)
	for _,aa := range a {
		if gr[aa]==nil {
			gr[aa] = new(group)
			gr[aa].n++
			gr[aa].v = aa
		} else {
			gr[aa].n++
		}
	}
	// which numbers need placing
	need := make([]int,n+1)
	ineed := 0
	for i:=1; i<=n; i++ {
		if gr[i] == nil {
			need[ineed] = i
			ineed++
		}
	}
	//fmt.Printf("Need %d places\n", ineed)
	// walk a and place need in groups
	ineed = 0
	perm = make([]int, n)
	for i,aa := range a {
		g := gr[aa]
		if g==nil {
			msg := fmt.Sprintf("gr cannot be nil i,aa = %d %d",i,aa)
			panic(msg)
		} else if g.n==1 {
			perm[i] = aa
		} else {
			// may be can place number from need
			nd := need[ineed]
			if g.usedv || (nd<g.v && g.used<g.n-1) {
				// use nd
				perm[i] = nd
				g.used++
				ineed++
				needChange++
				//fmt.Printf("i=%d Used %d instead of %d\n", i, nd, aa)
			} else {
				// use g.v
				perm[i] = g.v
				g.used++
				g.usedv = true
				//fmt.Printf("i=%d Used %d\n", i, nd)
			}
		}
	}
}

// printRes print problem solution in expected format.
func printRes() {
	fmt.Println(needChange)
	for _,aa := range perm {
		fmt.Printf("%d ", aa)
	}
	fmt.Println()
}

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

package main

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

func solve() {
	n := readInt()
	a := readIntArray(n)
	max := make(map[int]int)
	for i := 0; i < n; i++ {
		max[a[i]] = i
	}
	cur := 1
	used := make(map[int]bool)
	ans := 0
	for i := 0; i < n; i++ {
		for _, ok := max[cur]; ok; _, ok = max[cur] {
			cur++
		}
		if used[a[i]] {
			a[i] = cur
			cur++
			ans++
			continue
		}
		if cur < a[i] && max[a[i]] > i {
			a[i] = cur
			cur++
			ans++
		} else {
			used[a[i]] = true
		}
	}
	fmt.Println(ans)
	var buf bytes.Buffer
	for _, x := range a {
		buf.WriteString(strconv.Itoa(x))
		buf.WriteString(" ")
	}
	fmt.Println(buf.String())
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

func solve() {
	n := readInt()
	a := readIntArray(n)
	max := make(map[int]int)
	for i := 0; i < n; i++ {
		max[a[i]] = i
	}
	cur := 1
	used := make(map[int]bool)
	ans := 0
	for i := 0; i < n; i++ {
		for _, ok := max[cur]; ok; _, ok = max[cur] {
			cur++
		}
		if used[a[i]] {
			a[i] = cur
			cur++
			ans++
			continue
		}
		if cur < a[i] && max[a[i]] > i {
			a[i] = cur
			cur++
			ans++
		} else {
			used[a[i]] = true
		}
	}
	fmt.Println(ans)
	for _, x := range a {
		fmt.Print(x, " ")
	}
	fmt.Println()
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

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

	n := readInt()
	a := make([]int, n)
	m := make([][]int, n+1)
	used := make([]int, n+1)
	var dupes []int
	for i := range a {
		a[i] = readInt()
		m[a[i]] = append(m[a[i]], i)
		switch len(m[a[i]]) {
		case 1:
		case 2:
			dupes = append(dupes, m[a[i]]...)
		default:
			dupes = append(dupes, i)
		}
	}
	sort.Ints(dupes)
	ans := 0
	for i := 1; i <= n; i++ {
		if len(m[i]) == 0 {
			ans++
			d := dupes[0]
			for ; a[d] < i && m[a[d]][0] == d || used[a[d]] == len(m[a[d]])-1; d = dupes[0] {
				dupes = dupes[1:]
			}
			if m[a[d]][0] == d {
				m[a[d]] = m[a[d]][1:]
			} else {
				used[a[d]]++
			}
			a[d] = i
			dupes = dupes[1:]
		}
	}

	fmt.Fprintln(out, ans)
	for i := range a {
		if i+1 == n {
			fmt.Fprintln(out, a[i])
		} else {
			fmt.Fprint(out, a[i], " ")
		}
	}
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	count := make([]int, n+1)
	perm := make([]int, n)
	handled := make([]bool, n+1)
	ans := 0

	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &perm[i])
		count[perm[i]]++
	}
	var min int
	for min = 1; min <= n; min++ {
		if count[min] == 0 {
			break
		}
	}
	for i := 0; i < n; i++ {
		if count[perm[i]] > 1 {
			if (!handled[perm[i]] && min < perm[i]) || handled[perm[i]] {
				count[perm[i]]--
				count[min]++
				perm[i] = min
				for ; min <= n; min++ {
					if count[min] == 0 {
						break
					}
				}
				ans++
			}
			handled[perm[i]] = true
		}
	}
	fmt.Printf("%d\n", ans)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", perm[i])
	}
	fmt.Printf("\n")
}

package main

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

var st_input = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !st_input.Scan() {
		panic(st_input.Err())
	}
	res := 0
	for _, b := range st_input.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	st_input.Split(bufio.ScanWords)
	n := readInt()
	a_counts := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		a_counts[i] = 0
	}
	need := make([]int, 0, n+1)
	var a []int = make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = readInt()
		a_counts[a[i]] += 1
	}

	for i := 1; i < n+1; i++ {
		if a_counts[i] == 0 {
			need = append(need, i)
		}
	}

	result := 0
	left := make(map[int]int)
	current_need_index := 0

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

		//fmt.Printf("i=%v a[i]=%v a_counts=%v\n", i, a[i], a_counts[a[i]])
		//fmt.Printf("need=%v\n", need)
		//fmt.Printf("left=%v\n\n", left)

		temp := a[i]
		if a_counts[a[i]] == 1 {
			if left[a[i]] == 1 {
				a[i] = need[current_need_index]
				result += 1
				current_need_index += 1
			}
		} else if a_counts[a[i]] > 1 {
			if need[current_need_index] < a[i] {
				a[i] = need[current_need_index]
				result += 1
				current_need_index += 1
			} else if need[current_need_index] > a[i] && left[a[i]] == 1 {
				a[i] = need[current_need_index]
				result += 1
				current_need_index += 1
			}
			a_counts[temp] -= 1
		}
		left[a[i]] = 1
		if current_need_index == len(need) {
			break
		}
	}

	fmt.Printf("%v\n", result)
	for i := 0; i < n; i++ {
		fmt.Printf("%v ", a[i])
	}
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	scanner.Scan()
	strArr := strings.Split(scanner.Text(), " ")
	arr := make([]int, n)
	for i, v := range strArr {
		arr[i], _ = strconv.Atoi(v)
	}

	m := map[int]int{}

	for _, v := range arr {
		m[v]++
	}

	//Queue of values we need to create
	toCreate := priorityQueue{}

	for i := 1; i <= n; i++ {
		if m[i] == 0 {
			heap.Push(&toCreate, i)
		}
	}

	moves := 0

	minCandidate := heap.Pop(&toCreate)
	for i := 0; i < n && minCandidate != nil; i++ {
		v := arr[i]
		if m[v] > 1 {
			if minCandidate.(int) < v {
				arr[i] = minCandidate.(int)
				m[v]--
				moves++
				minCandidate = heap.Pop(&toCreate)
			}
		}
	}

	if minCandidate != nil {
		heap.Push(&toCreate, minCandidate)
	}

	toCreateMax := maxPriorityQueue{toCreate}
	heap.Init(&toCreateMax)

	maxCandidate := heap.Pop(&toCreateMax)
	for i := n - 1; i >= 0 && maxCandidate != nil; i-- {
		v := arr[i]
		if m[v] > 1 {
			if maxCandidate.(int) > v {
				arr[i] = maxCandidate.(int)
				m[v]--
				moves++
				maxCandidate = heap.Pop(&toCreateMax)
			}
		}
	}

	fmt.Printf("%d\n", moves)
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}
	fmt.Println()
}

type priorityQueue []int

type maxPriorityQueue struct {
	priorityQueue
}

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq priorityQueue) Swap(i, j int) {
	if pq.Len() > 0 {
		pq[i], pq[j] = pq[j], pq[i]
	}
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}

func (pq *priorityQueue) Pop() interface{} {
	n := pq.Len()
	if n == 0 {
		return nil
	}
	item := (*pq)[n-1]
	*pq = (*pq)[0 : n-1]
	return item
}

func (pq maxPriorityQueue) Less(i, j int) bool {
	return pq.priorityQueue[i] > pq.priorityQueue[j]
}

package main

import (
	"container/heap"
	"fmt"
)

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

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

	m := map[int]int{}

	for _, v := range arr {
		m[v]++
	}

	//Queue of values we need to create
	toCreate := priorityQueue{}

	toRemoveTotal := 0

	for i := 1; i <= n; i++ {
		entries := m[i]
		if entries == 0 {
			heap.Push(&toCreate, i)
		} else if entries > 1 {
			toRemoveTotal += entries
		}
	}

	moves := 0

	minCandidate := 0

	l := toCreate.Len()
	if l > 0 {
		minCandidate = heap.Pop(&toCreate).(int)
	}
	for i := 0; i < n && l > 0; i++ {
		v := arr[i]
		if m[v] > 1 {
			var removing bool
			if toRemoveTotal > l {
				removing = minCandidate < v
			} else {
				removing = true
			}
			if removing {
				arr[i] = minCandidate
				m[v]--
				toRemoveTotal--
				if m[v] == 1 {
					toRemoveTotal--
				}
				moves++
				l--
				if l > 0 {
					minCandidate = heap.Pop(&toCreate).(int)
				}
			} else {
				toRemoveTotal--
			}
		}
	}

	fmt.Printf("%d\n", moves)
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}

	fmt.Println()
}

type priorityQueue []int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}

func (pq *priorityQueue) Pop() interface{} {
	n := pq.Len()
	item := (*pq)[n-1]
	*pq = (*pq)[0 : n-1]
	return item
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
	"strings"
)

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

	const capacity = 100000000
	buf := make([]byte, capacity)
	scanner.Buffer(buf, capacity)

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

	scanner.Scan()
	strArr := strings.Fields(scanner.Text())

	arr := make([]int, len(strArr))
	for i, v := range strArr {
		arr[i], _ = strconv.Atoi(v)
	}

	m := map[int]int{}

	for _, v := range arr {
		m[v]++
	}

	//Queue of values we need to create
	toCreate := priorityQueue{}

	for i := 1; i <= n; i++ {
		if m[i] == 0 {
			heap.Push(&toCreate, i)
		}
	}

	moves := 0

	minCandidate := heap.Pop(&toCreate)
	for i := 0; i < n && minCandidate != nil; i++ {
		v := arr[i]
		if m[v] > 1 {
			if minCandidate.(int) < v {
				arr[i] = minCandidate.(int)
				m[v]--
				moves++
				minCandidate = heap.Pop(&toCreate)
			}
		}
	}

	if minCandidate != nil {
		heap.Push(&toCreate, minCandidate)
	}

	toCreateMax := maxPriorityQueue{toCreate}
	heap.Init(&toCreateMax)

	maxCandidate := heap.Pop(&toCreateMax)
	for i := n - 1; i >= 0 && maxCandidate != nil; i-- {
		v := arr[i]
		if m[v] > 1 {
			if maxCandidate.(int) > v {
				arr[i] = maxCandidate.(int)
				m[v]--
				moves++
				maxCandidate = heap.Pop(&toCreateMax)
			}
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fprintf(writer, "%d\n", moves)
	for _, v := range arr {
		fmt.Fprintf(writer, "%d ", v)

	}
	fmt.Fprintln(writer)

}

type priorityQueue []int

type maxPriorityQueue struct {
	priorityQueue
}

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i] < pq[j]
}

func (pq priorityQueue) Swap(i, j int) {
	if pq.Len() > 0 {
		pq[i], pq[j] = pq[j], pq[i]
	}
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(int))
}

func (pq *priorityQueue) Pop() interface{} {
	n := pq.Len()
	if n == 0 {
		return nil
	}
	item := (*pq)[n-1]
	*pq = (*pq)[0 : n-1]
	return item
}

func (pq maxPriorityQueue) Less(i, j int) bool {
	return pq.priorityQueue[i] > pq.priorityQueue[j]
}

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	cnt := make([][]int, n+1)
	for i := 0; i < n; i++ {
		a[i] = readInt()
		cnt[a[i]] = append(cnt[a[i]], i)
	}
	pos := 0
	changes := 0
	res := make([]int, n)
	for i := 1; i <= n; i++ {
		if len(cnt[i]) == 0 {
			for j := pos; j < n; j++ {
				if len(cnt[a[j]]) > 1 {
					pos = j
					arr := cnt[a[j]]
					res[arr[0]] = i
					cnt[a[j]] = arr[1:]
					changes++
					break
				}
			}
		} else {
			arr := cnt[i]
			res[arr[0]] = i
			cnt[i] = append(arr[1:], 99999999)
		}
	}

	fmt.Println(changes)
	var buffer bytes.Buffer
	for i := 0; i < n; i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(res[i]))
	}
	fmt.Println(buffer.String())
}

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

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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


package main

import "fmt"

const Mod = 1000000007
const Log = 10

var n int
var g [][]int
var p [][]int
var d []int

func main() {
	fmt.Scan(&n)
	g = make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	for i := 1; i < n; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		x -= 1
		y -= 1
		g[x] = append(g[x], y)
		g[y] = append(g[y], x)
	}

	dp := make([][]int64, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int64, n)
	}
	for i := 1; i < n; i++ {
		dp[0][i] = 1
		dp[i][0] = 0
	}
	ti := inverse(2)
	for i := 1; i < n; i++ {
		for j := 1; j < n; j++ {
			dp[i][j] = ti * (dp[i-1][j] + dp[i][j-1]) % Mod
		}
	}

	nInverse := inverse(int64(n))

	var answer int64
	for i := 0; i < n; i++ {
		p = make([][]int, n)
		for i := 0; i < n; i++ {
			p[i] = make([]int, Log)
			for j := 0; j < Log; j++ {
				p[i][j] = -1
			}
		}
		d = make([]int, n)
		for i := 0; i < n; i++ {
			d[i] = -1
		}

		dfs(i, -1)

		for x := 0; x < n; x++ {
			for y := x + 1; y < n; y++ {
				z := lca(x, y)
				dx := d[x] - d[z]
				dy := d[y] - d[z]
				answer = (answer + nInverse*dp[dy][dx]%Mod) % Mod
			}
		}
	}
	fmt.Println(answer)
}

func getParent(v int, ds int) int {
	for i := Log - 1; i >= 0; i-- {
		if ds&(1<<i) > 0 {
			v = p[v][i]
		}
	}
	return v
}

func lca(x int, y int) int {
	if d[x] > d[y] {
		x, y = y, x
	}

	y = getParent(y, d[y]-d[x])

	if x == y {
		return x
	}

	for i := Log - 1; i >= 0; i-- {
		if p[x][i] != p[y][i] {
			x = p[x][i]
			y = p[y][i]
		}
	}

	return p[x][0]
}

func dfs(x, z int) {
	p[x][0] = z
	for i := 1; i < Log; i++ {
		if p[x][i-1] != -1 {
			p[x][i] = p[p[x][i-1]][i-1]
		}
	}

	d[x] = 0
	if z != -1 {
		d[x] = d[z] + 1
	}
	for _, y := range g[x] {
		if y == z {
			continue
		}
		dfs(y, x)
	}
}

func power(x, y int64) int64 {
	if y == 0 {
		return 1
	}
	result := power(x, y/2)
	if y%2 == 0 {
		return result * result % Mod
	}
	return result * result % Mod * x % Mod
}

func inverse(x int64) int64 {
	return power(x, Mod-2)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1540B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int64 = 1e9 + 7
	const mod2 = (mod + 1) / 2
	pow := func(x, n int64) (res int64) {
		res = 1
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return
	}

	var n, v, w int
	Fscan(in, &n)
	dis := make([][]int, n)
	for i := range dis {
		dis[i] = make([]int, n)
		for j := range dis[i] {
			dis[i][j] = 1e9
		}
	}
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		dis[v][w] = 1
		dis[w][v] = 1
	}
	for k := range dis {
		for i := range dis {
			for j := range dis {
				dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j])
			}
		}
	}

	f := make([][]int64, n+1)
	for i := range f {
		f[i] = make([]int64, n+1)
		f[0][i] = 1
	}
	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			f[i][j] = (f[i-1][j] + f[i][j-1]) * mod2 % mod
		}
	}
	ans := int64(0)
	for _, d := range dis {
		for v, dv := range dis {
			for w, dvw := range dv[:v] {
				commonDis := (d[v] + d[w] - dvw) / 2
				ans += f[d[v]-commonDis][d[w]-commonDis]
			}
		}
	}
	Fprint(out, ans%mod*pow(int64(n), mod-2)%mod)
}

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

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


package main

// @snippet <contest.go#0.0.1:header/import.go>
import "fmt"
import "io"
import "os"
import "strings"
// @snippet <contest.go#0.0.1:header/typedef.go>
type Int int64
type IntSlice []Int
// @snippet<contest.go#0.0.1:utils/read.go>
var in io.Reader

func ReadInt(n *Int) bool {
  _, err := fmt.Fscan(in, n)
  return err != io.EOF
}

func ReadString(s *string) bool {
  _, err := fmt.Fscan(in, s)
  return err != io.EOF
}

// @snippet <contest.go#0.0.1:utils/stream.go>
func Stdin() io.Reader {
  return os.Stdin
}

func Strin(s string) io.Reader {
  return strings.NewReader(s)
}
// @snippet <contest.go#0.0.1:utils/min.go>

func MinRune(a rune, b rune) rune {
  if a < b {
    return a
  } else {
    return b
  }
}

func MinInt(a Int, b Int) Int {
  if a < b {
    return a
  } else {
    return b
  }
}
// @snippet <contest.go#0.0.1:main.go>

func GcdInt(a Int, b Int) Int {
  if b == 0 {
    return a
  } else {
    return GcdInt(b, a % b)
  }
}

type Solver struct {
  N Int
  X0 Int
  Y0 Int
  X IntSlice
  Y IntSlice
}

func (s *Solver) input() bool {
  if ReadInt(&s.N) {
    if ReadInt(&s.X0) && ReadInt(&s.Y0) {
      s.X = make(IntSlice, s.N)
      s.Y = make(IntSlice, s.N)
      for i := Int(0); i < s.N; i += 1 {
        ReadInt(&s.X[i])
        ReadInt(&s.Y[i])
        s.X[i] -= s.X0
        s.Y[i] -= s.Y0
      }
      return true
    }
  }
  return false
}

type pos struct {
  X Int
  Y Int
}

func AbsInt(x Int) Int {
  if x > 0 {
    return x
  } else {
    return -x
  }
}

func main() {
  in = Stdin()
  s := &Solver{}
  for s.input() {
    m := make(map[pos]bool)
    for i := Int(0); i < s.N; i += 1 {
      if s.X[i] == 0 && s.Y[i] == 0 {
        p := pos{0, 0}
        m[p] = true
      } else if s.X[i] == 0 {
        p := pos{0, 1}
        m[p] = true
      } else if s.Y[i] == 0 {
        p := pos{1, 0}
        m[p] = true
      } else {
        g := GcdInt(s.X[i], s.Y[i])
        p := pos{s.X[i] / g, s.Y[i] / g}
        m[p] = true
      }
    }
    offset := 0
    if m[pos{0, 0}] && (m[pos{0, 1}] || m[pos{1, 0}]) {
      offset = 1
    }
    fmt.Println(len(m) - offset)
  }
}

package main

import "fmt"

type point struct {
	x int
	y int
}

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

func main() {
	var n, x0, y0, x, y int
	points := make(map[point]bool)
	fmt.Scan(&n, &x0, &y0)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		x, y = x-x0, y-y0
		d := gcd(x, y)
		x, y = x/d, y/d
		points[point{x, y}] = true
	}
	fmt.Println(len(points))
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Target struct {
  X, Y int
  Done bool
}

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

  n, x, y := getI(), getI(), getI()
  targets := make([]*Target, n)
  for i := 0; i < n; i++ {
    targets[i] = &Target{ X: getI(), Y: getI() }
  }
  count := 0
  for i := 0; i < n; i++ {
    target := targets[i]
    if target.Done {
      continue
    }
    count++
    a, b := target.X - x, target.Y - y
    for j := i+1; j < n; j++ {
      other := targets[j]
      if other.Done {
        continue
      }
      c, d := other.X - x, other.Y - y
      if a*d == b*c {
        other.Done = true
      }
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", count))
}

package main

import (
	"fmt"
	"math"
)

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

	slopes := make([][]int, n)
	for i := 0; i < n; i++ {
		var x, y int
		if _, err := fmt.Scanf("%d %d\n", &x, &y); err != nil {
			return
		}
		// numerator, denominator
		numerator := y - y0
		denominator := x - x0
		// numerator and denominator cannot be both 0
		g := gcd(int(math.Abs(float64(numerator))), int(math.Abs(float64(denominator))))
		numerator = numerator / g
		denominator = denominator / g
		// Make sure that denominator is positive or zero
		if numerator <= 0 && denominator <= 0 || numerator > 0 && denominator < 0 {
			numerator = -numerator
			denominator = -denominator
		}
		slopes[i] = make([]int, 2)
		slopes[i][0] = numerator
		slopes[i][1] = denominator
	}

	shots := 0
	for i := 0; i < n; i++ {
		if slopes[i][1] != -1 { // denominator == 0 means stormtrooper destoried
			shots++
			for j := i + 1; j < n; j++ {
				if slopes[j][0] == slopes[i][0] && slopes[j][1] == slopes[i][1] {
					slopes[j][1] = -1 // Mark as destoried
				}
			}
			slopes[i][1] = -1
		}
	}
	fmt.Println(shots)
}

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

package main

import (
	"fmt"
)

type slope struct {
	// div, rem int
	// sign     bool
	m        float64
	vertical bool
}

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

func getSlope(x0, y0, x1, y1 int) slope {
	if y1 == y0 {
		// return slope{0, 0, false, true}
		return slope{0, true}
	}

	// div := (x1 - x0) / (y1 - y0)
	// rem := abs(x1-x0) % abs(y1-y0)
	// sign := div > 0
	// return slope{abs(div), rem, sign, false}
	return slope{float64(x1-x0) / float64(y1-y0), false}
}

func main() {
	var n, x0, y0 int

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

	shots := make(map[slope]bool)
	for i := 0; i < n; i++ {
		var xi, yi int
		fmt.Scanf("%d %d\n", &xi, &yi)
		shots[getSlope(x0, y0, xi, yi)] = true
	}
	fmt.Println(len(shots))
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Split(bufio.ScanWords)
	if !sc.Scan() {
		panic("could not scan a word from the reader")
	}
	return sc.Text()
}

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

func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Split(bufio.ScanLines)
	if !sc.Scan() {
		panic("could not scan a line from the reader")
	}
	return sc.Text()
}

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

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

func mkComp(x, y int) complex64 {
	if x < 0 {
		x, y = -x, -y
	}
	x1 := abs(x)
	y1 := abs(y)
	return complex(float32(x/gcd(x1, y1)), float32(y/gcd(x1, y1)))
}

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

func main() {
	N, X0, Y0 := nextInt(), nextInt(), nextInt()
	sts := make(map[complex64]bool)
	for i := 0; i < N; i++ {
		x, y := nextInt(), nextInt()
		x -= X0
		y -= Y0
		if x == 0 && y == 0 {
			continue
		}
		if y == 0 {
			sts[1] = true
			continue
		}
		if x == 0 {
			sts[1i] = true
			continue
		}
		sts[mkComp(x, y)] = true
	}
	fmt.Println(max(len(sts), 1))
}

package main

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

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, " ") == nil {
		solve(n)
	}
}

var x, y int

func solve(n int) {
	var ans int
	in := make([][3]int, n)
	I(&x, " ")
	I(&y, "\n")
	for i := 0; i < n; i++ {
		I(&in[i][0], " ")
		I(&in[i][1], "\n")
	}
	for i := 0; i < n; i++ {
		if in[i][2] == 1 {
			continue
		}
		ans++
		in[i][2] = 1
		for j := 0; j < n; j++ {
			if oo(in[i], in[j]) {
				in[j][2] = 1
			}
		}
	}
	O(ans, "\n")
}

func oo(a, b [3]int) bool {
	if x-a[0] != 0 {
		return (x-a[0])*(b[1]-a[1]) == (b[0]-a[0])*(y-a[1])
	} else if a[0] == b[0] && a[0] == x {
		return true
	}
	return false
}

package main

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

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

type Point struct {
	x, y int
}

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

	n, x, y := nextInt(), nextInt(), nextInt()
	p := make([]Point, n)
	minShot := 0

	for i := range p {
		p[i].x = nextInt()
		p[i].y = nextInt()
	}

	for i := range p {
		if p[i].x <= 10000 {
			minShot++

			for j := i+1; j < n; j++ {
				if x * (p[i].y - p[j].y) + p[i].x * (p[j].y - y) + p[j].x * (y - p[i].y) == 0 {
					p[j].x = 10001
				}
			}
		}
	}

	println(minShot)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

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

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

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

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

package main

import "fmt"

type point struct {
	x int
	y int
}

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

func main() {
	var n, x0, y0, x, y int
	points := make(map[point]bool)
	fmt.Scan(&n, &x0, &y0)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		x, y = x-x0, y-y0
		if x < 0 {
			x, y = -x, -y
		}
		if x == 0 {
			y = 1
		}
		if y == 0 {
			x = 1
		}
		for d := 2; d <= abs(x) && d <= abs(y); {
			if x%d == 0 && y%d == 0 {
				x, y = x/d, y/d
			} else {
				d++
			}
		}
		points[point{x, y}] = true
	}
	fmt.Println(len(points))
}

package main

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

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, " ") == nil {
		solve(n)
	}
}

var x, y int

func solve(n int) {
	var ans int
	in := make([][3]int, n)
	I(&x, " ")
	I(&y, "\n")
	for i := 0; i < n; i++ {
		I(&in[i][0], " ")
		I(&in[i][1], "\n")
	}
	for i := 0; i < n; i++ {
		if in[i][2] == 1 {
			continue
		}
		ans++
		in[i][2] = 1
		for j := 0; j < n; j++ {
			if oo(in[i], in[j]) {
				in[j][2] = 1
			}
		}
	}
	O(ans, "\n")
}

func oo(a, b [3]int) bool {
	var aa int = 1e7
	if x-a[0] != 0 {
		aa = int((float64(y-a[1])/float64(x-a[0]))*float64(b[0]-a[0]) + float64(a[1]))
	} else if a[0] == b[0] && a[0] == x {
		return true
	}
	return b[1] == aa
}

package main

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

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, " ") == nil {
		solve(n)
	}
}

var x, y int

func solve(n int) {
	var ans int
	in := make([][3]int, n)
	I(&x, " ")
	I(&y, "\n")
	for i := 0; i < n; i++ {
		I(&in[i][0], " ")
		I(&in[i][1], "\n")
	}
	for i := 0; i < n; i++ {
		if in[i][2] == 1 {
			continue
		}
		ans++
		in[i][2] = 1
		for j := 0; j < n; j++ {
			if oo(in[i], in[j]) {
				in[j][2] = 1
			}
		}
	}
	O(ans, "\n")
}

func oo(a, b [3]int) bool {
	var aa int = 1e9
	if x-a[0] != 0 {
		aa = ((y-a[1])/(x-a[0]))*(b[0]-a[0]) + a[1]
	} else if a[0] == b[0] && a[0] == x {
		return true
	}
	return b[1] == aa
}

package main

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

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, " ") == nil {
		solve(n)
	}
}

var x, y int

func solve(n int) {
	var ans int
	in := make([][3]int, n)
	I(&x, " ")
	I(&y, "\n")
	for i := 0; i < n; i++ {
		I(&in[i][0], " ")
		I(&in[i][1], "\n")
	}
	for i := 0; i < n; i++ {
		if in[i][2] == 1 {
			continue
		}
		ans++
		in[i][2] = 1
		for j := 0; j < n; j++ {
			if oo(in[i], in[j]) {
				in[j][2] = 1
			}
		}
	}
	O(ans, "\n")
}

func oo(a, b [3]int) bool {
	aa := 1e7
	if x-a[0] != 0 {
		aa = (float64(y-a[1])/float64(x-a[0]))*float64(b[0]-a[0]) + float64(a[1])
	} else if a[0] == b[0] && a[0] == x {
		return true
	}
	return float64(b[1]) == aa
}

package main

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

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, " ") == nil {
		solve(n)
	}
}

var x, y int

func solve(n int) {
	var ans int
	in := make([][3]int, n)
	I(&x, " ")
	I(&y, "\n")
	for i := 0; i < n; i++ {
		I(&in[i][0], " ")
		I(&in[i][1], "\n")
	}
	for i := 0; i < n; i++ {
		if in[i][2] == 1 {
			continue
		}
		ans++
		in[i][2] = 1
		for j := 0; j < n; j++ {
			if oo(in[i], in[j]) {
				in[j][2] = 1
			}
		}
	}
	O(ans, "\n")
}

func oo(a, b [3]int) bool {
	aa := float64(1e9)
	if x-a[0] != 0 {
		aa = float64(b[1]-y)/float64(float64(y-a[1])/float64(x-a[0])) + float64(x)
	} else if a[0] == b[0] && a[0] == x {
		return true
	}
	return float64(b[0]) == aa
}

package main

import "fmt"

type point struct {
	x int
	y int
}

func main() {
	var n, x0, y0, x, y int
	points := make(map[point]bool)
	fmt.Scan(&n, &x0, &y0)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		x, y = x-x0, y-y0
		if x < 0 {
			x, y = -1*x, -1*y
		}
		if x == 0 {
			y = 1
		}
		if y == 0 {
			x = 1
		}
		for d := 2; d <= x && d <= y; d++ {
			if x%d == 0 && y%d == 0 {
				x, y = x/d, y/d
			}
		}
		points[point{x, y}] = true
	}
	fmt.Println(len(points))
}

package main

import "fmt"

type point struct {
	x int
	y int
}

func main() {
	var n, x0, y0, x, y int
	points := make(map[point]bool)
	fmt.Scan(&n, &x0, &y0)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		x, y = x-x0, y-y0
		if x < 0 {
			x, y = -1*x, -1*y
		}
		if x == 0 {
			y = 1
		}
		for d := 2; d <= x && d <= y; d++ {
			if x%d == 0 && y%d == 0 {
				x, y = x/d, y/d
			}
		}
		points[point{x, y}] = true
	}
	fmt.Println(len(points))
}

package main

import (
	"fmt"
)

type slope struct {
	div, rem int
	sign     bool
	vertical bool
}

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

func getSlope(x0, y0, x1, y1 int) slope {
	if y1 == y0 {
		return slope{0, 0, false, true}
	}

	div := (x1 - x0) / (y1 - y0)
	rem := abs(x1-x0) % abs(y1-y0)
	sign := div > 0
	return slope{abs(div), rem, sign, false}
}

func main() {
	var n, x0, y0 int

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

	shots := make(map[slope]bool)
	for i := 0; i < n; i++ {
		var xi, yi int
		fmt.Scanf("%d %d\n", &xi, &yi)
		shots[getSlope(x0, y0, xi, yi)] = true
	}

	fmt.Println(len(shots))
}

package main

// @snippet <contest.go#0.0.1:header/import.go>
import "fmt"
import "io"
import "os"
import "strings"
// @snippet <contest.go#0.0.1:header/typedef.go>
type Int int64
type IntSlice []Int
// @snippet<contest.go#0.0.1:utils/read.go>
var in io.Reader

func ReadInt(n *Int) bool {
  _, err := fmt.Fscan(in, n)
  return err != io.EOF
}

func ReadString(s *string) bool {
  _, err := fmt.Fscan(in, s)
  return err != io.EOF
}

// @snippet <contest.go#0.0.1:utils/stream.go>
func Stdin() io.Reader {
  return os.Stdin
}

func Strin(s string) io.Reader {
  return strings.NewReader(s)
}
// @snippet <contest.go#0.0.1:utils/min.go>

func MinRune(a rune, b rune) rune {
  if a < b {
    return a
  } else {
    return b
  }
}

func MinInt(a Int, b Int) Int {
  if a < b {
    return a
  } else {
    return b
  }
}
// @snippet <contest.go#0.0.1:main.go>

func GcdInt(a Int, b Int) Int {
  if b == 0 {
    return a
  } else {
    return GcdInt(b, a % b)
  }
}

type Solver struct {
  N Int
  X0 Int
  Y0 Int
  X IntSlice
  Y IntSlice
}

func (s *Solver) input() bool {
  if ReadInt(&s.N) {
    if ReadInt(&s.X0) && ReadInt(&s.Y0) {
      s.X = make(IntSlice, s.N)
      s.Y = make(IntSlice, s.N)
      for i := Int(0); i < s.N; i += 1 {
        ReadInt(&s.X[i])
        ReadInt(&s.Y[i])
        s.X[i] -= s.X0
        s.Y[i] -= s.Y0
      }
      return true
    }
  }
  return false
}

type pos struct {
  X Int
  Y Int
}

func AbsInt(x Int) Int {
  if x > 0 {
    return x
  } else {
    return -x
  }
}

func main() {
  in = Stdin()
  s := &Solver{}
  for s.input() {
    m := make(map[pos]bool)
    for i := Int(0); i < s.N; i += 1 {
      if s.X[i] == 0 && s.Y[i] == 0 {
        p := pos{0, 0}
        m[p] = true
      } else if s.X[i] == 0 {
        p := pos{0, s.Y[i] / AbsInt(s.Y[i])}
        m[p] = true
      } else if s.Y[i] == 0 {
        p := pos{s.X[i] / AbsInt(s.X[i]), 0}
        m[p] = true
      } else {
        g := GcdInt(s.X[i], s.Y[i])
        p := pos{s.X[i] / g, s.Y[i] / g}
        m[p] = true
      }
    }
    fmt.Println(len(m))
  }
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Split(bufio.ScanWords)
	if !sc.Scan() {
		panic("could not scan a word from the reader")
	}
	return sc.Text()
}

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

func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Split(bufio.ScanLines)
	if !sc.Scan() {
		panic("could not scan a line from the reader")
	}
	return sc.Text()
}

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

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

func mkComp(x, y int) complex64 {
	if x < 0 {
		x, y = -x, -y
	}
	x1 := abs(x)
	y1 := abs(x)
	return complex(float32(x/gcd(x1, y1)), float32(y/gcd(x1, y1)))
}

func main() {
	N, X0, Y0 := nextInt(), nextInt(), nextInt()
	sts := make(map[complex64]bool)
	for i := 0; i < N; i++ {
		x, y := nextInt(), nextInt()
		x -= X0
		y -= Y0
		if y == 0 {
			sts[1] = true
			continue
		}
		if x == 0 {
			sts[1i] = true
			continue
		}
		sts[mkComp(x, y)] = true
	}
	fmt.Println(len(sts))
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Split(bufio.ScanWords)
	if !sc.Scan() {
		panic("could not scan a word from the reader")
	}
	return sc.Text()
}

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

func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Split(bufio.ScanLines)
	if !sc.Scan() {
		panic("could not scan a line from the reader")
	}
	return sc.Text()
}

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

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

func mkComp(x, y int) complex64 {
	if x < 0 {
		x, y = -x, -y
	}
	x1 := abs(x)
	y1 := abs(x)
	return complex(float32(x/gcd(x1, y1)), float32(y/gcd(x1, y1)))
}

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

func main() {
	N, X0, Y0 := nextInt(), nextInt(), nextInt()
	sts := make(map[complex64]bool)
	for i := 0; i < N; i++ {
		x, y := nextInt(), nextInt()
		x -= X0
		y -= Y0
		if x == 0 && y == 0 {
			continue
		}
		if y == 0 {
			sts[1] = true
			continue
		}
		if x == 0 {
			sts[1i] = true
			continue
		}
		sts[mkComp(x, y)] = true
	}
	fmt.Println(max(len(sts), 1))
}


package main

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

func solve() {
	lets := make(map[byte]bool)

	n := readInt()
	for j := byte('a'); j <= byte('z'); j++ {
		lets[j] = true
	}
	i := 1
	shocks := 0
	for ; i <= n; i++ {
		result := ([]byte(readString()))[0]
		letters := []byte(readString())

		if len(lets) == 1 {
			if result == '?' && i != n {
				shocks++
			} else if result == '!' {
				shocks++
			}
		}

		switch result {
		case '!':
			m1 := make(map[byte]bool)
			mu := make(map[byte]bool)
			for k, v := range lets {
				if v {
					m1[k] = true
					mu[k] = true
				}
			}

			m2 := make(map[byte]bool)
			for _, c := range letters {
				m2[c] = true
				mu[c] = true
			}

			for k, _ := range mu {
				if m1[k] && m2[k] {
					// intersection with what is
					// still viable and the current
					// string: do nothing
				} else {
					// Not in both sets, not viable
					delete(lets, k)
				}
			}
		case '.', '?':
			for _, c := range letters {
				delete(lets, c)
			}
		}

	}
	fmt.Println(shocks)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

package main

import (
  "fmt"
  "bufio"
  "os"
  "strconv"
  "strings"
  /*
  "sort"
  "math"
  */
)

func f(pos [26]int) bool {
  sum := 0
  for i := 0; i < 26; i++ {
    sum += pos[i]
  }
  return sum == 1
}

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

  n := ReadInt32()
  var pos [26]int
  for i := 0; i < 26; i++ {
    pos[i] = 1
  }
  ans := 0
  for i := 0; i < n - 1; i++ {
    scanner.Scan()
    event := scanner.Text()
    scanner.Scan()
    word := scanner.Text()
    if f(pos) && (event == "!" || event == "?") {
      ans++
    }
    if event == "!" {
      for j := 0; j < 26; j++ {
        if !strings.ContainsRune(word, rune('a' + j)) {
          pos[j] = 0
        }
      }
    } else {
      for j := 0; j < 26; j++ {
        if strings.ContainsRune(word, rune('a' + j)) {
          pos[j] = 0
        }
      }
    }
  }
  fmt.Println(ans)

}

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

func ReadInt32() int {
  scanner.Scan()
  ans, _ := strconv.Atoi(scanner.Text())
  return ans
}

func PrintInts(ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
}

package main

import (
  "fmt"
  "bufio"
  "os"
  "strconv"
  "strings"
  /*
  "sort"
  "math"
  */
)

func f(pos [26]int) bool {
  sum := 0
  for i := 0; i < 26; i++ {
    sum += pos[i]
  }
  return sum == 1
}

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

  n := ReadInt32()
  var pos [26]int
  for i := 0; i < 26; i++ {
    pos[i] = 1
  }
  ans := 0
  for i := 0; i < n - 1; i++ {
    scanner.Scan()
    event := scanner.Text()
    scanner.Scan()
    word := scanner.Text()
    if f(pos) && (event == "!" || event == "?") {
      ans++
    }
    if event == "!" {
      for j := 0; j < 26; j++ {
        if !strings.ContainsRune(word, rune('a' + j)) {
          pos[j] = 0
        }
      }
    }
    if event == "." {
      for j := 0; j < 26; j++ {
        if strings.ContainsRune(word, rune('a' + j)) {
          pos[j] = 0
        }
      }
    }
  }
  fmt.Print(ans)

}

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

func ReadInt32() int {
  scanner.Scan()
  ans, _ := strconv.Atoi(scanner.Text())
  return ans
}

func PrintInts(ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
}