You are given two integers $$$A$$$ and $$$B$$$, calculate the number of pairs $$$(a, b)$$$ such that $$$1 \le a \le A$$$, $$$1 \le b \le B$$$, and the equation $$$a \cdot b + a + b = conc(a, b)$$$ is true; $$$conc(a, b)$$$ is the concatenation of $$$a$$$ and $$$b$$$ (for example, $$$conc(12, 23) = 1223$$$, $$$conc(100, 11) = 10011$$$). $$$a$$$ and $$$b$$$ should not contain leading zeroes.

The first line contains $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case contains two integers $$$A$$$ and $$$B$$$ $$$(1 \le A, B \le 10^9)$$$.

Print one integer — the number of pairs $$$(a, b)$$$ such that $$$1 \le a \le A$$$, $$$1 \le b \le B$$$, and the equation $$$a \cdot b + a + b = conc(a, b)$$$ is true.

NoteThere is only one suitable pair in the first test case: $$$a = 1$$$, $$$b = 9$$$ ($$$1 + 9 + 1 \cdot 9 = 19$$$).

package main

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

func main() {
	for t := ReadInt64(); t > 0; t-- {
		A, B := ReadInt64(), ReadInt64()
		result := A * getCount(B)
		out <- S(result)
	}

	close(out)
	outWg.Wait()
}

func getCount(ii int64) int64 {
	cd := int64(0)

	counterA := int64(9)
	for counterA <= ii {
		cd++
		counterA = counterA*int64(10) + int64(9)
	}
	return cd
}

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	// set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt64() int64 {
	intStr := ReadString()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

func S(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscanf(in, "%d\n", &t)
	for tt := 0; tt < t; tt++ {
		a, b := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		cur := int64(9)
		ans := int64(0)
		for b >= cur {
			ans += a
			cur *= 10
			cur += 9
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

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

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	t := scanInt()

	for i := 0; i < t; i++ {
		a,b := scanInt64(), scanInt()

		c := 10
		ans := int64(0)

		for (b+1)/c>0 {
			ans+=a
			c*=10
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func calc(n int64) int64 {
	var r int64
	for n > 0 {
		r++
		n /= 10
	}
	return r
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b int64
		fmt.Scan(&a, &b)
		var v, cnt, j int64 = 9, 0, 0
		for j = 0; j < calc(b) && b >= v; j++ {
			cnt++
			v = v*10 + 9
		}
		fmt.Println(a * cnt)
	}
}

package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return a
}

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

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 {
			fmt.Fprint(wr, " ")
		}
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

var (
	T   int
	a   int64
	b   int64
	c   int64
	ans int64
)

func main() {
	sc.Split(bufio.ScanWords)
	T = scanInt()
	for cas := 0; cas < T; cas++ {
		a = scanInt64()
		b = scanInt64()
		c = int64(9)
		ans = int64(0)
		for c <= b {
			ans++
			c = c*10 + 9
		}
		fmt.Println(ans * a)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	var a, b int64
	fmt.Fscanln(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscanln(reader, &a, &b)
		log10 := math.Log10(float64(b))
		rights := int64(log10)
		if b == int64(math.Pow10(int(math.Ceil(log10))))-1 {
			rights += 1
		}
		fmt.Fprintln(writer, a*rights)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
func work() {
	A := ReadInt()
	B := ReadInt()
	Ans := 0
	for ok := 1; B > 0; B /= 10 {
		if (B > 9) {
			Ans++
			if B % 10 != 9 {
				ok = 0
			}
		} else if B == 9 {
			Ans += ok
		}

	}
	fmt.Println(int64(Ans) * int64(A))
}
func main() {
	for i := ReadInt() ; i > 0; i-- {
		work()
	}
	close(out)
}
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
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

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

func main() {
	for t := ReadInt64(); t > 0; t-- {
		A, B := ReadInt64(), ReadInt64()
		r := A * get9Count(B)
		fmt.Println(r)
	}
}

func get9Count(i int64) int64 {
	count9Occurances := int64(0)
	counter := int64(9)
	for counter <= i {
		count9Occurances++
		counter = counter*int64(10) + int64(9)
	}
	return count9Occurances
}

var in *bufio.Scanner

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
}

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadInt64() int64 {
	intStr := ReadString()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var T int
	fmt.Fscanln(os.Stdin, &T)

	var A, B int64
	for i := 0; i < T; i++ {
		fmt.Fscanln(os.Stdin, &A, &B)
		k := int64(0)
		k10 := int64(1)
		for {
			k10 *= 10
			k += 1
			if k10 > B {
				break
			}
		}
		if B != k10 - 1 {
			k -= 1
		}
		fmt.Println(A * k)
	}
}

package main

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

func main() {
	for t := ReadInt64(); t > 0; t-- {
		A, B := ReadInt64(), ReadInt64()
		r := A * get9Count(B)
		out <- S(r)
	}

	close(out)
	outWg.Wait()
}

func get9Count(i int64) int64 {
	c := int64(0)

	counter := int64(9)
	for counter <= i {
		c++
		counter = counter*int64(10) + int64(9)
	}
	return c
}

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	// set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

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

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt64() int64 {
	intStr := ReadString()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

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

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func S(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

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

func eval(A int64, B int64) int64 {
//   fmt.Println(A)
//   fmt.Println(B)
   result:=int64(0)
   i:=int64(9)
   for  {
        if i > B {break}
	result+=A
        i = 10*(i+1) - 1
   }
   return result
}

func main() {
    var i int64
    var s []int64
    fmt.Scanf("%d\n", &i)
    //reader := bufio.NewReader(os.Stdin)
    for k := int64(0); k < i; k++ {
     var t1, t2 int64
     fmt.Scanf("%d %d\n", &t1, &t2)
    //  fmt.Println(t1)
    //  fmt.Println(t2)
     result:= eval(t1, t2)
     s = append(s, result)
    }
    for _, k := range s {
    	fmt.Println(k)
    }
}

package main

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

const INFINITY = math.MaxInt32/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	for t := stdin.ReadInt(); t > 0; t-- {
		a := stdin.ReadInt64()
		b := stdin.ReadInt64()

		var n int64 = 1
		var m int64 = 0
		for Pow64(10, n)-1 <= b {
			n++
			m++
		}
		stdout.Println(a * m)
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadInt64() int64 {
	n, _ := strconv.ParseInt(s.Read(), 10, 64)
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

func (s *Stdin) ReadIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt()
	}
	return a
}

func (s *Stdin) ReadStringSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = s.Read()
	}
	return a
}

func (s *Stdin) ReadFloat64Slice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadFloat64()
	}
	return a
}

func (s *Stdin) ReadInt64Slice(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt64()
	}
	return a
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func IsPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}

func CeilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

func LCS(s, t string) string {
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	x := n
	y := m
	u := make([]byte, dp[n][m])
	i := dp[n][m] - 1
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			u[i] = s[x]
			i--
		}
	}

	return string(u)
}

// [0..n) から r個選んだ組合せを生成する。
// r < 0 の場合はすべての組合せを生成する。
func Combinations(n int, r int) [][]int {
	a := [][]int{}
	for i := uint(0); i < (1 << uint(n)); i++ {
		b := []int{}
		for j := uint(0); j < uint(n); j++ {
			if i&(uint(1)<<j) != 0 {
				b = append(b, int(j))
			}
		}

		if r < 0 || len(b) == r {
			a = append(a, b)
		}
	}
	return a
}

// [0..n)の順列を生成する。
func Permutations(n int) [][]int {
	type e struct {
		bit uint
		a   []int
	}

	q := []*e{}
	for i := 0; i < n; i++ {
		q = append(q, &e{bit: 1 << uint(i), a: []int{i}})
	}

	p := [][]int{}
	for x := 0; x < len(q); x++ {
		cur := q[x]
		if cur.bit == (1<<uint(n) - 1) {
			p = append(p, cur.a)
			continue
		}

		for i := 0; i < n; i++ {
			if cur.bit&(1<<uint(i)) != 0 {
				continue
			}

			m := len(cur.a) + 1
			b := make([]int, m)
			copy(b, cur.a)
			b[m-1] = i
			q = append(q, &e{bit: cur.bit | (1 << uint(i)), a: b})
		}
	}
	return p
}

func ReverseSlice(v interface{}) {
	if reflect.TypeOf(v).Kind() == reflect.Slice {
		slice := reflect.ValueOf(v)
		for i1, n := 0, slice.Len(); i1 < n/2; i1++ {
			i2 := n - i1 - 1
			v1 := reflect.ValueOf(slice.Index(i1).Interface())
			slice.Index(i1).Set(slice.Index(i2))
			slice.Index(i2).Set(v1)
		}
	}
}

func ReverseString(s string) string {
	t := []rune(s)
	ReverseSlice(t)
	return string(t)
}

func ToStringSlice(slice interface{}) []string {
	// 本来はerrを返却すべき。 利用する側(=自分)は引数がsliceであることを知っている。
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v is not slice", slice))
	}

	src := reflect.ValueOf(slice)
	n := src.Len()
	dst := make([]string, n)
	for i := 0; i < n; i++ {
		dst[i] = fmt.Sprintf("%v", src.Index(i))
	}
	return dst
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}

