The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each city won the candidate who got the highest number of votes in this city, and if several candidates got the maximum number of votes, then the winner is the one with a smaller index.At the second stage of elections the winner is determined by the same principle over the cities: the winner of the elections is the candidate who won in the maximum number of cities, and among those who got the maximum number of cities the winner is the one with a smaller index.Determine who will win the elections.

The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It is guaranteed that the total number of people in all the cities does not exceed 109.

Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.

NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a smaller index, so the city chose candidate 1. City 2 chosen candidate 3. City 3 chosen candidate 1, due to the fact that everyone has the same number of votes, and 1 has the smallest index. City 4 chosen the candidate 3. On the second stage the same number of cities chose candidates 1 and 3. The winner is candidate 1, the one with the smaller index.

package main

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

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

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

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

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

type Int int64

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

func solve(m, n Int) {
	in := make([][]Int, m)
	o := make([]Int, n)
	for i := Int(0); i < m; i++ {
		in[i] = make([]Int, n)
		var max, jmax Int
		for j := Int(0); j < n; j++ {
			I(&in[i][j])
			if in[i][j] > max {
				max = in[i][j]
				jmax = j
			}
		}
		o[jmax]++
	}
	var ans, max Int
	for i := Int(0); i < n; i++ {
		if o[i] > max {
			max = o[i]
			ans = i
		}
	}
	O(ans+1, "\n")
}

package main

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

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

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

	n, m := nextInt(), nextInt()
	candidates := make([]int, n)

	for i := 0; i < m; i++ {
		winnerIndex := 0
		lastVote := 0

		for j := 0; j < n; j++ {
			vote := nextInt()

			if vote > lastVote {
				winnerIndex = j
				lastVote = vote
			}
		}

		candidates[winnerIndex]++
	}

	winner := 0

	for i := range candidates {
		if candidates[i] > candidates[winner] {
			winner = i
		}
	}

	println(winner + 1)
}

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

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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 print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import "fmt"

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

    votes := make([]int, n)
    for i := 0; i < m; i++ {
        idx := 0
        max := 0
        for j := 0; j < n; j++ {
            var v int
            if j == n - 1 {
                fmt.Scanf("%d\n", &v)
            } else {
                fmt.Scanf("%d", &v)
            }
            if v > max {
                idx = j
                max = v
            }
        }
        votes[idx]++
    }

    idx := 0
    for i := 1; i < n; i++ {
        if votes[i] > votes[idx] {
            idx = i
        }
    }
    fmt.Println(idx + 1)
}

package main

import "fmt"

func main() {
	var candidates, cities int
	fmt.Scan(&candidates)
	fmt.Scan(&cities)
	results := make([]int, candidates)
	votes := make([][]int, cities)
	for i := 0; i < cities; i++ {
		votes[i] = make([]int, candidates)
	}
	for i := 0; i < cities; i++ {
		for j := 0; j < candidates; j++ {
			fmt.Scan(&votes[i][j])
		}
	}

	votemax := 0
	idmax := 0
	for i := 0; i < cities; i++ {
		for j := 0; j < candidates; j++ {
			if votes[i][j] > votemax {
				votemax = votes[i][j]
				idmax = j
			}
		}
		results[idmax]++
		idmax = 0
		votemax = 0
	}

	for i := 0; i < candidates; i++ {
		if results[i] > votemax {
			votemax = results[i]
			idmax = i
		}
	}

	fmt.Print(idmax + 1)
}

package main

import "fmt"

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

	var ticket int64
	candidates := make([]int, n)
	for i := 0; i < m; i++ {
		max := int64(0)
		win := 0
		for j := 0; j < n; j++ {
			fmt.Scan(&ticket)
			if ticket > max {
				max = ticket
				win = j
			}
		}

		candidates[win] += 1
	}

	win := 0
	for i := 1; i < n; i++ {
		if candidates[i] > candidates[win] {
			win = i
		}
	}

	fmt.Print(win + 1)
}

// Codeforces 851 B done
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)
	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
}

var n,m int
var a [][]int
var winner int

func readData() {
 	in = bufio.NewReader(os.Stdin)
	// reading n
    n,m,_,_,_ = readFive()
    a = make([][]int, m)
    for i:=0; i<m; i++ {
        a[i] = make([]int, n)
        aaa := readLineNumbs(n)
        for j:=0; j<n; j++ {
            a[i][j] = aaa[j]
        }
    }
}

func findWinner(a []int, n int) int {
	winCnt := -1
	winPers := -1
	for i:=0; i<n; i++ {
		if a[i]>winCnt {
			winCnt = a[i]
			winPers = i+1
			//fmt.Printf("winCnt,winPers = %d %d\n", winCnt,winPers)
		}
	}
	//fmt.Println("winPers = ", winPers)
	return winPers
}

func solve() {
	wcnt := make([]int, n)
	for i:=0; i<m; i++ {
		wp := findWinner(a[i],n)
		wcnt[wp-1] += 1
	}
	winner = findWinner(wcnt,n)
}

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

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

package main

import "fmt"

const N = 1e2 + 2

var a[N][N] int64
var vis[N] int64

func main() {
  var m, n int
  fmt.Scan(&n, &m)
  for i := 1; i <= m; i++ {
    for j := 1; j <= n; j++ {
      fmt.Scan(&a[i][j])
    }
  }
  for i := 1; i <= m; i++ {
    var cur int64
    var pos int
    cur = a[i][1]
    pos = 1
    for j := 2; j <= n; j++ {
      if a[i][j] > cur {
        cur = a[i][j]
        pos = j
      }
    }
    vis[pos]++
  }
  var res int64
  var pos int
  res = 0
  for i := 1; i <= n; i++ {
    if res < vis[i] {
      res = vis[i]
      pos = i
    }
  }
  fmt.Println(pos);
}

package main

import (
    "fmt"
    )

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

    votes := make([]uint, n, n)
    for i := 0; i < m; i++ {
        v := 0
        vm := 0
        vmi := 0
        for j := 0; j < n; j++ {
            fmt.Scan(&v)
            if v > vm {
                vm = v
                vmi = j
            }
        }
        votes[vmi]++
    }

    result := 0
    for i := 1; i < n; i++ {
        if votes[i] > votes[result] {
            result = i
        }
    }

    fmt.Println(result + 1)
}

package main

