package main

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

func scanInt(scanner *bufio.Scanner) int {
  scanner.Scan()
  x, _ := strconv.Atoi(scanner.Text())
  return x
}

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  scanner.Scan()
  code := scanner.Text()
  digits := map[string]int{}
  for i := 0; i < 10; i++ {
    scanner.Scan()
    digits[scanner.Text()] = i
  }
  for i := 0; i < 8; i++ {
    digit := digits[code[10*i:10*(i+1)]]
    writer.WriteString(fmt.Sprintf("%d", digit))
  }
  writer.WriteString("\n")
}


package main

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

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

const isDebug = false

func scan() {
	if !r.Scan() {
		panic(r.Err())
	}
}

func readInt() int {
	scan()
	x, err := strconv.Atoi(r.Text())
	if err != nil {
		panic(err)
	}
	return x
}

func readLine() string {
	scan()
	return r.Text()
}

func readInt64() int64 {
	scan()
	x, _ := strconv.ParseInt(r.Text(), 10, 64)
	return x
}

func solveProblem() {
	// #513_B
	var n = readInt64()
	var result = 0
	var tmp int64 = 0
	for tmp*10+9 < n {
		tmp = tmp*10 + 9
		result += 9
	}
	tmp = n - tmp
	for tmp > 0 {
		result += int(tmp % 10)
		tmp /= 10
	}
	w.WriteString(fmt.Sprintln(result))
}

func main() {
	if isDebug {
		fi, err := os.Open("input.txt")
		if err != nil {
			panic(err)
		}
		fo, err := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
		if err != nil {
			panic(err)
		}
		defer fi.Close()
		defer fo.Close()

		r = bufio.NewScanner(fi)
		w = bufio.NewWriter(fo)
	} else {
		r = bufio.NewScanner(os.Stdin)
		w = bufio.NewWriter(os.Stdout)
	}
	solveProblem()
	defer w.Flush()

}


// 90A
package main

import (
	"fmt"
)

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

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)
	r++
	r /= 2
	g++
	g /= 2
	b++
	b /= 2
	ans := 30 + max(3*r-3, max(3*g-2, 3*b-1))
	fmt.Print(ans)
}


package main

import "fmt"

func main() {
    var n int
    var k int
    fmt.Scanf("%d %d\n", &n, &k)
    sum := 0
    for i := 0; i < n; i++ {
    	var x int
    	fmt.Scanf("%d", &x)
    	sum += x
    }
    ret := 0
    for 2 * sum < (ret + n) * (2 * k - 1) {
    	/*
    	sum / (ret + n) >= (k - 0.5)
    	2 * sum / (ret + n) >= 2 * k - 1
    	2 * sum >= (ret + n) * (2 * k - 1)
    	*/
    	sum += k
    	ret += 1
    }
    fmt.Printf("%d\n", ret)
}


package main

import (
    "fmt"
    "bytes"
)

const ZERO int = int('0')

func process(s string) []int {
    var cnt [10]int
    for _, c := range s {
        cnt[int(c) - ZERO]++
    }
    return cnt[:]
}

func getMax(cnt []int) string {
    var buffer bytes.Buffer
    for i := 9; i >= 0; i-- {
        for j := 0; j < cnt[i]; j++ {
            buffer.WriteRune(rune(i + ZERO))
        }
    }
    return buffer.String()
}

func main() {
    var a, b string
    fmt.Scan(&a, &b)
    cnt := process(a)
    var ans string
    if len(b) > len(a) {
        ans = getMax(cnt)
    } else {
        var buffer bytes.Buffer
        valid := true
        for i, c := range b {
            numb := int(c) - ZERO

            // attempt to go lower
            for numb--; numb >= 0 && cnt[numb] == 0; numb-- {}
            if numb >= 0 {
                buffer.WriteRune(rune(numb + ZERO))
                cnt[numb]--
                buffer.WriteString(getMax(cnt))
                ans = buffer.String()
                cnt[numb]++
                buffer.Truncate(i)
            }

            // reset
            numb = int(c) - ZERO
            if cnt[numb] > 0 {
                buffer.WriteRune(c)
                cnt[numb]--
            } else {
                for ; numb >= 0 && cnt[numb] == 0; numb-- { }
                if numb >= 0 {
                    buffer.WriteRune(rune(numb + ZERO))
                    cnt[numb]--
                    buffer.WriteString(getMax(cnt))
                } else {
                    valid = false
                }
                break
            }
        }
        if valid {
            ans = buffer.String()
        }
    }
    fmt.Println(ans)
}


package main

import "os"
import "bufio"
import "strconv"

func main(){
	var n, m, t int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	r.Scan()
	t, _ = strconv.Atoi(r.Text())
	var pa1, pa2, num int64 = 0, 0, 0
	for i:=4; i<t; i++ {
		pa1 = 1
		pa2 = 1
		for j:=1; j<=i; j++ {
			pa1 *= int64(n - i + j)
			pa1 /= int64(j)
		}
		for j:=1; j<=t-i; j++ {
			pa2 *= int64(m - (t-i)+j)
			pa2 /= int64(j)
		}
		num += pa1 * pa2
	}
	w.WriteString(strconv.FormatInt(num, 10)+"\n")
	w.Flush()
}


//13A
package main
import "fmt"

func main() {
	var aa, k, l, ttl int
	fmt.Scan(&aa)
	for i:=2; i<aa; i++ {
		k=aa
		for k>0 {
			ttl=ttl+(k%i)
			k/=i
			if k<i {
				ttl=ttl+k
				break
			}
		}
	}
	l=aa-2
	for i:=l; i>1; i-- {
		if ttl%i==0 && l%i==0 {
			ttl/=i
			l/=i
			break
		}
	}
	fmt.Print(ttl,"/",l)
	fmt.Println()
}


package main
import("fmt")
func main () {
    var s, t string;
    fmt.Scanf("%s %s", &s, &t);
    if (s == t) {
        fmt.Println(s);
    } else {
        fmt.Println(1);
    }
}


package main

import "fmt"

func readTime() int {
	var hh, mm int

	fmt.Scanf("%d:%d\n", &hh, &mm)

	return hh*60 + mm
}

func printTime(time int) {
	time %= 60 * 24
	hh := time / 60
	mm := time % 60
	fmt.Printf("%02d:%02d\n", hh, mm)
}

func main() {
	time := readTime()
	var a int
	fmt.Scanf("%d", &a)
	time += a
	printTime(time)
}


package main

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

var T, n int
var number [10][]int

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

func calc(x int) int {
	res := 0
	for tmp := x; tmp > 0; tmp /= 10 {
		res++
	}
	return res
}
func main() {
	for i := 1; i <= 9; i++ {
		for x := i; x <= 9999; x = x*10 + i {
			number[i] = append(number[i], x)
		}
	}

	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		var x int
		ans := 0
		_, _ = fmt.Fscan(_r, &x)
		for _, val_slice := range number {
			for _, val := range val_slice {
				ans += calc(val)
				if val == x {
					goto out
				}
			}
		}
	out:
		_, _ = fmt.Fprintln(_w, ans)
		_ = _w.Flush()
	}

}


package main

import "fmt"