func Min64(a int64, b ...int64) int64 {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max64(a int64, b ...int64) int64 {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs64(x int64) int64 {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow64(x, y int64) int64 {
	z := int64(1)
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y--
		}
	}
	return z
}

func IsPrime64(x int64) bool {
	if x < 2 {
		return false
	}

	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm64(x, y int64) int64 {
	return x * y / Gcd64(x, y)
}

func CeilDiv64(x, y int64) int64 {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscanf(in, "%d\n", &t)
	for tt := 0; tt < t; tt++ {
		a, b := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		cur := int64(9)
		ans := int64(0)
		for b > cur {
			ans += a
			cur *= 10
			cur += 9
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

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

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

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

	t := scanInt()

	for i := 0; i < t; i++ {
		a,b := scanInt(), scanInt()

		c := 10
		ans := 0

		for (b+1)/c>0 {
			ans+=a
			c*=10
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func calc(n int) int {
	r := 0
	for n > 0 {
		r++
		n /= 10
	}
	return r
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		v, cnt := 9, 0
		for i := 0; i < calc(b) && b >= v; i++ {
			cnt++
			v = v*10 + 9
		}
		fmt.Println(a * cnt)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	var a, b int64
	fmt.Fscanln(reader, &t)
	for ;t > 0; t-- {
		fmt.Fscanln(reader, &a, &b)
		rights := int64(math.Log10(float64(b)))
		fmt.Fprintln(writer, a * rights)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
func work() {
	A := ReadInt()
	B := ReadInt()
	Ans := 0
	for ; B > 0; B /= 10 {
		if B >= 9 {
			Ans++
		}
	}
	fmt.Println(int64(Ans) * int64(A))
}
func main() {
	for i := ReadInt() ; i > 0; i-- {
		work()
	}
	close(out)
}
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
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

import (
	"fmt"
	"os"
)

func main() {
	var T int
	fmt.Fscanln(os.Stdin, &T)

	var A, B int
	for i := 0; i < T; i++ {
		fmt.Fscanln(os.Stdin, &A, &B)
		k := 0
		k10 := 1
		for {
			k10 *= 10
			k += 1
			if k10 > B {
				break
			}
		}
		k -= 1
		fmt.Println(A * k)
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var T int
	fmt.Fscanln(os.Stdin, &T)

	var A, B int
	for i := 0; i < T; i++ {
		fmt.Fscanln(os.Stdin, &A, &B)
		k := 0
		k10 := 1
		for {
			k10 *= 10
			k += 1
			if k10 > B {
				break
			}
		}
		if B != k10 - 1 {
			k -= 1
		}
		fmt.Println(A * k)
	}
}

package main

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

func eval(A int, B int) int {
   result:=0
   i:=9
   for  {
        if i > B {break}
	result+=A
        i = 10*(i+1) - 1
   }
   return result
}

func main() {
    var i int
    var s []int
    fmt.Scanf("%d", &i)
    //reader := bufio.NewReader(os.Stdin)
    for k := 0; k < i; k++ {
     var t1, t2 int
     fmt.Scanf("%d %d", &t1, &t2)
     result:= eval(t1, t2)
     s = append(s, result)
    }
    for _, k := range s {
    	fmt.Println(k)
    }
}

package main

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

func eval(A int, B int) int {
//   fmt.Println(A)
//   fmt.Println(B)
   result:=0
   i:=9
   for  {
        if i > B {break}
	result+=A
        i = 10*(i+1) - 1
   }
   return result
}

func main() {
    var i int
    var s []int
    fmt.Scanf("%d\n", &i)
    //reader := bufio.NewReader(os.Stdin)
    for k := 0; k < i; k++ {
     var t1, t2 int
     fmt.Scanf("%d %d\n", &t1, &t2)
    //  fmt.Println(t1)
    //  fmt.Println(t2)
     result:= eval(t1, t2)
     s = append(s, result)
    }
    for _, k := range s {
    	fmt.Println(k)
    }
}


Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached $$$100$$$ million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?You're given a tree — a connected undirected graph consisting of $$$n$$$ vertices connected by $$$n - 1$$$ edges. The tree is rooted at vertex $$$1$$$. A vertex $$$u$$$ is called an ancestor of $$$v$$$ if it lies on the shortest path between the root and $$$v$$$. In particular, a vertex is an ancestor of itself.Each vertex $$$v$$$ is assigned its beauty $$$x_v$$$ — a non-negative integer not larger than $$$10^{12}$$$. This allows us to define the beauty of a path. Let $$$u$$$ be an ancestor of $$$v$$$. Then we define the beauty $$$f(u, v)$$$ as the greatest common divisor of the beauties of all vertices on the shortest path between $$$u$$$ and $$$v$$$. Formally, if $$$u=t_1, t_2, t_3, \dots, t_k=v$$$ are the vertices on the shortest path between $$$u$$$ and $$$v$$$, then $$$f(u, v) = \gcd(x_{t_1}, x_{t_2}, \dots, x_{t_k})$$$. Here, $$$\gcd$$$ denotes the greatest common divisor of a set of numbers. In particular, $$$f(u, u) = \gcd(x_u) = x_u$$$.Your task is to find the sum$$$$$$ \sum_{u\text{ is an ancestor of }v} f(u, v). $$$$$$As the result might be too large, please output it modulo $$$10^9 + 7$$$.Note that for each $$$y$$$, $$$\gcd(0, y) = \gcd(y, 0) = y$$$. In particular, $$$\gcd(0, 0) = 0$$$.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100\,000$$$) — the number of vertices in the tree. The following line contains $$$n$$$ integers $$$x_1, x_2, \dots, x_n$$$ ($$$0 \le x_i \le 10^{12}$$$). The value $$$x_v$$$ denotes the beauty of vertex $$$v$$$. The following $$$n - 1$$$ lines describe the edges of the tree. Each of them contains two integers $$$a, b$$$ ($$$1 \le a, b \le n$$$, $$$a \neq b$$$) — the vertices connected by a single edge.

Output the sum of the beauties on all paths $$$(u, v)$$$ such that $$$u$$$ is ancestor of $$$v$$$. This sum should be printed modulo $$$10^9 + 7$$$.

NoteThe following figure shows all $$$10$$$ possible paths for which one endpoint is an ancestor of another endpoint. The sum of beauties of all these paths is equal to $$$42$$$:

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1210C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int64 = 1e9 + 7
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var n, v, w int
	Fscan(in, &n)
	a := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	g := make([][]int, n+1)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	type pair struct{ g, c int64 }
	cnt := make([][]pair, n+1)
	var f func(v, fa int)
	f = func(v, fa int) {
		x := a[v]
		for _, p := range cnt[fa] {
			if gg := gcd(p.g, x); cnt[v] == nil || gg != cnt[v][len(cnt[v])-1].g {
				cnt[v] = append(cnt[v], pair{gg, p.c})
			} else {
				cnt[v][len(cnt[v])-1].c += p.c
			}
		}
		if cnt[v] == nil || x != cnt[v][len(cnt[v])-1].g {
			cnt[v] = append(cnt[v], pair{x, 1})
		} else {
			cnt[v][len(cnt[v])-1].c++
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
			}
		}
	}
	f(1, 0)
	ans := int64(0)
	for _, ps := range cnt {
		for _, p := range ps {
			ans = (ans + p.g*p.c) % mod
		}
	}
	Fprint(out, ans)
}

func main() {
	//debug.SetGCPercent(-1)
	CF1210C(os.Stdin, os.Stdout)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1210C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int64 = 1e9 + 7
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var n, v, w int
	Fscan(in, &n)
	a := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	g := make([][]int, n+1)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	type pair struct{ g, c int64 }
	cnt := make([][]pair, n+1)
	var f func(v, fa int)
	f = func(v, fa int) {
		x := a[v]
		for _, p := range cnt[fa] {
			if y := gcd(p.g, x); cnt[v] == nil || y != cnt[v][len(cnt[v])-1].g {
				cnt[v] = append(cnt[v], pair{y, p.c})
			} else {
				cnt[v][len(cnt[v])-1].c += p.c
			}
		}
		if cnt[v] == nil || x != cnt[v][len(cnt[v])-1].g {
			cnt[v] = append(cnt[v], pair{x, 1})
		} else {
			cnt[v][len(cnt[v])-1].c++
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
			}
		}
	}
	f(1, 0)
	ans := int64(0)
	for _, ps := range cnt {
		for _, p := range ps {
			ans = (ans + p.g*p.c) % mod
		}
	}
	Fprint(out, ans)
}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"runtime/debug"
)

// github.com/EndlessCheng/codeforces-go
func CF1210C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int64 = 1e9 + 7
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var n, v, w int
	Fscan(in, &n)
	a := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	g := make([][]int, n+1)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	type pair struct{ g, c int64 }
	cnt := make([][]pair, n+1)
	var f func(v, fa int)
	f = func(v, fa int) {
		x := a[v]
		for _, p := range cnt[fa] {
			if gg := gcd(p.g, x); cnt[v] == nil || gg != cnt[v][len(cnt[v])-1].g {
				cnt[v] = append(cnt[v], pair{gg, p.c})
			} else {
				cnt[v][len(cnt[v])-1].c += p.c
			}
		}
		if cnt[v] == nil || x != cnt[v][len(cnt[v])-1].g {
			cnt[v] = append(cnt[v], pair{x, 1})
		} else {
			cnt[v][len(cnt[v])-1].c++
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
			}
		}
	}
	f(1, 0)
	ans := int64(0)
	for _, ps := range cnt {
		for _, p := range ps {
			ans = (ans + p.g*p.c) % mod
		}
	}
	Fprint(out, ans)
}

func main() {
	debug.SetGCPercent(-1)
	CF1210C(os.Stdin, os.Stdout)
}


Slime has a sequence of positive integers $$$a_1, a_2, \ldots, a_n$$$.In one operation Orac can choose an arbitrary subsegment $$$[l \ldots r]$$$ of this sequence and replace all values $$$a_l, a_{l + 1}, \ldots, a_r$$$ to the value of median of $$$\{a_l, a_{l + 1}, \ldots, a_r\}$$$.In this problem, for the integer multiset $$$s$$$, the median of $$$s$$$ is equal to the $$$\lfloor \frac{|s|+1}{2}\rfloor$$$-th smallest number in it. For example, the median of $$$\{1,4,4,6,5\}$$$ is $$$4$$$, and the median of $$$\{1,7,5,8\}$$$ is $$$5$$$.Slime wants Orac to make $$$a_1 = a_2 = \ldots = a_n = k$$$ using these operations.Orac thinks that it is impossible, and he does not want to waste his time, so he decided to ask you if it is possible to satisfy the Slime's requirement, he may ask you these questions several times.

The first line of the input is a single integer $$$t$$$: the number of queries. The first line of each query contains two integers $$$n\ (1\le n\le 100\,000)$$$ and $$$k\ (1\le k\le 10^9)$$$, the second line contains $$$n$$$ positive integers $$$a_1,a_2,\dots,a_n\ (1\le a_i\le 10^9)$$$ The total sum of $$$n$$$ is at most $$$100\,000$$$.

The output should contain $$$t$$$ lines. The $$$i$$$-th line should be equal to 'yes' if it is possible to make all integers $$$k$$$ in some number of operations or 'no', otherwise. You can print each letter in lowercase or uppercase.

NoteIn the first query, Orac can't turn all elements into $$$3$$$.In the second query, $$$a_1=6$$$ is already satisfied.In the third query, Orac can select the complete array and turn all elements into $$$2$$$.In the fourth query, Orac can't turn all elements into $$$3$$$.In the fifth query, Orac can select $$$[1,6]$$$ at first and then select $$$[2,10]$$$.

package main

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

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

	var t, n, k int
o:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &k)
		ok := false
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			if a[i] == k {
				ok = true
			}
		}
		if !ok {
			Fprintln(out, "no")
			continue
		}
		if n == 1 {
			Fprintln(out, "yes")
			continue
		}
		for i := 0; i < n-1; i++ {
			if a[i] >= k && (a[i+1] >= k || i < n-2 && a[i+2] >= k) {
				Fprintln(out, "yes")
				continue o
			}
		}
		Fprintln(out, "no")
	}
}

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

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(r, &n, &k)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}

		nk := 0
		ok := false
		for i := 0; i < n; i++ {
			if a[i] == k {
				nk++
			}
			if i > 0 && a[i] >= k && a[i-1] >= k {
				ok = true
			} else if i > 1 && a[i] >= k && a[i-2] >= k {
				ok = true
			}
		}
		if nk <= 0 {
			ok = false
		}
		if n == 1 && a[0] == k {
			ok = true
		}

		if ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(r, &n, &k)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}

		var l, h int
		var found bool
		var ok bool
		for i := 0; i < n; i++ {
			if a[i] < k {
				l++
			} else {
				h++
			}
			if a[i] == k {
				found = true
			}
			if found && h > l && h >= 2 {
				ok = true
				break
			}
			if h < l {
				l, h = 0, 0
				found = false
			}
		}
		if n == 1 && a[0] == k {
			ok = true
		}
		if ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(r, &n, &k)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])

		}

		var ok, found bool
		var d int
		for i := 0; i < n; i++ {
			if a[i] == k {
				found = true
			}
			if a[i] >= k {
				d++
			} else {
				d--
			}
			if i != 0 && d > 0 && found {
				ok = true
				break
			}
			if a[i] == k {
				d = 1
			}
		}

		if n == 1 && a[0] == k {
			ok = true
		}
		if ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}