import (
    "fmt"
)

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

    counts := make([]int, n);
    for i := 0; i < n; i++ {
        counts[i] = 0;
    }

    for i := 0; i < m; i++ {
        most := 0
        idx := 0
        for j := 0; j < n; j++ {
            c := 0
            fmt.Scan(&c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+1)
}

package main

import (
    "fmt"
)

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

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

    for i := 0; i < m; i++ {
        most := 0
        idx := 0
        for j := 0; j < n; j++ {
            c := 0
            fmt.Scan(&c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

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

	wins := make([]int, 100)

	for i := 0; i < m; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d\n", ind+1)
}

package main

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

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

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

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

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

type Int int64

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

func solve(m, n Int) {
	in := make([][]Int, m)
	o := make([]Int, n)
	for i := Int(0); i < m; i++ {
		in[i] = make([]Int, n)
		var max, jmax Int
		for j := Int(0); j < n; j++ {
			I(&in[i][j])
			if in[i][j] > max {
				max = in[i][j]
				jmax = j
			}
		}
		o[jmax]++
	}
	var ans, max Int
	for i := Int(0); i < n; i++ {
		if o[i] > max {
			max = o[i]
			ans = i
		}
	}
	O(ans+1, "\n")
}

package main

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

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

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

	n, m := nextInt(), nextInt()
	candidates := make([]int, m)

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

		for j := 0; j < m; j++ {
			vote := nextInt()

			if vote > lastVote {
				winnerIndex = j
				lastVote = vote
			}
		}

		candidates[winnerIndex]++
	}

	winner := 0

	for i := range candidates {
		if candidates[i] > candidates[winner] {
			winner = i
		}
	}

	println(winner + 1)
}

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

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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 print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import "fmt"

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

    votes := make([]int, n)
    for i := 0; i < m; i++ {
        idx := 0
        max := 0
        for j := 0; j < n; j++ {
            var v int
            fmt.Scanf("%d", &v)
            if v > max {
                idx = j
                max = v
            }
        }
        votes[idx]++
    }

    idx := 0
    for i := 1; i < n; i++ {
        if votes[i] > votes[idx] {
            idx = i
        }
    }
    fmt.Println(idx + 1)
}

package main

import "fmt"

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

    votes := make([]int, n)
    for i := 0; i < m; i++ {
        idx := 0
        max := 0
        for j := 0; j < n; j++ {
            var v int
            fmt.Scanf("%d", &v)
            if v > max {
                idx = j
                max = v
            }
        }
        votes[idx]++
    }

    idx := 0
    for i := 1; i < n; i++ {
        if votes[i] > votes[idx] {
            idx = i
        }
    }
    fmt.Println(idx + 1)
}

package main

import "fmt"

func main() {
	var candidates, cities int
	fmt.Scan(&candidates);
	fmt.Scan(&cities)
	results := make([]int, candidates);
	votes := make([][]int, cities);
	for i := 0; i < cities; i++ {
		votes[i] = make([]int, cities);
	}
	for i := 0; i < cities; i++ {
		for j := 0; j < candidates; j++ {
			fmt.Scan(&votes[i][j])
		}
	}

	votemax := 0;
	idmax := 0;
	for i := 1; i < cities; i++ {
		for j := 0; j < candidates; j++ {
			if votes[i][j] > votemax {
				votemax = votes[i][j]
				idmax = j
			}
		}
		results[idmax]++;
		idmax = 0;
		votemax = 0;
	}

	for i := 0; i < candidates; i++ {
		if results[i] > votemax {
			votemax = results[i];
			idmax = i;
		}
	}

	fmt.Print(idmax + 1);
}

package main

import (
    "fmt"
)

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

    counts := make([]int, n);
    for i := 0; i < m; i++ {
        most := int64(0)
        idx := 0
        for j := 0; j < n; j++ {
            var c int64
            fmt.Scanf("%d", &c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+1)
}

package main

import (
    "fmt"
)

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

    counts := make([]int, n);
    for i := 0; i < n; i++ {
        counts[i] = 0;
    }

    for i := 0; i < m; i++ {
        most := int64(0)
        idx := 0
        for j := 0; j < n; j++ {
            var c int64
            fmt.Scanf("%d", &c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+1)
}

package main

import (
    "fmt"
)

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

    counts := make([]int, n);
    for i := 0; i < n; i++ {
        counts[i] = 0;
    }

    for i := 0; i < m; i++ {
        most := int64(0)
        idx := 0
        for j := 0; j < n; j++ {
            var c int64
            fmt.Scanf("%d", &c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+2)
}

package main

import (
    "fmt"
)

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

    counts := make([]int, n);
    for i := 0; i < n; i++ {
        counts[i] = 0;
    }

    for i := 0; i < m; i++ {
        most := 0
        idx := 0
        for j := 0; j < n; j++ {
            c := 0
            fmt.Scanf("%d", &c)
            if c > most {
                most = c
                idx = j
            }
        }
        counts[idx] += 1
    }

    won_counts := 0
    winner := 0
    for i := 0; i < n; i++ {
        if counts[i] > won_counts {
            won_counts = counts[i]
            winner = i
        }
    }
    fmt.Println(winner+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		votes[i] = make([]int, 100)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &votes[i][j])
		}
		fmt.Scanf("\n")
	}

	wins := make([]int, 100)
	for i := 0; i < n; i++ {
		wins[i] = 0
	}

	for i := 0; i < n; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d\n", ind+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		votes[i] = make([]int, 100)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &votes[i][j])
		}
	}

	wins := make([]int, 100)
	for i := 0; i < n; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d\n", ind+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		votes[i] = make([]int, 100)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &votes[i][j])
		}
	}

	wins := make([]int, 100)
	for i := 0; i < n; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d", ind+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

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

	wins := make([]int, 100)
	for i := 0; i < n; i++ {
		wins[i] = 0
	}

	for i := 0; i < n; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d\n", ind+1)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	votes := make([][]int, 100)

	fmt.Scanf("%d %d", &n, &m)
	for i := 0; i < n; i++ {
		votes[i] = make([]int, 100)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &votes[i][j])
		}
	}

	wins := make([]int, 100)
	for i := 0; i < n; i++ {
		wins[i] = 0
	}

	for i := 0; i < n; i++ {
		max := -1
		ind := 0
		for j := 0; j < n; j++ {
			if votes[i][j] > max {
				max = votes[i][j]
				ind = j
			}
		}
		wins[ind]++
	}

	ind := -1
	max := -1
	for i := 0; i < n; i++ {
		if wins[i] > max {
			ind = i
			max = wins[i]
		}
	}

	fmt.Printf("%d\n", ind+1)
}


When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:   transform lowercase letters to uppercase and vice versa;  change letter «O» (uppercase latin letter) to digit «0» and vice versa;  change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other. For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.

The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50  — the login itself. The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins. The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.

Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it. Otherwise print «No» (without quotes).

NoteIn the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.In the third sample case the new login is similar with the second one.

package main

import (
	"fmt"
	"strings"
)

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

	user = strings.ToLower(user)
	user = strings.Replace(user, "0", "o", -1)
	user = strings.Replace(user, "l", "1", -1)
	user = strings.Replace(user, "i", "1", -1)
	answer := "Yes"
	for i := 0; i < n; i++ {
		if answer == "No" {
			continue
		}
		var temp string
		fmt.Scan(&temp)
		if len(user) != len(temp) {
			continue
		}
		temp = strings.ToLower(temp)
		temp = strings.Replace(temp, "0", "o", -1)
		temp = strings.Replace(temp, "l", "1", -1)
		temp = strings.Replace(temp, "i", "1", -1)
		if user == temp {
			answer = "No"
		}
	}
	fmt.Println(answer)

}

package main

import (
	"fmt"
	"strings"
)

func replace(str string) string {
	str = strings.ToLower(str)

	str = strings.ReplaceAll(str, "0", "o")
	str = strings.ReplaceAll(str, "1", "l")
	str = strings.ReplaceAll(str, "i", "l")
	return str
}

