package main

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

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

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

func toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var MD int64 = 1000000007
var f map[int]int

func deg(d int) int64 {
	if d == 0 {
		return 1
	}
	t := deg(d / 2)
	t *= t
	t %= MD
	if d % 2 == 1 {
		t = t * 2 % MD
	}
	return t
}

func calc(x int) int {
	if val, exists := f[x]; exists {
		return val
	}
	res := int(deg(x - 1))
	for i:= 2;i * i <= x; i++ {
		if x % i == 0 {
			first := i
			second := x / i
			res = res - calc(x / first)
			if res < 0 {
				res += 1000000007
			}
			if second != first {
				res = res - calc(x / second)
				if res < 0 {
					res += 1000000007
				}
			}
		}
	}
	res = res - 1
	if res < 0 {
		res += 1000000007
	}
	f[x] = res
	return res
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var x,y int
	f = make(map[int]int)
	f[1] = 1
	fmt.Fscanf(in, "%d %d\n", &x, &y)
	if y % x != 0 {
		fmt.Println(0)
		os.Exit(0)
	}
	y /= x
	fmt.Println(calc(y))
}


package main

import (
	"fmt"
)

func main() {
	var n, k, cnt int

	fmt.Scanln(&n, &k)

	if ((n - k) <= (k - 1)) && (n > 2) {
		cnt = (3 * n) + (n - k)
	} else if ((n - k) > (k - 1)) && (n > 2) {
		cnt = (3 * n) + (k - 1)
	} else {
		cnt = 3 * n
	}

	fmt.Println(cnt)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, k, res int
	fmt.Fscan(reader, &n, &k)
	if k == 1 || k == n {
		res = 3 * n
	} else {

		res = 3*n + min(k-1, n-k)
	}
	fmt.Printf("%d", res)
}
func min(a, b int) int {
	if a <= b {
		return a
	} else {
		return b
	}

}


package main

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

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

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

	step := n-k
	if step > k-1{
		step = k-1
	}
	fmt.Printf("%d\n",3*n+step)
}


package main

import (
	"fmt"
)

func main() {
	var total int
	var current int
	var left, right, max, min int
	var totalMoves int
	fmt.Scanln(&total, &current)
	left = current - 1
	right = total - current
	min, max = minMax(left, right)
	totalMoves = min * 2 + max + total *2 + 1
	fmt.Println(totalMoves)
}

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


package main

import "fmt"

func solve(n, k int) int {
	min := n - k
	if k-1 < min {
		min = k - 1

	}

	return min + 3*n
}

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

	fmt.Println(solve(n, k))
}


// Author: sighduck
// URL: https://codeforces.com/contest/1136/problem/B

package main

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

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

func Solve(n int, k int) int {
	return 2*n + 1 + min(n-k, k-1) + n - 1
}

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

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

	fmt.Fprintf(writer, "%d\n", Solve(n, k))
}


// 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]

	if n == 1 {
		fmt.Println("1")
		return
	}

	fmt.Println(n/2 + 1)

}

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

func main(){
    var n int
    fmt.Scan(&n)
    fmt.Println(n/2+1)
}


package main

import "fmt"

var x int

func main() {
	fmt.Scanf("%d", &x)
	fmt.Println(x/2 + 1)
}


package main

import "fmt"

func main(){
	var t int
	fmt.Scan(&t)
	fmt.Print(t/2 + 1)
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println(n/2 + 1)
}


// Codeforces 785 B Anton and Classes done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
	"sort"
)
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 k []int
var canShine bool

func readData() {
	k = make([]int, 3)
	in = bufio.NewReader(os.Stdin)
	k[0],k[1],k[2],_,_ = readFive()
	sort.Ints(k)
}

func solve() {
	if k[0]==1 {
		canShine = true
	} else if k[0]==2 && k[1]==2 {
		canShine = true
	} else if k[0]==2 && k[1]==4 && k[2]==4 {
		canShine = true
	} else if k[0]==3 && k[1]==3 && k[2]==3 {
		canShine = true
	} else {
		canShine = false
	}
}

func printRes() {
	if canShine {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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


package main

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

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

	N, H := readTwoNums(reader)

	fmt.Println(solve(N, H))
}

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

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

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

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

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

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

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

	return i
}

func solve(N, H int) int64 {
	dp := make([][]int64, N+1)
	fp := make([][]int64, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int64, N+1)
		fp[i] = make([]int64, N+1)
	}

	for h := 0; h <= N; h++ {
		dp[0][h] = 1
	}

	for h := 1; h <= N; h++ {
		for n := h; n <= N; n++ {
			for x := 0; x < n; x++ {
				dp[n][h] += dp[x][h-1] * dp[n-1-x][h-1]
			}
			fp[n][h] = dp[n][h]
			dp[n][h] += dp[n][h-1]
		}
	}
	var res int64
	for h := H; h <= N; h++ {
		res += fp[N][h]
	}

	return res
}


package main

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

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

	N, H := readTwoNums(reader)

	fmt.Println(solve(N, H))
}

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

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

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

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

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

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

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

	return i
}

func solve(N, H int) uint64 {
	dp := make([][]uint64, N+1)

	for i := 0; i <= N; i++ {
		dp[i] = make([]uint64, N+1)
	}
	//
	for h := 0; h <= N; h++ {
		dp[0][h] = 1
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			for k := 0; k < i; k++ {
				dp[i][j] += dp[k][j-1] * dp[i-k-1][j-1]
			}
		}
	}

	res := dp[N][N] - dp[N][H-1]

	return res
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF101C(in io.Reader, out io.Writer) {
	var x, y [3]int64
	for i := 0; i < 3; i++ {
		Fscan(in, &x[i], &y[i])
	}
	d := x[2]*x[2] + y[2]*y[2]
	for i := 0; i < 4; i++ {
		x[0], y[0] = y[0], -x[0]
		dx, dy := x[1]-x[0], y[1]-y[0]
		d1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]
		if d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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


package main

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

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

	var x, y [3]int64
	for i := 0; i < 3; i++ {
		Fscan(in, &x[i], &y[i])
	}
	d := x[2]*x[2] + y[2]*y[2]
	for i := 0; i < 4; i++ {
		x[0], y[0] = y[0], x[0]
		y[0] = -y[0]
		dx, dy := x[1]-x[0], y[1]-y[0]
		d1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dx*x[2]
		if d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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


package main

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

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

	const mod int = 1e9 + 7
	var n int
	Fscan(in, &n)
	f := [1001][1001]int{}
	f[0][0] = 1
	ans := 0
	for i := 1; i <= n; i++ {
		f[i][0] = f[i-1][0]
		if i&1 == 1 {
			ans = (ans + f[i][0]) % mod
		}
		for j := 1; j <= i; j++ {
			f[i][j] = (f[i-1][j] + f[i][j-1]) % mod
			if (i+j)&1 == 1 {
				ans = (ans + f[i][j]) % mod
			}
		}
	}
	Fprint(out, ans)
}

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


package main

import (
	"fmt"
)

func main() {
	ans := []int{0, 2, 3, 1, 2, 1}
	var n int
	fmt.Scanf("%d", &n)
	fmt.Printf("%d", ans[n])
}


// Codeforces 859 C Pie Rules train
package main

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

var in *bufio.Reader

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

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

var n int
var p []int  // pie slices sizes
var pAlice,pBob int
var mem [][]int  // mem[0] - bob win, mem[1] - alice win
var pSum int
var pSumLeft []int  // sum left after step

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

func initMemSum() {
	mem = make([][]int, 2)
	for ba := 0; ba<2; ba++ {
		mem[ba] = make([]int, n)
		for j:=0; j<n; j++ {
			mem[ba][j] = -1;
		}
	}
	pSum = 0
	pSumLeft = make([]int,n+1)
	pSumLeft[n] = 0
	for i:=n-1; i>=0; i-- {
		pSum += p[i]
		pSumLeft[i] = pSum;
	}
}

// Return for player with fishka.
func play(ba int, step int) int {
	if step>=n {
		return 0
	} else if mem[ba][step]>=0 {
		return mem[ba][step]
	}
	// pass fishka
	retp := p[step] + (pSumLeft[step+1] - play(1-ba, step+1));
	// stay with fishka
	rets := play(ba, step+1)
	// max result
	ret := retp
	if ret < rets {
		ret = rets
	}
	// fmt.Printf("play(%d, %d) returned %d\n", ba,step, ret)
	mem[ba][step] = ret;
	return ret;
}

// solve func solves our problem.
func solve() {
	initMemSum()
	pBob = play(1,0)
	pAlice = pSum - pBob
}

// printRes print problem solution in expected format.
func printRes() {
	fmt.Printf("%d %d\n", pAlice, pBob)
}

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


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

var mem [2][51]int

func get(sum int, slices []int, decider bool) (returned int) {
	if len(slices) == 0 {
		return 0
	}

	dec := 0
	if decider {
		dec = 1
	}

	if mem[dec][len(slices)] != 0 {
		return mem[dec][len(slices)]
	}
	defer func() { mem[dec][len(slices)] = returned }()

	ans := get(sum-slices[0], slices[1:], decider)
	if x := sum - get(sum-slices[0], slices[1:], !decider); ans < x {
		ans = x
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	slices := make([]int, n)
	sum := 0
	for i := range slices {
		fmt.Scan(&slices[i])
		sum += slices[i]
	}
	bob := get(sum, slices, true)
	fmt.Println(sum-bob, bob)
}


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(dp[n], sum[n]-dp[n])
}


package main

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

type graph struct {
	edges  [][]int
	degree []int
	scc    int
	color  []int
}

func (g *graph) add(from, to int) {
	g.edges[from] = append(g.edges[from], to)
	g.degree[from]++
}

func (g *graph) addBoth(from, to int) {
	g.add(from, to)
	if from != to {
		g.add(to, from)
	}
}

func (g *graph) dfs(v int) {
	g.color[v] = g.scc
	for _, w := range g.edges[v] {
		if g.color[w] == 0 {
			g.dfs(w)
		}
	}
}

func (g *graph) check() bool {
	cnt := 0
	for _, c := range g.color {
		if c == g.scc {
			cnt++
		}
	}
	for i, c := range g.color {
		if c == g.scc && g.degree[i] != cnt-1 {
			return false
		}
	}
	return true
}

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

	var n, m int
	Fscan(in, &n, &m)
	g := &graph{
		edges:  make([][]int, n+1),
		degree: make([]int, n+1),
		scc:    1,
		color:  make([]int, n+1),
	}
	for ; m > 0; m-- {
		var v, w int
		Fscan(in, &v, &w)
		g.addBoth(v, w)
	}

	g.dfs(1)
	if !g.check() {
		Fprint(out, "No")
		return
	}
	g.scc++
	for i := 2; i <= n; i++ {
		if g.color[i] == 0 {
			g.dfs(i)
			break
		}
	}
	if !g.check() {
		Fprint(out, "No")
		return
	}
	for _, c := range g.color[1:] {
		if c == 0 {
			Fprint(out, "No")
			return
		}
	}

	Fprintln(out, "Yes")
	for _, c := range g.color[1:] {
		if c == 1 {
			Fprint(out, "a")
		} else {
			Fprint(out, "c")
		}
	}
}

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