Asya loves animals very much. Recently, she purchased $$$n$$$ kittens, enumerated them from $$$1$$$ and $$$n$$$ and then put them into the cage. The cage consists of one row of $$$n$$$ cells, enumerated with integers from $$$1$$$ to $$$n$$$ from left to right. Adjacent cells had a partially transparent partition wall between them, hence there were $$$n - 1$$$ partitions originally. Initially, each cell contained exactly one kitten with some number.Observing the kittens, Asya noticed, that they are very friendly and often a pair of kittens in neighboring cells wants to play together. So Asya started to remove partitions between neighboring cells. In particular, on the day $$$i$$$, Asya:  Noticed, that the kittens $$$x_i$$$ and $$$y_i$$$, located in neighboring cells want to play together.  Removed the partition between these two cells, efficiently creating a single cell, having all kittens from two original cells. Since Asya has never putted partitions back, after $$$n - 1$$$ days the cage contained a single cell, having all kittens.For every day, Asya remembers numbers of kittens $$$x_i$$$ and $$$y_i$$$, who wanted to play together, however she doesn't remember how she placed kittens in the cage in the beginning. Please help her and find any possible initial arrangement of the kittens into $$$n$$$ cells.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 150\,000$$$) — the number of kittens. Each of the following $$$n - 1$$$ lines contains integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \ne y_i$$$) — indices of kittens, which got together due to the border removal on the corresponding day. It's guaranteed, that the kittens $$$x_i$$$ and $$$y_i$$$ were in the different cells before this day.

For every cell from $$$1$$$ to $$$n$$$ print a single integer — the index of the kitten from $$$1$$$ to $$$n$$$, who was originally in it. All printed integers must be distinct. It's guaranteed, that there is at least one answer possible. In case there are multiple possible answers, print any of them.

NoteThe answer for the example contains one of several possible initial arrangements of the kittens.The picture below shows how the cells were united for this initial arrangement. Note, that the kittens who wanted to play together on each day were indeed in adjacent cells.

package main

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

var (
	cj []int
)

type LinkNode struct {
	id   int
	next *LinkNode
}

var head []*LinkNode
var tail []*LinkNode

func findF(pre int) int {
	if pre == cj[pre] {
		return pre
	}
	cj[pre] = findF(cj[pre])
	return cj[pre]
}
func merge(x, y int) {
	fx := findF(x)
	fy := findF(y)
	if fx == fy {
		return
	}
	cj[fx] = fy
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d\n", &n)
	head = make([]*LinkNode, n+1)
	tail = make([]*LinkNode, n+1)
	cj = make([]int, n+1)
	for i := 0; i < n; i++ {
		head[i+1] = nil
		node := &LinkNode{
			id:   i + 1,
			next: head[i+1],
		}
		head[i+1] = node
		tail[i+1] = node
		cj[i+1] = i + 1
	}
	var x, y int
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(buf, "%d %d\n", &x, &y)
		fx := findF(x)
		fy := findF(y)
		tail[fx].next = head[fy]
		tail[fx] = tail[fy]
		head[fy] = head[fx]
		merge(x,y)
	}
	root := head[findF(1)]
	first := true
	for root != nil {
		if first ==false{
			fmt.Printf(" ")
		}
		first = false
		fmt.Printf("%d", root.id)
		root = root.next
	}
	fmt.Printf("\n")
}

/**
4
1 2
3 4
3 2
 */

package main

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

const N = 150007

type Node struct {
	count int
	vertex int
}
var child [N][]Node
var root[N] int
var res [N]int
var n int

func get_root(r int) int {
	if root[r] < 0 {
		return r
	} else {
		root[r] = get_root(root[r])
		return root[r]
	}
}

func size(r int) int {
	return -root[get_root(r)]
}

func union(u, v int) {
	u = get_root(u)
	v = get_root(v)
	if u == v {
		return
	}
	if root[u] > root[v] {
		u, v = v, u
	}
	child[u] = append(child[u], Node{ -root[v], v })
	root[u] += root[v];
	root[v] = u
}

func build(u, index int) {
	if size(u) == 1 {
		res[index] = u
	} else {
		sz := len(child[u])
		v := child[u][sz - 1].vertex
		count := child[u][sz - 1].count
		root[v] = -count
		root[u] = -(size(u) - size(v))
		child[u] = child[u][:sz - 1]
		build(v, index + size(u))
		build(u, index)
	}
}

func main() {
	rbuf := bufio.NewReader(os.Stdin)
	fmt.Fscanln(rbuf, &n)
	for i := 0; i < n; i++ {
		root[i] = -1
	}
	for i := 0; i + 1 < n; i++ {
		var u, v int
		fmt.Fscanln(rbuf, &u, &v)
		union(u - 1, v - 1)
	}
	build(get_root(0), 0)

	write_buf := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		fmt.Fprintf(write_buf, "%d ", res[i] + 1)
	}
	write_buf.Flush()
}

package main

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

const N = 150007

type Node struct {
	count int
	vertex int
}
var child [N][]Node
var root[N] int
var res [N]int
var n int

func get_root(r int) int {
	if root[r] < 0 {
		return r
	} else {
		root[r] = get_root(root[r])
		return root[r]
	}
}

func size(r int) int {
	return -root[get_root(r)]
}

