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


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

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


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

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


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


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


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


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
    _, 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 (
	"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 "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"
	"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"

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

}


package main

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

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

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

	n, k := nextInt(), nextInt()
	a := make([]int, n)
	sum := 0

	for i := range a {
		a[i] = nextInt()
		sum += a[i] / 10
		a[i] %= 10
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	for i := 0; i < len(a) && k > 0; i++ {
		if a[i] == 0 {
			break
		}

		if k+a[i] >= 10 {
			sum += 1
			k -= 10 - a[i]
		}
	}

	for sum < n*10 && k >= 10 {
		sum += 1
		k -= 10
	}

	println(sum)
}

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

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

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

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

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

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"fmt"
	"sort"
)

type slice []int

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make(slice, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(a)
	for i := range a {
		if a[i] == 100 {
			continue
		}
		r := 10 - a[i]%10
		if k -= r; k > -1 {
			a[i] += r
		}
	}
	for i := range a {
		r := 100 - a[i]
		if k > r {
			a[i] += r
			k -= r
		} else if k > 0 {
			a[i] += k
			break
		}
	}
	ans := 0
	for _, v := range a {
		ans += v / 10
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"sort"
)

type slice []int

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make(slice, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(a)
	for i := range a {
		r := 10 - a[i]%10
		if k -= r; k > -1 {
			a[i] += r
		}
		if a[i] > 100 {
			r = a[i] - 100;
			a[i] = 100
			k += r
		}
	}
	for i := range a {
		r := 100 - a[i]
		if k > r {
			a[i] += r
			k -= r
		} else if k > 0 {
			a[i] += k
			break
		}
	}
	ans := 0
	for _, v := range a {
		ans += v / 10
	}
	fmt.Println(ans)
}

package main

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

func getCost(n uint8) uint8 {
	if n == 100 {
		return 0
	}
	return (n/10+1)*10 - n
}

type byCost []uint8

func (this byCost) Len() int           { return len(this) }
func (this byCost) Swap(i, j int)      { this[i], this[j] = this[j], this[i] }
func (this byCost) Less(i, j int) bool { return getCost(this[i]) < getCost(this[j]) }

func main() {
	//defer profile.Start(profile.ProfilePath(".")).Stop()
	defer flush()

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

	sort.Sort(byCost(a))
	for i := 0; i < n; i++ {
		if cost := getCost(a[i]); k >= int(cost) {
			k -= int(cost)
			a[i] += cost
		} else {
			break
		}
	}
	for i := 0; i < n; i++ {
		if l := k / 10; l > 0 {
			r := int((100 - a[i]) / 10)
			if l < r {
				k -= l * 10
				a[i] += uint8(l * 10)
			} else {
				k -= r * 10
				a[i] += uint8(r * 10)
			}
		} else {
			break
		}
	}
	sum := 0
	for _, ai := range a {
		sum += int(ai / 10)
	}
	printn(sum)
}

func init() {
	scanner.Split(bufio.ScanWords)
}

var scanner = bufio.NewScanner(os.Stdin)

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

func nextWord() string {
	return next()
}

func nextLine() string {
	defer scanner.Split(bufio.ScanWords)
	scanner.Split(bufio.ScanLines)
	return strings.TrimSpace(next())
}

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

var stdout = bufio.NewWriter(os.Stdout)

func printa(a ...interface{}) (int, error) {
	return fmt.Fprint(stdout, a...)
}

func printn(a ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, a...)
}

func printf(format string, a ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, format, a...)
}

func flush() error {
	return stdout.Flush()
}

package main

import "sort"
import "fmt"

type Slice []int

func (a Slice) Len() int {
	return len(a)
}

func (a Slice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Slice) Less(i, j int) bool {
	return a[i]%10 < a[j]%10
}

func main() {
	var n, k int

	fmt.Scan(&n, &k)
	a := make(Slice, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(a))
	ans := 0
	for i := 0; i < n; i++ {
		need := 10 - a[i]%10
		if need <= k {
			k -= need
			ans += (a[i] + need) / 10
		} else {
			ans += a[i] / 10
		}
		//fmt.Printf("%d %d\n", i, ans)
	}
	if k/10 > 0 {
		ans += k / 10
	}
	if ans >= n*10 {
		ans = n * 10
	}
	fmt.Println(ans)
}

package main

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

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

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

	n, k := nextInt(), nextInt()
	a := make([]int, n)
	sum := 0

	for i := range a {
		a[i] = nextInt()
		sum += a[i] / 10
		a[i] %= 10
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	for i := 0; i < len(a) && k > 0; i++ {
		if k+a[i] >= 10 {
			sum += 1
			k -= 10 - a[i]
		}
	}

	for sum < n*10 && k >= 10 {
		sum += 1
		k -= 10
	}

	println(sum)
}

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

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

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

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

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

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"fmt"
	"sort"
)