func min(a,b int) int {
	var ret int
	if(a < b ){
		ret = a
	}else {
		ret = b
	}
	return ret

}
func main(){
  var n ,m int
  fmt.Scanf("%d %d",&n,&m)
  mi := -1
  for i := 0;i <= n; i = i + 1{
  	 b := n - i
	 if 0 == b % 2 && 0 == (b / 2 + i) % m{
	 	if(-1 == mi){
			mi =  b / 2 + i
		}else {
			mi = min(mi,b/2 + i)
		}

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


package main

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

func recv(N, k int64) int64 {
	n := pow(2, N)
	c := n / 2

	if c == k {
		return N
	}
	if k > c {
		k = k - c
	}
	return recv(N - 1, k)
}
func main() {
	sc := NewScanner()
	N, k := sc.NextInt64(), sc.NextInt64()
	if N == 1 {
		fmt.Println(1)
		return
	}
	if k % 2 == 1 {
		fmt.Println(1)
		return
	}
	if (k / 2) % 2 == 1 {
		fmt.Println(2)
		return
	}
	fmt.Println(recv(N, k))

}
//aのb乗をします
func pow(a int64, b int64) int64 {
	total := int64(1)
	tmp := a
	for b > 0 {
		if b % 2 == 1 {
			total *= tmp
		}
		b /= 2
		tmp *= tmp
	}
	return total
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

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

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

func cmax(a *int, b int) {
	if b > *a {
		*a = b
	}
}
func main() {
	defer out.Flush()
	inn.Buffer([]byte{}, 10000000)
	inn.Split(bufio.ScanWords)
	type ll int64
	//prep
	n, k := rd(), rd()
	s := rds()
	ss := rds()
	a, b := ss[0], ss[1]
	dp := make([][][]int, n+1)
	for i := range dp {
		dp[i] = make([][]int, n+1)
		for j := range dp[i] {
			dp[i][j] = make([]int, n+1)
			for k := range dp[i][j] {
				dp[i][j][k] = -1000000000
			}
		}
	}
	dp[0][0][0] = 0
	for i := 0; i < n; i++ {
		for j := 0; j <= k && j <= i; j++ {
			for c := 0; c <= i; c++ {
				var e1, e2, e3 int
				if s[i] == a {
					e1 = 1
				}
				if s[i] == b {
					e2 = 1
				}
				if a == b {
					e3 = 1
				}
				cmax(&dp[i+1][j][c+e1], dp[i][j][c]+e2*c)
				if j < k {
					cmax(&dp[i+1][j+1][c+1], dp[i][j][c]+e3*c)
					cmax(&dp[i+1][j+1][c+e3], dp[i][j][c]+c)
				}
			}
		}
	}
	ans := 0
	for _, it := range dp[n][k] {
		ans = max(ans, it)
	}
	Fprintln(out, ans)
}

//-------------------template------------------
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxll(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	x, _ = strconv.Atoi(string(inn.Bytes()))
	return x
}
func rdll() (x int64) {
	inn.Scan()
	x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
	return x
}
func rdch() (x byte) {
	inn.Scan()
	return inn.Bytes()[0]
}
func rds() string {
	inn.Scan()
	return string(inn.Bytes())
}


package main

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

func check7(A int) bool {
	return A%10 == 7
}

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A, B := sc.NextInt(), sc.NextInt()

	cnt := 0
	for {
		if check7(A) || check7(B) {
			fmt.Println(cnt)
			return
		}
		B -= N
		if B < 0 {
			A--
			A += 24
			A %= 24
			B += 60
		}
		cnt++
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import "fmt"

func main() {
    var n,m,a int
    fmt.Scan(&n,&m)
    ans, bus := 1, 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if (bus+a) <= m {
            bus += a
        } else {
            ans++
            bus = a
        }
    }
    fmt.Println(ans)
}


package main

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

var a [9]int64
var helper SHelper

func main() {
	helper.Init()

	for k := uint64(1); k <= 8; k++ {
		l := (1 << k) - 1 // shift count type int64, must be unsigned integer
		r := 1 << (k - 1)
		v := l * r
		a[k] = int64(v)
	}

	n := helper.ReadInt64()
	for k := int64(8); k >= 1; k-- {
		if n >= a[k] && n % a[k] == 0 {
			fmt.Println(a[k])
			return
		}
	}
}

type SHelper struct {
	file *os.File
	scanner *bufio.Scanner
}

func (this *SHelper) Init() {
	this.file = os.Stdin
	this.scanner = bufio.NewScanner(this.file)
	this.scanner.Split(bufio.ScanWords)
}

func (this *SHelper) ReadInt64() int64 {
	this.scanner.Scan()
	n, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}


package main

import "fmt"

func main() {
    var n,k int
    fmt.Scan(&n,&k)
    if (k/n) > 2 {
        fmt.Println(0)
    } else {
        fmt.Println(n-(k%n))
    }
}


package main

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

func Solve(io *FastIO) {
	A := io.NextInt()
	B := io.NextInt()

	if A + B > 0 && Abs(A - B) <= 1 {
		io.Println("YES")
	} else {
		io.Println("NO")
	}
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}


package main

import "fmt"

func main() {
    var n, k, x, res int
    var a []int

    fmt.Scan(&n, &k, &x)

    a = make([]int, n)

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

    for i := 0; i < n - k; i++ {
        res += a[i]
    }

    fmt.Print(res + k * x)
}


package main

import "fmt"

func main() {
	var x int
	var k string
	m := make(map[string]int, 100000)
	max := 0
	sol := ""
	fmt.Scan(&x,&k)
	for i := 0; i < x-1; i++ {
		s := "" + string(k[i]) + string(k[i+1])
		if m[s] > 0  {
			m[s] += 1
		} else {
			m[s] = 1
		}
		if max < m[s] {
			max = m[s]
			sol = s
		}
	}

	fmt.Println(sol)
}


package main

import "fmt"

func main(){
	var n,a,b,x,y int
	fmt.Scan(&n,&a,&x,&b,&y)
	vis:=make([]int,n+1)
	t:=1
	for i:=a;;{
		vis[i]=t
		if i==x{
			break
		}
		i++
		if i==n+1 {
			i = 1
		}
		t++
	}

	//fmt.Println(vis)
	t=1
	for i:=b;;{
		if vis[i]==t{
			fmt.Println("YES")
			return
		}
		if(i==y){
			break
		}
		i--
		if i==0{
			i=n
		}

		t++
	}
	fmt.Println("NO")
}


package main

import (
	"fmt"
)

func solve(s, t string) string {
	// atomaton
	first := 0
	second := 0

	for ; first < len(s); first++ {
		if s[first] == t[second] {
			second++
		}
		if second == len(t) {
			break
		}
	}

	if second == len(t) && first <= len(s) {
		return "automaton"
	}

	// counts
	count_s := make([]int, 26, 26)
	count_t := make([]int, 26, 26)
	for i := 0; i < len(s); i++ {
		count_s[s[i]-'a']++
	}
	for i := 0; i < len(t); i++ {
		count_t[t[i]-'a']++
	}

	// array
	array := true
	for i := 0; i < 26; i++ {
		if count_t[i] != count_s[i] {
			array = false
			break
		}
	}
	if array {
		return "array"
	}

	// both
	both := true
	for i := 0; i < 26; i++ {
		if count_t[i] > count_s[i] {
			both = false
			break
		}
	}
	if both {
		return "both"
	}

	return "need tree"
}

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	fmt.Println(solve(s, t))
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1085B(_r io.Reader, _w io.Writer) {
	var n, k int
	Fscan(_r, &n, &k)
	ans := int(2e9)
	for i := k - 1; i > 0; i-- {
		if n%i == 0 {
			if v := n/i*k + i; v < ans {
				ans = v
			}
		}
	}
	Fprint(_w, ans)
}

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


package main

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

func solve(j Jam) {
	size := int32(j.Int())
	infinite := false
	sum := int32(0)
	prevPrevFigure := int64(0)
	prevFigure := int64(0)
	for i := int32(0); i < size; i++ {
		figure := j.Int();
		switch figure {
		case 1: //	circle
			switch prevFigure {
			case 1:
				infinite = true
			case 2:
				sum += 3
			case 3:
				sum += 4
			}
		case 2: //	triangle
			switch prevFigure {
			case 1:
				if prevPrevFigure == 3 {
					sum += 2
				} else {
					sum += 3
				}
			case 2:
				infinite = true
			case 3:
				infinite = true
			}
		case 3: //	square
			switch prevFigure {
			case 1:
				sum += 4
			case 2:
				infinite = true
			case 3:
				infinite = true
			}
		}
		if infinite {
			break
		}

		prevPrevFigure = prevFigure
		prevFigure = figure
	}
	if infinite {
		j.P("Infinite\n")
	} else {
		j.P("Finite\n")
		j.P("%d\n", sum)
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solve(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Int() int64
	Float() float64

	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Int() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

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

	_, _ = fmt.Fprintf(os.Stderr, "scanned %d", res)
	_ = os.Stderr.Sync()

	return res
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}


package main

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

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

func main() {
	var test int
	//fmt.Fscan(in, &test)
	test = 1
	for i := 0; i < test; i++ {
		solve()
	}

}
func solve() {
	var n, m int64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &m)
	var dp = make([]int64, n+1)
	dp[1] = 1
	var currentWays int64 = 1
	for i := 2; i <= int(n); i++ {
		dp[i] = currentWays
		for j := 1; j*j <= i; j++ {
			//smaller ocurrance
			var numberOfOccurance = int64(i/j - i/(j+1))
			dp[i] += (dp[j] * numberOfOccurance) % m
			dp[i] %= m
			if j != i/j && j > 1 {
				dp[i] += dp[i/j]
				dp[i] %= m
			}
		}
		currentWays += dp[i]
		currentWays %= m
	}
	fmt.Println(dp[n])
}

//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-

type pair struct {
	a int64
	b int64
}

func sortPair(pairs []pair) {
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
}
func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }


// 371B
package main

import (
	"fmt"
)

var x, y, k1, k2, ans int

func kol(d int) int {
	k1 = 0
	k2 = 0
	for x%d == 0 {
		x /= d
		k1++
	}
	for y%d == 0 {
		y /= d
		k2++
	}
	if k1 > k2 {
		return k1 - k2
	} else {
		return k2 - k1
	}
}

func main() {
	fmt.Scan(&x, &y)
	ans = kol(2) + kol(3) + kol(5)
	if x == y {
		fmt.Print(ans)
	} else {
		fmt.Print(-1)
	}
}


//http://codeforces.com/problemset/problem/146/A
//A. Lucky Ticket

package main

import (
	"fmt"
)

func main() {
	var (
		n, i, j, sum int32
		num          string
	)

	fmt.Scan(&n)
	fmt.Scan(&num)

	islucky := func(c byte) bool { return c == '4' || c == '7' }

	j = n - 1
	for i < j {
		if !islucky(num[i]) || !islucky(num[j]) {
			break
		}
		sum += int32(num[i]) - int32(num[j])
		i++
		j--
	}

	if i < j || sum != 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


package main

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

type move struct {
	x  int
	y  int
	dx int
	dy int
	w  int
}

const W = 5000 * 1000
const H = 5*30*2 + 10
const Z = H / 2

var used [H][H][3][3]bool
var wave [H][H][3][3][30]bool
var t [31]int
var n int

var q [W]move
var hd, tl int

func push(m move) {
	q[tl] = m
	if tl == W-1 {
		tl = 0
	} else {
		tl += 1
	}
}

func pop() move {
	ret := q[hd]
	if hd == W-1 {
		hd = 0
	} else {
		hd += 1
	}
	return ret
}

func empty() bool {
	return hd == tl
}

var ndx [3][3]int
var ndy [3][3]int
var ndxx [3][3]int
var ndyy [3][3]int

func do() {
	m := pop()

	tt := t[m.w]
	lx := m.x + (tt-1)*m.dx
	ly := m.y + (tt-1)*m.dy

	//fmt.Printf("%d lines from (%d, %d) with dir (%d, %d)\n", tt, m.x-Z, m.y-Z, m.dx, m.dy)

	for i := 0; i < tt; i++ {
		used[m.x+i*m.dx][m.y+i*m.dy][1+m.dx][1+m.dy] = true
	}

	if m.w+1 < n {
		ndx1 := ndx[1+m.dx][1+m.dy]
		ndy1 := ndy[1+m.dx][1+m.dy]
		x1 := lx + ndx1
		y1 := ly + ndy1
		if !wave[x1][y1][1+ndx1][1+ndy1][m.w+1] {
			wave[x1][y1][1+ndx1][1+ndy1][m.w+1] = true
			push(move{x1, y1, ndx1, ndy1, m.w + 1})
		}

		ndx2 := ndxx[1+m.dx][1+m.dy]
		ndy2 := ndyy[1+m.dx][1+m.dy]
		x2 := lx + ndx2
		y2 := ly + ndy2
		if !wave[x2][y2][1+ndx2][1+ndy2][m.w+1] {
			wave[x2][y2][1+ndx2][1+ndy2][m.w+1] = true
			push(move{x2, y2, ndx2, ndy2, m.w + 1})
		}
	}
}

func main() {

	ndy = [3][3]int{
		{0, 1, 1},
		{-1, 0, 1},
		{-1, -1, 0},
	}

	ndx = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndyy = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndxx = [3][3]int{
		{0, -1, -1},
		{1, 0, -1},
		{1, 1, 0},
	}

	in := bufio.NewReader(os.Stdin)

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

	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			for i := 0; i < 3; i++ {
				for j := 0; j < 3; j++ {
					for z := 0; z < n; z++ {
						wave[x][y][i][j][z] = false
					}
					used[x][y][i][j] = false
				}
			}
		}
	}

	wave[Z][Z][0][1][0] = true
	push(move{Z, Z, 0, 1, 0})

	for !empty() {
		do()
	}

	ret := 0
	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			fg := false
			for i := 0; i < 3; i++ {
				if fg {
					break
				}
				for j := 0; j < 3; j++ {
					if used[x][y][i][j] {
						fg = true
						break
					}
				}
			}
			if fg {
				ret += 1
			}
		}
	}
	fmt.Println(ret)
}


package main

import (
    "fmt"
    )

func main() {
    var n1, n2, k1, k2 int
    fmt.Scan(&n1, &n2, &k1, &k2)
    if n1 > n2 {
        fmt.Println("First")
    } else {
        fmt.Println("Second")
    }
}


package main

import (
	"fmt"
	"sort"
	"math"
)

func main() {
	li := make([]int, 5)
	sum := 0
	for i := 0 ; i < 5; i++ {
		fmt.Scanf("%d", &li[i])
		sum += li[i]
	}
	sort.Ints(li)
	cut := 0.0
	for i:=4; i>= 0; i-- {
		if i >= 2 && li[i] == li[i-1] && li[i-1] == li[i-2] {
			cut = math.Max(cut, float64(li[i] * 3))
		}
		if i >= 1 && li[i]  == li[i-1] {
			cut = math.Max(cut, float64(li[i] * 2.0))
		}
	}
	fmt.Printf("%d", sum-int(cut))
}


    package main

    import "fmt"

    func calculate(a,b,c int) int {
    	if a+b <= c {
    		return c-(b+a)+1
    	}
    	return 0
    }

    func main()  {
    	var a,b,c int
    	fmt.Scan(&a,&b,&c)
    	fmt.Println(calculate(a,b,c) + calculate(a,c,b) + calculate(b,c,a))
    }


package main

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

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

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

	n := nextInt()

	a := make([]int, n)

	for i := range a {
		a[i] = nextInt()
	}

	sort.Ints(a)

	for i := range a{
		print(a[i], " ")
	}
}

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

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

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

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

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