func union(u, v int) {
	u = get_root(u)
	v = get_root(v)
	if u == v {
		return
	}
	if root[u] > root[v] {
		u, v = v, u
	}
	child[u] = append(child[u], Node{ -root[v], v })
	root[u] += root[v];
	root[v] = u
}

func build(u, index int) {
	if size(u) == 1 {
		res[index] = u
	} else {
		sz := len(child[u])
		v := child[u][sz - 1].vertex
		count := child[u][sz - 1].count
		root[v] = -count
		root[u] = -(size(u) - size(v))
		child[u] = child[u][:sz - 1]
		build(v, index + size(u))
		build(u, index)
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanln(buf, &n)
	for i := 0; i < n; i++ {
		root[i] = -1
	}
	for i := 0; i + 1 < n; i++ {
		var u, v int
		fmt.Fscanln(buf, &u, &v)
		union(u - 1, v - 1)
	}
	build(get_root(0), 0)
	for i := 0; i < n; i++ {
		fmt.Print(res[i] + 1, " ")
	}
}

package main

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

type LinkNode struct {
	id int
	next *LinkNode
}

var  head []*LinkNode
var  tail []*LinkNode
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d\n", &n)
	head = make([]*LinkNode,n+1)
	tail = make([]*LinkNode,n+1)
	for i := 0;i < n;i++{
		head[i+1] = nil
		node := &LinkNode{
			id:i+1,
			next:head[i+1],
		}
		head[i+1] = node
		tail[i+1] = node
	}
	var x,y int
	for i:=0;i < n-1;i++{
		fmt.Fscanf(buf, "%d %d\n", &x,&y)
		tail[x].next = head[y]
		tail[x]=tail[y]
		head[y] = head[x]
	}
	root := head[1]
	for root != nil{
		if root != head[1]{
			fmt.Printf(" ")
		}
		fmt.Printf("%d",root.id)
		root = root.next
	}
	fmt.Printf("\n")
}


The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.R2 has m Spyke chats just to discuss all sorts of issues. In each chat, some group of employees exchanges messages daily. An employee can simultaneously talk in multiple chats. If some employee is in the k-th chat, he can write messages to this chat and receive notifications about messages from this chat. If an employee writes a message in the chat, all other participants of the chat receive a message notification.The R2 company is conducting an audit. Now the specialists study effective communication between the employees. For this purpose, they have a chat log and the description of chat structure. You, as one of audit specialists, are commissioned to write a program that will use this data to determine the total number of message notifications received by each employee.

The first line contains three space-separated integers n, m and k (2 ≤ n ≤ 2·104; 1 ≤ m ≤ 10; 1 ≤ k ≤ 2·105) — the number of the employees, the number of chats and the number of events in the log, correspondingly.  Next n lines contain matrix a of size n × m, consisting of numbers zero and one. The element of this matrix, recorded in the j-th column of the i-th line, (let's denote it as aij) equals 1, if the i-th employee is the participant of the j-th chat, otherwise the element equals 0. Assume that the employees are numbered from 1 to n and the chats are numbered from 1 to m. Next k lines contain the description of the log events. The i-th line contains two space-separated integers xi and yi (1 ≤ xi ≤ n; 1 ≤ yi ≤ m) which mean that the employee number xi sent one message to chat number yi. It is guaranteed that employee number xi is a participant of chat yi. It is guaranteed that each chat contains at least two employees.

Print in the single line n space-separated integers, where the i-th integer shows the number of message notifications the i-th employee receives.

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

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

  n, m, k := getI(), getI(), getI()
  channels := make([][]int, m+1)
  for c := 1; c <= m; c++ {
    channels[c] = []int{}
  }
  for u := 1; u <= n; u++ {
    for c := 1; c <= m; c++ {
      if getI() == 1 {
        channels[c] = append(channels[c], u)
      }
    }
  }

  userCounts := make([]int, n+1)
  channelCounts := make([]int, m+1)
  for i := 0; i < k; i++ {
    u, c := getI(), getI()
    userCounts[u]--
    channelCounts[c]++
  }
  for c := 1; c <= m; c++ {
    delta := channelCounts[c]
    for _, u := range channels[c] {
      userCounts[u] += delta
    }
  }
  writer.WriteString(fmt.Sprintf("%d", userCounts[1]))
  for u := 2; u <= n; u++ {
    writer.WriteString(fmt.Sprintf(" %d", userCounts[u]))
  }
  writer.WriteString("\n")
}


Let's define a balanced multiset the following way. Write down the sum of all elements of the multiset in its decimal representation. For each position of that number check if the multiset includes at least one element such that the digit of the element and the digit of the sum at that position are the same. If that holds for every position, then the multiset is balanced. Otherwise it's unbalanced.For example, multiset $$$\{20, 300, 10001\}$$$ is balanced and multiset $$$\{20, 310, 10001\}$$$ is unbalanced:   The red digits mark the elements and the positions for which these elements have the same digit as the sum. The sum of the first multiset is $$$10321$$$, every position has the digit required. The sum of the second multiset is $$$10331$$$ and the second-to-last digit doesn't appear in any number, thus making the multiset unbalanced.You are given an array $$$a_1, a_2, \dots, a_n$$$, consisting of $$$n$$$ integers.You are asked to perform some queries on it. The queries can be of two types:  $$$1~i~x$$$ — replace $$$a_i$$$ with the value $$$x$$$;  $$$2~l~r$$$ — find the unbalanced subset of the multiset of the numbers $$$a_l, a_{l + 1}, \dots, a_r$$$ with the minimum sum, or report that no unbalanced subset exists. Note that the empty multiset is balanced.For each query of the second type print the lowest sum of the unbalanced subset. Print -1 if no unbalanced subset exists.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of queries, respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i < 10^9$$$). Each of the following $$$m$$$ lines contains a query of one of two types:   $$$1~i~x$$$ ($$$1 \le i \le n$$$, $$$1 \le x < 10^9$$$) — replace $$$a_i$$$ with the value $$$x$$$;  $$$2~l~r$$$ ($$$1 \le l \le r \le n$$$) — find the unbalanced subset of the multiset of the numbers $$$a_l, a_{l + 1}, \dots, a_r$$$ with the lowest sum, or report that no unbalanced subset exists.  It is guaranteed that there is at least one query of the second type.

NoteAll the subsets of multiset $$$\{20, 300, 10001\}$$$ are balanced, thus the answer is -1.The possible unbalanced subsets in the third query are $$$\{20, 310\}$$$ and $$$\{20, 310, 10001\}$$$. The lowest sum one is $$$\{20, 310\}$$$. Note that you are asked to choose a subset, not a subsegment, thus the chosen elements might not be adjancent in the array.The fourth query includes only the empty subset and subset $$$\{20\}$$$. Both of them are balanced.The last query includes the empty subset and the subsets $$$\{20\}$$$, $$$\{20\}$$$ and $$$\{20, 20\}$$$. Only $$$\{20, 20\}$$$ is unbalanced, its sum is $$$40$$$. Note that you are asked to choose a multiset, thus it might include equal elements.

package main

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

type Node struct {
	max1 [9]int
	max2 [9]int
}

var segTree [700000]Node

func query(index, left, right, l, r int) Node {
	if r < l {
		return Node{}
	}
	if left == l && right == r {
		return segTree[index]
	}
	mid := (left + right) / 2
	if r <= mid {
		return query(index * 2 + 1, left, mid, l, r)
	} else if l > mid {
		return query(index * 2 + 2, mid + 1, right, l, r)
	} else {
		ans0 := query(index * 2 + 1, left, mid, l, mid)
		ans1 := query(index * 2 + 2, mid + 1, right, mid + 1, r)
		ans := Node{}
		for i := 0;i < 9;i ++ {
			p := []int{ans0.max1[i], ans0.max2[i], ans1.max1[i], ans1.max2[i]}
			if p[0] >= p[2] {
				ans.max1[i] = p[0]
				if p[1] >= p[2] {
					ans.max2[i] = p[1]
				} else {
					ans.max2[i] = p[2]
				}
			} else {
				ans.max1[i] = p[2]
				if p[0] >= p[3] {
					ans.max2[i] = p[0]
				} else {
					ans.max2[i] = p[3]
				}
			}
		}
//		fmt.Printf("left=%+v right=%+v ans=%+v\n", left, right, ans)
		return ans
	}
}