func main() {
	// fmt.Println("hello")
	var checkLogin string;
	var regCount int;

	fmt.Scan(&checkLogin);
	checkLogin = replace(checkLogin)
	fmt.Scan(&regCount);

	registered := make([]string, regCount)
	for i := 0; i < regCount; i++ {
		fmt.Scan(&registered[i])
		registered[i] = replace(registered[i])
	}

	for _, v := range registered {
		if checkLogin == v {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


This is an interactive problem.There was a tournament consisting of $$$2^n$$$ contestants. The $$$1$$$-st contestant competed with the $$$2$$$-nd, the $$$3$$$-rd competed with the $$$4$$$-th, and so on. After that, the winner of the first match competed with the winner of second match, etc. The tournament ended when there was only one contestant left, who was declared the winner of the tournament. Such a tournament scheme is known as the single-elimination tournament.You don't know the results, but you want to find the winner of the tournament. In one query, you select two integers $$$a$$$ and $$$b$$$, which are the indices of two contestants. The jury will return $$$1$$$ if $$$a$$$ won more matches than $$$b$$$, $$$2$$$ if $$$b$$$ won more matches than $$$a$$$, or $$$0$$$ if their number of wins was equal.Find the winner in no more than $$$\left \lceil \frac{1}{3} \cdot 2^{n + 1} \right \rceil$$$ queries. Here $$$\lceil x \rceil$$$ denotes the value of $$$x$$$ rounded up to the nearest integer.Note that the tournament is long over, meaning that the results are fixed and do not depend on your queries.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 2^{14}$$$) — the number of test cases. The only line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 17$$$). It is guaranteed that the sum of $$$2^n$$$ over all test cases does not exceed $$$2^{17}$$$.

NoteThe tournament in the first test case is shown below. The number of wins is $$$[1,0,0,2,0,1,3,0]$$$.    In this example, the winner is the $$$7$$$-th contestant.

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

var in = bufio.NewReader(os.Stdin)
var winner [2][1 << 20]int

func main() {
	var t, n, i, record, l int
	fmt.Scan(&t)
	for ; t != 0; t-- {
		fmt.Scan(&n)
		l = 1 << n
		for i = 1; i <= l; i++ {
			winner[0][i] = i
		}
		last, cur, lastLen, curLen := 0, 1, l, 0
		for lastLen > 2 {
			for i = 1; i <= lastLen; i += 4 {
				curLen++
				fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+2])
				fmt.Scan(&record)
				if record == 0 {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+3])
					fmt.Scan(&record)
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else if record == 1 {
					fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+3])
					fmt.Scan(&record)
					if record == 1 {
						winner[cur][curLen] = winner[last][i]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+2])
					fmt.Scan(&record)
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+2]
					}
				}
			}
			last, cur, lastLen, curLen = cur, last, curLen, 0
		}
		if lastLen == 2 {
			fmt.Printf("? %d %d\n", winner[last][1], winner[last][2])
			fmt.Scan(&record)
			if record == 1 {
				fmt.Printf("! %d\n", winner[last][1])
			} else {
				fmt.Printf("! %d\n", winner[last][2])
			}
		} else {
			fmt.Printf("! %d\n", winner[last][1])
		}

	}
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

var in = bufio.NewReader(os.Stdin)
var winner [2][1 << 20]int

func main() {
	var t, n, i, record, l int
	t = readInt()
	for ; t != 0; t-- {
		n = readInt()
		l = 1 << n
		for i = 1; i <= l; i++ {
			winner[0][i] = i
		}
		last, cur, lastLen, curLen := 0, 1, l, 0
		for lastLen > 2 {
			for i = 1; i <= lastLen; i += 4 {
				curLen++
				fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+2])
				record = readInt()
				if record == 0 {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+3])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else if record == 1 {
					fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+3])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+2])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+2]
					}
				}
			}
			last, cur, lastLen, curLen = cur, last, curLen, 0
		}
		if lastLen == 2 {
			fmt.Printf("? %d %d\n", winner[last][1], winner[last][2])
			record = readInt()
			if record == 1 {
				fmt.Printf("! %d\n", winner[last][1])
			} else {
				fmt.Printf("! %d\n", winner[last][2])
			}
		} else {
			fmt.Printf("! %d\n", winner[last][1])
		}

	}
}

package main

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

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

	ask := func(a, b int) int {
		fmt.Printf("? %d %d\n", a, b)
		return readNum(reader)
	}

	tc := readNum(reader)

	for tc > 0 {
		tc--

		n := readNum(reader)

		res := solve(n, ask)

		fmt.Printf("! %d\n", res)
	}

}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, ask func(int, int) int) int {
	arr := make([]int, 1<<n)

	for i := 0; i < len(arr); i++ {
		arr[i] = i + 1
	}

	m := len(arr)

	for m >= 4 {
		var j int
		for i := 0; i < m; i += 4 {
			a, b, c, d := arr[i], arr[i+1], arr[i+2], arr[i+3]
			x := ask(a, c)
			if x == 1 {
				// a win, b & c won't win
				x = ask(a, d)
				if x == 1 {
					arr[j] = a
				} else {
					// x == 2
					arr[j] = d
				}
			} else if x == 2 {
				// c win, then a & d won't win
				x = ask(b, c)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = c
				}
			} else {
				// x == 0,
				x = ask(b, d)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = d
				}
			}

			j++
		}
		m = j
	}
	if m == 2 {
		x := ask(arr[0], arr[1])
		if x == 2 {
			arr[0] = arr[1]
		}
	}
	return arr[0]
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		ask := do(n)
		for {
			w1, w2, w3 := ask()
			fmt.Fprint(w, w2)
			for _, v := range w3 {
				fmt.Fprint(w, " ", v)
			}
			fmt.Fprintln(w)
			if w, ok := w.(flush); ok {
				w.Flush()
			}
			ans, ok := w1.(fans)
			if !ok {
				break
			}
			var k int
			fmt.Fscan(r, &k)
			w1 = ans(k)
			ask, ok = w1.(fask)
			if !ok {
				break
			}
		}
	}
}

type fask = func() (interface{}, string, []int)
type fans = func(k int) interface{}
type flush interface{ Flush() error }

func do(n int) fask {
	var ask, ask2, ask4 fask
	var ans fans
	a := make([]int, 1<<n)
	for i := range a {
		a[i] = i + 1
	}
	b := []int{}
	ask = func() (interface{}, string, []int) {
		if len(a) >= 4 {
			b, a = a[:4], a[4:]
			return ask4()
		} else if len(a) >= 2 {
			b, a = a[:2], a[2:]
			return ask2()
		}
		return nil, "!", a
	}
	ans = func(k int) interface{} {
		a = append(a, b[k-1])
		return ask
	}
	ask2 = func() (interface{}, string, []int) {
		return ans, "?", b[:2]
	}
	ask4 = func() (interface{}, string, []int) {
		b[1], b[2] = b[2], b[1]
		return func(k int) interface{} {
			switch k {
			case 0:
				b = b[2:]
			case 1: // b[0]>b[1]
				b[1] = b[3]
			case 2: // b[0]<b[1]
				b[0] = b[2]
			}
			return ask2
		}, "?", b[:2]
	}
	return ask
}

package main

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

func init() {}

func req(i, j int) int {
	fmt.Fprintf(out, "? %d %d\n", i, j)
	flush()
	return get()
}

func ans(i int) {
	fmt.Fprintf(out, "! %d\n", i)
	flush()
}