package main

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

type graph struct {
	size   int
	edges  [][]bool
	degree []int
	color  []int
}

func (g *graph) add(from, to int) {
	g.edges[from][to] = true
	g.degree[from]++
}

func (g *graph) addBoth(from, to int) {
	g.add(from, to)
	if from != to {
		g.add(to, from)
	}
}

func (g *graph) _isBipartite(v int) bool {
	for w, e := range g.edges[v] {
		if e || w == v {
			continue
		}
		if g.color[w] == g.color[v] {
			return false
		}
		if g.color[w] == 0 {
			g.color[w] = 3 - g.color[v]
			if !g._isBipartite(w) {
				return false
			}
		}
	}
	return true
}

func (g *graph) isBipartite() bool {
	checked := false
	cnt := 0
	for i, deg := range g.degree {
		deg = g.size - 1 - deg
		if deg > 0 {
			if checked {
				if g.color[i] == 0 {
					return false
				}
				continue
			}
			g.color[i] = 1
			if !g._isBipartite(i) {
				return false
			}
			for w := range g.edges[i] {
				if g.color[w] == 2 {
					cnt++
				}
			}
			checked = true
		}
	}
	if cnt > 0 {
		for v, c := range g.color {
			if c == 1 {
				cntW := 0
				for w, e := range g.edges[v] {
					if e || w == v {
						continue
					}
					if g.color[w] == 2 {
						cntW++
					}
				}
				if cntW != cnt {
					return false
				}
			}
		}
	}
	return true
}

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

	var n, m int
	Fscan(in, &n, &m)
	g := &graph{
		size:   n,
		edges:  make([][]bool, n),
		degree: make([]int, n),
		color:  make([]int, n),
	}
	for i := range g.edges {
		g.edges[i] = make([]bool, n)
	}
	for ; m > 0; m-- {
		var v, w int
		Fscan(in, &v, &w)
		g.addBoth(v-1, w-1)
	}

	// 若反图为空或二分图，则存在
	if !g.isBipartite() {
		Fprint(out, "No")
		return
	}

	Fprintln(out, "Yes")
	for _, c := range g.color {
		Fprintf(out, "%c", "bac"[c])
	}
}

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


// 79A
package main

import (
	"fmt"
)

func main() {
	var x, y int64
	w := true
	fmt.Scan(&x, &y)
	for x*10+y >= 22 && y >= 2 {
		if w || (y < 12) {
			x -= 2
			y -= 2
		} else if y < 22 {
			x--
			y -= 12
		} else {
			y -= 22
		}
		w = !w
	}
	if w == true {
		fmt.Print("Hanako")
	} else {
		fmt.Print("Ciel")
	}
}


package main

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

func sum(n int64) int64 {
	var summ int64
	for n > 0 {
		summ += n%10
		n /= 10
	}
	return summ
}

func main(){
	var n int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	var l int64 = int64(math.Sqrt(float64(n)))-40
	if l < 0 {
		l = 1
	}
	var s int64 = int64(math.Sqrt(float64(n)))+1
	for i:=l; i<s; i++ {
		if i*i+i*sum(i) == n {
			w.WriteString(strconv.FormatInt(i, 10)+"\n")
			w.Flush()
			return
		}
	}
}


// 233B
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, i, sum int64
	fmt.Scan(&a)
	b = int64(math.Sqrt(float64(a)))
	for i = b - 100; i <= b; i++ {
		if i < 1 {
			continue
		}
		c = i
		sum = 0
		for c > 0 {
			sum = sum + c%10
			c /= 10
		}
		if (sum+i)*i == a {
			fmt.Print(i)
			return
		}
	}
	c = -1
	fmt.Print(c)
}


package main

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

func sum(n int64) int64 {
	var summ int64
	for n > 0 {
		summ += n%10
		n /= 10
	}
	return summ
}

func main(){
	var n int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	var l int64 = int64(math.Sqrt(float64(n)))-40
	if l < 0 {
		l = 1
	}
	var s int64 = int64(math.Sqrt(float64(n)))+1
	for i:=l; i<s; i++ {
		if i*i+i*sum(i) == n {
			w.WriteString(strconv.FormatInt(i, 10)+"\n")
			w.Flush()
			return
		}
	}
	w.WriteString("-1\n")
	w.Flush()
}


package main

import "fmt"

func readTime() int {
	var hh, mm int

	fmt.Scanf("%d:%d", &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
	a = 10
	fmt.Scanf("%d", &a)
	time += a
	printTime(time)
}


package main

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

//N _
const (
	N = 1e6 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	str := strings.Split(*<-strs, ":")
	a , _ := strconv.ParseInt(str[0], 10, 64)
	b , _ := strconv.ParseInt(str[1], 10, 64)
	c , _ := strconv.ParseInt(*<-strs, 10, 64)

	b += c

	a += b/60
	b %= 60
	a %= 24

	ws.WriteString(fmt.Sprintf("%02d:%02d", a, b))
	ws.Flush()
}


package main

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

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

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

	times := strings.Split(next(), ":")
	h, _ := strconv.Atoi(times[0])
	m, _ := strconv.Atoi(times[1])
	a := nextInt()

	h = (h + a/60)
	m = (m + (a % 60))

	if m >= 60 {
		h++
		m = m % 60
	}

	h = h % 24

	printf("%02d:%02d\n", h, m)
}

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

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

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

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

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


package main
import (
    "fmt"
    )