func updateValue(index, left, right, target, value int) {
	if left == right {
		for i, j := 1, 0;i < 1000000000;i, j = i * 10, j + 1 {
			if (value / i) % 10 != 0 {
				segTree[index].max1[j] = 1000000000 - value
			} else {
				segTree[index].max1[j] = 0
			}
			segTree[index].max2[j] = 0
		}
	} else {
		mid := (left + right) / 2
		if target <= mid {
			updateValue(index * 2 + 1, left, mid, target, value)
		} else {
			updateValue(index * 2 + 2, mid + 1, right, target, value)
		}
		for i := 0;i < 9;i ++ {
			p := [4]int{segTree[index * 2 + 1].max1[i], segTree[index * 2 + 1].max2[i], segTree[index * 2 + 2].max1[i], segTree[index * 2 + 2].max2[i]}
			if p[0] >= p[2] {
				segTree[index].max1[i] = p[0]
				if p[1] >= p[2] {
					segTree[index].max2[i] = p[1]
				} else {
					segTree[index].max2[i] = p[2]
				}
			} else {
				segTree[index].max1[i] = p[2]
				if p[0] >= p[3] {
					segTree[index].max2[i] = p[0]
				} else {
					segTree[index].max2[i] = p[3]
				}
			}
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	writer := bytes.NewBuffer(make([]byte, 0, 10000000))
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 0;i < n;i ++ {
		var a int
		if i < n - 1 {
			fmt.Fscanf(reader, "%d ", &a)
		} else {
			fmt.Fscanf(reader, "%d\n", &a)
		}
		updateValue(0, 0, n - 1, i, a)
	}
	for i := 0;i < m;i ++ {
		var q, arg1, arg2 int
		fmt.Fscanf(reader, "%d %d %d\n", &q, &arg1, &arg2)
		if q == 1 {
			arg1 --
			updateValue(0, 0, n - 1, arg1, arg2)
		} else {
			arg1 --
			arg2 --
			var minValue uint = 2000000000
			ans := query(0, 0, n - 1, arg1, arg2)
			for i := 0;i < 9;i ++ {
				if ans.max1[i] != 0 && ans.max2[i] != 0 {
					value := 2000000000 - uint(ans.max1[i]) - uint(ans.max2[i])
					if value < minValue {
						minValue = value
					}
				}
			}
			if minValue == 2000000000 {
				fmt.Fprintf(writer, "-1\n")
			} else {
				fmt.Fprintf(writer, "%d\n", minValue)
			}
		}
	}
	writer.WriteTo(os.Stdout)
}

package main

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

type Node struct {
	max uint
	pos int
}

var segTree [9][]Node

func query(tree []Node, index, left, right, l, r int) Node {
	if r < l {
		return Node{0, 0}
	}
	if left == l && right == r {
		return tree[index]
	}
	mid := (left + right) / 2
	if r <= mid {
		return query(tree, index * 2 + 1, left, mid, l, r)
	} else if l > mid {
		return query(tree, index * 2 + 2, mid + 1, right, l, r)
	} else {
		ans0 := query(tree, index * 2 + 1, left, mid, l, mid)
		ans1 := query(tree, index * 2 + 2, mid + 1, right, mid + 1, r)
		if ans0.max > ans1.max {
			return ans0
		} else {
			return ans1
		}
	}
}

func updateValue(tree []Node, index, left, right, target int, value uint) {
	if left == right {
		tree[index].max = value
		tree[index].pos = target
	} else {
		mid := (left + right) / 2
		if target <= mid {
			updateValue(tree, index * 2 + 1, left, mid, target, value)
		} else {
			updateValue(tree, index * 2 + 2, mid + 1, right, target, value)
		}
		if tree[index * 2 + 1].max >= tree[index * 2 + 2].max {
			tree[index] = tree[index * 2 + 1]
		} else {
			tree[index] = tree[index * 2 + 2]
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	writer := bytes.NewBuffer(make([]byte, 10000000))
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 0;i < 9;i ++ {
		segTree[i] = make([]Node, 1000000)
	}
	for i := 0;i < n;i ++ {
		var a uint
		if i < n - 1 {
			fmt.Fscanf(reader, "%d ", &a)
		} else {
			fmt.Fscanf(reader, "%d\n", &a)
		}
		for j, k := uint(1), 0;j < 1000000000;j, k = j * 10, k + 1 {
			if (a / j) % 10 != 0 {
				updateValue(segTree[k], 0, 0, n - 1, i, 1000000000 - a)
			}
		}
	}
	for i := 0;i < m;i ++ {
		var q, arg1, arg2 int
		fmt.Fscanf(reader, "%d %d %d\n", &q, &arg1, &arg2)
		if q == 1 {
			arg1 --
			for j, k := 1, 0;j < 1000000000;j, k = j * 10, k + 1 {
				if (arg2 / j) % 10 != 0 {
					updateValue(segTree[k], 0, 0, n - 1, arg1, 1000000000 - uint(arg2))
				}
			}
		} else {
			arg1 --
			arg2 --
			var minValue uint = 2000000000
			for i := 0;i < 9;i ++ {
				ans1 := query(segTree[i], 0, 0, n - 1, arg1, arg2)
				ansleft := query(segTree[i], 0, 0, n - 1, arg1, ans1.pos - 1)
				ansright := query(segTree[i], 0, 0, n - 1, ans1.pos + 1, arg2)
				var ans2 Node
				if ansleft.max >= ansright.max {
					ans2 = ansleft
				} else {
					ans2 = ansright
				}
				if ans1.max != 0 && ans2.max != 0 {
					ans := 2000000000 - ans1.max - ans2.max
					if ans < minValue {
						minValue = ans
					}
				}
			}
			if minValue == 2000000000 {
				fmt.Fprintf(writer, "-1\n")
			} else {
				fmt.Fprintf(writer, "%d\n", minValue)
			}
		}
	}
	writer.WriteTo(os.Stdout)
}

package main

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

type Node struct {
	max uint
	pos int
}

var segTree [9][]Node

func query(tree []Node, index, left, right, l, r int) Node {
	if r < l {
		return Node{0, 0}
	}
	if left == l && right == r {
		return tree[index]
	}
	mid := (left + right) / 2
	if r <= mid {
		return query(tree, index * 2 + 1, left, mid, l, r)
	} else if l > mid {
		return query(tree, index * 2 + 2, mid + 1, right, l, r)
	} else {
		ans0 := query(tree, index * 2 + 1, left, mid, l, mid)
		ans1 := query(tree, index * 2 + 2, mid + 1, right, mid + 1, r)
		if ans0.max > ans1.max {
			return ans0
		} else {
			return ans1
		}
	}
}

func updateValue(tree []Node, index, left, right, target int, value uint) {
	if left == right {
		tree[index].max = value
		tree[index].pos = target
	} else {
		mid := (left + right) / 2
		if target <= mid {
			updateValue(tree, index * 2 + 1, left, mid, target, value)
		} else {
			updateValue(tree, index * 2 + 2, mid + 1, right, target, value)
		}
		if tree[index * 2 + 1].max >= tree[index * 2 + 2].max {
			tree[index] = tree[index * 2 + 1]
		} else {
			tree[index] = tree[index * 2 + 2]
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	writer := bytes.NewBuffer(make([]byte, 0, 10000000))
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 0;i < 9;i ++ {
		segTree[i] = make([]Node, 1000000)
	}
	for i := 0;i < n;i ++ {
		var a uint
		if i < n - 1 {
			fmt.Fscanf(reader, "%d ", &a)
		} else {
			fmt.Fscanf(reader, "%d\n", &a)
		}
		for j, k := uint(1), 0;j < 1000000000;j, k = j * 10, k + 1 {
			if (a / j) % 10 != 0 {
				updateValue(segTree[k], 0, 0, n - 1, i, 1000000000 - a)
			}
		}
	}
	for i := 0;i < m;i ++ {
		var q, arg1, arg2 int
		fmt.Fscanf(reader, "%d %d %d\n", &q, &arg1, &arg2)
		if q == 1 {
			arg1 --
			for j, k := 1, 0;j < 1000000000;j, k = j * 10, k + 1 {
				if (arg2 / j) % 10 != 0 {
					updateValue(segTree[k], 0, 0, n - 1, arg1, 1000000000 - uint(arg2))
				}
			}
		} else {
			arg1 --
			arg2 --
			var minValue uint = 2000000000
			for i := 0;i < 9;i ++ {
				ans1 := query(segTree[i], 0, 0, n - 1, arg1, arg2)
				ansleft := query(segTree[i], 0, 0, n - 1, arg1, ans1.pos - 1)
				ansright := query(segTree[i], 0, 0, n - 1, ans1.pos + 1, arg2)
				var ans2 Node
				if ansleft.max >= ansright.max {
					ans2 = ansleft
				} else {
					ans2 = ansright
				}
				if ans1.max != 0 && ans2.max != 0 {
					ans := 2000000000 - ans1.max - ans2.max
					if ans < minValue {
						minValue = ans
					}
				}
			}
			if minValue == 2000000000 {
				fmt.Fprintf(writer, "-1\n")
			} else {
				fmt.Fprintf(writer, "%d\n", minValue)
			}
		}
	}
	writer.WriteTo(os.Stdout)
}


A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of English alphabet. Comments have tree-like structure, that means each comment except root comments (comments of the highest level) has exactly one parent comment.When Polycarp wants to save comments to his hard drive he uses the following format. Each comment he writes in the following format:   at first, the text of the comment is written;  after that the number of comments is written, for which this comment is a parent comment (i. e. the number of the replies to this comments);  after that the comments for which this comment is a parent comment are written (the writing of these comments uses the same algorithm).  All elements in this format are separated by single comma. Similarly, the comments of the first level are separated by comma.For example, if the comments look like:  then the first comment is written as "hello,2,ok,0,bye,0", the second is written as "test,0", the third comment is written as "one,1,two,2,a,0,b,0". The whole comments feed is written as: "hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0". For a given comments feed in the format specified above print the comments in a different format:   at first, print a integer d — the maximum depth of nesting comments;  after that print d lines, the i-th of them corresponds to nesting level i;  for the i-th row print comments of nesting level i in the order of their appearance in the Policarp's comments feed, separated by space.

The first line contains non-empty comments feed in the described format. It consists of uppercase and lowercase letters of English alphabet, digits and commas.  It is guaranteed that each comment is a non-empty string consisting of uppercase and lowercase English characters. Each of the number of comments is integer (consisting of at least one digit), and either equals 0 or does not contain leading zeros. The length of the whole string does not exceed 106. It is guaranteed that given structure of comments is valid.

Print comments in a format that is given in the statement. For each level of nesting, comments should be printed in the order they are given in the input.

NoteThe first example is explained in the statements.

package main

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

var pos int
var seg [][]byte
var maxDepth = 0
var result [][][]byte

func parseReply(s []byte, count int64, depth int) {
	if depth > maxDepth {
		maxDepth = depth
		result = append(result, [][]byte{})
	}
	result[depth - 1] = append(result[depth - 1], s)
	for i := int64(0);i < count;i ++ {
		l, _ := strconv.ParseInt(string(seg[pos + 1]), 10, 64)
		r := seg[pos]
		pos += 2
		parseReply(r, l, depth + 1)
	}
}

func main() {
	writer := bytes.NewBuffer(make([]byte, 0, 10000000))
	bs, _ := ioutil.ReadAll(os.Stdin)
	seg = bytes.Split(bs, []byte{','})
	result = make([][][]byte, 0)

	for pos = 0;pos < len(seg); {
		l, _ := strconv.ParseInt(string(seg[pos + 1]), 10, 64)
		c := seg[pos]
		pos += 2
		parseReply(c, l, 1)
	}
	fmt.Fprintf(writer, "%d\n", maxDepth)
	for i := 0;i < maxDepth;i ++ {
		for j := 0;j < len(result[i]);j ++ {
			writer.Write(result[i][j])
			writer.WriteByte(' ')
		}
		writer.WriteByte('\n')
	}
	writer.WriteTo(os.Stdout)
}

package main

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

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

	var s string
	Fscan(bufio.NewReader(in), &s)
	sp := strings.Split(s, ",")
	ss := [4e5][]interface{}{}
	maxD, p := 0, 0
	var f func(d int)
	f = func(d int) {
		if d > maxD {
			maxD = d
		}
		ss[d] = append(ss[d], sp[p])
		ch, _ := strconv.Atoi(sp[p+1])
		p += 2
		for ; ch > 0; ch-- {
			f(d + 1)
		}
	}
	for p < len(sp) {
		f(0)
	}
	Fprintln(out, maxD+1)
	for _, a := range ss[:maxD+1] {
		Fprintln(out, a...)
	}
}

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


Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. For example, instead of the phrase "how are you" he can type "hhoow aaaare yyoouu". Polycarp decided to automate the process of correcting such errors. He decided to write a plug-in to the text editor that will remove pairs of identical consecutive letters (if there are any in the text). Of course, this is not exactly what Polycarp needs, but he's got to start from something! Help Polycarp and write the main plug-in module. Your program should remove from a string all pairs of identical letters, which are consecutive. If after the removal there appear new pairs, the program should remove them as well. Technically, its work should be equivalent to the following: while the string contains a pair of consecutive identical letters, the pair should be deleted. Note that deleting of the consecutive identical letters can be done in any order, as any order leads to the same result.

The input data consists of a single line to be processed. The length of the line is from 1 to 2·105 characters inclusive. The string contains only lowercase Latin letters.

Print the given string after it is processed. It is guaranteed that the result will contain at least one character.

package main

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

func main() {
    //var s, end string
    var s string
    fmt.Scan(&s)
    out := bufio.NewWriter(os.Stdout)
    ps:= utf8.RuneCountInString(s)
    t := make([]rune,0,ps)
    lent := len(t)
    for i:=0;i<ps;i++{
    	lent = len(t)
    	if (lent!=0) && (t[lent-1]==rune(s[i])) {
    		t=t[:lent-1]
    	} else {
    		t=append(t,rune(s[i]))
    	}
    }
    for _,tt:=range t {
    	//end+=string(tt)
    	out.WriteRune(tt)
    }
    //out.WriteString(end)
    out.Flush()
}

package main

import (
	"fmt"
)

func main() {
	var (
		i, si, lword int32
		word         string
		stack        []byte
	)

	fmt.Scan(&word)
	lword = int32(len(word))
	stack = make([]byte, lword+1, lword+1)
	stack[0] = 'a' - 1
	si = 1

	for i = 0; i < lword; i++ {
		c := word[i]
		if c == stack[si-1] {
			si--
		} else {
			stack[si] = c
			si++
		}
	}
	word = string(stack[1:si])
	fmt.Println(word)
}

package main

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

func main() {
    writer := bufio.NewWriter(os.Stdout)
    var s string
    fmt.Scan(&s)
    ans := make([]rune,0,len(s))
    for _, v := range s {
        if (len(ans) != 0) && (ans[len(ans)-1] == v) {
            ans = ans[:len(ans)-1]
        } else {
            ans = append(ans,v)
        }
    }
    for i := 0; i < len(ans); i++ {
        writer.WriteRune(ans[i])
    }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

import (
    "fmt"
    "bufio"
    "os"
    //"strconv"
    "unicode/utf8"
    //"sort"
    "strings"

)

func stripchars(str, chr string) string {
    return strings.Map(func(r rune) rune {
        if strings.IndexRune(chr, r) < 0 {
            return r
        }
        return -1
    }, str)
}

func main() {
    out := bufio.NewWriter(os.Stdout)
    var s, end string
    fmt.Scan(&s)
    ps:= utf8.RuneCountInString(s)
    t := make([]rune,ps)
    lent := len(t)
    for i:=0;i<ps;i++{
    	lent = len(t)
    	if (lent!=0) && (t[lent-1]==rune(s[i])) {
    		t=t[:lent-1]
    	} else {
    		t=append(t,rune(s[i]))
    	}
    }
    for _,tt:=range t {
    	end+=string(tt)
    }
    end+="\n"
    end=stripchars(end," ")
    out.WriteString(end)
    out.Flush()
}

package main

import (
    "fmt"
    "bufio"
    "os"
    //"strconv"
    "unicode/utf8"
    //"sort"
    "strings"

)

func stripchars(str, chr string) string {
    return strings.Map(func(r rune) rune {
        if strings.IndexRune(chr, r) < 0 {
            return r
        }
        return -1
    }, str)
}

func main() {
    out := bufio.NewWriter(os.Stdout)
    var s, end string
    fmt.Scan(&s)
    ps:= utf8.RuneCountInString(s)
    t := make([]rune,ps)
    lent := len(t)
    for i:=0;i<ps;i++{
    	lent = len(t)
    	if (lent!=0) && (t[lent-1]==rune(s[i])) {
    		t=t[:lent-1]
    	} else {
    		t=append(t,rune(s[i]))
    	}
    }
    end=""
    for _,tt:=range t {
    	end+=string(tt)
    }
    end+="\n"
    end=stripchars(end," ")
    out.WriteString(end)
    out.Flush()
}

package main

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

func main() {
    writer := bufio.NewWriter(os.Stdout)
    var s string
    fmt.Scan(&s)
    ans := make([]rune,len(s))
    for _, v := range s {
        if len(ans) != 0 {
            if ans[len(ans)-1] == v {
                ans = ans[:len(ans)-1]
            } else {
                ans = append(ans,v)
            }
        }
    }
    for i := 0; i < len(ans); i++ {
        writer.WriteRune(ans[i])
    }
    writer.WriteRune('\n')
    writer.Flush()
}


This is an interactive problem.Anton and Harris are playing a game to decide which of them is the king of problemsetting.There are three piles of stones, initially containing $$$a$$$, $$$b$$$, and $$$c$$$ stones, where $$$a$$$, $$$b$$$, and $$$c$$$ are distinct positive integers. On each turn of the game, the following sequence of events takes place:  The first player chooses a positive integer $$$y$$$ and provides it to the second player.  The second player adds $$$y$$$ stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns. The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if $$$1000$$$ turns have passed without the second player losing.Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting!

The first line of input contains three distinct positive integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$)  — the initial number of stones in piles $$$1$$$, $$$2$$$, and $$$3$$$ respectively.

NoteIn the sample input, the piles initially have $$$5$$$, $$$2$$$, and $$$6$$$ stones. Harris decides to go first and provides the number $$$2$$$ to Anton. Anton adds $$$2$$$ stones to the third pile, which results in $$$5$$$, $$$2$$$, and $$$8$$$.In the next turn, Harris chooses $$$3$$$. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king.

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	a, b, c := readThreeNums(reader)
	solve(a, b, c, reader)
}

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(a, b, c int, reader *bufio.Reader) {
	// choose first to play
	fmt.Println("First")

	ps := make([]*Pair, 3)
	ps[0] = &Pair{int64(a), 1}
	ps[1] = &Pair{int64(b), 2}
	ps[2] = &Pair{int64(c), 3}

	sort.Sort(Pairs(ps))

	arr := make([]int, 3)
	for i := 0; i < 3; i++ {
		arr[ps[i].second-1] = i
	}

	var play func()

	play = func() {
		p, q, r := ps[0].first, ps[1].first, ps[2].first

		y := 2*r - p - q

		fmt.Printf("%d\n", y)

		x := readNum(reader)

		i := arr[x-1]
		if i == 0 {
			fmt.Printf("%d\n", r-q)
		} else if i == 1 {
			fmt.Printf("%d\n", r-p)
		} else {
			ps[2].first += y
			play()
		}
	}
	play()
}

type Pair struct {
	first  int64
	second int
}

type Pairs []*Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first < ps[j].first
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	a, b, c := readThreeNums(reader)
	solve(a, b, c, reader)
}

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(a, b, c int, reader *bufio.Reader) {
	// choose first to play
	fmt.Println("First")

	ps := make([]*Pair, 3)
	ps[0] = &Pair{a, 1}
	ps[1] = &Pair{b, 2}
	ps[2] = &Pair{c, 3}

	sort.Sort(Pairs(ps))

	arr := make([]int, 3)
	for i := 0; i < 3; i++ {
		arr[ps[i].second-1] = i
	}

	var play func()

	play = func() {
		p, q, r := ps[0].first, ps[1].first, ps[2].first

		y := 2*r - p - q

		fmt.Printf("%d\n", y)

		x := readNum(reader)

		i := arr[x-1]
		if i == 0 {
			fmt.Printf("%d\n", r-q)
		} else if i == 1 {
			fmt.Printf("%d\n", r-p)
		} else {
			ps[2].first += y
			play()
		}
	}
	play()
}

type Pair struct {
	first, second int
}

type Pairs []*Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first < ps[j].first
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}


Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. In total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from 1 to n. Let's denote the rating of i-th student as ai. After the contest ends, every student will end up with some positive integer position. GukiZ expects that his students will take places according to their ratings. He thinks that each student will take place equal to . In particular, if student A has rating strictly lower then student B, A will get the strictly better position than B, and if two students have equal ratings, they will share the same position. GukiZ would like you to reconstruct the results by following his expectations. Help him and determine the position after the end of the contest for each of his students if everything goes as expected.

The first line contains integer n (1 ≤ n ≤ 2000), number of GukiZ's students.  The second line contains n numbers a1, a2, ... an (1 ≤ ai ≤ 2000) where ai is the rating of i-th student (1 ≤ i ≤ n).

In a single line, print the position after the end of the contest for each of n students in the same order as they appear in the input.

NoteIn the first sample, students 2 and 3 are positioned first (there is no other student with higher rating), and student 1 is positioned third since there are two students with higher rating.In the second sample, first student is the only one on the contest.In the third sample, students 2 and 5 share the first position with highest rating, student 4 is next with third position, and students 1 and 3 are the last sharing fourth position.

package main
import "fmt"

func main(){
    var n int
    _, err := fmt.Scanf("%d",&n)
    if err != nil{
        return
        }
    var niza = make([]int, n+1)
    for i, _:= range niza{
        fmt.Scanf("%d", &niza[i])
        //fmt.Printf("%d %d\n", i, niza[i])
    }
    var cnt int
    for i,v1 := range niza{
        cnt = 1
        for _,v2 := range niza{
            if v1 < v2{
                cnt = cnt + 1

            }
            // fmt.Printf(" i: %d j: %d \n", v1, v2)
             //fmt.Printf("%d %d \n", cnt, j)

        }
        if i!=0{
            fmt.Printf("%d ", cnt)
            }
        cnt =0
    }
    return
}

package main

import "fmt"

type stu struct{
	rating int
	index int
	rank int
}
func main(){
	var n int
	fmt.Scan(&n)
	a := make([]int,n)
	readN(a,0,n)
	b := setup(a,n)
	sort(b,0,n-1)
	rank := 1
	lastRating := b[0].rating
	for i,v := range b{
		if v.rating != lastRating{
			rank=i+1
			lastRating = v.rating
		}
		b[i].rank = rank
	}
	for _,v:= range b{
		a[v.index]=v.rank
	}
	for _,v:= range a{
		fmt.Printf("%d ",v)
	}
}

func setup(a []int,n int)[]stu{
	out := make([]stu,n)
	for i := range out{
		out[i]=stu{
			rating: a[i],
			index: i,
		}
	}
	return out
}

func merge(a []stu,l,mid,h int){
	la := make([]stu,mid-l+1)
	ra := make([]stu,h-mid)
	copy(la,a[l:mid+1])
	copy(ra,a[mid+1:h+1])
	var i,j int
	k := l
	for ; i < len(la) && j < len(ra);k++{
		if la[i].rating > ra[j].rating{
			a[k] = la[i]
			i++
		}else{
			a[k]=ra[j]
			j++
		}
	}
	for ;i < len(la);i,k=i+1,k+1{
		a[k]=la[i]
	}
	for ;j<len(ra);j,k=j+1,k+1{
		a[k]= ra[j]
	}
}

func sort(a []stu,l,h int){
	if l>=h{
		return
	}
	mid := (l+h)/2
	sort(a,l,mid)
	sort(a,mid+1,h)
	merge(a,l,mid,h)
}

func readN(all []int,i,n int){
	if n==0{
		return
	}
	if m,err := fmt.Scan(&all[i]);m!=1{
		panic(err)
	}
	readN(all,i+1,n-1)
}

package main

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

func solve(n int, arr []int) []int {
	arr2 := make([]int, n)
	copy(arr2, arr)
	cache := make([]int, 2001)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] > arr2[j] })

	for i := range arr2 {
		if cache[arr2[i]] == 0 {
			cache[arr2[i]] = i + 1
		}
	}

	for i := range arr {
		arr[i] = cache[arr[i]]
	}

	return arr
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, arr)

	for i := range result {
		fmt.Fprintf(os.Stdout, "%d ", result[i])
	}
}