func solve() {
	n := get()
	n = 1 << n
	a := ints(n, 0)
	for i := 0; i < n; i++ {
		a[i] = i + 1
	}
	d := 1
	for n > 1 {
		if n == 2 {
			x := req(a[0], a[d])
			if x == 2 {
				a[0] = a[d]
			}
			break
		}
		for i := 0; i < n; i += 4 {
			x := req(a[d*i], a[d*(i+2)])
			if x == 0 {
				x = req(a[d*(i+1)], a[d*(i+3)])
				if x == 1 {
					a[i*d] = a[d*(i+1)]
				} else {
					a[i*d] = a[d*(i+3)]
				}
				continue
			}
			if x == 1 {
				x = req(a[d*i], a[d*(i+3)])
				if x == 2 {
					a[d*i] = a[d*(i+3)]
				}
				continue
			}
			x = req(a[d*(i+1)], a[d*(i+2)])
			if x == 1 {
				a[d*i] = a[d*(i+1)]
			} else {
				a[d*i] = a[d*(i+2)]
			}
		}
		d *= 4
		n /= 4
	}
	ans(a[0])
}

const (
	once       = false
	useBuf     = false
	maxBufSize = 10_000_000
	YES        = "YES"
	NO         = "NO"
)

var (
	splitFunc = bufio.ScanWords
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	if useBuf {
		in.Buffer(make([]byte, maxBufSize), maxBufSize)
	}

	out = bufio.NewWriter(os.Stdout)
	defer flush()

	if once {
		solve()
		return
	}

	for t := get(); t > 0; t-- {
		solve()
	}
}

var (
	in  *bufio.Scanner
	out *bufio.Writer
)

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func geta1(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get() - 1
	}
	return a
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func get64a(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64()
	}
	return a
}

func get64a1(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64() - 1
	}
	return a
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func getfa(n int) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = getf()
	}
	return a
}

func gets() string {
	scan()
	return in.Text()
}

func scanN(n int) {
	for n > 0 {
		scan()
		n--
	}
}

func scan() {
	in.Scan()
}

func putc(c rune) {
	out.WriteRune(c)
}

func line() {
	putc('\n')
}

func space() {
	putc(' ')
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func putln(i int) {
	put(i)
	line()
}

func puta(a []int) {
	for _, v := range a {
		put(v)
		space()
	}
	line()
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func put64ln(x int64) {
	put64(x)
	line()
}

func put64a(a []int64) {
	for _, v := range a {
		put64(v)
		space()
	}
	line()
}

func flush() {
	out.Flush()
}

func puts(s string) {
	out.WriteString(s)
}

func putsln(s string) {
	puts(s)
	line()
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts(YES)
	line()
}

func no() {
	puts(NO)
	line()
}

func putf(x float64) {
	out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
}

func putfln(x float64) {
	putf(x)
	line()
}

func putfa(a []float64) {
	for _, v := range a {
		putf(v)
		space()
	}
	line()
}

type IntTp interface {
	int | int64
}

type Tp interface {
	IntTp | float64
}

func abs[T IntTp](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func fabs(x float64) float64 {
	return math.Abs(x)
}

func max1[T Tp](x T, y T) T {
	if x > y {
		return x
	}
	return y
}

func max[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = max1(r, x)
	}
	return r
}

func maxa[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] <= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func min1[T Tp](x T, y T) T {
	if x < y {
		return x
	}
	return y
}

func min[T Tp](xs ...T) T {
	r := xs[0]
	for _, x := range xs[1:] {
		r = min1(r, x)
	}
	return r
}

func mina[T Tp](a []T) (i int, val T) {
	i, val = 0, a[0]
	for j := 1; j < len(a); j++ {
		if a[j] >= val {
			continue
		}
		i = j
		val = a[j]
	}
	return
}

func L(i int) int64 {
	return int64(i)
}

func F(i int) float64 {
	return float64(i)
}

func ints(n int, val int) (a []int) {
	a = make([]int, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func int64s(n int, val int64) (a []int64) {
	a = make([]int64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func floats(n int, val float64) (a []float64) {
	a = make([]float64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

const heapBase = 4

func children(i int) (int, int) {
	start := heapBase * i
	return start + 1, start + (1 + heapBase)
}

func parent(i int) int {
	return (i - 1) / heapBase
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

var in = bufio.NewReader(os.Stdin)

func main() {
	t := readInt()
	for i := 0; i < t; i++ {
		n := readInt()
		cur := 1 << n
		a := make([]int, cur)
		for j := range a {
			a[j] = j + 1
		}
		for cur >= 4 {
			for j := 0; j < cur; j += 4 {
				fmt.Printf("? %d %d\n", a[j], a[j+3])
				ans := readLine()
				if ans == "1" {
					fmt.Printf("? %d %d\n", a[j], a[j+2])
					ans = readLine()
					if ans == "1" {
						a[j/4] = a[j]
					} else {
						a[j/4] = a[j+2]
					}
				} else if ans == "0" {
					fmt.Printf("? %d %d\n", a[j+1], a[j+2])
					ans = readLine()
					if ans == "1" {
						a[j/4] = a[j+1]
					} else {
						a[j/4] = a[j+2]
					}
				} else {
					fmt.Printf("? %d %d\n", a[j+1], a[j+3])
					ans = readLine()
					if ans == "1" {
						a[j/4] = a[j+1]
					} else {
						a[j/4] = a[j+3]
					}
				}
			}
			cur /= 4
		}
		if cur == 1 {
			fmt.Printf("! %d\n", a[0])
		} else {
			fmt.Printf("? %d %d\n", a[0], a[1])
			ans := readLine()
			if ans == "1" {
				fmt.Printf("! %d\n", a[0])
			} else {
				fmt.Printf("! %d\n", a[1])
			}
		}
	}
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

var in = bufio.NewReader(os.Stdin)
var winner [2][1 << 20]int

func main() {
	var t, n, i, record, l int
	t = readInt()
	for ; t != 0; t-- {
		n = readInt()
		l = 1 << n
		for i = 1; i <= l; i++ {
			winner[0][i] = i
		}
		last, cur, lastLen, curLen := 0, 1, l, 0
		for lastLen > 1 {
			for i = 1; i <= lastLen; i += 4 {
				curLen++
				fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+2])
				record = readInt()
				if record == 0 {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+3])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else if record == 1 {
					fmt.Printf("? %d %d\n", winner[last][i], winner[last][i+3])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i]
					} else {
						winner[cur][curLen] = winner[last][i+3]
					}
				} else {
					fmt.Printf("? %d %d\n", winner[last][i+1], winner[last][i+2])
					record = readInt()
					if record == 1 {
						winner[cur][curLen] = winner[last][i+1]
					} else {
						winner[cur][curLen] = winner[last][i+2]
					}
				}
			}
			last, cur, lastLen, curLen = cur, last, curLen, 0
		}
		fmt.Printf("! %d\n", winner[last][1])
	}
}

package main

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

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

	ask := func(a, b int) int {
		fmt.Printf("? %d %d\n", a, b)
		return readNum(reader)
	}

	tc := readNum(reader)

	for tc > 0 {
		tc--

		n := readNum(reader)

		res := solve(n, ask)

		fmt.Printf("! %d\b", res)
	}

}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, ask func(int, int) int) int {
	arr := make([]int, 1<<n)

	for i := 0; i < len(arr); i++ {
		arr[i] = i + 1
	}

	m := len(arr)

	for m >= 4 {
		var j int
		for i := 0; i < m; i += 4 {
			a, b, c, d := arr[i], arr[i+1], arr[i+2], arr[i+3]
			x := ask(a, c)
			if x == 1 {
				// a win, b & c won't win
				x = ask(a, d)
				if x == 1 {
					arr[j] = a
				} else {
					// x == 2
					arr[j] = d
				}
			} else if x == 2 {
				// c win, then a & d won't win
				x = ask(b, c)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = c
				}
			} else {
				// x == 0,
				x = ask(b, d)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = d
				}
			}

			j++
		}
		m = j
	}
	if m == 2 {
		x := ask(arr[0], arr[1])
		if x == 2 {
			arr[0] = arr[1]
		}
	}
	return arr[0]
}

package main

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

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

	ask := func(a, b int) int {
		fmt.Printf("? %d %d\n", a, b)
		return readNum(reader)
	}

	tc := readNum(reader)

	for tc > 0 {
		tc--

		n := readNum(reader)

		res := solve(n, ask)

		fmt.Printf("! %d\b", res)
	}

}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, ask func(int, int) int) int {
	arr := make([]int, 1<<n)

	for i := 0; i < len(arr); i++ {
		arr[i] = i + 1
	}

	for n > 1 {
		var j int
		for i := 0; i < (1 << n); i += 4 {
			a, b, c, d := arr[i], arr[i+1], arr[i+2], arr[i+3]
			x := ask(a, c)
			if x == 1 {
				// a win, b & c won't win
				x = ask(a, d)
				if x == 1 {
					arr[j] = a
				} else {
					// x == 2
					arr[j] = d
				}
			} else if x == 2 {
				// c win, then a & d won't win
				x = ask(b, c)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = c
				}
			} else {
				// x == 0,
				x = ask(b, d)
				if x == 1 {
					arr[j] = b
				} else {
					arr[j] = d
				}
			}

			j++
		}
		n -= 2
	}
	if n == 1 {
		x := ask(arr[0], arr[1])
		if x == 2 {
			arr[0] = arr[1]
		}
	}
	return arr[0]
}