type slice []int

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make(slice, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(a)
	for i := range a {
		r := 10 - a[i]%10
		if k -= r; k > -1 {
			a[i] += r
		}
	}
	if k > 0 {
		a[0] += k
	}
	ans := 0
	for _, v := range a {
		ans += v / 10
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"sort"
)

type slice []int

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make(slice, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(a)
	for i := range a {
		r := 10 - a[i]%10
		if k -= r; k > -1 {
			a[i] += r
		}
	}
	for i := range a {
		r := 100 - a[i]
		if k > r {
			a[i] += r
			k -= r
		} else if k > 0 {
			a[i] += k
			break
		}
	}
	ans := 0
	for _, v := range a {
		ans += v / 10
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"sort"
)

type slice []int

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make(slice, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(a)
	for i := range a {
		r := 10 - a[i]%10
		if k -= r; k > -1 {
			a[i] += r
		}
		if a[i] > 100 {
			r = a[i] - 100;
			a[i] = 100
			k += r
		}
	}
	for i := range a {
		r := 100 - a[i]
		if k > r {
			a[i] += r
			k -= r
		} else {
			a[i] += k
		}
	}
	ans := 0
	for _, v := range a {
		ans += v / 10
	}
	fmt.Println(ans)
}

package main

import "sort"
import "fmt"

type Slice []int

func (a Slice) Len() int {
	return len(a)
}

func (a Slice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Slice) Less(i, j int) bool {
	return a[i]%10 < a[j]%10
}

func main() {
	var n, k int

	fmt.Scanf("%d %d", &n, &k)
	a := make(Slice, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	sort.Sort(sort.Reverse(a))
	ans := 0
	for i := 0; i < n; i++ {
		need := 10 - a[i]%10
		if need <= k {
			k -= need
			ans += (a[i] + need) / 10
		} else {
			ans += a[i] / 10
		}
	}
	fmt.Println(ans)
}

package main

import "sort"
import "fmt"

type Slice []int

func (a Slice) Len() int {
	return len(a)
}

func (a Slice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Slice) Less(i, j int) bool {
	return a[i]%10 < a[j]%10
}

func main() {
	var n, k int

	fmt.Scan(&n, &k)
	a := make(Slice, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(a))
	ans := 0
	for i := 0; i < n; i++ {
		need := 10 - a[i]%10
		if need <= k {
			k -= need
			ans += (a[i] + need) / 10
		} else {
			ans += a[i] / 10
		}
	}
	fmt.Println(ans)
}


package main

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

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

	var k int
	fmt.Fscan(in, &k)
	var str string
	fmt.Fscan(in, &str)
	n := 1 << k
	tree := make([]int, 2*n)
	for i := range tree {
		tree[i] = 1
	}
	s := reverse([]byte(str))
	for i := n - 2; i >= 0; i-- {
		upd(s, tree, i)
	}
	var q, p int
	var c string
	fmt.Fscan(in, &q)
	for i := 0; i < q; i++ {
		fmt.Fscan(in, &p)
		fmt.Fscan(in, &c)
		p = n - 1 - p
		s[p] = c[0]
		for i := p; i != 0; i = (i - 1) / 2 {
			upd(s, tree, i)
		}
		upd(s, tree, 0)
		fmt.Fprintln(out, tree[0])
	}

}

func upd(s []byte, tree []int, i int) {
	left, right := 0, 0
	if s[i] != '0' {
		left = tree[2*i+1]
	}
	if s[i] != '1' {
		right += tree[2*i+2]
	}
	tree[i] = left + right
}

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

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

func reverse(s []byte) []byte {
	a := []byte(s)
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
	return a
}

package main

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

var (
	N, M      int
	resultNew []byte
	fn        []int
)

func compute(i int) {
	if i >= M>>1 {
		fn[i] = 1
		if resultNew[i] == '?' {
			fn[i] = 2
		}
	} else {
		if resultNew[i] == '0' {
			fn[i] = fn[i<<1]
		} else if resultNew[i] == '1' {
			fn[i] = fn[i<<1|1]
		} else {
			fn[i] = fn[i<<1] + fn[i<<1|1]
		}
	}
}

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

	N = sc.NextInt()
	M = 1 << N

	resultOld := make([]byte, M)
	copy(resultOld[1:], []byte(sc.Next()))
	idxMap := make([]int, M)
	resultNew = make([]byte, M)
	curIdx := 1
	for i := N - 1; i >= 0; i-- {
		for j := 0; j < (1 << i); j++ {
			newIdx := (1 << i) + j
			idxMap[curIdx] = newIdx
			resultNew[newIdx] = resultOld[curIdx]
			curIdx++
		}
	}

	fn = make([]int, M)
	for i := M - 1; i >= 1; i-- {
		compute(i)
	}

	Q := sc.NextInt()
	for q := 0; q < Q; q++ {
		p := sc.NextInt()
		c := sc.Next()

		idx := idxMap[p]
		resultNew[idx] = c[0]
		for idx > 0 {
			compute(idx)
			idx >>= 1
		}
		fmt.Fprintln(wr, fn[1])
	}

}

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func InitInts1D(n int, val int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = val
	}
	return res
}
func InitInts2D(n, m int, val int) [][]int {
	res := make([][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts1D(m, val)
	}
	return res
}
func InitInts3D(n, m, k int, val int) [][][]int {
	res := make([][][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts2D(m, k, val)
	}
	return res
}

type StepState struct {
	step, dist int
}
type PriorityQueue []*StepState

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].step != pq[j].step {
		return pq[i].step < pq[j].step
	}
	return pq[i].dist < pq[j].dist
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*StepState)
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