func main(){
    var n
    i := 1
    fmt.Scan(&n)
    while(n>i){
        n -= i
        i++
    }
    if n == i {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main
import (
    "fmt"
    )
func main(){
    var n int
    i := 1
    fmt.Scan(&n)
    while(n>i){
        n -= i
        i++
    }
    if n == i {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main
import (
    "fmt"
    )
func main(){
    var n int
    i := 1
    fmt.Scan(&n)
    for ;n>i;i++{
        n -= i
    }
    if n == i {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main
import (
	"fmt"
)
func main() {
	var n,i int
	fmt.Scan(&n)
	flag:=false
	for i=1;i<=n;i++ {
		if i*(i+1)/2==n {
			flag=true
		}
	}
	if flag==true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


package main

import "fmt"

func main() {
	// 从左开始遇到1就扩大右边界，直到超出右边界为止。
	var (
		n, d int
		s    string
	)
	fmt.Scanf("%d%d", &n, &d)
	fmt.Scan(&s)
	f := make([]int, n)
	for i := 0; i < n; i++ {
		f[i] = -1
	}
	if s[0] == '1' {
		f[0] = 0
	}
	for l, r := 0, 0; l <= r; l++ {
		if s[l] != '1' {
			continue
		}
		for r < l+d && r+1 < n {
			r++
			if s[r] == '1' {
				f[r] = f[l] + 1
			}
		}
	}

	fmt.Printf("%d\n", f[n-1])
}


package main

import (
	"fmt"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	var a string
	fmt.Scan(&a)
	i := 0
	flag := false
	count := 0
	var j int
	for i < n {
		if i+d >= n {
			j = n - 1
		} else {
			j = i + d
		}
		for (j > i && j < n) && a[j] != '1' {
			j--
		}
		if j <= n-1 {
			if a[j] != '1' || j == i {
				flag = true
				break
			} else {
				i = j
				if j == n-1 {
					count++
					break
				}
				count++
			}
		}
	}
	if flag {
		fmt.Println(-1)
	} else {
		fmt.Println(count)
	}
}


package main

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

func main() {
	var (
		a, b, x, y int
	)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	b, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	x, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	y, _ = strconv.Atoi(scanner.Text())

	del := gcd(x, y)
	x, y = x/del, y/del

	f, s := a/x, b/y

	mn := f
	if mn > s {
		mn = s
	}
	fmt.Println(mn)
}

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


package main

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

func main() {
	var (
		a, b, x, y int64
	)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	scanner.Scan()
	b, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	scanner.Scan()
	x, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	scanner.Scan()
	y, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	g := gcd(x, y)

	x /= g
	y /= g

	f, s := a/x, b/y

	res := min(f, s)
	fmt.Println(res)
}

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

	return y
}

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

func lcm(a, b int64) int64 {
	return a / gcd(a, b) * b
}


package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
var (
	r *bufio.Scanner
	w *bufio.Writer
)

const ISDEBUG = false

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

func readInt() int {
	r.Scan()
	x, _ := strconv.Atoi(r.Text())
	return x
}

func readInts(n int) []int {
	var res []int
	for i:=0; i<n; i++ {
		if !r.Scan() {
			fmt.Println(r.Err())
		}
		x, _ := strconv.Atoi(r.Text())
		res = append(res, x)
	}
	return res
}

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

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

func buytv() int64 {
	a, b, x, y := readInt64(), readInt64(), readInt64(), readInt64()

	gxy := gcd(x, y)
	x = x / gxy
	y = y / gxy

	r1, r2 := a/x, b/y
	if r1 < r2 {
		return r1
	}
	return r2
}

func main() {
	if ISDEBUG {
		fi, err := os.Open("input.txt")
		if err != nil {
			panic(err)
		}
		fo, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
		r = bufio.NewScanner(fi)
		w = bufio.NewWriter(fo)

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

	w.WriteString(fmt.Sprintf("%v\n",buytv()))
}


// 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 "fmt"

func main() {
	var pp, dd, x, y, t, w, h int64
	w=1
	fmt.Scan(&pp, &dd)
	x=pp-dd
	y=pp
	for {
		t=y
		w*=10
		h=pp%w
		if h==w-1 {
			h--
		}
		y=pp-(h+1)
		if y<x {
			break
		}
	}
	fmt.Println(t)
}


package main

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

func Init() {
}

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

	var sb bytes.Buffer
	rem := K
	c := 'a'
	for rem > 0 {
		sz := 0
		for sz <= rem {
			sb.WriteRune(c)
			rem -= sz
			sz++
		}
		c++
	}
	io.Println(sb.String())
}

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

func min(nums ...int) int {
	res := math.MaxInt32
	for _, num := range nums {
		if num < res {
			res = num
		}
	}
	return res
}

func main() {
	n, m, a, b, countMap := 0, 0, 0, 0, map[int]int{}
	fmt.Scan(&n, &m)

	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		countMap[b] += a
	}

	pointer, result := 10, 0
	for (n > 0) && (pointer > 0) {
		steal := min(n, countMap[pointer])
		result, n, pointer = result+steal*pointer, n-steal, pointer-1
	}

	fmt.Println(result)
}


// 70A
package main

import (
	"fmt"
)

func main() {
	var m int
	e := 1
	fmt.Scan(&m)
	for j := 1; j <= m-1; j++ {
		e = (3 * e) % 1000003
	}
	fmt.Print(e)
}


//70A
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn, a int64
	a=1
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.ParseInt(r.Text(), 0, 64)
	if nn==1 {
		a=1
	} else {
		for i:=2; int64(i)<=nn; i++ {
			a=(a*3)%1000003
		}
	}
	fmt.Println(a)
}


// 70A
package main

import (
	"fmt"
)

func main() {
	var m, n int
	e := 1
	fmt.Scan(&m)
	for j = 1; j <= m-1; j++ {
		e = (3 * e) % 1000003
	}
	fmt.Print(e)
}


package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n int
	fmt.Scan(&n)
	weight := make([]int,2*n)
	for i := 0; i < 2*n; i++ {
		fmt.Scan(&weight[i])
	}
	sort.Ints(weight)
	res := 50000
	for i := 0; i < 2*n-1; i++ { //enumerate the two elements
		for j := i + 1; j < 2*n; j++ {
			tot := 0
			for k := 0; k < 2*n-1; k++ { //left weight
				if k==i || k==j{continue} //skip it
				r := k+1
				for r==i || r==j {r++} //right weight
				tot += weight[r] - weight[k]
				k = r //update left
			}
			if tot < res { res = tot} //update the result
		}
	}
	fmt.Println(res)

}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	n *= 2
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}

	res := -1
	for i, _ := range a {
		for j, _ := range a {
			if j == i {
				continue
			}

			cur := make([]int, 0)
			for k, _ := range a {
				if k != i && k != j {
					cur = append(cur, a[k])
				}
			}
			sort.Ints(cur)

			ans := 0
			for k := 0; k < len(cur); k += 2 {
				ans += cur[k+1] - cur[k]
			}
			if res == -1 {
				res = ans
			} else if res > ans {
				res = ans
			}
		}
	}
	fmt.Println(res)
}


package main

import . "fmt"

type vec struct {
	x, y int64
}

func (a vec) sub(b vec) vec                   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) dot(b vec) int64                 { return a.x*b.x + a.y*b.y }
func isOrthogonal(a, b, c vec) bool           { return a.sub(b).dot(c.sub(b)) == 0 }
func isRectangle(a, b, c, d vec) bool         { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }
func isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }

// github.com/EndlessCheng/codeforces-go
func main() {
	mp := map[vec]int{}
	for i := 0; i < 4; i++ {
		var x, y int64
		Scan(&x, &y)
		p0 := vec{x, y}
		Scan(&x, &y)
		p1 := vec{x, y}
		mp[p0]++
		mp[p1]++
	}
	arr := []vec{}
	for vec, v := range mp {
		if v != 2 {
			Print("NO")
			return
		}
		arr = append(arr, vec)
	}
	if isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {
		Print("YES")
	} else {
		Print("NO")
	}
}


package main

import . "fmt"

type vec struct {
	x, y int64
}

func (a vec) sub(b vec) vec                   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) dot(b vec) int64                 { return a.x*b.x + a.y*b.y }
func isOrthogonal(a, b, c vec) bool           { return a.sub(b).dot(c.sub(b)) == 0 }
func isRectangle(a, b, c, d vec) bool         { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }
func isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }

// github.com/EndlessCheng/codeforces-go
func main() {
	mp := map[vec]int{}
	for i := 0; i < 4; i++ {
		var x, y int64
		Scan(&x, &y)
		p0 := vec{x, y}
		Scan(&x, &y)
		p1 := vec{x, y}
		v := p1.sub(p0)
		if v.x != 0 && v.y != 0 {
			Print("NO")
			return
		}
		mp[p0]++
		mp[p1]++
	}
	arr := []vec{}
	for vec, v := range mp {
		if v != 2 {
			Print("NO")
			return
		}
		arr = append(arr, vec)
	}
	if isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {
		Print("YES")
	} else {
		Print("NO")
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1034B(in io.Reader, out io.Writer) {
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}
	var n, m, ans int64
	Fscan(in, &n, &m)
	if n > m {
		n, m = m, n
	}
	if n == 1 {
		ans = m - m%6 + max(m%6-3, 0)*2
	} else if n == 2 {
		switch m {
		case 2:
			ans = 0
		case 3:
			ans = 4
		case 7:
			ans = 12
		default:
			ans = m * 2
		}
	} else {
		ans = n * m &^ 1
	}
	Fprint(out, ans)
}

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


package main

import "fmt"

func main() {
    var n int
    var m int
    fmt.Scan(&m)
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var res int
        res = m / n
        if i < m % n {
            res = res + 1
        }
        fmt.Print(res, " ")
    }
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF533C(in io.Reader, out io.Writer) {
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}
	var x1, y1, x2, y2 int
	Fscan(in, &x1, &y1, &x2, &y2)
	if x1+y1 <= max(x2, y2) || x1 <= x2 && y1 <= y2 {
		Fprint(out, "Polycarp")
	} else {
		Fprint(out, "Vasiliy")
	}
}

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


package main

import "fmt"

const MOD = int64(1e9 + 7)

var (
	k   int64
	n   int64
	inv [100]int64
)

func qpow(x, k int64) int64 {
	var y int64 = 1
	for k > 0 {
		if k%2 > 0 {
			y = y * x % MOD
		}
		k >>= 1
		x = x * x % MOD
	}
	return y
}
func solve(x int64, cnt int64) int64 {
	dp := [10001][60]int64{}
	s := int64(1)
	for i := int64(0); i <= cnt; i++ {
		dp[0][i] = s
		s = s * x % MOD
	}
	for i := int64(1); i <= k; i++ {
		var s int64 = 0
		for j := int64(0); j <= cnt; j++ {
			s += dp[i-1][j]
			if s >= MOD {
				s -= MOD
			}
			dp[i][j] = s * inv[j+1] % MOD
		}
	}
	return dp[k][cnt]
}