package main

import "fmt"

func calc(t, s, v int) int {
	t *= 2
	t += s * v
	return t
}

func main() {
	var s, v1, v2, t1, t2 int
	fmt.Scan(&s, &v1, &v2, &t1, &t2)

	t := calc(t1, s, v1) - calc(t2, s, v2)

	switch {
	case t == 0:
		fmt.Println("Friendship")
	case t < 0:
		fmt.Println("First")
	case t > 0:
		fmt.Println("Second")
	}
}


package main

import "fmt"

func main(){
	var r1, r2, c1, c2, d1, d2 int
	found := false
	fmt.Scan(&r1, &r2, &c1, &c2, &d1, &d2)
	for i:=1; i<=9; i++ {
		for j:=1; j<=9; j++ {
			for k:=1; k<=9; k++ {
				for l:=1; l<=9; l++ {
					if i+j==r1 && k+l==r2 && i+k==c1 && j+l==c2 && i+l==d1 && j+k==d2 && different(i, j, k, l) {
						fmt.Println(i, j)
						fmt.Println(k, l)
						found = true
					}
					if (found) {
						break
					}
				}
				if (found) {
					break
				}
			}
			if (found) {
				break
			}
		}
		if (found) {
			break
		}
	}
	if (!found) {
		fmt.Println(-1)
	}
}

func different(a, b, c, d int) bool {
	if a==b || a==c || a== d {
		return false
	}
	if b==c || b==d || c== d{
		return false
	}
	return true
}


package main

import (
        "fmt"
)

var n int
var sum [60]int
var dp [60]int
var pie [60]int

func main() {
        fmt.Scan(&n)
        for i := n; i >= 1; i-- {
                fmt.Scan(&pie[i])
        }
        for i := 1; i <= n; i++ {
                sum[i] = sum[i-1] + pie[i]
                if dp[i-1] > sum[i-1]-dp[i-1]+pie[i] {
                        dp[i] = dp[i-1]
                } else {
                        dp[i] = sum[i-1] - dp[i-1] + pie[i]
                }
        }
        fmt.Println(sum[n]-dp[n], dp[n])
}


package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

var n,m int
var k int
var turn int
const MOD int64 = 1e9 + 7
var s,t string
func solve(){
	Fscan(r,&n,&m,&k)
	if n%2==0 && m%2==0{
		if k%2==0{
			Fprint(w,"YES\n")
		}else{
			Fprint(w,"NO\n")
		}
	}else if n%2==1 && m%2==0{
		if (k-m/2)%2==0 && k>=m/2{
			Fprint(w,"YES\n")
		}else{
			Fprint(w,"NO\n")
		}
	}else if n%2==0 && m%2==1{
		if k%2==0 && k<=(m-1)*n/2{
			Fprint(w,"YES\n")
		}else{
			Fprint(w,"NO\n")
		}
	}else{
		Fprint(w,"NO\n")
	}

	return
}

func main(){
	defer w.Flush()
	// Fscan(r,&n,&m)
	// Fscan(r,&n)
	Fscan(r,&turn)
	// Fscan(r,&s)
	// Fscan(r,&k)

	for i:=0;i<turn;i++{
	    solve()
	}

	// solve()
}

/* ===========================PART 1: Math Func ============================  */
func max(x, y int64) int64 {if x > y {return x};return y}
func abs(x int64) int64 {if x > 0 {return x};return -x}
func min(x, y int64) int64 {if x < y {return x};return y}
func memset(a []int, v int) {
    if len(a) == 0 {return}
    a[0] = v
    for bp := 1; bp < len(a); bp *= 2 {
        copy(a[bp:], a[:bp])
    }
}