You are given a string $$$s$$$ consisting of exactly $$$n$$$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.Your task is to replace minimum number of characters in this string with other characters to obtain a balanced ternary string (balanced ternary string is a ternary string such that the number of characters '0' in this string is equal to the number of characters '1', and the number of characters '1' (and '0' obviously) is equal to the number of characters '2').Among all possible balanced ternary strings you have to obtain the lexicographically (alphabetically) smallest.Note that you can neither remove characters from the string nor add characters to the string. Also note that you can replace the given characters only with characters '0', '1' and '2'.It is guaranteed that the answer exists.

The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 3 \cdot 10^5$$$, $$$n$$$ is divisible by $$$3$$$) — the number of characters in $$$s$$$. The second line contains the string $$$s$$$ consisting of exactly $$$n$$$ characters '0', '1' and '2'.

Print one string — the lexicographically (alphabetically) smallest balanced ternary string which can be obtained from the given one with minimum number of replacements. Because $$$n$$$ is divisible by $$$3$$$ it is obvious that the answer exists. And it is obvious that there is only one possible answer.

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	var str []byte
	fmt.Fscanf(buf, "%d\n", &n)
	fmt.Fscanf(buf, "%s\n", &str)
	cnt := make([]int,3)
	for i:= 0;i < n;i++{
		cnt[str[i]-byte('0')]++
	}
	cnt[0] -= n/3
	cnt[1] -= n/3
	cnt[2] -= n/3
	for i:= 0;i < n;i++{
		tmp := str[i]-byte('0')
		if cnt[tmp] > 0{
			for j := 0;j < int(tmp);j++{
				if cnt[j] < 0{
					str[i] = byte('0')+byte(j)
					cnt[j]++
					cnt[tmp]--
					break
				}
			}
		}
	}
//	fmt.Printf("%s\n", str)
	for i:= n-1;i >= 0;i--{
		tmp := str[i]-byte('0')
		if cnt[tmp] > 0{
			for j := 2;j > int(tmp);j--{
				if cnt[j] < 0{
					str[i] = byte('0')+byte(j)
					cnt[j]++
					cnt[tmp]--
					break
				}
			}
		}
	}
	fmt.Printf("%s\n", str)
}

package main

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

func main() {
	start := time.Now()
	defer func() {
		run := time.Since(start)
		_ = run
		// fmt.Println("Run in", run)
	}()

	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	stdin = bufio.NewReader(os.Stdin)

	var n int
	var s []byte
	var cnt = []int{0, 0, 0}
	fmt.Fscanln(stdin, &n)
	fmt.Fscanln(stdin, &s)

	var l = len(s)
	for i := 0; i < l; i++ {
		cnt[s[i]-'0']++
	}

	for i := l - 1; i >= 0 && cnt[0] > n/3; i-- {
		if s[i] == '0' {
			cnt[0]--
			if cnt[2] < n/3 {
				s[i] = 50
				cnt[2]++
			} else {
				s[i] = 49
				cnt[1]++
			}
		}
	}
	for i := 0; i < l && cnt[1] > n/3 && cnt[0] < n/3; i++ {
		if s[i] == '1' {
			cnt[1]--
			s[i] = 48
			cnt[0]++
		}
	}
	for i := l - 1; i >= 0 && cnt[1] > n/3 && cnt[2] < n/3; i-- {
		if s[i] == '1' {
			cnt[1]--
			s[i] = 50
			cnt[2]++
		}
	}
	for i := 0; i < l && cnt[2] > n/3; i++ {
		if s[i] == '2' {
			cnt[2]--
			if cnt[0] < n/3 {
				cnt[0]++
				s[i] = 48
			} else {
				cnt[1]++
				s[i] = 49
			}
		}
	}

	fmt.Println(string(s))
	// fmt.Println(s)
	// fmt.Println(cnt)
}

package main

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

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

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

func main() {
	defer writer.Flush()

	const maxCapacity = 300050
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

    scanner.Split(bufio.ScanWords)

	n := ReadInt()

	scanner.Scan()
	bla := scanner.Text()
	str := []byte(bla)

	var um, zero, dois int

	for _, elem := range str {
		if elem == '0' {
			zero++
		} else if elem == '1' {
			um++
		} else {
			dois++
		}
	}

	qt := n/3

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '2' && dois > qt {
	            str[i] = '0'
	            dois--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '1' && um > qt {
	            str[i] = '0'
	            um--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '2' && dois > qt {
                str[i] = '1'
                dois--
                um++
            }

            if um == qt {
                break
            }
        }
    }

    cont0 := 0

    if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '0' && cont0 >= qt {
                str[i] = '1'
                zero--
                um++
            }

            if str[i] == '0' {
            	cont0++
            }

            if um == qt {
                break
            }
        }
    }

    if dois < qt {
        for i := n-1; i >= 0; i-- {
            if str[i] == '1' && um > qt {
                str[i] = '2'
                um--
                dois++
            } else if str[i] == '0' && zero > qt {
                str[i] = '2'
                zero--
                dois++
            }

            if dois == qt {
                break
            }
        }
    }

    writer.WriteString(string(str))

}

package main

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

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

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

func init() {
	const maxCapacity = 300050
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)
    scanner.Split(bufio.ScanWords)
}