package main

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

func solve(n int, arr []int) []int {
	arr2 := make([]int, n)
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] > arr2[j] })
	cache := make([]int, arr2[0]+1)

	for i := range arr2 {
		if cache[arr2[i]] == 0 {
			cache[arr2[i]] = i + 1
		}
	}

	for i := range arr {
		arr[i] = cache[arr[i]]
	}

	return arr
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, arr)

	for i := range result {
		fmt.Fprintf(os.Stdout, "%d ", result[i])
	}
}

package main

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

func solve(n int, arr []int) []int {
	arr2 := make([]int, n)
	copy(arr2, arr)
	table := make(map[int]int)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] > arr2[j] })

	for i := range arr2 {
		if _, ok := table[arr2[i]]; !ok {
			table[arr2[i]] = i + 1
		}
	}

	for i := range arr {
		arr[i] = table[arr[i]]
	}

	return arr
}
func main() {
	r := bufio.NewReader(os.Stdin)

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	result := solve(n, arr)

	for i := range result {
		fmt.Fprintf(os.Stdout, "%d ", result[i])
	}
}

package main

import "fmt"

var rating [2001][]int
var students [2000]int

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

	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		rating[v] = append(rating[v], i)
	}

	pos := 1
	for i := 2000; i > 0; i-- {
		if len(rating[i]) == 0 {
			continue
		}

		for _, r := range rating[i] {
			students[r] = pos
		}
		pos += len(rating[i])
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d ", students[i])
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var size int
	fmt.Fscanf(r, "%d\n", &size)

	input := make([]int, size)
	rank := [2000][2]int{}
	max := -1

	for i := range input {
		var number int
		fmt.Fscanf(r, "%d ", &number)
		number--
		input[i] = number

		rank[number][0]++
		rank[number][1] = 1

		if max < number {
			max = number
		}
	}

	for i := max - 1; i >= 0; i-- {
		rank[i][1] = rank[i+1][1] + rank[i+1][0]
	}

	for i := 0; i < size-1; i++ {
		num := input[i]
		fmt.Printf("%d ", rank[num][1])
	}
	num := input[size-1]
	fmt.Printf("%d", rank[num][1])
}