func main() {
	for i := int64(1); i < 100; i++ {
		inv[i] = qpow(i, MOD-2)
	}
	fmt.Scanln(&n, &k)
	var ans int64 = 1
	for i := int64(2); i*i <= n; i++ {
		var c int64 = 0
		for n%i == 0 {
			c++
			n /= i
		}
		if c > 0 {
			ans = ans * solve(i, c) % MOD
		}
	}
	if n > 1 {
		ans = ans * solve(n, 1) % MOD
	}
	fmt.Println(ans)
}


package main
import (
    "fmt"
)
func main(){
    var n int
    fmt.Scan(&n)
    fmt.Printf("1%d\n",n)
}


package main

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

func solve() {
	var st int
	Readf("%d", &st)

	Writef("%d\n", st + rand.Intn(100))
}

func main()  {
	// If io still contains some buffered data flush it before
	// quiting
	defer io.Flush()

	// Solution of the problem goes here
	solve()
}

var (
	// fmt.Print and fmt.Scan is slow, we will use bufio
	// for read and write from stdin.
	io = bufio.NewReadWriter(
		bufio.NewReader(os.Stdin),
		bufio.NewWriter(os.Stdout),
	)
)

func Readf(format string, args ...interface{})  {
	fmt.Fscanf(io, format, args...)
}

func Writef(format string, args ...interface{})  {
	fmt.Fprintf(io, format, args...)
}


package main

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

func solve() {
	var st int
	Readf("%d", &st)

	sqrt := int(math.Sqrt(float64(st)))
	var a, b int

	var ok bool
	for i := 2; i <= sqrt; i++ {
		if st % i == 0 {
			a = i
			b = st / i

			ok = true
			break
		}
	}

	if ok {
		Writef("%d%d\n", a, b)
	} else {
		Writef("-1\n")
	}
}

func main()  {
	// If io still contains some buffered data flush it before
	// quiting
	defer io.Flush()

	// Solution of the problem goes here
	solve()
}

var (
	// fmt.Print and fmt.Scan is slow, we will use bufio
	// for read and write from stdin.
	io = bufio.NewReadWriter(
		bufio.NewReader(os.Stdin),
		bufio.NewWriter(os.Stdout),
	)
)

func Readf(format string, args ...interface{})  {
	fmt.Fscanf(io, format, args...)
}

func Writef(format string, args ...interface{})  {
	fmt.Fprintf(io, format, args...)
}


package main

import "fmt"

func main() {
    var n, ans int64
    var a [10]int64
    fmt.Scan(&n)

    for i := 0; i < 9; i++ {
        a[i] = n / 9
        if i != 0 && n % 9 >= i {
            a[i] += 1
        }
    }

    for i := 0; i < 9; i++ {
        for j := 0; j < 9; j++ {
            ans += a[i] * a[j] * a[i * j]
        }
    }

    for i := 1; i <= n; i++ {
        ans -= n / int64(i)
    }
    fmt.Println(ans)

    return
}


package main

import "fmt"

func main() {
    var n, ans int64
    var a [10]int64
    fmt.Scan(&n)

    for i := 0; i < 9; i++ {
        a[i] = n / 9
        if i != 0 && n % 9 >= int64(i) {
            a[i] += 1
        }
    }

    for i := 0; i < 9; i++ {
        for j := 0; j < 9; j++ {
            ans += a[i] * a[j] * a[i * j % 9]
        }
    }

    for i := 1; int64(i) <= n; i++ {
        ans -= n / int64(i)
    }
    fmt.Println(ans)

    return
}


package main

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

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

	var n int
	Fscan(in, &n)

	ans := int64(0)
	cnts := [9]int64{}
	for i := 1; i <= n; i++ {
		cnts[i%9]++
		ans -= int64(n / i)
	}
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			ans += cnts[i] * cnts[j] * cnts[i*j%9]
		}
	}
	Fprint(out, ans)
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF888E(_r io.Reader, out io.Writer) {
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}
	in := bufio.NewReader(_r)
	var n, m, ans int
	Fscan(in, &n, &m)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}

	b := a[:(n+1)/2]
	f := func(i int) int {
		s := int64(0)
		for j, v := range b {
			if i>>j&1 > 0 {
				s += v
			}
		}
		return int(s % int64(m))
	}
	x := []int{}
	for i := 0; i < 1<<len(b); i++ {
		s := f(i)
		ans = max(ans, s)
		x = append(x, s)
	}
	sort.Ints(x)
	b = a[(n+1)/2:]
	for i := 0; i < 1<<len(b); i++ {
		s := f(i)
		ans = max(ans, s)
		if j := sort.SearchInts(x, m-s); j > 0 {
			ans = max(ans, s+x[j-1])
		}
	}
	Fprint(out, ans)
}

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


//In the Name of God
//Ya Ali

package main

import "fmt"

const MOD int = 1e9 + 7

func mulInt(x, y int) int {
	return int(int64(x) * int64(y) % int64(MOD))
}

func powInt(a int, k int) (r int) {
	r = 1
	for k > 0 {
		if k % 2 == 1 {
			r = mulInt(r, a)
		}
		a = mulInt(a, a)
		k /= 2
	}
	return
}

type Matrix struct {
	n int
	m int
	a [][]int
}

func makeMat(n, m int) Matrix {
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
	}
	return Matrix{n, m, a}
}

func mulMat(a Matrix, b Matrix) (c Matrix) {
	c = makeMat(a.n, b.m)
	for i := 0; i < a.n; i ++ {
		for j := 0; j < b.m; j ++ {
			for k := 0; k < a.n; k ++ {
				c.a[i][j] = (c.a[i][j] + mulInt(a.a[i][k], b.a[k][j])) % MOD
			}
		}
	}
	return
}

func powMat(a Matrix, k int) (c Matrix) {
	c = makeMat(a.n, a.m)
	for i := 0; i < a.n; i ++ {
		c.a[i][i] = 1
	}
	for k > 0 {
		if k%2 == 1 {
			c = mulMat(c, a)
		}
		a = mulMat(a, a)
		k /= 2
	}
	return
}

func main() {
	var n, k int
	_, _ = fmt.Scan(&n, &k)

	ar := make([]int, n)

	A, a := 0, 0
	B := 0

	for i := 0; i < n; i ++ {
		_, _ = fmt.Scan(&ar[i])
		A += ar[i]
	}

	for i := 0; i < A; i ++ {
		a += ar[n - 1 - i]
	}

	B = n - A

	mat := makeMat(A + 1, A + 1)

	for i := 0; i <= A; i ++ {
		if B >= A - i {
			pls := (A - i) * (A - i)
			mns := i * (B - A + i)
			sm := n * (n - 1) / 2 - pls - mns
			if i > 0 {
				mat.a[i - 1][i] = mns
			}
			if i < A {
				mat.a[i + 1][i] = pls
			}
			mat.a[i][i] = sm
		}
	}

	mat = powMat(mat, k)
	res := makeMat(A + 1, 1)
	res.a[a][0] = 1

	res = mulMat(mat, res)

	ans := mulInt(res.a[A][0], powInt(powInt(n * (n - 1) / 2, k), MOD - 2))

	fmt.Println(ans)
}


package main

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

const (
	BIG = 1024 * 1024 * 10
)

func readLine(r *bufio.Reader) string {
	bytes, _, err := r.ReadLine()
	if err != nil {
		log.Fatalln("Failed to read line")
	}

	return string(bytes)
}

func readInts(r *bufio.Reader) []int {
	elems := strings.Fields(readLine(r))

	ret := make([]int, len(elems))
	for i, el := range elems {
		tmp, err := strconv.ParseInt(el, 10, 64)
		if err != nil {
			log.Fatalf("Failed to parse number %v", el)
		}
		ret[i] = int(tmp)
	}

	return ret
}

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

func combination(a, b int64) int64 {
	b = min(b, a-b)
	nom, denom := int64(1), int64(1)
	for b > 0 {
		nom *= a
		denom *= b
		a -= 1
		b -= 1
	}

	return nom / denom
}

func pow(a, b int64) int64 {
	ret := int64(1)
	for b > 0 {
		ret *= a
		b -= 1
	}

	return ret
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, BIG)

	n := readInts(r)[0]

	var res int64
	if n == 3 {
		res = int64(4*(n-1)) * pow(int64(3), int64(n-2))
	} else {
		res = int64(4*2*3) * pow(int64(4), int64(n-3))        // The n-block is in the beginning/end
		res += int64(4*(n-3)*3*3) * pow(int64(4), int64(n-4)) // The n-block has blocks to the left/right
	}

	fmt.Println(res)
}


package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

const MOD = 998244353
const LCM16 = 720720 // lcm(1, 2, 3, ..., 16)
const MAXK = 17

func add(a, b int) int {
	return (a + b) % MOD
}

func mul(a, b int) int {
	return int(int64(a) * int64(b) % MOD)
}

var dp [MAXK][LCM16]int
var pown [MAXK + 1]int