/* ===========================PART 2: Heap func ============================  */
// type hp struct{ sort.IntSlice }
// func (h hp) Less(i, j int) bool  { return h.IntSlice[i] > h.IntSlice[j] }
// func (h *hp) Push(v interface{}) { h.IntSlice = append(h.IntSlice, v.(int)) }
// func (h *hp) Pop() interface{}   { a := h.IntSlice; v := a[len(a)-1]; h.IntSlice = a[:len(a)-1]; return v }

// /* ===========================PART 3: String func ============================  */
// func reverse(a []byte){
// 	for i,n :=0,len(a);i<n/2;i++{
// 		a[i],a[n-1-i]=a[n-1-i],a[i]
// 	}
// }

// /* ===========================PART 4: Array func ============================  */
// func reverse(a []int){
// 	for i,n :=0,len(a);i<n/2;i++{
// 		a[i],a[n-1-i]=a[n-1-i],a[i]
// 	}
// }

// /* ===========================PART 5: Hash func ============================  */
// func containKey(m map[int]int, key int) bool {
// 	if _, ok := m[key]; ok {
// 		return true
// 	}
// 	return false
// }


package main

import "fmt"

type Site struct {
	row int
	pos int
}

var keyboards [3][]byte
var sites map[byte]*Site

func init() {
	keyboards[0] = []byte("qwertyuiop")
	keyboards[1] = []byte("asdfghjkl;")
	keyboards[2] = []byte("zxcvbnm,./")

	sites = make(map[byte]*Site)
	for i := 0; i < 3; i++ {
		for j := 0; j < len(keyboards[i]); j++ {
			sites[keyboards[i][j]] = &Site{i, j}
		}
	}
}

func main() {
	var c, word string
	fmt.Scan(&c, &word)

	for i := 0; i < len(word); i++ {
		site := sites[word[i]]
		if c == "R" {
			fmt.Printf("%c", keyboards[site.row][site.pos-1])
		} else {
			fmt.Printf("%c", keyboards[site.row][site.pos+1])
		}
	}
}


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

package main

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

const debug = true

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

	n := gsli(reader)[0] - 1
	p12 := gsli(reader)[0]
	p13 := gsli(reader)[0]
	p23 := gsli(reader)[0]
	cur := 1
	length := 0

	for n > 0 {
		switch cur {
		case 1:
			if p12 < p13 {
				length += p12
				cur = 2
			} else {
				length += p13
				cur = 3
			}
			break
		case 2:
			if p12 < p23 {
				length += p12
				cur = 1
			} else {
				length += p23
				cur = 3
			}
			break
		case 3:
			if p23 < p13 {
				length += p23
				cur = 2
			} else {
				length += p13
				cur = 3
			}
			break
		}
		n--
	}
	fmt.Println(length)
}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// String helpers

// Is Lowercase
// Given some string[i], return whether it is lower case or not.

func isl(b byte) bool {
	var r rune
	r = rune(b)
	return unicode.IsLower(r)
}

// Math helpers

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

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

// Max Int
// Returns the max of two ints

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

// Distance formule
// Calculates the distance to the origin

func dist(x, y float64) float64 {
	return math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))
}

// Output helpers

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}

// Debug helpers

// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss

func dbg(s string, a ...interface{}) {
	if debug {
		fmt.Printf(s, a...)
	}
}


package main

import (
	"fmt"
)

var mod uint64 = 1000000007

func main() {
	var a, b uint64
	fmt.Scanf("%d %d", &a, &b)
	sum1 := (b - 1) * b / 2
	sum1 = sum1 % mod
	sum2 := a * (a + 1) / 2
	sum2 = sum2 % mod
	sum2 = sum2 * b
	sum2 = sum2 % mod
	sum := sum1 * (a + sum2)
	sum = sum % mod
	fmt.Println(sum)
}


package main

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

func main() {
	var reader *bufio.Reader = bufio.NewReader(os.Stdin)
	var k, n, s, p int
	fmt.Fscanf(reader, "%d %d %d %d", &k, &n, &s, &p)

	// number of paper sheets each person needs
	sheetEach := n / s
	if n % s > 0 {
		sheetEach += 1
	}
	totalSheet := sheetEach * k

	// number of packs to buy
	packs := totalSheet / p
	if totalSheet % p > 0 {
		packs += 1
	}

	fmt.Println(packs)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n string
	fmt.Fscan(in, &n)
	l := len(n)
	i := 0
	bin := 0
	for i < l && n[i] < '2' {
		pow2 := 1 << (l - i - 1)
		bin += (int(n[i]-'0') * pow2)
		i++
	}
	offset := l - i
	rest := 1<<(offset) - 1
	ans := bin | rest
	fmt.Fprintln(out, ans)
}


package main

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

func solve() {
	n := readInt64()
	k := readInt64() - 1
	res := []int64{}
	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i < n {
				res = append(res, n/i)
			}

		}
	}
	sort.Sort(int64arr(res))
	if int(k) < len(res) {
		fmt.Println(res[k])
	} else {
		fmt.Println(-1)
	}
}

type int64arr []int64

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import (
	"fmt"
	"math"
)

var allLuckNumber[] int64

func dfs(dep int, number int64, num4, num7 int){
	if num4 == num7{
		allLuckNumber = append(allLuckNumber, number)
	}
	if dep > 10{
		return;
	}
	dfs(dep + 1, number * 10 + 4, num4 + 1, num7)
	dfs(dep + 1, number * 10 + 7, num4, num7 + 1)
}

func main(){
	var n, ans int64
	ans = math.MaxInt64
	dfs(0, 4, 1, 0)
	dfs(0, 7, 0 ,1)
	fmt.Scan(&n)
	for _,each := range allLuckNumber{
		if each >= n && each < ans{
			ans = each
		}
	}
	fmt.Println(ans)

}


// Codeforces 1076 B Divisor Subtraction train
package main

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

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

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

var n int64
var sieve []int
var primes []int64
var nPrimes int
var nsub int64

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n int64
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	s = strings.Trim(s, " \n\r")
	n, err = strconv.ParseInt(s, 10, 64)
	if err != nil {
		fmt.Println("Parse int64 failed, err,s:", err,s)
		panic(err)
	}
}

func count_primes() {
	maxPrime := 100222
	sieve = make([]int, maxPrime)
	primes = make([]int64, 19000)
	nPrimes = 0
	for i := 2; i<maxPrime; i++ {
		if sieve[i]==0 {
			primes[nPrimes] = int64(i);
			nPrimes++
			for j:=i+i; j<maxPrime; j+=i {
				sieve[j] = 1
			}
		}
	}
}

func solve() {
	if n % 2 == 0 {
		nsub = n/2
		return
	}
	count_primes()
	for i:=0; i<nPrimes; i++ {
		if (n % int64(primes[i])) == 0 {
			n -= int64(primes[i])
			nsub = 1 + (n/2)
			return
		}
	}
	// now n is prime number
	nsub = 1
}

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

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


package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextLong()
	K := io.NextLong()

	if K >= 1024 {
	  io.Println("No")
	  return
	}

	for i := int64(1); i <= K; i++ {
	  if (N + 1) % i != 0 {
	    io.Println("No")
	    return
	  }
	}
	io.Println("Yes")
}

func smallestDivisor(n int64) int64 {
  if n % 2 == 0 {
    return 2
  }
  for d := int64(3); d * d <= n; d += 2 {
    if n % d == 0 {
      return d
    }
  }
  return n
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 3)
	var d, res int
	fmt.Scan(&a[0], &a[1], &a[2], &d)
	sort.Ints(a)
	if d > a[1]-a[0] {
		res += d - (a[1] - a[0])
	}
	if d > a[2]-a[1] {
		res += d - (a[2] - a[1])
	}
	fmt.Println(res)
}


package main

import (
        "fmt"
)

var num int
var temp int

func main() {
        fmt.Scan(&num)
        max := -1
        for i := 0; i < num; i++ {
                fmt.Scan(&temp)
                if temp > max {
                        max = temp
                }
        }
        if max > 25 {
                fmt.Println(max - 25)
        } else {
                fmt.Println(0)
        }
}


package main

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

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

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

func ReadInt64() int64 {
    scanner.Scan()
    ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)
    return ans
}

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

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

func check(v, r, g, b int64) bool {
    if r+g+b < 3 {
        return false
    }

    a := make([]int, 3)
    a[0] = int(r)
    a[1] = int(g)
    a[2] = int(b)
    sort.Ints(a)
    r = int64(a[0]) // min
    g = int64(a[1])
    b = int64(a[2]) //max

    if b >= v {
        if b >= 2*v {
            return r+g >= v
        } else {
            b -= v
            return r+g+b >= v
        }
    } else {
        return false
    }
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    var min, max, mid, a int64
    r := ReadInt64()
    g := ReadInt64()
    b := ReadInt64()
    min = 0
    a = 0
    max = (r + g + b) / 3
    for min < max {
        // print(mid)
        // print(" ")
        // println(check(mid, r, g, b))
        mid = (max + min) / 2
        if check(mid, r, g, b) {
            a = mid
            min = mid + 1
        } else {
            max = mid
        }
    }

    if check(min, r, g, b) {
        writer.WriteString(strconv.FormatInt(min, 10) + "\n")
    } else {
        writer.WriteString(strconv.FormatInt(a, 10) + "\n")
    }
}