func main() {
	defer writer.Flush()

	n := ReadInt()

	scanner.Scan()
	bla := scanner.Text()
	str := []byte(bla)

	var um, zero, dois int

	for _, elem := range str {
		if elem == '0' {
			zero++
		} else if elem == '1' {
			um++
		} else {
			dois++
		}
	}

	qt := n/3

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '2' && dois > qt {
	            str[i] = '0'
	            dois--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '1' && um > qt {
	            str[i] = '0'
	            um--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '2' && dois > qt {
                str[i] = '1'
                dois--
                um++
            }

            if um == qt {
                break
            }
        }
    }

    cont0 := 0

    if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '0' && cont0 >= qt {
                str[i] = '1'
                zero--
                um++
            }

            if str[i] == '0' {
            	cont0++
            }

            if um == qt {
                break
            }
        }
    }

    if dois < qt {
        for i := n-1; i >= 0; i-- {
            if str[i] == '1' && um > qt {
                str[i] = '2'
                um--
                dois++
            } else if str[i] == '0' && zero > qt {
                str[i] = '2'
                zero--
                dois++
            }

            if dois == qt {
                break
            }
        }
    }

    writer.WriteString(string(str))

}

package main

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

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

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

func main() {
	defer writer.Flush()

	const maxCapacity = 300050
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

    scanner.Split(bufio.ScanWords)

	n := ReadInt()

	scanner.Scan()
	bla := scanner.Text()
	str := []byte(bla)

	if n == 300000 {
		fmt.Println(len(bla))
	}

	var um, zero, dois int

	for _, elem := range str {
		if elem == '0' {
			zero++
		} else if elem == '1' {
			um++
		} else {
			dois++
		}
	}

	qt := n/3

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '2' && dois > qt {
	            str[i] = '0'
	            dois--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if n == 300000 {
		fmt.Println("oi")
	}

	if zero < qt {
	    for i := 0; i < n; i++ {
	        if str[i] == '1' && um > qt {
	            str[i] = '0'
	            um--
	            zero++
	        }
	        if zero == qt {
	            break
	        }
	    }
	}

	if n == 300000 {
		fmt.Println("oi")
	}

	if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '2' && dois > qt {
                str[i] = '1'
                dois--
                um++
            }

            if um == qt {
                break
            }
        }
    }

    if n == 300000 {
		fmt.Println("oi")
	}

    cont0 := 0

    if um < qt {
        for i := 0; i < n; i++ {
            if str[i] == '0' && cont0 >= qt {
                str[i] = '1'
                zero--
                um++
            }

            if str[i] == '0' {
            	cont0++
            }

            if um == qt {
                break
            }
        }
    }

    if n == 300000 {
		fmt.Println("oi")
	}

    if dois < qt {
        for i := n-1; i >= 0; i-- {
            if str[i] == '1' && um > qt {
                str[i] = '2'
                um--
                dois++
            } else if str[i] == '0' && zero > qt {
                str[i] = '2'
                zero--
                dois++
            }

            if dois == qt {
                break
            }
        }
    }

    if n == 300000 {
		fmt.Println("oi")
	}

    writer.WriteString(string(str))

}

package main

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

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

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

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

    n := ReadInt()

    qt := n/int(3)

    scanner.Scan()
    str := scanner.Text()

    resp := make([]string, n)
    for i, elem := range str {
    	resp[i] = string(elem)
    }

    var zero, um, dois int

    for i := 0; i < n; i++ {
    	if resp[i] == "0" {
    		zero++
    	} else if resp[i] == "1" {
    		um++
    	} else{
    		dois++
    	}
    }

    if zero < qt {
    	for i := 0; i < n; i++ {
    		if resp[i] == "2" && dois > qt {
				resp[i] = "0"
				dois--
				zero++
    		} else if resp[i] == "1" && um > qt {
    			resp[i] = "0"
    			um--
    			zero++
    		}

    		if zero == qt {
    			break
    		}
    	}
    }

    cont0 := 0

    if um < qt {
    	for i := 0; i < n; i++ {
    		if resp[i] == "2" && dois > qt {
				resp[i] = "1"
				dois--
				um++
    		} else if resp[i] == "0" && cont0 >= qt {
    			resp[i] = "1"
    			zero--
    			um++
    		}

    		if resp[i] == "0" {
    			cont0++
    		}

    		if um == qt {
    			break
    		}
    	}
    }

    if dois < qt {
    	for i := n-1; i >= 0; i-- {
    		if resp[i] == "1" && um > qt {
    			resp[i] = "2"
    			um--
    			dois++
    		} else if resp[i] == "0" && zero > qt {
    			resp[i] = "2"
    			zero--
    			dois++
    		}

    		if dois == qt {
    			break
    		}
    	}
    }

    ans := ""

    for _, elem := range resp {
    	ans += elem
    }

    writer.WriteString(ans)
}


At the store, the salespeople want to make all prices round. In this problem, a number that is a power of $$$10$$$ is called a round number. For example, the numbers $$$10^0 = 1$$$, $$$10^1 = 10$$$, $$$10^2 = 100$$$ are round numbers, but $$$20$$$, $$$110$$$ and $$$256$$$ are not round numbers. So, if an item is worth $$$m$$$ bourles (the value of the item is not greater than $$$10^9$$$), the sellers want to change its value to the nearest round number that is not greater than $$$m$$$. They ask you: by how many bourles should you decrease the value of the item to make it worth exactly $$$10^k$$$ bourles, where the value of $$$k$$$ — is the maximum possible ($$$k$$$ — any non-negative integer).For example, let the item have a value of $$$178$$$-bourles. Then the new price of the item will be $$$100$$$, and the answer will be $$$178-100=78$$$.

The first line of input data contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases . Each test case is a string containing a single integer $$$m$$$ ($$$1 \le m \le 10^9$$$) — the price of the item.

For each test case, output on a separate line a single integer $$$d$$$ ($$$0 \le d < m$$$) such that if you reduce the cost of the item by $$$d$$$ bourles, the cost of the item will be the maximal possible round number. More formally: $$$m - d = 10^k$$$, where $$$k$$$ — the maximum possible non-negative integer.

package main

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

func solve(in io.Reader, out io.Writer) {
	var n int
	fmt.Fscan(in, &n)
	base := int(math.Log10(float64(n)))
	ans := n - int(math.Pow10(base))
	fmt.Fprintln(out, ans)
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		solve(in, os.Stdout)
		t--
	}
}

package main

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

func solve(out io.Writer) {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		base := int(math.Log10(float64(n)))
		ans := n - int(math.Pow10(base))
		fmt.Fprintln(out, ans)
	}
}

func main() {
	solve(os.Stdout)
}

package main

import (
	"fmt"
	"math"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	base := int(math.Log10(float64(n)))
	fmt.Printf("%d\n", n-int(math.Pow10(base)))
}

func main() {
	var t int
	fmt.Scanf("%v\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

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

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

	var T int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)
		for i := 1; i <= int(1E9); i *= 10 {
			if x >= i && x < i*10 {
				Fprintln(out, x-i)
			}
		}
	}
}

package main

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

var st []int64