package main

import "fmt"

const MAX_RATE = 2000

func main() {
	n := 0
	fmt.Scan(&n)

	arrRate := make([]int, n)
	arrRateCount := make([]int, MAX_RATE+1)
	arrRatePos := make([]int, MAX_RATE+1)

	for i := 0; i < n; i++ {
		a := 0
		fmt.Scan(&a)
		arrRate[i] = a
		arrRateCount[a]++
	}

	pos := 1
	for i := MAX_RATE; i >= 1; i-- {
		if arrRateCount[i] > 0 {
			arrRatePos[i] = pos
			pos += arrRateCount[i]
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(arrRatePos[arrRate[i]], " ")
	}
}

// cf551a
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	b := make([]int, n)
	c := make([]string, n)
	for i, _ := range a {
		fmt.Fscan(in, &a[i])
	}

	copy(b, a)

	sort.Slice(b, func(i, j int) bool { return b[j] < b[i] })
	p := 1
	pr := b[0]
	m := make(map[int]int)
	m[pr] = p
	for _, e := range b {
		if pr != e {
			m[e] = p
			pr = e
		}
		p++
	}
	for i, e := range a {
		c[i] = strconv.Itoa(m[e])
	}
	fmt.Fprint(out, strings.Join(c, " "))
}

package main

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

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

type Student struct {
	index, rating, pos int
}

type ByIndex []Student

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