package main

import (
	"fmt"
)

type pair struct {
	location int
	dist     int
}

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

	if n >= m {
		fmt.Println(n - m)
	} else {
		visited := make([]bool, m+2)

		queue := make([]pair, 1)
		queue[0] = pair{n, 0}

		ans := 0
		visited[n] = true
		for {
			// pop front element
			tmp := queue[0]
			queue = queue[1:]
			// copy(queue[0:len(queue)-1], queue[1:])

			if tmp.location == m { // reached destination
				ans = tmp.dist
				break
			}

			// adist neighbors to the queue
			if tmp.location*2 <= m+1 && visited[tmp.location*2] == false {
				queue = append(queue, pair{tmp.location * 2, tmp.dist + 1})
				visited[tmp.location*2] = true
			}
			if tmp.location-1 >= 0 && visited[tmp.location-1] == false {
				queue = append(queue, pair{tmp.location - 1, tmp.dist + 1})
				visited[tmp.location-1] = true
			}
		}

		fmt.Println(ans)
	}
}


package main

import "fmt"

func main() {
    var n,a,ans int
    var cnt [3]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        cnt[i%3] += a
        if cnt[ans] < cnt[i%3] { ans = i%3 }
    }
    if ans == 0 {
        fmt.Println("chest")
    } else if ans == 1 {
        fmt.Println("biceps")
    } else {
        fmt.Println("back")
    }
}


package main

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

var (
	bufin  = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
)

func printf(f string, a ...interface{}) { fmt.Fprintf(bufout, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(bufin, f, a...) }

/*
f(x) = 2*x - .5
4*x - 1.5
2^(n+1) x - (2^n - 1)
*/

const M = 1000000007

func main() {
	defer bufout.Flush()
	var N, K uint64
	scanf("%d%d", &N, &K)
	if N == 0 {
		printf("0\n")
		return
	}
	N = (2*N - 1) % M
	z := getx(K)
	printf("%d\n", (int64(z)*int64(N)+1)%M)
}

func getx(N uint64) int {
	if N < 30 {
		return 1 << N
	}
	if N%2 == 0 {
		Y := getx(N >> 1)
		return int(int64(Y) * int64(Y) % M)
	}
	return getx(N-1) * 2 % M
}


package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

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

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func LITTLE(x int) int64 {
	var answer int64
	answer = answer + int64((x*x*x*x-x*x)/4) + int64(x*x*(x-1)*(x-1)/8) - int64(x*(x-1)*(x+x+1)*(x+x-1)/12)
	return answer
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(input, &n)
	if n == 1 {
		fmt.Println(1)
	}

	if n > 1 {
		var answer int64
		answer = 1
		var mm int64
		mm = 1

		for i := 2; i < n+1; i++ {
			qq := int64(NumberOfDivisors(i))
			answer = (answer*2 + qq - mm) % 998244353
			mm = qq

		}
		fmt.Println(answer)

	}
}


package main

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

type TupleInt struct {
	first  int
	second int
	third  int
}

func main() {
	in := NewScanner()
	_ = in.NextInt()
	S := in.NextLine()
	inside := false
	mx := 0
	count := 0
	comma := false
	ln := 0
	for _, s := range S {
		if s == '(' {
			inside = true
			comma = true
		} else if s == ')' {
			inside = false
			comma = true

		} else if s == '_' {
			comma = true
		} else {
			if !inside {
				ln++
				mx = max(mx, ln)
			}

			if comma {
				if inside {
					count++
				}
				comma = false
			}
		}
		if comma {
			ln = 0
		}

	}
	fmt.Println(mx, count)
}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}

func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import "fmt"

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

	if n > 31 {
		n = uint64(31)
	}

	pow := uint64(2) << (n - 1)

	fmt.Println(m % pow)
}


package main

import (
	"bufio"
	"os"
)

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

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

func printText(text string) {
	writer.WriteString(text)
}

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

	// letters := []string{"A", "B", "C"}
	str := readText()
	// printText(str)

	str_len := len(str)
	for i, _ := range str {
		if i < str_len-2 {
			l1 := str[i]
			l2 := str[i+1]
			l3 := str[i+2]

			if (l1 == 'A' && l2 == 'B' && l3 == 'C') ||
				(l1 == 'A' && l2 == 'C' && l3 == 'B') ||
				(l1 == 'B' && l2 == 'A' && l3 == 'C') ||
				(l1 == 'B' && l2 == 'C' && l3 == 'A') ||
				(l1 == 'C' && l2 == 'A' && l3 == 'B') ||
				(l1 == 'C' && l2 == 'B' && l3 == 'A') {
				printText("Yes")
				goto a1
			}
		}
	}

	printText("No")
a1:
}


package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	for i := 1; i < n; i++ {
		if s[i - 1] == s[i] && s[i] != '?' {
			fmt.Print("No")
			return
		}
	}
	if s[0] == '?' || s[n - 1] == '?' {
		fmt.Print("Yes")
		return
	}
	for i := 1; i < n; i++ {
		if s[i - 1] == '?' && s[i] == '?' {
			fmt.Print("Yes")
			return
		}
	}
	for i := 1; i < n - 1; i++ {
		if s[i] == '?' && s[i - 1] == s[i + 1] {
			fmt.Print("Yes")
			return
		}
	}
	fmt.Print("No")
	return
}


package main

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

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

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

	var dice1, dice2 int
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d %d", &dice1, &dice2)

		maxDice := dice2
		if dice1 > dice2 {
			maxDice = dice1
		}

		possibleWin := 6 - maxDice + 1

		divisor := gcd(6, possibleWin)

		top := possibleWin / divisor
		bottom := 6 / divisor

		fmt.Printf("%d/%d", top, bottom)

	}
}


package main
import (
	"fmt"
)
func main() {
	var x,y,p int
	fmt.Scan(&x,&y)
	if y>x && x>=-y {
		p=-2+y*4
	}
	if y>=x && x<(-y) {
		p=-1+4*-x
	}
	if x>y && -x+1>=y {
		p=-y*4
	}
	if x>=y && -x+1<y {
		p=-3+x*4
	}

	fmt.Println(p)
}


package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int64
	fmt.Fscan(in, &n,&x)
	const INF = 1000000000
	maxv := int64(1)
	for i := 1;i < n;i++ {
		maxv *= 10
	}
	m := make(map[int64]int)
	min := func(x,y int) int {
		if x < y {
			return x
		}
		return y
	}
	var dfs func(x int64) int
	dfs = func(x int64) int {
		if x >= maxv {return 0}
		if v,ok := m[x];ok {return v}
		m[x] = INF
		res := m[x]
		s := x
		for s != 0 {
			y := s % 10
			s /= 10
			if y >= 2 {
				res = min(res,1 + dfs(x * y))
			}
		}
		m[x] = res
		return res
	}
	res := dfs(x)
	if res == INF {
		res = -1
	}
	fmt.Println(res)
}


package main

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

const Mod = 998244353

func main() {
	defer _w.Flush()
	solve()
}
func solve() {
	n, x := ReadInt(), ReadInt()

	var pow [501][501]int64
	for i := int64(0); i < 501; i++ {
		pow[i][0] = 1
		for j := 0; j < 500; j++ {
			pow[i][j+1] = pow[i][j] * i % Mod
		}
	}

	var dp [501][501]int64
	for i := 2; i <= n; i++ {
		jj := Min(x, i-1)
		for j := 1; j <= jj; j++ {
			// dp[i][j] = j^i - (j-1)^i
			dp[i][j] = pow[j][i] - pow[j-1][i]
			dp[i][j] %= Mod
		}
	}

	for i := 2; i <= n; i++ {
		for j := 1; j <= x; j++ {
			if dp[i][j] == 0 {
				continue
			}
			for k := 0; k <= n-i; k++ {
				nj := j + i + k - 1
				if nj > x {
					break
				}
				dp[i+k][nj] += dp[i][j] * pow[i+k-1][k] % Mod * ModCombination(i+k, k)
				dp[i+k][nj] %= Mod
			}
		}
	}

	ans := int64(0)
	for j := 1; j <= x; j++ {
		ans += dp[n][j]
		ans %= Mod
	}
	println(((ans % Mod) + Mod) % Mod)
}

func ModCombination(n, k int) (ret int64) {
	if n < k {
		return 0
	}
	for ret = 1; n > 0 || k > 0; n, k = n/Mod, k/Mod {
		ret = ret * fac[n%Mod] % Mod * finv[k%Mod] % Mod * finv[(n-k)%Mod] % Mod
	}
	return
}

const MAX = 500

var fac, finv, inv [MAX + 1]int64