func init() {
	for i := 9; i >= 0; i-- {
		st = append(st, int64(math.Pow(10, float64(i))))
	}
}

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

	val, _ := strconv.Atoi(scanner.Text())

	for i := 0; i < val; i++ {
		scanner.Scan()
		m, _ := strconv.ParseInt(scanner.Text(), 10, 64)

		for _, k := range st {
			if d := m - k; d >= 0 && d < m {
				fmt.Println(d)
				break
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
  // "reflect"
)

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func power(n int64) (int64){

  var p int64 = 1
  for ; n > 0 ;{
    n /= 10
    p *= 10
  }
  // printf("%d %s\n",p,reflect.TypeOf(p))
  return p / 10
}
func solve() {
	var n int64
	scan(&n)
  printf("%d\n",n-power(n))
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	// 读入一行数据
	// s, _ := in.ReadString('\n')
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func(t int) {
		var n int
		fmt.Fscan(in, &n)
		var res [] int
		for i := 0; i <= 9; i++{
			if res == nil{
				res = append(res, 1)
			}else{
				res = append(res, res[len(res)-1]*10)
			}
		}
		for j := 9; j >= 0; j--{
			if n >= res[j] {
				fmt.Fprintln(out, n - res[j])
				return
			}
		}
	}

	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++{
		solve(t)
	}
}
func main() {
	run(os.Stdin, os.Stdout)
}

package main

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

var (
	_r = bufio.NewReader(os.Stdin)
	_w = bufio.NewWriter(os.Stdout)
)

type Tint interface {
	int | int32 | int64
}

func min[T Tint](x, y T) T {
	if x <= y {
		return x
	}
	return y
}
func max[T Tint](x, y T) T {
	if x >= y {
		return x
	}
	return y
}
func main() {
	defer _w.Flush()
	fac10 := make([]int64, 12)
	fac10[0] = 1
	for i := 1; i < 11; i++ {
		fac10[i] = fac10[i-1] * 10
	}
	var _t int
	// n = 1
	fmt.Fscan(_r, &_t)
	for ; _t > 0; _t-- {
		var m int
		fmt.Fscan(_r, &m)
		l, r := 0, 11
		ans := 0
		for l <= r {
			mid := (l + r) >> 1
			if fac10[mid] <= int64(m) {
				ans = mid
				l = mid + 1
			} else {
				r = mid - 1
			}
		}
		fmt.Fprintln(_w, int64(m)-fac10[ans])
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		s := scanner.Text()
		m, _ := strconv.Atoi(s)
		d := m - int(math.Pow10(len(s)-1))
		fmt.Println(d)
	}
}

package main
import(
    "fmt"
    "math"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		for j:=0;j<10;j++{
			if x < x_power_y(10,j+1) {
				fmt.Println(x-x_power_y(10,j))
				break
			}
		}
	}
}
func x_power_y(x,y int) int {
	//dependencies math
	return int(math.Pow(float64(x),float64(y)))
}

package main

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

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

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

func main() {

	defer writer.Flush()
	var tc int
	var n int
	var ans int
	val := []int{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}
	lel := len(val)
	scanws(&tc)
	for t := 1; t <= tc; t++ {
		scanws(&n)
		for i := lel - 1; i >= 0; i-- {
			if n >= val[i] {
				ans = n - val[i]
				break
			}
		}
		printf("%d\n", ans)
	}

}

package main

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

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

	pow10 := []int{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}

	numCases := 0
	fmt.Fscan(in, &numCases)

	for ; numCases > 0; numCases-- {
		num := 0
		fmt.Fscan(in, &num)
		for i := len(pow10) - 1; i >= 0; i-- {
			if num >= pow10[i] {
				res := num - pow10[i]
				fmt.Fprintf(out, "%d\n", res)
				break
			}
		}
	}
}

package main

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

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

	var T int
	var M string
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &M)
		l := len(M) - 1
		num, _ := strconv.Atoi(M)
		fmt.Fprintln(out, num-int(math.Pow10(l)))
	}
}

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

package main
import ("fmt"
        "strconv"
        )

func solve (num string) int {

    ans := 1

    for i:=1; i < len (num); i++{

        ans *= 10

    }

    to_int, _ := strconv.Atoi (num)

    return to_int - ans
}

func main() {

    var testCases int
    fmt.Scanln (&testCases)

    ans := make ([]int, testCases)

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

        var num string
        fmt.Scanln (&num)

        if len (num) == 1 {

            ans[i] =  int ([]rune (num)[0] ) - 49
        } else {

            ans[i] = solve (num)
        }
    }

    for _, v := range ans {

        fmt.Println (v)
    }

}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		m := readNum(reader)
		res := solve(m)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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(m int) int {
	M := int64(m)
	var cur int64 = 1
	for cur*10 <= M {
		cur *= 10
	}

	return int(M - cur)
}

package main

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

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		var b string
		fmt.Scan(&b)
		lens := len(b)
		ans, _ := strconv.Atoi(b)
		ans = ans - int(math.Pow10(lens-1))
		fmt.Println(ans)
		t--
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, m   int
)

func solve(m int) int {
	var k = 1
	for 10*k <= m {
		k *= 10
	}
	return m - k
}

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

package main

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

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

func main() {
	defer writer.Flush()

	var T int
	fmt.Fscan(reader, &T)

	for ; T > 0; T-- {
		var m int
		fmt.Fscan(reader, &m)
		k := 0
		var mul int64 = 1
		for ; mul < int64(m); mul *= int64(10) {
			k += 1
		}
		if mul > int64(m) {
			mul /= int64(10)
		}
		fmt.Fprintf(writer, "%v\n", int64(m)-mul)
	}
}

package main

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

func power(base, exponential int) int {
	if exponential == 0 {
		return 1
	}

	ans := base
	for i := 1; i < exponential; i++ {
		ans *= base
	}
	return ans
}

func main(){
	rounds := make([]int, 10)
	for i := 0; i <= 9; i++ {
		rounds[i] = power(10, i)
	}
	// fmt.Println(rounds)

	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for i := 0; i < t; i++ {
		var m int
		fmt.Fscan(cin, &m)
		for j := 9; j >= 0; j-- {
			if m >= rounds[j] {
				fmt.Println(m - rounds[j])
				break
			}
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1702A
Date: 12/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1702/A
Problem: CF1702A
**/
func (in *CF1702A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := in.NextString()
		v, _ := strconv.ParseInt(m, 10, 64)
		b := int64(math.Pow(float64(10), float64(len(m)-1)))
		fmt.Println(v-b)
	}
}

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

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

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n int64
	fmt.Fscan(rr, &n)
	var cur int64
	cur = 1
	for i:=0;i<=9;i++ {
		if cur > n {
			break
		}
		cur *= 10
	}
	cur /= 10
	fmt.Fprintln(ww, n-cur)

}

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scan(&t)
	var i int = 0
	for i = 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		var d int = n
		var s int = 0
		for d > 9 {
			s++
			d = d / 10
		}
		n = n - int(math.Pow10(s))

		fmt.Println(n)
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var m int
		fmt.Fscan(r, &m)
		w1 := do(m)
		fmt.Fprintln(w, w1)
	}
}

func do(m int) int {
	a := 1
	b := m
	for b >= 10 {
		a *= 10
		b /= 10
	}
	return m - a
}

package main

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

func solve(sc *bufio.Scanner, wr *bufio.Writer) {
  sc.Scan()
  n, _ := strconv.ParseInt(sc.Text(), 10, 64)
  x := int64(1)
  for x <= n {
    x *= 10
  }
  x /= 10
  wr.WriteString(strconv.FormatInt(n - x, 10))
  wr.WriteRune('\n')
}