type ByRating []Student

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

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

	n := nextInt()
	students := make([]Student, n)

	for i := range students {
		students[i].index = i
		students[i].rating = nextInt()
	}

	sort.Sort(sort.Reverse(ByRating(students)))

	for i := 0; i < len(students); i++ {
		if i != 0 && students[i].rating == students[i-1].rating {
			students[i].pos = students[i-1].pos
		} else {
			students[i].pos = i + 1
		}
	}

	sort.Sort(ByIndex(students))

	for i := range students {
		printf("%d ", students[i].pos)
	}
	println()
}

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 (
	"bufio"
	"os"
	"fmt"
	"sort"
	"strconv"
	"strings"
)

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

	//var n int
	//var a int
	//var b int
	var a []string

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	a = strings.Split(strings.TrimSpace(inputLine2), " ")

	//a = convertStringToInt(tmpArray)

	sortedA := make([]string, len(a))
	copy(sortedA, a)
	sort.Slice(sortedA, func(i, j int) bool {
		prev, _ := strconv.Atoi(sortedA[i])
		next, _ := strconv.Atoi(sortedA[j])
		return prev > next
	})

	length := len(a)
	cnt := map[string]int{}
	position := 1
	cnt[sortedA[0]] = 1
	positionRange := 0

	for i := 1; i < length; i++ {
		if sortedA[i] == sortedA[i - 1] {
			positionRange++
		} else {
			position += positionRange + 1
			cnt[sortedA[i]] = position
			positionRange = 0
		}
	}

	for i := 0; i < length; i++ {
		a[i] = strconv.Itoa(cnt[a[i]])
	}

	fmt.Println(strings.Join(a[:], " "))
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

import (
    "fmt"
    "sync"
)

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

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

    var wg sync.WaitGroup

    solve := func(i int) {
        defer wg.Done()
        cnt := 0
        for j := 0; j < n; j++ {
            if a[i] < a[j] {
                cnt++
            }
        }
        r[i] = cnt+1
    }

    wg.Add(n)
    for i := 0; i < n; i++ {
        go solve(i)
    }
    wg.Wait()

    for i := 0; i < n; i++ {
        if i != 0 {
            fmt.Printf(" ")
        }
        fmt.Printf("%d", r[i])
    }
    fmt.Println("")
}

package main

import "fmt"

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

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

    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if a[i] < a[j] {
                cnt++
            }
        }
        if i != 0 {
            fmt.Printf(" ")
        }
        fmt.Printf("%d", 1 + cnt)
    }
    fmt.Println("")
}

package main

import (
    "fmt"
    "sync"
)

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

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

    var wg sync.WaitGroup

    solve := func(i int) {
        defer wg.Done()
        cnt := 0
        for j := 0; j < n; j++ {
            if a[i] < a[j] {
                cnt++
            }
        }
        r[i] = cnt+1
    }

    wg.Add(n)
    for i := 0; i < n; i++ {
        solve(i)
    }
    wg.Wait()

    for i := 0; i < n; i++ {
        if i != 0 {
            fmt.Printf(" ")
        }
        fmt.Printf("%d", r[i])
    }
    fmt.Println("")
}

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

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

  n := getI()
  values := make([]int, n)
  for i := range values {
    values[i] = getI()
  }
  result := make([]int, n)
  for i, value := range values {
    count := 0
    for _, x := range values {
      if x > value {
        count++
      }
    }
    result[i] = 1+count
  }
  writer.WriteString(fmt.Sprintf("%d", result[0]))
  for i := 1; i < n; i++ {
    writer.WriteString(fmt.Sprintf(" %d", result[i]))
  }
  writer.WriteString("\n")
}

package main

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

type P struct {
    Id, R int
}

type Comparable []P

func (p Comparable) Len() int {
    return len(p)
}

func (p Comparable) Less(i, j int) bool {
    return p[i].R > p[j].R
}

func (p Comparable) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}

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

func main() {

    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := NextInt()
    p := make([]P, n)
    for i := 0; i < n; i++ {
        p[i] = P{Id:i, R:NextInt()}
    }
    sort.Sort(Comparable(p))
    var place int = 1
    ret := make([]int, n)
    for i := 0; i < n; i++ {
        var j int = i
        for j < n && p[j].R == p[i].R {
            ret[p[j].Id] = place
            j++
        }
        place += j - i
        i = j - 1
    }
    for _, v := range ret {
        fmt.Fprint(out, v, " ")
    }
    fmt.Fprintln(out)
}

func Next() string{
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func NextInt() int{
    ret, _ := strconv.Atoi(Next())
    return ret
}

package main
import "fmt"

func main(){
    var n int
    fmt.Scanf("%d",&n)
    var niza = make([]int, n)
    for i:= range niza{
        fmt.Scanf("%d", &niza[i])
    }
    for i:= range niza{
        var cnt int = 1
        for j:= range niza{
            if niza[i] < niza[j]{
                cnt++
            }
        }
        fmt.Printf("%d ", cnt)
    }
    return
}

 package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := range niza {
        cnt:=1
        for j := range niza {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        fmt.Printf("%d ", cnt)
    }

}

 package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := range niza {
        cnt:=1
        for j := range niza {
            if niza[j] > niza[i] {
                cnt++
            }
        }
    fmt.Printf("%d ", cnt)
    cnt =1

    }

}

package main

import "fmt"

func main() {
	n := 0
	fmt.Scan(&n)

	arrRate := make([]int, n)
	arrCountRate := make([]int, 2000+1)
	arrRatePos := make([]int, 2000+1)

	for i := 0; i < n; i++ {
		a := 0
		fmt.Scan(&a)
		arrRate[i] = a
		arrCountRate[a]++
	}

	pos := 1
	for i := n; i >= 1; i-- {
		if arrCountRate[i] > 0 {
			arrRatePos[i] = pos
			pos += arrCountRate[i]
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(arrRatePos[arrRate[i]], " ")
	}
}

package main

import "fmt"

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

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

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

}

package main

import "fmt"

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

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

    //fmt.Println(a)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if a[i] < a[j] {
                cnt++
            }
        }
        fmt.Printf(" %d", 1 + cnt)
    }
    fmt.Println("")
}

package main

import "fmt"

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

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

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

package main

import "fmt"

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

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

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

package main

import "fmt"

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

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

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

package main

import "fmt"

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

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

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

}

package main

import "fmt"

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

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

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

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
    res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        res[i] = cnt
    }
    for i := 0; i < n; i++ {
        fmt.Printf("%d ",res[i]+1)
    }

}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
            fmt.Printf("%d ",cnt+1)
    }

}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        return
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            return
        }
    }
    res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        res[i] = cnt
    }
    for i := 0; i < n; i++ {
        fmt.Print(res[i], " ")
    }
}

package main
import "fmt"

func main(){
    var n int
    _, err := fmt.Scanf("%d",&n)
    if err != nil{
        return
        }
    var niza = make([]int, n+1)
    for i, _:= range niza{
        fmt.Scanf("%d", &niza[i])
        fmt.Printf("%d %d\n", i, niza[i])
    }
    var cnt int
    for i,v1 := range niza{
        cnt = 1
        for _,v2 := range niza{
            if v1 < v2{
                cnt = cnt + 1

            }
            // fmt.Printf(" i: %d j: %d \n", v1, v2)
             //fmt.Printf("%d %d \n", cnt, j)

        }
        if i!=0{
            fmt.Printf("%d ", cnt)
            }
        cnt =0
    }
    return
}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
    res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        res[i] = cnt
    }
    for i := 0; i < n; i++ {
        fmt.Print(res[i]+1, " ")
    }
}

 package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := range niza {
        cnt:=1
        for j := range niza {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        if i == 1{
            fmt.Printf("1 ")
        }else {
            fmt.Printf("%d ", cnt)
        }
    }

}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        return
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            return
        }
    }
    res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        res[i] = cnt
    }
    for i := 0; i < n; i++ {
        fmt.Print(niza[i], " ")
    }
}

package main
import "fmt"

func main(){
	var n int
	fmt.Scanf("%d",&n)
	var niza = make([]int, n)
	for i:= range niza{
		fmt.Scanf("%d", &niza[i])
	}
	var cnt int
	for i:= range niza{
		cnt = 1
		for j:= range niza{
			if niza[i] < niza[j]{
				cnt++
			}
		}
		fmt.Printf("%d ", cnt)
		cnt =0
	}
	return
}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := range niza {
        var cnt = 0
        for j := range niza {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        fmt.Printf("%d ",cnt+1)
    }

}

package main
import "fmt"

func main(){
    var n int
    _, err := fmt.Scanf("%d",&n)
    if err != nil{
        return
        }
    var niza = make([]int, n)
    for i, _:= range niza{
        fmt.Scanf("%d", &niza[i])
       // fmt.Printf("%d %d\n", i, niza[i])
    }
    var cnt int
    for _,v1 := range niza{
        cnt = 1
        for _,v2 := range niza{
            if v1 < v2{
                cnt = cnt + 1

            }
            // fmt.Printf(" i: %d j: %d \n", v1, v2)
             //fmt.Printf("%d %d \n", cnt, j)

        }

        fmt.Printf("%d ", cnt)
        cnt =0
    }
    return
}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        return
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            return
        }
    }
    res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 0
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
        res[i] = cnt
    }
    for i := 0; i < n; i++ {
        fmt.Print(res[i]+1, " ")
    }
}

package main

import (
    "fmt"
)

func main() {

    var n int
    _, err := fmt.Scanf("%d", &n)
    if err != nil {
        err = nil
    }
    niza := make([]int, n)
    for i := 0; i < n; i++ {
        _, err := fmt.Scanf("%d", &niza[i])
        if err != nil {
            err = nil
        }
    }
//  res := make([]int, n)
    for i := 0; i < n; i++ {
        cnt := 1
        for j := 0; j < n; j++ {
            if niza[j] > niza[i] {
                cnt++
            }
        }
            fmt.Printf("%d ",cnt)
    }

}