func main() {
	defer flush()

	var n, a0, k, ai int
	var genX, genY, genMod int64
	scan(&n, &a0, &genX, &genY, &k, &genMod)

	pown[0] = 1
	for i := 1; i <= MAXK; i++ {
		pown[i] = mul(pown[i-1], n)
	}

	ans := 0
	ai = a0
	for i := 0; i < n; i++ {
		dp[0][ai%LCM16]++
		ans = add(ans, mul(ai-ai%LCM16, mul(k, pown[k-1])))
		ai = int((int64(ai)*genX + genY) % genMod)
	}

	for i := 0; i+1 < k; i++ {
		for j := 0; j < LCM16; j++ {
			dp[i+1][j-j%(i+1)] = add(dp[i+1][j-j%(i+1)], dp[i][j])
			dp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], n-1))
		}
	}

	for j := 1; j <= k; j++ {
		for i := 0; i < LCM16; i++ {
			ans = add(
				ans,
				mul(mul(dp[j-1][i], i), pown[k-j]),
			)
		}
	}

	printf("%d\n", ans)
}


package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

const MOD = 998244353
const LCM16 = 720720 // lcm(1, 2, 3, ..., 16)
const MAXK = 17

func add(a, b int) int {
	return (a + b) % MOD
}

func mul(a, b int) int {
	return int(int64(a) * int64(b) % MOD)
}

func fpow(b, e int) int {
	r := 1
	for ; e > 0; e >>= 1 {
		if (e & 1) > 0 {
			r = mul(r, b)
		}
		b = mul(b, b)
	}
	return r
}

var dp [MAXK][LCM16]int

func main() {
	defer flush()

	var n, a0, k, ai int
	var genX, genY, genMod int64
	scan(&n, &a0, &genX, &genY, &k, &genMod)

	ans := 0
	ai = a0
	for i := 0; i < n; i++ {
		dp[0][ai%LCM16]++
		ans += mul(ai-ai%LCM16, mul(k, fpow(n, k-1)))
		ai = int((int64(ai)*genX + genY) % genMod)
	}

	for i := 0; i+1 < k; i++ {
		for j := 0; j < LCM16; j++ {
			dp[i+1][j-j%(i+1)] = add(dp[i+1][j-j%(i+1)], dp[i][j])
			dp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], n-1))
		}
	}

	for j := 1; j <= k; j++ {
		for i := 0; i < LCM16; i++ {
			ans = add(
				ans,
				mul(mul(dp[j-1][i], i), fpow(n, k-j)),
			)
		}
	}

	printf("%d\n", ans)
}


package main

import "fmt"

func nextPermutation(a []int) bool {
    i := len(a)-1
    for (i > 0) && (a[i] <= a[i-1]) { i-- }
    if (i == 0) { return false }
    j := len(a)-1
    for a[j] <= a[i-1] { j-- }
    a[j], a[i-1] = a[i-1], a[j]
    j = len(a)-1
    for i < j {
        a[i], a[j] = a[j], a[i]
        i++; j--
    }
    return true
}

func main() {
    var g [5][5]int
    a := make([]int,5)
    for i := 0; i < 5; i++ {
        a[i] = i
        for j := 0; j < 5; j++ {
            fmt.Scan(&g[i][j])
        }
    }
    max := 0
    for {
        cnt := 0
        for i := 0; i < 4; i++ {
            for j := 0; (i+j) < 4; j += 2 {
                cnt += g[a[i+j]][a[i+j+1]]+g[a[i+j+1]][a[i+j]]
            }
        }
        if max < cnt { max = cnt }
        if !nextPermutation(a) { break }
    }
    fmt.Println(max)
}


package main

import "fmt"

func check(px, py, x, y, a, b, n, m int) int {
    var anw = 100000000
    var tx = px - x; if(tx < 0) { tx = -tx;}
    var ty = py - y; if(ty < 0) { ty = -ty;}
    if(tx == 0 && ty == 0) {
        return 0;
    }
    if(x+a > n && x-a < 1) {
        return anw;
    }
    if(y+b > m && y-b < 1) {
        return anw;
    }
    if(tx/a%2 == ty/b%2) {
        if(tx/a < ty/b) {
            return ty/b;
        }
        return tx/a;
    } else {
        return anw;
    }
    return anw;
}

func main() {
    var n, m, x, y, a, b int
    fmt.Scanf("%d %d %d %d %d %d", &n, &m, &x, &y, &a, &b);
    var tmp int
    var anw = -1;
    tmp = check(n, 1, x, y, a, b, n, m);
    //fmt.Println(tmp);
    if anw == -1 || tmp < anw {
        anw = tmp;
    }
    tmp = check(1, m, x, y, a, b, n, m);
    //fmt.Println(tmp);
    if anw == -1 || tmp < anw {
        anw = tmp;
    }
    tmp = check(n, m, x, y, a, b, n, m);
    //fmt.Println(tmp);
    if anw == -1 || tmp < anw {
        anw = tmp;
    }
    tmp = check(1, 1, x, y, a, b, n, m);
    //fmt.Println(tmp);
    if anw == -1 || tmp < anw {
        anw = tmp;
    }
    if anw != -1 && anw != 100000000{
        fmt.Println(anw)
    } else {
        fmt.Println("Poor Inna and pony!")
    }
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
	sum := make([]int, n+1)
	for i := n - 1; i >= 0; i-- {
		if s[i] == ')' {
			sum[i] = sum[i+1] + 1
		} else {
			sum[i] = sum[i+1] - 1
		}
	}

	if sum[0] != 0 {
		fmt.Printf("0\n1 1\n")
		return
	}

	min := 2 * n
	total := 0
	a := 1
	b := 1

	for i := 0; i < n; i++ {
		if sum[i] < min {
			min = sum[i]
			total = 1
		} else if sum[i] == min {
			total++
		}
	}

	//fmt.Printf("%d %d\n%d %d\n", min, total, a, b)

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if s[i] == s[j] {
				continue
			}

			sub := 0
			if s[i] == ')' {
				sub = 2
			} else {
				sub = -2
			}
			cha := 0
			tmin := 2 * n
			ttotal := 0

			for k := 0; k < n; k++ {
				if k > i && k <= j {
					cha = sub
				} else {
					cha = 0
				}

				if sum[k]+cha < tmin {
					tmin = sum[k]
					ttotal = 1
				} else if sum[k]+cha == tmin {
					ttotal++
				}
			}

			if ttotal > total {
				total = ttotal
				a = i
				b = j
			}
		}
	}

	fmt.Printf("%d\n%d %d\n", total, a+1, b+1)
}


package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n int
var S []rune

func main() {
	n = ReadInt()
	S = ReadRuneSlice()

	// S[4], S[9] = S[9], S[4]
	// sub()

	ans := 0
	l, r := 0, 0
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			// 入れ替える
			S[i], S[j] = S[j], S[i]

			tmp := sub()
			if ans < tmp {
				ans = tmp
				l, r = i, j
			}

			// もとに戻す
			S[i], S[j] = S[j], S[i]
		}
	}
	fmt.Println(ans)
	fmt.Println(l+1, r+1)
}

type Char struct {
	idx int
	c   rune
}

func sub() int {
	// スタックで字句解析する
	s := make([]Char, 0, 1000)
	memo := []int{}
	for i := 0; i < n; i++ {
		r := S[i]
		char := Char{idx: i, c: r}

		if len(s) == 0 || r == '(' {
			s = append(s, char)
			continue
		}

		if r == ')' && s[len(s)-1].c == '(' {
			popped := s[len(s)-1]
			s = s[:len(s)-1]
			if len(s) == 0 || s[len(s)-1].c == ')' {
				memo = append(memo, popped.idx)
			}
		} else {
			s = append(s, char)
		}
	}

	// スタックに何も残っていないときはmemoの長さ
	if len(s) == 0 {
		return len(memo)
	}

	// 残ったカッコの数をチェック
	op, cl := 0, 0
	for i := 0; i < len(s); i++ {
		if s[i].c == '(' {
			op++
		} else {
			cl++
		}
	}
	// 数が一致しないとダメ
	if op != cl {
		return 0
	}

	l, r := 0, 0
	for i := 0; i < len(s); i++ {
		if s[i].c == '(' {
			r = s[i].idx
			break
		}
	}
	for i := len(s) - 1; i >= 0; i-- {
		if s[i].c == ')' {
			l = s[i].idx
			break
		}
	}

	// fmt.Println(memo)
	// for i := 0; i < len(s); i++ {
	// 	fmt.Printf("%d: %c\n", s[i].idx, s[i].c)
	// }
	// fmt.Printf("lidx: %d, ridx: %d\n", l, r)

	ans := 0
	for i := 0; i < len(memo); i++ {
		if l < memo[i] && memo[i] <= r {
			ans++
		}
	}

	return ans + 1
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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


package main
import (
    "fmt"
    "sort"
)

type Trie struct {
    x, i, v int
}

var n, m int

type Tries []*Trie
var P Tries
func (s Tries) Len() int      { return len(s) }
func (s Tries) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

type ByPos struct {Tries}
func (s ByPos) Less(i, j int) bool { return s.Tries[i].i < s.Tries[j].i}

type ByVal struct {Tries}
func (s ByVal) Less(i, j int) bool { return s.Tries[i].x < s.Tries[j].x}

func main(){
    fmt.Scanf("%d %d", &n, &m)
    P = make([]*Trie, n)
    for i := range P {
        P[i] = new(Trie)
        fmt.Scan(&P[i].x)
        P[i].i = i
    }
    sort.Sort(ByVal{P})
    for i, p := range P {
        p.v = i % 2
    }
    sort.Sort(ByPos{P})
    for _, p := range P {
        fmt.Print(p.v, " ")
    }
}


package main

import "fmt"

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


package main
import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
)