package main

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

func main() {
	cin := bufio.NewReader(os.Stdin)
	var k int
	fmt.Fscan(cin, &k)
	var s string
	fmt.Fscan(cin, &s)
	a := make([]int, 4*len(s))
	for i := 0; i < len(a); i++ {
		a[i] = 1
	}
	runes := []rune(s)
	for j, i := 0, len(s)-1; i >= 0; i-- {
		if s[i] == '1' {
			runes[j] = '0'
		} else if s[i] == '0' {
			runes[j] = '1'
		} else {
			runes[j] = '?'
		}
		j++
	}
	for i := len(s) - 1; i >= 0; i-- {
		if runes[i] == '1' {
			a[i] = a[2*i+2]
		} else if runes[i] == '0' {
			a[i] = a[2*i+1]
		} else {
			a[i] = a[2*i+1] + a[2*i+2]
		}
	}
	var q, x int
	var c string
	fmt.Fscan(cin, &q)
	for i := 0; i < q; i++ {
		fmt.Fscan(cin, &x)
		fmt.Fscan(cin, &c)
		x = len(s) - x
		ch := c[0]
		if ch != '?' {
			ch = '1' - c[0]
		}
		runes[x] = rune(ch + '0')
		for j := x; j > 0; j = (j - 1) / 2 {
			if runes[j] == '1' {
				a[j] = a[2*j+2]
			} else if runes[j] == '0' {
				a[j] = a[2*j+1]
			} else {
				a[j] = a[2*j+1] + a[2*j+2]
			}
		}
		if runes[0] == '1' {
			a[0] = a[2]
		} else if runes[0] == '0' {
			a[0] = a[1]
		} else {
			a[0] = a[1] + a[2]
		}
		fmt.Println(a[0])
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
type pair struct {
	b byte
	i int
}
type seg []struct {
	l, r int
	val  int
	pair
	//id   int
}

var mp []int

var a [][]pair

func (t seg) build(o, l, r, d int) {
	t[o].l, t[o].r = l, r
	if l == r {
		b := a[d][0]
		a[d] = a[d][1:]
		if b.b == '?' {
			t[o].val = 2
		} else {
			t[o].val = 1
		}
		t[o].pair = b
		mp[b.i] = o
		return
	}
	m := (l + r) >> 1
	t.build(o<<1, l, m, d+1)
	t.build(o<<1|1, m+1, r, d+1)

	lo, ro := t[o<<1], t[o<<1|1]
	b := a[d][0]
	a[d] = a[d][1:]
	if b.b == '?' {
		t[o].val = lo.val + ro.val
	} else if b.b == '0' {
		t[o].val = lo.val
	} else {
		t[o].val = ro.val
	}
	t[o].pair = b
	mp[b.i] = o

}

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

	var k, q int
	var s []byte
	Fscan(in, &k, &s, &q)
	tmp := append([]byte(nil), s...)
	j := len(tmp)
	for l := 1; l <= len(tmp); l <<= 1 {
		s := tmp[len(tmp)-l:]
		tmp = tmp[:len(tmp)-l]
		b := make([]pair, len(s))
		for i := len(s) - 1; i >= 0; i-- {
			ch := s[i]
			b[i] = pair{ch, j}
			j--
		}
		a = append(a, b)
	}
	//for _, s := range a {
	//	Println(string(s))
	//}

	mp = make([]int, len(s)+10)

	t := make(seg, len(s)+1)
	t.build(1, 1, len(s)>>1+1, 0)
	for qi := 1; qi <= q; qi++ {
		var p int
		var c string
		Fscan(in, &p, &c)
		b := c[0]
		o := mp[p]
		cur := true
		for {
			if o<<1 >= len(t) || t[o<<1].l==0 {
				if cur {
					t[o].b = b
					cur =false
				}
				if b == '?' {
					t[o].val = 2
				} else {
					t[o].val = 1
				}
			} else {
				if cur {
					t[o].b = b
					cur =false
				}
				b = t[o].b
				lo, ro := t[o<<1], t[o<<1|1]
				if b == '?' {
					t[o].val = lo.val + ro.val
				} else if b == '0' {
					t[o].val = lo.val
				} else {
					t[o].val = ro.val
				}
			}

			if o == 1 {
				break
			}
			o>>=1
		}

		res := t[1].val
		Fprintln(out, res)
	}
}

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