func init() {
	fac[int64(0)], fac[int64(1)], finv[int64(0)], finv[int64(1)], inv[int64(1)] = int64(1), int64(1), int64(1), int64(1), int64(1)
	for i := int64(2); i <= MAX; i++ {
		fac[i], inv[i] = fac[i-int64(1)]*i%Mod, Mod-inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-int64(1)] * inv[i] % Mod
	}
}

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

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

func ReadString() (s string)   { fmt.Fscan(_r, &s); return }
func ReadInt() (i int)         { fmt.Fscan(_r, &i); return }
func print(a ...interface{})   { fmt.Fprint(_w, a...) }
func println(a ...interface{}) { fmt.Fprintln(_w, a...) }
func prints(s []int64)         { v := fmt.Sprint(s); println(v[int64(1) : int64(len(v))-int64(1)]) }


package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	var n, k, d, t int

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d %d %d\n", &n, &k, &d)

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

		set := make(map[int]int)
		ans := 0
		for i := 1; i <= d; i++ {
			k, v := set[a[i]]
			if v == false {
				ans++
			}
			set[a[i]] = k + 1
		}

		temp := ans
		for i := d + 1; i <= n; i++ {
			k, _ := set[a[i-d]]
			if k > 1 {
				set[a[i-d]] = k - 1
			} else {
				delete(set, a[i-d])
				temp--
			}

			k, v := set[a[i]]
			if v == false {
				temp++
			}
			set[a[i]] = k + 1

			if temp < ans {
				ans = temp
			}
		}

		fmt.Println(ans)
	}
}


package main

import "fmt"

func main() {
	var n, k int64
	fmt.Scanf("%v %v", &n, &k)
	if ((n%(int64(2)*k)) >= k) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}


package main
import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	a := []rune(s)
	words := make(map[string]string)
	for i := 0; i < len(a); i++ {
		word := string(a[i:]) + string(a[:i])
		_, ok := words[word]
		if ok {
			// key already exists, therefore done
			break
		} else {
			// key does not exist, add key
			words[word] = word
		}
	}
	fmt.Println(len(words))
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1359E(in io.Reader, out io.Writer) {
	const mod int64 = 998244353
	const mx int = 1e6
	F := [mx + 1]int64{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * int64(i) % mod
	}
	pow := func(x, n int64) int64 {
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	invF := [...]int64{mx: pow(F[mx], mod-2)}
	for i := mx; i > 0; i-- {
		invF[i-1] = invF[i] * int64(i) % mod
	}
	C := func(n, k int) int64 { return F[n] * invF[k] % mod * invF[n-k] % mod }

	var n, k int
	Fscan(in, &n, &k)
	ans := int64(0)
	for i := 1; n/i >= k; i++ {
		ans = (ans + C(n/i-1, k-1)) % mod
	}
	Fprint(out, ans)
}

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


package main

import (
	"fmt"
	"sort"
)

func next_permutation(idx []int) bool {
	n := len(idx)
	for i := n - 1; i >= 1; i-- {
		if idx[i] > idx[i-1] {
			idx[i], idx[i-1] = idx[i-1], idx[i]
			sort.Ints(idx[i:])
			return true
		}
	}

	return false
}

func main() {
	var n, a, b int
	fmt.Scanf("%d\n%d\n%d", &n, &a, &b)
	frames := make([]int, 6)
	idxs := make([]int, 6)
	for i := 0; i < 6; i++ {
		if i < 4 {
			frames[i] = a
		} else {
			frames[i] = b
		}
		idxs[i] = i
	}

	bestAnswer := 6
	for {
		count, leftover := 0, 0
		for i := 0; i < 6; i++ {
			if leftover < frames[idxs[i]] {
				count++
				leftover = n
			}
			leftover -= frames[idxs[i]]
		}
		if count < bestAnswer {
			bestAnswer = count
		}
		if !next_permutation(idxs) {
			break
		}
	}

	fmt.Println(bestAnswer)
}


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

package main

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

const debug = false

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

	n := gsli(reader)[0]
	s := gsls(reader)[0]

	max := 0

	for i := 0; i < n; i++ {
		if isl(s[i]) {
			cur := 1
			dbg("%v is lowercase\n", s[i])
			for j := i; j < n; j++ {
				if s[i] == s[j] {
					dbg("Continuing...\n")
					continue
				} else if !isl(s[j]) {
					dbg("Uppercase...\n")
					break
				} else {
					doIncrement := true
					for k := i; k < j; k++ {
						if s[k] == s[j] {
							doIncrement = false
						}
					}
					if doIncrement {
						dbg("Incrementing...\n")
						cur++
					}
				}
			}
			max = maxInt(max, cur)
		}
	}

	fmt.Printf("%v", max)
}

func isl(b byte) bool {
	var r rune
	r = rune(b)
	return unicode.IsLower(r)
}

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

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

// Output helpers

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}

// Debug helpers

// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss

func dbg(s string, a ...interface{}) {
	if debug {
		fmt.Printf(s, a...)
	}
}


package main

import (
	"fmt"
)

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

	an := fn(x, y, n)
	if an < 0 {
		fmt.Println((1000000007 - (-an % 1000000007)) % 1000000007)
	} else {
		fmt.Println(an % 1000000007)
	}
}

func fn(x, y, n int) int {
	if n == 1 {
		return x
	} else if n == 2 {
		return y
	} else if n == 3 {
		return y - x
	} else { // n > 3
		head := [3]int{y - x, x, y}
		pos := n % 3
		sign := 1
		if ((n-1)/3)%2 != 0 {
			sign = -1
		}
		return head[pos] * sign
	}
}


package main

import (
	"bufio"
	"os"
	"strconv"
	"time"
	"unicode/utf8"
)

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

//two functions from go source:
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r', ':':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u180e', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return 0, nil, nil
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(ScanWords)
	tyme1, tyme2 := time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC),
		time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC)
	ans := int(tyme2.Sub(tyme1).Hours() / 24)
	if ans < 0 {
		ans = -ans
	}
	printInt(ans)
	w.Flush()
	//YOU FORGOT TO FLUSH!
}


package main

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

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

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

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

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

func main() {
	defer w.Flush()
	var a int
	for I(&a) == nil {
		solve(a)
	}
}

func solve(a1 int) {
	var a2, a3, b1, b2, b3, n int
	I(&a2, &a3, &b1, &b2, &b3, &n)
	a := a1 + a2 + a3
	b := b1 + b2 + b3
	oa := a / 5
	if a%5 != 0 {
		oa++
	}
	ob := b / 10
	if b%10 != 0 {
		ob++
	}
	if n >= oa+ob {
		O("YES", "\n")
	} else {
		O("NO", "\n")
	}
}


package main

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