func main() {
	var a,b,c,d int
	fmt.Scan(&a,&b,&c)
	d=c*b+(a-1)*b+(c-1)*(a-1)
	fmt.Println(d)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1030C(_r io.Reader, out io.Writer) {
	var n, s int
	var a []byte
	Fscan(bufio.NewReader(_r), &n, &a)
o:
	for i, v := range a[:n-1] {
		s += int(v & 15)
		for j := i + 1; j < n; {
			s2 := int(a[j] & 15)
			for j++; j < n && (s2 < s || s2 == s && a[j] == '0'); j++ {
				s2 += int(a[j] & 15)
			}
			if s2 != s {
				continue o
			}
		}
		Fprintln(out, "YES")
		return
	}
	Fprintln(out, "NO")
}

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


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/128/A

package main

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

type Position struct {
	X int
	Y int
}

type Node struct {
	Position Position
	Time     int
}

func getNeighbors(p Position) []Position {
	var validNeighbors []Position
	for i := -1; i <= 1; i++ {
		for j := -1; j <= 1; j++ {
			x := p.X + i
			y := p.Y + j
			if 0 <= x && x < 8 && 0 <= y && y < 8 {
				validNeighbors = append(validNeighbors, Position{X: x, Y: y})
			}
		}
	}
	return validNeighbors
}

func hasStatue(board [8]string, p Position, time int) bool {
	if 0 <= p.X-time && p.X-time < 8 {
		if string(board[p.X-time][p.Y]) == "S" {
			return true
		}
	}
	if 0 <= p.X-time-1 && p.X-time-1 < 8 {
		if string(board[p.X-time-1][p.Y]) == "S" {
			return true
		}
	}
	return false
}

func Solve(board [8]string) string {
	stack := []Node{{Position: Position{X: 7, Y: 0}, Time: 0}}
	for {
		currentNode := stack[len(stack)-1]
		stack = stack[:len(stack)-1]
		if currentNode.Time == 8 || currentNode.Position.X == 0 {
			return "WIN"
		}
		for _, neighbor := range getNeighbors(currentNode.Position) {
			if !hasStatue(board, neighbor, currentNode.Time) {
				stack = append(stack, Node{Position: neighbor, Time: currentNode.Time + 1})
			}
		}
		if len(stack) == 0 {
			break
		}
	}
	return "LOSE"
}

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

	var board [8]string
	for i := 0; i < 8; i++ {
		fmt.Fscanf(reader, "%s\n", &board[i])
	}
	fmt.Fprintf(writer, "%s\n", Solve(board))
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/128/A

package main

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

type Position struct {
	X int
	Y int
}

type Node struct {
	Maria Position
	Time  int
}

func getNeighbors(p Position) []Position {
	neighbors := []Position{
		{X: p.X - 1, Y: p.Y - 1},
		{X: p.X - 1, Y: p.Y},
		{X: p.X - 1, Y: p.Y + 1},
		{X: p.X, Y: p.Y - 1},
		{X: p.X, Y: p.Y},
		{X: p.X, Y: p.Y + 1},
		{X: p.X + 1, Y: p.Y - 1},
		{X: p.X + 1, Y: p.Y},
		{X: p.X + 1, Y: p.Y + 1},
	}
	var validNeighbors []Position
	for _, neighbor := range neighbors {
		if 0 <= neighbor.X && neighbor.X < 8 && 0 <= neighbor.Y && neighbor.Y < 8 {
			validNeighbors = append(validNeighbors, neighbor)
		}
	}
	return validNeighbors
}

func hasStatue(board [8]string, p Position, time int) bool {
	if 0 <= p.X-time && p.X-time < 8 {
		if string(board[p.X-time][p.Y]) == "S" {
			return true
		}
	}
	if 0 <= p.X-time-1 && p.X-time-1 < 8 {
		if string(board[p.X-time-1][p.Y]) == "S" {
			return true
		}
	}
	return false
}

func Solve(board [8]string) string {
	stack := []Node{{Maria: Position{X: 7, Y: 0}, Time: 0}}
	for {
		currentNode, stack := stack[len(stack)-1], stack[:len(stack)-1]
		if currentNode.Time == 8 || currentNode.Maria.X == 0 {
			return "WIN"
		}
		for _, neighbor := range getNeighbors(currentNode.Maria) {
			if !hasStatue(board, neighbor, currentNode.Time) {
				stack = append(stack, Node{Maria: neighbor, Time: currentNode.Time + 1})
			}
		}
		if len(stack) == 0 {
			break
		}
	}
	return "LOSE"
}

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

	var board [8]string
	for i := 0; i < 8; i++ {
		fmt.Fscanf(reader, "%s\n", &board[i])
	}
	fmt.Fprintf(writer, "%s\n", Solve(board))
}


package main

import "fmt"

func genCount(t string, target map[int]int)  {
	for _,ch := range t{
		target[int(ch-'0')]++
	}
	target[2] += target[5]
	target[6] += target[9]
	delete(target,5)
	delete(target,9)
}

func main()  {
	var t,seq string
	fmt.Scan(&t,&seq)
	target := make(map[int]int)
	source := make(map[int]int)
	genCount(t,target)
	genCount(seq,source)
	var cnt int = 200
	for k,_ := range target{
		if target[k] == 0 {continue}
		if cnt > source[k]/target[k] {cnt = source[k]/target[k]}
	}
	fmt.Println(cnt)
}


package main
import "fmt"

func main(){
    var s string
    fmt.Scan(&s)
    fmt.Println(len(s)*25+26)
}


package main

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

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var s string

func main() {
	fmt.Fscan(reader, &s)
	m := make(map[string]int)
	for i := 0; i <= len(s); i++ {
		for j := 0; j < 26; j++ {
			t := s[0:i] + string(j+'a') + s[i:len(s)]
			m[t] = 1
		}
	}
	fmt.Println(len(m))
}


package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scan(&n)
	if n <= 5 {
		if n == 2 || n == 5 {
			fmt.Println("1")
		} else {
			fmt.Println("0")
		}
		return
	}
	lvl0 := (n - 2) / 3
	free := (n - 2) % 3
	have := int64(0)
	if free == 0 {
		have = 0
	} else if free == 2 {
		have = 1
	} else {
		lvl0 -= 2
		if lvl0 < 2 {
			fmt.Println("0")
			return
		}
		have = 2
	}
	ret := 1
	for {
		lvl0 -= have
		have++
		lvl0 -= have
		have++
		lvl0 -= have
		have++
		lvl0 -= 2
		if lvl0 < have {
			break
		}
		ret++
	}
	fmt.Println(ret)
}


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

func main() {
    var n int64
    fmt.Scan(&n)
    for a := int64(1); ; a *= 3 {
        if (n%a) != 0 {
            fmt.Println((n/a)+1)
            break
        }
    }
}


package main
import (
	"fmt"
)
func main() {
	var n int64
	fmt.Scan(&n)
	for ;n%3==0; {
		n/=3
	}
	fmt.Println(n/3+1)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadBytes('\n')
	var n, k uint64
	pos := readUint64(s, 0, &n)
	readUint64(s, pos+1, &k)

	fmt.Println(solve(int(n), int64(k)))
}

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

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

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

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

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

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

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

	return i
}

const N = 50

var s [N + 1]int

var dp [N + 1][2][2]int64

func solve(n int, k int64) string {
	nPrefix := n>>1 + n&1

	for i := 0; i <= n; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				dp[i][j][k] = -1
			}
		}
		s[i] = 0
	}

	rem := k + 1
	var found bool

	for prefix := 0; prefix < 1<<nPrefix; prefix++ {
		if prefix > 0 {
			i := nPrefix - 1
			for i >= 0 {
				if s[i] == 0 {
					s[i] = 1
					break
				}
				s[i] = 0
				i--
			}

			for j := n - nPrefix; j <= n-1-i; j++ {
				dp[j][0][0] = -1
				dp[j][0][1] = -1
				dp[j][1][0] = -1
				dp[j][1][1] = -1
			}
		}

		//firstPos := nPrefix
		less, lessRev := 1, 1
		if n&1 == 1 && s[nPrefix-1] == 1 {
			lessRev = 0
		}
		tmp := f(n, nPrefix, less, lessRev)

		if tmp < rem {
			rem -= tmp
		} else {
			found = true
			break
		}
	}

	if !found {
		return "-1"
	}

	less, lessRev := 1, 1
	if n&1 == 1 && s[nPrefix-1] == 1 {
		lessRev = 0
	}

	for pos := nPrefix; pos < n; pos++ {
		nextLess, nextLessRev := less, lessRev
		if 0 < s[n-1-pos] {
			nextLess = 0
		}
		if 1 > s[n-1-pos] {
			nextLessRev = 1
		}

		tmp := f(n, pos+1, nextLess, nextLessRev)

		if tmp >= rem {
			s[pos] = 0
			less, lessRev = nextLess, nextLessRev
			continue
		}

		rem -= tmp
		s[pos] = 1
		if 1 > s[n-1-pos] {
			less = 1
		}
		if 0 < s[n-1-pos] {
			lessRev = 0
		}
	}
	var buf bytes.Buffer
	for i := 0; i < n; i++ {
		if s[i] == 0 {
			buf.WriteByte('0')
		} else {
			buf.WriteByte('1')
		}
	}
	return buf.String()
}