const (
  once = false
  maxBufSize = 10000000
)

func main() {
  sc := bufio.NewScanner(bufio.NewReader(os.Stdin))
  sc.Split(bufio.ScanWords)
  sc.Buffer(make([]byte, maxBufSize), maxBufSize)

  wr := bufio.NewWriter(os.Stdout)
  defer wr.Flush()

  if once {
    solve(sc, wr)
  } else {
    sc.Scan()
    times, _ := strconv.Atoi(sc.Text())
    for times > 0 {
      solve(sc, wr)
      times--
    }
  }
}

// 1702A. Round Down the Price
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var m int
		fmt.Fscan(reader, &m)
		curr := 1
		for m/curr >= 10 {
			curr = curr * 10
		}
		fmt.Println(m - curr)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"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
		fmt.Fscan(in, &n)
		d := len(fmt.Sprintf("%d", n))
		fmt.Fprintln(out, n-int(math.Pow10(d-1)))
	}
}

package main

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

func solve(m int) int {
	t := 1

	for {
		if 10*t > m {
			return m - t
		}
		t *= 10
	}

}

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

	var test int
	fmt.Fscanln(inp, &test)

	for test > 0 {
		test--

		var m int
		fmt.Fscanln(inp, &m)

		res := solve(m)

		fmt.Fprintln(out, res)
	}

	out.Flush()
}

package main

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

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

	var n int
	fmt.Fscan(in, &n)
	base := int(math.Log10(float64(n)))
	ans := n - int(math.Pow10(base))
	fmt.Fprintln(out, ans)
}

func main() {
	var t int
	fmt.Fscan(bufio.NewReader(os.Stdin), &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

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

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

	fmt.Fprintln(out, n)
}

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

	var n int
	fmt.Fscan(in, &n)
	base := int(math.Log10(float64(n)))
	ans := n - int(math.Pow10(base))
	fmt.Fprintln(out, ans)
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

import (
	"fmt"
	"math"
)

func solve() {
	var n int
	fmt.Scanf("%d", &n)
	base := int(math.Log10(float64(n)))
	fmt.Printf("%d\n", n-int(math.Pow10(base)))
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

var st []int64

func init() {
	for i := 9; i >= 0; i-- {
		st = append(st, int64(math.Pow(10, float64(i))))
	}
}

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

	val, _ := strconv.Atoi(scanner.Text())

	for i := 0; i < val; i++ {
		scanner.Scan()
		m, _ := strconv.ParseInt(scanner.Text(), 10, 64)

		for _, k := range st {
			if d := m - k; d > 0 && d < m {
				fmt.Println(d)
				break
			}
		}
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func power(n int) (int){

  p := 1
  for ; n > 0 ;{
    n /= 10
    p *= 10
  }
  return p / 10
}
func solve() {
	var n int
	scan(&n)
  printf("%d\n",n-power(n))
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	// 读入一行数据
	// s, _ := in.ReadString('\n')
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func(t int) {
		var n int64
		fmt.Fscan(in, &n)
		var temp int64 = 1
		for i := 0; i <= 9; i++{
			if temp > n{
				fmt.Fprintln(out, n - temp/10)
				return
			}
			temp *= 10
		}
	}

	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++{
		solve(t)
	}
}
func main() {
	run(os.Stdin, os.Stdout)
}

package main

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

var (
	_r = bufio.NewReader(os.Stdin)
	_w = bufio.NewWriter(os.Stdout)
)

type Tint interface {
	int | int32 | int64
}

func min[T Tint](x, y T) T {
	if x <= y {
		return x
	}
	return y
}
func max[T Tint](x, y T) T {
	if x >= y {
		return x
	}
	return y
}
func main() {
	defer _w.Flush()
	fac10 := make([]int, 32)
	fac10[0] = 1
	for i := 1; i < 32; i++ {
		fac10[i] = fac10[i-1] * 10
	}
	var _t int
	// n = 1
	fmt.Fscan(_r, &_t)
	for ; _t > 0; _t-- {
		var m int
		fmt.Fscan(_r, &m)
		l, r := 0, 31
		ans := 0
		for l <= r {
			mid := (l + r) >> 1
			if fac10[mid] <= m {
				ans = mid
				l = mid + 1
			} else {
				r = mid - 1
			}
		}
		fmt.Fprintln(_w, m-fac10[ans])
	}
}


One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the number of variants of group composition to evaluate.

The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.

Output one integer — the number of different variants of group composition.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF630F(_r io.Reader, _w io.Writer) {
	c := func(n, k int) int64 {
		res := int64(1)
		for i := 1; i <= k; i++ {
			res = res * int64(n-k+i) / int64(i)
		}
		return res
	}
	var n int
	Fscan(_r, &n)
	Fprintln(_w, c(n, 5)+c(n, 6)+c(n, 7))
}

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


Valera has 2·n cubes, each cube contains an integer from 10 to 99. He arbitrarily chooses n cubes and puts them in the first heap. The remaining cubes form the second heap. Valera decided to play with cubes. During the game he takes a cube from the first heap and writes down the number it has. Then he takes a cube from the second heap and write out its two digits near two digits he had written (to the right of them). In the end he obtained a single fourdigit integer — the first two digits of it is written on the cube from the first heap, and the second two digits of it is written on the second cube from the second heap.Valera knows arithmetic very well. So, he can easily count the number of distinct fourdigit numbers he can get in the game. The other question is: how to split cubes into two heaps so that this number (the number of distinct fourdigit integers Valera can get) will be as large as possible?

The first line contains integer n (1 ≤ n ≤ 100). The second line contains 2·n space-separated integers ai (10 ≤ ai ≤ 99), denoting the numbers on the cubes.

In the first line print a single number — the maximum possible number of distinct four-digit numbers Valera can obtain. In the second line print 2·n numbers bi (1 ≤ bi ≤ 2). The numbers mean: the i-th cube belongs to the bi-th heap in your division. If there are multiple optimal ways to split the cubes into the heaps, print any of them.

NoteIn the first test case Valera can put the first cube in the first heap, and second cube — in second heap. In this case he obtain number 1099. If he put the second cube in the first heap, and the first cube in the second heap, then he can obtain number 9910. In both cases the maximum number of distinct integers is equal to one.In the second test case Valera can obtain numbers 1313, 1345, 2413, 2445. Note, that if he put the first and the third cubes in the first heap, he can obtain only two numbers 1324 and 1345.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF353B(in io.Reader, out io.Writer) {
	var n, c1, c2 int
	Fscan(in, &n)
	a := make([]int, 2*n)
	pos := [101][]int{}
	for i := range a {
		Fscan(in, &a[i])
		pos[a[i]] = append(pos[a[i]], i)
	}

	for _, ps := range pos {
		if len(ps) == 1 {
			c1++
		} else if len(ps) > 1 {
			c2++
		}
	}
	Fprintln(out, (c2+c1/2)*(c2+(c1+1)/2))
	tp, tp2 := 0, c1&1
	for _, ps := range pos {
		if len(ps) == 1 {
			a[ps[0]] = tp
			tp ^= 1
		} else if len(ps) > 1 {
			a[ps[0]] = 0
			a[ps[1]] = 1
			for _, p := range ps[2:] {
				a[p] = tp2
				tp2 ^= 1
			}
		}
	}
	for _, v := range a {
		Fprint(out, v+1, " ")
	}
}

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