func solve() {
	_ = readInt()
	k := readInt()
	cnt := map[rune]int{}
	for _, v := range readString() {
		cnt[v]++
	}
	for _, v := range cnt {
		if v > k {
			fmt.Println("NO")
			return
		}

	}
	fmt.Println("YES")
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1097B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	f := func(sub int) (res int) {
		for i, v := range a {
			if sub>>i&1 == 0 {
				res += v
			} else {
				res -= v
			}
		}
		return
	}
	for sub := 0; sub < 1<<n; sub++ {
		if f(sub)%360 == 0 {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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


package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	a1 := nextInt()
	a2 := nextInt()
	k1 := nextInt()
	k2 := nextInt()
	n := nextInt()

	//	a := a1+a2

	res1 := a1 + a2
	res2 := 0

	for i := 0; i <= a1; i++ {
		tmp1 := n - k1*i
		co1 := (k1 - 1) * (a1 - i)
		for j := 0; j <= a2; j++ {
			tmp2 := tmp1 - k2*j
			co2 := (k2 - 1) * (a2 - j)
			if tmp2 >= 0 {
				if tmp2 <= co1+co2 {
					sum := i + j
					if res1 > sum {
						res1 = sum
					}
					if res2 < sum {
						res2 = sum
					}
				}
			}
		}
	}

	fmt.Fprint(writer, res1, " ", res2)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

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


/*
URL:
https://codeforces.com/problemset/problem/787/A
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	a, b, c, d int
)

func main() {
	a, b, c, d = ReadInt4()

	for i := 0; i <= 3000; i++ {
		for j := 0; j <= 3000; j++ {
			if b+i*a == d+j*c {
				fmt.Println(b + i*a)
				return
			}
		}
	}
	fmt.Println(-1)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


package main

import "fmt"

func main() {
	p := [6]int{}
	sum := 0
	for i := 0; i < 6; i++ {
		fmt.Scanf("%d", &p[i])
		sum += p[i]
	}

	if sum%2 != 0 {
		fmt.Println("NO")
		return
	}

	needed := sum >> 1
	for i := 0; i < 6; i++ {
		for j := i + 1; j < 6; j++ {
			for k := j + 1; k < 6; k++ {
				if p[i]+p[j]+p[k] == needed {
					fmt.Println("YES")
					return
				}
			}
		}
	}

	fmt.Println("NO")
}


package main
import(
	"fmt"
)

func main()  {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	if a < b{
		a, b = b, a
	}
	if c > a - b{
		fmt.Println((a+b+c)/2*2)
	}else{
		fmt.Println((b+c)*2)
	}
}


package main

import "fmt"

var mod int64 = 1000000007

func main() {
    var n, m, k int64
    fmt.Scan(&n)
    fmt.Scan(&m)
    fmt.Scan(&k)
    if k > n {
        fmt.Println(pow(m, n))
    } else if k == n {
        fmt.Println(pow(m, (n + 1) / 2))
    } else if k == 1 {
        fmt.Println(pow(m, n))
    } else if k % 2 == 0 {
        fmt.Println(m)
    } else if k % 1 == 0 {
        fmt.Println(pow(m, 2))
    }
    return
}

func pow(a, b int64) int64 {
    var ans int64 = 1
    for; b > 0; b-- {
        ans = ans * a % mod
    }
    return ans
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1558B(in io.Reader, out io.Writer) {
	var n, m int
	Fscan(in, &n, &m)
	f := make([]int, n+2)
	f[n] = 1
	for i := n - 1; i > 0; i-- {
		f[i] = f[i+1] * 2 % m
		for j, k := 2, n/i; j <= k; j++ {
			f[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m
		}
	}
	Fprint(out, (f[1]-f[2]+m)%m)
}

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

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


package main

import "os"
import "bufio"
import "strconv"
import "math"

func main(){
	var n, k int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	flag, flag1 := false, false
	t, count := 0, 0
	var a [1000]int
	for i:=2; i<=n; i++ {
		flag = false
		for j:=2; j<=int(math.Sqrt(float64(i))); j++ {
			if i%j == 0 {
				flag = true
				break
			}
		}
		if flag == false {
			t += 1
			a[t] = i
		}
	}
	for i:=0; i<t; i++ {
		for j:=0; j<i; j++ {
			if a[j]+a[j+1]+1 == a[i] {
				count += 1
				break
			}
		}
		if count == k {
			flag1 = true
			break
		}
	}
	if flag1 == true {
		w.WriteString("YES\n")
	} else {
		w.WriteString("NO\n")
	}
	w.Flush()
}


package main

import "fmt"
import "strconv"

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

func main() {
	var p int
	var s, l uint64
	fmt.Scanln(&p, &l)
	for i := 1; i < p+1; i++ {
		r, k := strconv.Itoa(i), strconv.Itoa(i)
		r = reverse(r)
		m, _ := strconv.ParseUint(k+r, 10, 64)
		s += m
	}
	s = s % l
	fmt.Println(s)
}


// 219B
package main

import (
	"fmt"
)

func main() {
	var p, d, t, ans int64
	fmt.Scan(&p, &d)
	p++
	ans = p
	for t = 10; ; t *= 10 {
		if p%t > d {
			break
		}
		ans = p - p%t
	}
	fmt.Print(ans - 1)
}


package main

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

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

const mod =  998244353
const N = 2
var n, m, L, R int

type matrix struct {
	f[N][N] int64
}

func print_out(a matrix)  {
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			fmt.Fprintf(writer, "%d ", a.f[i][j])
		}
		fmt.Fprintf(writer, "\n")
	}
}

func mul(a matrix, b matrix) matrix {
	var c = matrix{}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				c.f[i][j] += a.f[i][k] * b.f[k][j]
				c.f[i][j] %= mod
			}
		}
	}
	return c
}

func pw(a matrix, b int64) matrix {
	var ret = matrix{}
	for i := 0; i < N; i++ {
		ret.f[i][i] = 1
	}

	for b > 0 {
		if (b & 1) == 1 {
			ret = mul(ret, a)
			b--
		} else {
			a = mul(a, a)
			b /= 2
		}
	}
	return ret
}

func main()  {
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d %d %d", &n, &m, &L, &R)

	var O = int64(R - L + 1) / 2
	var E = int64(R - L + 1) / 2
	if (R - L + 1) % 2 != 0 {
		if L%2 == 0 {
			E++
		} else {
			O++
		}
	}

	var T = int64(n) * int64(m)

	var mt = matrix{}
	mt.f[0][0] = E
	mt.f[0][1] = O
	mt.f[1][0] = O
	mt.f[1][1] = E

	//print_out(mt)

	mt = pw(mt, T - 1)

	//print_out(mt)

	var dp_odd = O
	var dp_evn = E

	var fn_dp_odd = mt.f[0][0] * dp_odd % mod + mt.f[1][0] * dp_evn % mod
	fn_dp_odd %= mod

	var fn_dp_evn = mt.f[1][0] * dp_odd % mod + mt.f[1][1] * dp_evn % mod
	fn_dp_evn %= mod

	var ret int64
	if T % 2 == 1 {
		ret = (fn_dp_odd + fn_dp_evn) % mod
	} else {
		ret = fn_dp_evn
	}

	fmt.Fprintf(writer, "%d", ret)
}


package main
import (
	"fmt"
)

func main() {
	var a,b,c,d,e,f int
	fmt.Scan(&a,&b,&c)
	d=(a+b-c)/2
	e=(b+c-a)/2
	f=(a+c-b)/2
	if ((a+b+c)%2!=0) || ((a+b)<c) || ((b+c)<a) || ((a+c)<b) {
		fmt.Println("Impossible")
	} else {
		fmt.Println(d,e,f)
	}
}


// cf682a project main.go
package main

import (
	"fmt"
)

// 0 3 1 3 -- 1 / 1 4 ; 2 / 2 3 / 2 8 ; 3  / 3 2 / 3 7 /

func main() {
	var n, m, l,i int64
	fmt.Scan(&n, &m)
	for i=1; i<=n; i++{
		l += (m + i%5)/5
	}
	fmt.Println(l)

}


package main

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

func main() {

	tim := make(map[string]int64)
	tim["a"] = 4
	tim["b"] = 5
	tim["c"] = 6
	tim["d"] = 3
	tim["e"] = 2
	tim["f"] = 1

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	seat := string(text[len(text)-1])
	number, _ := strconv.ParseInt(text[:len(text)-1], 10, 64)

	var time int64
	time = (number - 1) / 4
	time *= (16)
	if (number % 2) == 0 {
		time += 7
	}

	time += tim[seat]
	fmt.Println(time)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m, h := 0, 0, 0
	fmt.Fscanf(in, "%d %d %d\n", &n, &h, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = h
	}
	for i := 0; i < m; i++ {
		l, r, res := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &l, &r, &res)
		l--
		r--
		for j := l; j <= r; j++ {
			//fmt.Println(j)
			if a[j] > res {
				a[j] = res
			}
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i] * a[i]
	}
	//fmt.Println(odd1, odd2, even1, even2)
	fmt.Fprintf(out, "%d\n", ans)
	return
}
func minstep(a, b byte) int {
	return min(int(a-b+26)%26, int(b-a+26)%26)
}

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


package main

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

func main() {
    //io
    scanner := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    //---
    var a, b, ans int
    fmt.Fscan(scanner, &a, &b)
    if a > b {
        a, b = b, a
    }

    for a > 0 && b > 1 {
        a--
        b -= 2
        ans++
        if a > b {
            a, b = b, a
        }
    }
    writer.WriteString(strconv.Itoa(ans))
    writer.Flush()
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int;
	fmt.Scanf("%d",&n)
	a := make([]int,50)
	var i int
	var tmp string

	for i = 0;i < n;i++ {
		for {
			fmt.Scanf("%s",&tmp)
			if tmp == "" {
				continue
			}
			if tmp != "\n" {
				a[i] , _= strconv.Atoi(tmp)
				tmp = ""
				//fmt.Println(a[i])
				break;
			}
		}
	}

	var flag bool = false;
	for i = 1;i < n;i++ {
		if(a[i] - a[i-1] >= 2 || a[i] - a[i-1] <= -2 ){

			flag = true;
		}
	}
	if flag {
		fmt.Println("NO");
	}else {
		fmt.Println("YES");
	}

}


package main

import (
	"fmt"
	"math"
)

func numberOfMoves(x1, y1, x2, y2 int) int {
	diffX := math.Abs(float64(x1 - x2))
	diffY := math.Abs(float64(y1 - y2))
	return int(math.Max(diffX, diffY))
}

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(numberOfMoves(x1, y1, x2, y2))
}


package main

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

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

func main() {
	defer out.Flush()
	var n uint
	fmt.Fscan(in, &n)
	ans := make([]int, 0)
	for i := 20; i >= 0; i-- {
		if (n>>uint(i))&1 == 1 {
			ans = append(ans, i+1)
		}
	}
	for i, x := range ans {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x)
	}
	fmt.Fprintln(out)
}


package main

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

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

var writer *bufio.Writer
var best int = -1
var g [][]int
var numRows, numCols int

func permute(i int) {
  if i == numCols {
    xs := make([]int, numRows)
    for i := range g {
      x := 0
      for _, d := range g[i] {
        x = 10*x + d
      }
      xs[i] = x
    }
    sort.Ints(xs)
    diff := xs[numRows-1] - xs[0]
    if best == -1 || diff < best {
      best = diff
    }
  } else {
    permute(i+1)
    for j := i+1; j < numCols; j++ {
      for k := range g {
        g[k][i], g[k][j] = g[k][j], g[k][i]
      }
      permute(i+1)
      for k := range g {
        g[k][i], g[k][j] = g[k][j], g[k][i]
      }
    }
  }
}

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

  numRows, numCols = getI(), getI()
  g = make([][]int, numRows)
  for i := range g {
    s := getS()
    g[i] = make([]int, numCols)
    for j := range g[i] {
      g[i][j] = int(s[j]-'0')
    }
  }
  permute(0)

  writer.WriteString(fmt.Sprintf("%d\n", best))
}


package main

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

type Prob struct {
    in *bufio.Reader
}

func (prob *Prob) NextLine() string {
    line, _, _ := prob.in.ReadLine()
    return string(line[:])
}

func (prob *Prob) NextByte() byte {
    bt, _ := prob.in.ReadByte()
    return bt
}

func (prob *Prob) Next() string {
    var buff bytes.Buffer
    bt := prob.NextByte()
    for bt == '\n' || bt == ' ' {
        bt = prob.NextByte()
    }
    for bt != '\n' && bt != ' ' {
        buff.WriteByte(bt)
        bt = prob.NextByte()
    }
    return buff.String()
}

func (prob *Prob) NextInt() int {
    var x int
    bt := prob.NextByte()
    for bt > '9' || bt < '0' {
        if bt == '-' {
            return -prob.NextInt()
        }
        bt = prob.NextByte()
    }
    for bt >= '0' && bt <= '9' {
        x = x * 10 + int(bt - '0')
        bt = prob.NextByte()
    }
    return x
}

func (prob Prob) Solve() {
    h1 := prob.NextInt()
    m1 := prob.NextInt()
    h2 := prob.NextInt()
    m2 := prob.NextInt()
    df := ((h2 - h1) * 60 + m2 - m1) / 2
    m1 += df
    h1 += m1 / 60
    m1 %= 60
    fmt.Printf("%02d:%02d\n", h1, m1)
}

func main() {
    Prob{in: bufio.NewReader(os.Stdin)}.Solve()
}


package main

import "fmt"

func main() {
	var n int
	var k int
	fmt.Scan(&n, &k)
	var data = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&data[i])
	}

	var cnt = 0
	for i := 0; i < n; i++ {
		if data[i] > k {
			break
		} else {
			cnt++
		}

	}

	for i := n - 1; i >= 0; i-- {
		if data[i] > k {
			break
		} else {
			cnt++
		}
	}

	if cnt > n {
		cnt /= 2
	}
	fmt.Println(cnt)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF735D(_r io.Reader, _w io.Writer) {
	isP := func(n int) bool {
		for i := 2; i*i <= n; i++ {
			if n%i == 0 {
				return false
			}
		}
		return true
	}

	var n int
	if Fscan(_r, &n); isP(n) {
		Fprint(_w, 1)
	} else if n%2 == 0 || isP(n-2) {
		Fprint(_w, 2)
	} else {
		Fprint(_w, 3)
	}
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1557C(in io.Reader, out io.Writer) {
	const mod int64 = 1e9 + 7
	pow := func(x int64, n int) (res int64) {
		res = 1
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return
	}
	p2 := [2e5]int64{1}
	for i := 1; i < 2e5; i++ {
		p2[i] = p2[i-1] << 1 % mod
	}

	var T, n, k int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		if n&1 > 0 {
			Fprintln(out, pow(p2[n-1]+1, k))
		} else {
			ans := int64(1)
			for i := 0; i < k; i++ {
				ans = (pow(p2[i], n) + (p2[n-1]-1)*ans) % mod
			}
			Fprintln(out, ans)
		}
	}
}

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


package main

import (
	"fmt"
)

var rotate = [][]int{
	{5, 6, 17, 18, 21, 22, 13, 14},
	{7, 8, 19, 20, 23, 24, 15, 16},
	{3, 4, 19, 20, 23, 24, 15, 16},
	{1, 2, 18, 20, 12, 11, 15, 13},
	{2, 4, 6, 8, 10, 12, 23, 21},
	{1, 3, 5, 7, 9, 11, 24, 22}}

func main() {
	var cube = make([]int, 24)
	for i := 0; i < 24; i++ {
		fmt.Scanf("%d", &cube[i])
	}
	//rotate
	for i := 0; i < 6; i++ {
		//90-angle
		if check_rotate(cube, rotate[i], move_left2(rotate[i])) {
			fmt.Println("YES")
			return
		}
		//another 90-angle
		if check_rotate(cube, rotate[i], move_right2(rotate[i])) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

func move_left2(in []int) []int {
	ret := append(in[2:len(in)], in[0:2]...)
	return ret
}

func move_right2(in []int) []int {
	ret := append(in[len(in)-2:len(in)], in[0:len(in)-2]...)
	return ret
}

func check_rotate(cube, rotate, moved []int) bool {
	after := make([]int, len(cube))
	copy(after, cube)
	for i := 0; i < 8; i++ {
		after[moved[i]-1] = cube[rotate[i]-1]
	}
	return check_solved(after)
}

func check_solved(cube []int) bool {
	for i := 0; i < 6; i++ {
		if cube[i*4] != cube[i*4+1] || cube[i*4] != cube[i*4+2] || cube[i*4] != cube[i*4+3] {
			return false
		}
	}
	return true
}


package main

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

/*
1
1 1
1 2
2 1
2 3
---
0
0
2 [0,1], [1,0]
X [0,7], [7,0],

*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n, k int64
		scanf("%d %d\n", &n, &k)

		ans := big.NewInt(0).Exp(big.NewInt(n), big.NewInt(k), big.NewInt(1e9+7)).Int64()

		fmt.Fprintln(writer, ans)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}


package main

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

func cube(x int) int64 {
	return int64(x) * int64(x) * int64(x)
}

func foo(n int64) int64 {
	var ans int64
	for k := 2; ; k++ {
		x := n / cube(k)
		if x == 0 {
			break
		}
		ans += x
	}
	return ans
}

// najmniejszy argument, dla ktorego f(arg) zwraca prawde
// funkcja logiczna powinna byc niemalejaca
func bin_search(f func(int64) bool, lo, up, eps int64) int64 {
	up++
	cnt := up - lo
	var mid, step int64
	for cnt >= eps {
		step = cnt / 2
		mid = lo + step
		if !f(mid) {
			lo = mid + eps
			cnt -= step + eps
		} else {
			cnt = step
		}
	}
	return lo
}

func main() {
	m := getInt64()
	mx := int64(4949100894494448)
	x := func(n int64) bool {
		return foo(n) >= m
	}

	p := bin_search(x, 1, mx, 1)

	if foo(p) != m {
		p = -1
	}

	fmt.Println(p)
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func getInt64() int64 {
	globalInput.Scan()
	x, _ := strconv.ParseInt(globalInput.Text(), 10, 64)
	return x
}
func getInt() int {
	globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x
}
func getIntOk() (int, bool) {
	ok := globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x, ok
}
func getNint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = getInt()
	}
	return v
}
func getVint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = getIntOk()
	}
	return ok
}
func getWord() string {
	globalInput.Scan()
	return globalInput.Text()
}
func getWordOk() (string, bool) {
	ok := globalInput.Scan()
	return globalInput.Text(), ok
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func minStr(a, b string) string {
	if a < b {
		return a
	}
	return b
}
func maxStr(a, b string) string {
	if a < b {
		return b
	}
	return a
}
func remin(a *int, b int) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax(a *int, b int) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func remin64(a *int64, b int64) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax64(a *int64, b int64) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func reminStr(a *string, b string) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remaxStr(a *string, b string) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}

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

type (
	FLess    func(i, j int) bool
	FSwap    func(i, j int)
	wrapSort struct {
		Length int
		FLess
		FSwap
	}
)

func (w *wrapSort) Len() int           { return w.Length }
func (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }
func (w *wrapSort) Swap(i, j int)      { w.FSwap(i, j) }
func wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {
	sort.Sort(&wrapSort{length, fless, fswap})
}


package main

import (
	"fmt"
)

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

	var counter int
	var answer []int
	for i := 0; i <= n; i++ {
		if (i == n || (i != 0 && str[i-1] != str[i])) && counter != 0 {
			answer = append(answer, counter)
			counter = 0
		}
		if i < n && str[i] == 'B' {
			counter++
		}
	}

	fmt.Println(len(answer))
	for _, a := range answer {
		fmt.Printf("%d ", a)
	}
	fmt.Println()
}