func f(n int, pos int, less int, lessRev int) int64 {
	if dp[pos][less][lessRev] != -1 {
		return dp[pos][less][lessRev]
	}
	if pos >= n {
		dp[pos][less][lessRev] = int64(less & lessRev)

		return dp[pos][less][lessRev]
	}

	var ret int64

	for i := 0; i <= 1; i++ {
		nextLess := less
		nextLessRev := lessRev
		if i > s[n-1-pos] {
			nextLess = 1
		} else if i < s[n-1-pos] {
			nextLess = 0
		}
		if 1-i > s[n-1-pos] {
			nextLessRev = 1
		} else if 1-i < s[n-1-pos] {
			nextLessRev = 0
		}
		ret += f(n, pos+1, nextLess, nextLessRev)
	}

	dp[pos][less][lessRev] = ret
	return ret
}


// A1. Good Matrix Elements
/*
The Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, where n is odd. The Smart Beaver considers the following matrix elements good:

    Elements of the main diagonal.
    Elements of the secondary diagonal.
    Elements of the "middle" row — the row which has exactly rows above it and the same number of rows below it.
    Elements of the "middle" column — the column that has exactly columns to the left of it and the same number of columns to the right of it.

The figure shows a 5 × 5 matrix. The good elements are marked with green.

Help the Smart Beaver count the sum of good elements of the given matrix.

Input
The first line of input data contains a single odd integer n. Each of the next n lines contains n integers a ij (0 ≤ a ij ≤ 100) separated by single spaces — the elements of the given matrix.

The input limitations for getting 30 points are:

    1 ≤ n ≤ 5

The input limitations for getting 100 points are:

    1 ≤ n ≤ 101

Output
Print a single integer — the sum of good matrix elements.

Examples
Input
3
1 2 3
4 5 6
7 8 9

Output
45

Input
5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

Output
17

Note
In the first sample all matrix elements will be good. Good elements in the second sample are shown on the figure.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	total := 0
	for i := 0; i < n; i++ {
		input2, _ := reader.ReadString('\n')
		for j := 0; j < n; j++ {
			arr := strings.Split(strings.TrimSpace(input2), " ")
			x, _ := strconv.Atoi(arr[j])
			if i == j {
				total += x
			} else if i+j == n-1 {
				total += x
			} else if j == (n-1)/2 {
				total += x
			} else if i == (n-1)/2 {
				total += x
			}
		}
	}
	fmt.Print(total)
}


package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math/big"
	"math/bits"
	"os"
)

func solve(n, x uint64) uint64 {
	if x > n {
		return 0
	}

	res := uint64(1)
	if x % 2 == 0 {
		res += solve(n, x + 1)
	}

	xlen := bits.Len64(x)
	nlen := bits.Len64(n)

	nx := x << (nlen - xlen)

	if nlen > xlen {
		res += (uint64(1) << (nlen - xlen)) - 2
	}

	if nx <= n && nlen > xlen {
		if n >> (nlen - xlen) == x {
			res += n - nx + 1
		} else {
			res += uint64(1) << (nlen - xlen)
		}
	}

	return res
}

func solveStupid(n, x uint64) uint64 {
	if x > n {
		return 0
	}

	res := uint64(1)
	if x % 2 == 0 {
		res += solveStupid(n, x + 1)
	}
	res += solveStupid(n, x * 2)

	return res
}

func main() {
	defer writer.Flush()

	n, k := uint64(NextInt64()), uint64(NextInt64())

	x := uint64(1)
	l := 0
	for ; solve(n, x * 2) >= k; x *= 2 {
		l++
	}

	for i := 0; i < l; i++ {
		if solve(n, x + (uint64(1) << (l - i - 1))) >= k {
			x += uint64(1) << (l - i - 1)
		}
	}

	println(x)
}

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

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

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

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

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

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}

func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func AbsInt64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

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

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

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


package main

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

var scanner *bufio.Scanner

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

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

  s := getS()
  n := len(s)
  for i := range s {
    if s[i] == '.' {
      continue
    }
    jump := 0
    for {
      jump++
      if i + 4*jump >= n {
        break
      }
      okay := true
      for j := 1; j <= 4; j++ {
        if s[i+j*jump] == '.' {
          okay = false
          break
        }
      }
      if okay {
        writer.WriteString("yes\n")
        return
      }
    }
  }
  writer.WriteString("no\n")
}


package main

/*
	To solve this problem basically we just need to generate login
	string which alphabetically earliest than any other string login string.

	The rules to generate login string are following:
	- must concatenate prefix of user's first name & last name
	- each prefix must not be empty
	- any prefix can be full name

	A string is said alphabetically earlier than other string if:
	- string is prefix of other string (ab >< abc, ab is earlier)
	- string is coincide up to some point with another
	  string then string has char which alphabetically earlier than
	  corresponding letter in another string (a >< ab >< ac => a < ab < ac)

	Notice that the minimum string we can generate is first[0] + last[0], yet
	with only this we already got decent enough early string. But can we make
	this string much earlier?

	Yes! If all char in first[1:] is alphabetically earlier than last[0]. So yeah,
	basically we just need to get all chars in first name which earlier than last[0],
	then combine them into a string.
*/

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

func main() {
	var first, second string
	stdio := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdio, "%s %s", &first, &second)
	idx := 1
	for i := 1; i < len(first); i++ {
		if first[i] < second[0] {
			idx++
		} else {
			break
		}
	}
	fmt.Println(first[:idx] + "" + second[:1])
}


package main

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

func main() {
	var first, second string
	stdio := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdio, "%s %s", &first, &second)
	idx := 1
	for i := 1; i < len(first); i++ {
		if first[i] < second[0] {
			idx++
		} else {
			break
		}
	}
	fmt.Println(first[:idx] + "" + second[:1])
}


package main
import (
	"fmt"
)
func divisors(n int) int{
	c:= 1
	for d:=2; d<100; d++{
		if (n % d == 0){
			alpha := 0;
			for ;n % d == 0; {
				n /= d
				alpha++
			}
			c *= (alpha + 1)
		}
	}
	return c
}

func main() {
	var sum , al, bl, cl int
	sum=0
	fmt.Scan(&al,&bl,&cl)
	for a := 1; a <= al; a++{
		for b := 1; b <= bl; b++{
			for c := 1; c <= cl; c++{
				sum += divisors(a*b*c);
				sum %= 1073741824;
			}
		}
	}
	fmt.Println(sum)
}


package main

import (
    "fmt"
)

func main() {
    var s string
    fmt.Scanln(&s)
    res := 0
    for i, c := range s {
        if c >= 'a' && c <= 'z' {
            res = res - int(s[i]-'a') - 1
        }
        if c >= 'A' && c <= 'Z' {
            res = res + int(s[i]-'A') + 1
        }
    }
    fmt.Println(res)
}


package main

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

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

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

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

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

	idx := max(a[1:]) + 1

	for a[0] <= a[idx] {
		a[0]++
		a[idx]--
		bribe++
		// println(idx, a, bribe)
		idx = max(a[1:]) + 1
	}

	println(bribe)
}

func max(a []int) int {
	idx := 0

	for i := range a {
		if a[i] > a[idx] {
			idx = i
		}
	}

	return idx
}

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

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

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

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

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

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


package main

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

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

	votes := make([]int, n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		votes[i] = a
	}

	bubble_sort(votes, 1, n)

	bribing := 0
	for votes[0] <= votes[1] {
		votes[0]++
		votes[1]--
		bribing++
		if len(votes) > 2 {
			for i := 2; i < n && votes[i-1] < votes[i]; i++ {
				swap(i-1, i, votes)
			}
		}
	}
	fmt.Println(bribing)
}

func swap(a, b int, array []int) {
	array[a], array[b] = array[b], array[a]
}

func bubble_sort(array []int, start, end int) {
	for i := start; i < end; i++ {
		for j := start; j < end; j++ {
			if array[i] > array[j] {
				swap(i, j, array)
			}
		}
	}
}


package main

import (
  "fmt"
)

func main() {
  var total, downloaded, q float64
  fmt.Scanf("%f %f %f", &total, &downloaded, &q)

  var listened = 0.0
  var ans = 0

  for {
    ans++

    var t = (downloaded - listened) * q
    if t >= total {
      break
    } else {
      downloaded = t
      listened = 0
    }
  }

  fmt.Println(ans)
}


package main

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

func check(n, m int, matrix [][]int) (bool, int, int, int, int) {
	legalRow := []int{}
	legalCol := []int{}
	for i := 0; i <= n-3; i++ {
		for j := 0; j <= m-3; j++ {
			var p [16]bool
			k := matrix[i][j] >> 4
			pFailed, kFailed := false, false

			for r := 0; r < 3; r++ {
				for c := 0; c < 3; c++ {
					pm, km := matrix[i+r][j+c]&0xf, matrix[i+r][j+c]>>4
					if p[pm] {
						pFailed = true
					}
					if k != km {
						kFailed = true
					}
					p[pm] = true
				}
			}
			if !pFailed || !kFailed {
				legalRow = append(legalRow, i)
				legalCol = append(legalCol, j)
			}
		}
	}

	for i := 0; i < len(legalRow); i++ {
		for j := i + 1; j < len(legalRow); j++ {
			if legalRow[j]-legalRow[i] >= 3 || legalCol[j]-legalCol[i] >= 3 {
				return true, legalRow[i], legalCol[i], legalRow[j], legalCol[j]
			}
		}
	}
	return false, 0, 0, 0, 0
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewReader(bs)
	cards := make([]bool, 64)

	pointByte := [14]byte{'0', 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'}
	kindByte := [4]byte{'C', 'D', 'H', 'S'}
	point := map[byte]int{
		'A': 1,
		'2': 2,
		'3': 3,
		'4': 4,
		'5': 5,
		'6': 6,
		'7': 7,
		'8': 8,
		'9': 9,
		'T': 10,
		'J': 11,
		'Q': 12,
		'K': 13,
	}
	kind := map[byte]int{
		'C': 0,
		'D': 1,
		'H': 2,
		'S': 3,
	}
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	matrix := make([][]int, n)
	j1, j2 := false, false
	var j1Row, j1Col, j2Row, j2Col int
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, m)
		for j := 0; j < m-1; j++ {
			var s string
			fmt.Fscanf(reader, "%s ", &s)
			if s == "J1" {
				j1, j1Row, j1Col = true, i, j
			} else if s == "J2" {
				j2, j2Row, j2Col = true, i, j
			} else {
				matrix[i][j] = point[s[0]] + (kind[s[1]] << 4)
				cards[matrix[i][j]] = true
			}
		}
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		if s == "J1" {
			j1, j1Row, j1Col = true, i, m-1
		} else if s == "J2" {
			j2, j2Row, j2Col = true, i, m-1
		} else {
			matrix[i][m-1] = point[s[0]] + (kind[s[1]] << 4)
			cards[matrix[i][m-1]] = true
		}
	}
	for i := 0; i < 4; i++ {
		cards[i<<4] = true
		cards[(i<<4)+14] = true
		cards[(i<<4)+15] = true
	}
	for i := 0; i < 64; i++ {
		for j := 0; j < 64; j++ {
			if i == j || cards[i] || cards[j] {
				continue
			}
			if j1 {
				matrix[j1Row][j1Col] = i
			}
			if j2 {
				matrix[j2Row][j2Col] = j
			}
			if ok, r0, c0, r1, c1 := check(n, m, matrix); ok {
				fmt.Printf("Solution exists.\n")
				if j1 && !j2 {
					fmt.Printf("Replace J1 with %c%c.\n", pointByte[i&0xf], kindByte[i>>4])
				}
				if j2 && !j1 {
					fmt.Printf("Replace J2 with %c%c.\n", pointByte[j&0xf], kindByte[j>>4])
				}
				if !j1 && !j2 {
					fmt.Printf("There are no jokers.\n")
				}
				if j1 && j2 {
					fmt.Printf("Replace J1 with %c%c and J2 with %c%c.\n", pointByte[i&0xf], kindByte[i>>4], pointByte[j&0xf], kindByte[j>>4])
				}
				fmt.Printf("Put the first square to (%d, %d).\n", r0+1, c0+1)
				fmt.Printf("Put the second square to (%d, %d).\n", r1+1, c1+1)
				return
			}
		}
	}
	fmt.Printf("No solution.")
}


package main

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

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()
	k := scanInt(scanner)
	scanner.Scan()
	s := scanner.Text()
	n := len(s)
	pal := make([]int, n)
	for i, ch := range s {
		pal[i] = int(ch)
	}
	for i := (n-1)/2; i >= 0; i-- {
		j := n-1-i
		if pal[i] == pal[j] {
			continue
		}
		if pal[i] == '?' {
			pal[i] = pal[j]
		} else if pal[j] == '?' {
			pal[j] = pal[i]
		} else {
			writer.WriteString("IMPOSSIBLE\n")
			return
		}
	}
	seen := map[int]bool{}
	for i := 0; i < k; i++ {
		seen['a'+int(i)] = false
	}
	for _, ch := range pal {
		if ch != '?' {
			seen[ch] = true
		}
	}
	need := []int{}
	for ch, ok := range seen {
		if !ok {
			need = append(need, ch)
		}
	}
	sort.Ints(need)
	/*
	for _, ch := range pal {
		writer.WriteString(fmt.Sprintf("%c", ch))
	}
	writer.WriteString(fmt.Sprintf(" (k = %d)\n", k))
	writer.WriteString(fmt.Sprintf("need %d:", len(need)))
	for _, ch := range need {
		writer.WriteString(fmt.Sprintf(" %c", ch))
	}
	writer.WriteString("\n")
	*/
	nix := len(need)-1
	for i := (n-1)/2; i >= 0; i-- {
		if pal[i] != '?' {
			continue
		}
		j := n-1-i
		if nix == -1 {
			pal[i] = 'a'
			pal[j] = 'a'
		} else {
			pal[i] = need[nix]
			pal[j] = need[nix]
			nix--
		}
	}
	if nix != -1 {
		writer.WriteString("IMPOSSIBLE\n")
		return
	}
	for _, ch := range pal {
		writer.WriteString(fmt.Sprintf("%c", ch))
	}
	writer.WriteString("\n")
}


package main

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

var arr [][]int64

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

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

	var n, m, a, b int
	var g, x, y, z int64
	fmt.Fscanf(reader, "%d %d %d %d\n", &n, &m, &a, &b)
	fmt.Fscanf(reader, "%d %d %d %d\n", &g, &x, &y, &z)
	arr = make([][]int64, n)
	for i := 0;i < n;i ++ {
		arr[i] = make([]int64, m)
		for j := 0;j < m;j ++ {
			arr[i][j] = g
			g = (g * x + y) % z
		}
	}
	var ax, bx int
	for bx = 2;bx <= b;bx <<= 1 {
		for i := 0;i < n;i ++ {
			for j := 0;j <= m - bx;j ++ {
				arr[i][j] = min(arr[i][j], arr[i][j + bx / 2])
			}
		}
	}
	for ax = 2;ax <= a;ax <<= 1 {
		for i := 0;i <= n - ax;i ++ {
			for j := 0;j < m;j ++ {
				arr[i][j] = min(arr[i][j], arr[i + ax / 2][j])
			}
		}
	}
	ax, bx = ax / 2, bx / 2
	var res int64 = 0
	for i := 0;i <= n - a;i ++ {
		for j := 0;j <= m - b;j ++ {
			di, dj := i + a, j + b
			res += min(min(arr[i][j], arr[di - ax][j]), min(arr[i][dj - bx], arr[di - ax][dj - bx]))
		}
	}
	fmt.Printf("%d", res)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	i:=0.0
	fmt.Scanln(&i)
	c:=math.Log2(i)
	d:=float64(int(c))
	if c-d<0.000001 {
		fmt.Println("YES")
	}else {
		fmt.Println("NO")
	}
}


package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, total := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &total)
	t := make([]int, n)
	g := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &t[i], &g[i])
		sum += t[i]
	}
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if t[i] < t[j] {
				t[i], t[j] = t[j], t[i]
				g[i], g[j] = g[j], g[i]
			}
		}
	}
	help(0, n, total, t, g, 0, 0, 0, 0, sum)
	fmt.Fprintf(out, "%d\n", ans)
	return
}

func help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {
	//fmt.Println(i, cur)
	if i == n {
		if cur == total {
			cal(c1, c2, c3)
		}
		return
	}
	if cur > total {
		return
	}
	if cur+remaining < total {
		return
	}
	switch g[i] {
	case 1:
		help(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])
	case 2:
		help(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])
	case 3:
		help(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])
	}
	help(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}


package main

import "fmt"

const (
	MaxSum = 10005
	MaxNums = 101
	Type = 2
	Same = 0
	Different = 1
)

var n int
var a [MaxNums]int
var dp[MaxSum][MaxNums][Type]bool

func computeDp() {
	dp[a[0]][1][Same] = true
	for i := 1; i < n; i++ {
		for s := MaxSum - 1; s >= 0; s-- {
			for cnt := 1; cnt <= i; cnt++ {
				if dp[s][cnt][Same] {
					k := s / cnt
					if k == a[i] {
						dp[s+k][cnt+1][Same] = true
					} else {
						dp[s+a[i]][cnt+1][Different] = true
					}
				}
				if dp[s][cnt][Different] {
					dp[s+a[i]][cnt+1][Different] = true
				}
			}
		}
		dp[a[i]][1][Same] = true
	}
}

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

	if len(counter) == 2 {
		fmt.Println(n)
		return
	}

	computeDp()

	best := 1
	for weight := range counter {
		for count := 1; count <= counter[weight]; count++ {
			if dp[weight*count][count][Same] && !dp[weight*count][count][Different] && best < count {
				best = count
			}
		}
	}
	fmt.Println(best)
}


package main

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

var scanner *bufio.Scanner

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

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

  s := getS()
  n := len(s)
  max := 0
  seen := map[string]bool{}
  for i := 0; i < n; i++ {
    for j := i+1; j <= n; j++ {
      if seen[s[i:j]] && j-i > max {
        max = j-i
      }
      seen[s[i:j]] = true
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", max))
}