package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

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

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	h += 1
	if a == 0 {
		return 1
	}
	if b == 0 {
		if a >= h {
			return 1
		}
		return 0
	}
	p := 0
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var a1,b1,c1,a2,b2,c2 int
	fmt.Fscanf(reader, "%d %d %d\n", &a1, &b1, &c1)
	fmt.Fscanf(reader, "%d %d %d", &a2, &b2, &c2)

	if a1 * b2 - a2 * b1 != 0 {
		fmt.Printf("1")
	} else if a1 * c2 - a2 * c1 == 0 {
		fmt.Printf("-1")
	} else {
		fmt.Printf("0")
	}
	return
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var a1,b1,c1,a2,b2,c2 int
	fmt.Fscanf(reader, "%d %d %d\n", &a1, &b1, &c1)
	fmt.Fscanf(reader, "%d %d %d", &a2, &b2, &c2)

	if a1 * b2 - a2 * b1 != 0 {
		fmt.Printf("1")
	} else if a1 * c2 - a2 * c1 == 0 && b1 * c2 - b2 * c1 == 0{
		if a1 == 0 && a2 == 0 && b1 == 0 && b2 == 0 && (c1 != 0 || c2 != 0) {
			fmt.Printf("0")
		} else {
			fmt.Printf("-1")
		}
	} else {
		fmt.Printf("0")
	}
	return
}


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 gcd(a, b int) int {
  sign := 1
  if a < 0 {
    a = -a
    sign = -sign
  }
  if b < 0 {
    b = -b
    sign = -sign
  }
  for b != 0 {
    a, b = b, a%b
  }
  return sign*a
}

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

  result := 0
  a1, b1, c1 := getI(), getI(), getI()
  a2, b2, c2 := getI(), getI(), getI()
  g1, g2 := gcd(a1, b1), gcd(a2, b2)
  a1, b1, a2, b2 = a1/g1, b1/g1, a2/g2, b2/g2
  if a1 == a2 && b1 == b2 {
    if c1 == c2 {
      result = -1
    }
  } else {
    result = 1
  }

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


package main

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

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

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


// Find all the positive integers that smaller than k that divides n, can calc the result from there.
package main

import (
	"fmt"
	"math"
)

func main() {
	n, k, best := 0, 0, math.MaxInt32
	fmt.Scan(&n, &k)

	for modRes := 1; modRes < k; modRes++ {
		if n%modRes != 0 {
			continue
		}

		divRes := n / modRes
		potentialNum := divRes*k + modRes

		if potentialNum < best {
			best = potentialNum
		}
	}

	fmt.Println(best)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, k := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &k)
	ans := -1
	for i := 1; i <= n; i++ {
		if n%i == 0 {
			a := i
			b := n / i
			if b >= k {
				continue
			}
			x := a*k + b
			if x < ans || ans == -1 {
				ans = x
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}


package main

import "fmt"

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

	lo, hi := int64(0), n*m
	largest := int64(0)
	for lo <= hi {
		mid := (lo + hi) / 2

		count := int64(0)
		for i := int64(1); i <= n; i++ {
			x := min(m, mid/i)
			count += x
		}

		if count < k {
			largest = mid
			lo = mid + 1
		} else {
			hi = mid - 1
		}
	}

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

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


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	var i int

	fmt.Scanf("%d", &i)
	for i := 1; i < 1001; i++ {
		s += strconv.Itoa(i)
	}
	fmt.Println(string(s[i-1]))
}


package main

import (
         "fmt"
       )

func splitToDigits(n int) []int {
    var a []int = make([]int, 0)
    for n > 0 {
        a = append(a, n%10)
        n = n/10
    }
    return a
}

func main() {
    var n int
    fmt.Scanf("%v\n", &n)
    pos := 0
    for q := 1; q <= n; q++ {
        a := splitToDigits(q)
        pos += len(a)
        //fmt.Printf("%v %v\n", pos, a)
        if pos == n {
            fmt.Printf("%v", a[0])
            return
        } else if pos > n {
            for i := 0; i < len(a); i++ {
                pos -= 1
                if pos == n-1 {
                    fmt.Printf("%v", a[i])
                    return
                }
            }
        }
    }
}


package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

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

func main() {
	defer w.Flush()
	var n int
	s := ""
	for i := 1; i < 1001; i++ {
		s += strconv.Itoa(i)
	}
	for I(&n, "\n") == nil {
		O(string(s[n-1]), "\n")
	}
}


package main

import "fmt"
import "strconv"

func main() {
    var n int
    fmt.Scan(&n)
    str := "0"
    for i:=1; i<=n; i++{
        s := strconv.Itoa(i)
        str += s
    }
    fmt.Print(str[n])
}


package main

import "fmt"
import "strconv"

func main() {
    var n int
    fmt.Scan(&n)
    str := "0"
    for i:=1; i<=n; i++{
        s := strconv.Itoa(i)
        str += s
    }
    fmt.Println(str)
    fmt.Printf("%d", str[n])
}


package main

import "fmt"
import "strconv"

func main() {
    var n int
    fmt.Scan(&n)
    str := "0"
    for i:=1; i<=n; i++{
        s, _ := strconv.Itoa(i)
        str += s
    }
    fmt.Print(str[n])
}


package main

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

func main() {
	var n, i uint
	input := bufio.NewScanner(os.Stdin)
	//input.Split(bufio.ScanWords)
	scanInt := func() int {
		input.Scan()
		number, _ := strconv.Atoi(input.Text())
		return number
	}
	n = uint(scanInt())
	aa := make([]int, n)
	for i = 0; i < n; i++ {
		aa[i] = scanInt()
	}
	for b := 0; b < (1 << n); b++ {
		sum := 0
		for i = 0; i < n; i++ {
			if b & (1 << i) != 0 {
				sum += aa[i]
				} else { sum -= aa[i] }
		}
		if sum % 360 == 0 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

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

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

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


// https://codeforces.com/problemset/problem/1097/B

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var n int64
	scanf("%d\n", &n)
	arr := make([]int64, n)

	for i:=int64(0);i<n;i++ {
		var temp int64
		scanf("%d\n", &temp)
		arr[i] = temp
	}

	for i:=int64(0);i<(int64(1) << n);i++ {
		sum := int64(0)
		for j:=int64(0);j<n;j++ {
			if i & (int64(1) << j) != 0 {
				sum += arr[j]
			} else {
				sum -= arr[j]
			}
		}

		if sum % 360 == 0 {
			printf("%s\n", "YES")
			return
		}
	}

	printf("%s\n", "NO")
}


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanInt := func() int {
		scanner.Scan()
		num, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		return num
	}

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

	solutionCount := uint(math.Pow(2.0, float64(n)))
	for i := uint(0); i < solutionCount; i++ {
		sum := 0
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				sum += a[j]
			} else {
				sum -= a[j]
			}
		}
		if sum%360 == 0 {
			fmt.Println("YES")
			os.Exit(0)
		}
	}

	fmt.Println("NO")
}


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 main() {
	r := bufio.NewReaderSize(os.Stdin, BIG)

	n := readInts(r)[0]

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

	coll := make(map[int]bool)
	coll[0] = true
	for _, ai := range ais {
		nColl := make(map[int]bool)
		for el, _ := range coll {
			nColl[el-ai] = true
			nColl[el+ai] = true
		}
		coll = nColl
	}
	for el, _ := range coll {
		if el%360 == 0 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, x, y, xp, yp, steps int

	fmt.Scan(&r, &x, &y, &xp, &yp)

	distanceSquare := (xp-x)*(xp-x) + (yp-y)*(yp-y)

	if distanceSquare%((2*r)*(2*r)) == 0 {
		steps = int(math.Sqrt(float64(distanceSquare))) / (2 * r)
	} else {
		steps = (int(math.Sqrt(float64(distanceSquare))) + 2*r) / (2 * r)
	}

	fmt.Println(steps)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, x, y, xp, yp int

	fmt.Scan(&r, &x, &y, &xp, &yp)

	fmt.Println((int(math.Ceil(math.Sqrt(float64(
		(xp-x)*(xp-x)+(yp-y)*(yp-y))))) + r*2 - 1) / (r * 2))
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, x, y, xp, yp, steps int

	fmt.Scan(&r, &x, &y, &xp, &yp)

	distanceSquare := (xp-x)*(xp-x) + (yp-y)*(yp-y)

	steps = (int(math.Ceil(math.Sqrt(float64(distanceSquare)))) + 2*r - 1) / (2 * r)

	fmt.Println(steps)
}


package main

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

var scanner *bufio.Scanner

func getI() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
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()

  r, x1, y1, x2, y2 := getI(), getI(), getI(), getI(), getI()
  d := math.Sqrt(float64((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))
  result := int(math.Ceil(d / float64(2*r)))
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import "fmt"

func main() {
	var r, x, y, nx, ny int64
	fmt.Scanf("%d %d %d %d %d", &r, &x, &y, &nx, &ny)
	s := (x-nx)*(x-nx) + (y-ny)*(y-ny)
	r *= 2
	var i int64
	for i = 0; i*i*r*r < s; i++ {

	}
	fmt.Println(i)
}


package main

import (
	"fmt"
	m "math"
)

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

	var distance = m.Sqrt(m.Abs(float64(x-x_dash))*m.Abs(float64(x-x_dash)) +
		m.Abs(float64(y-y_dash))*m.Abs(float64(y-y_dash)))
	var moves = int(distance / (float64(2 * r)))
	if distance-float64(moves*r*2) > 0 {
		moves++
	}

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


package main

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

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

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

	r, x1, y1, x2, y2 := nextInt(), int64(nextInt()), int64(nextInt()), int64(nextInt()), int64(nextInt())
	steps := 0

	x1 -= x2
	y1 -= y2

	dis := math.Sqrt(float64(x1 * x1 + y1 * y1))

	for dis > 0 {
		dis -= float64(r * 2)
		steps++
	}

	println(steps)
}

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

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


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, x0, y0, x1, y1 float64
	fmt.Scan(&r, &x0, &y0, &x1, &y1)
	d := math.Hypot(x0-x1, y0-y1)
	r += 1e-10
	fmt.Println(math.Ceil(d / (2 * r)))
}


package main

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

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

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

func ReadFloat64() float64 {
    f64, _ := strconv.ParseFloat(ReadString(), 64)
    return f64
}

func ReadInt64() int64 {
    i64, _ := strconv.ParseInt(ReadString(), 10, 0)
    return i64
}

func ReadInt() int {
    return int(ReadInt64())
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    r, x1, y1, x2, y2 := ReadInt64(), ReadInt64(), ReadInt64(), ReadInt64(), ReadInt64()
    r *= 2
    len := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    sqrt_len := math.Sqrt(float64(len))
    ans := int64(sqrt_len) / r
    sqrt_len -= float64(ans * r)
    for sqrt_len > 1E-8 {
        sqrt_len -= float64(r)
        ans++
    }
    fmt.Fprintln(writer, ans)
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n*2)
	ys := make([]int, n*2)
	area := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[2*i], &ys[2*i], &xs[2*i+1], &ys[2*i+1])
		area += (xs[2*i+1] - xs[2*i]) * (ys[2*i+1] - ys[2*i])
	}
	sort.Ints(xs)
	sort.Ints(ys)
	squareArea := (xs[2*n-1] - xs[0]) * (ys[2*n-1] - ys[0])
	if squareArea == area {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main
import (
    "fmt"
    )
func main(){
    var n int
    fmt.Scan(&n)
	fmt.Println(con(n))
}

func con(n int) int {
	r := n & (1 << 5)
	r += (n & (1 << 4)) >> 2
	r += (n & (1 << 3)) >> 3
	r += (n & (1 << 2)) << 1
	r += n & (1 << 1)
	r += (n & 1) << 4
	return r
}


package main
import (
    "fmt"
    )
func main(){
    var a int
    fmt.Scan(&a)
	fmt.Println(fun(a))
}

func fun(a int) int {
	res := a & (1 << 5)
	res += (a & (1 << 4)) >> 4
	res += (a & (1 << 3)) >> 1
	res += (a & (1 << 2)) << 1
	res += a & (1 << 1)
	res += (a & 1) << 4
	return res
}


package main

import "fmt"

func main() {
	var a, ans uint
	fmt.Scanf("%d", &a)
	in3 := (a & 0x8) != 0
	in2 := (a & 0x4) != 0
	in1 := (a & 0x2) != 0
	in0 := (a & 0x1) != 0

	out3 := !in3
	out2 := out3 != in2
	out1 := in1 != (out3 && out2)
	out0 := in0 != (out3 && out2 && out1)

	if out3 {
		ans += 8
	}
	if out2 {
		ans += 4
	}
	if out1 {
		ans += 2
	}
	if out0 {
		ans += 1
	}
	fmt.Printf("%d", ans)

}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)
var input io.Reader

type qu struct {
	pos, old int
}

func main() {
	var (
		recipe string
		nb, ns, nc int64
		pb, ps, pc int64
		cb, cs, cc int64
		rub int64
	)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &recipe)
	fmt.Fscan(input, &nb, &ns, &nc)
	fmt.Fscan(input, &pb, &ps, &pc)
	fmt.Fscan(input, &rub)

	for i := 0; i < len(recipe); i++ {
		switch recipe[i] {
		case 'B': cb++
		case 'S': cs++
		case 'C': cc++
		}
	}
	l, r := int64(0), int64(1e12 + 1000)
	for l < r {
		mid := l + (r - l) / 2
		cost := mid*(nn(cb*pb - nb*pb) + nn(cs*ps - ns*ps) + nn(cc*pc - nc*pc))
		if cost <= rub {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(r - 1)
}

func nn(z int64) int64 {
	if z < 0 {
		return 0
	}
	return z
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)
var input io.Reader

type qu struct {
	pos, old int
}

func main() {
	var (
		recipe string
		nb, ns, nc int64
		pb, ps, pc int64
		cb, cs, cc int64
		rub int64
	)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &recipe)
	fmt.Fscan(input, &nb, &ns, &nc)
	fmt.Fscan(input, &pb, &ps, &pc)
	fmt.Fscan(input, &rub)

	for i := 0; i < len(recipe); i++ {
		switch recipe[i] {
		case 'B': cb++
		case 'S': cs++
		case 'C': cc++
		}
	}
	l, r := int64(0), int64(1e12 + 1000)
	for l < r {
		mid := l + (r - l) / 2
		var b, s, c int64
		if cb > 0 { b = mid*cb*pb - nb*pb }
		if cs > 0 { s = mid*cs*ps - ns*ps }
		if cc > 0 { c = mid*cc*pc - nc*pc }
		cost := b + s + c
		if cost <= rub {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(r - 1)
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/371/C

package main

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

const MaxBurgers = int64(1e12)

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

func p(burgers, cb, cs, cc, nb, ns, nc, pb, ps, pc int64) int64 {
	return max(0, cb*burgers-nb)*pb + max(0, cs*burgers-ns)*ps + max(0, cc*burgers-nc)*pc
}

func _Solve(left, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles int64) int64 {
	if !(left < right) {
		return left
	}
	m := (left + right + 1) / 2
	cost := p(m, cb, cs, cc, nb, ns, nc, pb, ps, pc)
	if cost <= rubles {
		return _Solve(m, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
	}
	return _Solve(left, m-1, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
}

func Solve(s string, nb, ns, nc, pb, ps, pc, r int64) int64 {
	cb := int64(strings.Count(s, "B"))
	cs := int64(strings.Count(s, "S"))
	cc := int64(strings.Count(s, "C"))
	return _Solve(0, MaxBurgers, cb, cs, cc, nb, ns, nc, pb, ps, pc, r)
}

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

	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	var nb, ns, nc int64
	fmt.Fscanf(reader, "%d %d %d\n", &nb, &ns, &nc)
	var pb, ps, pc int64
	fmt.Fscanf(reader, "%d %d %d\n", &pb, &ps, &pc)
	var r int64
	fmt.Fscanf(reader, "%d\n", &r)

	fmt.Fprintf(writer, "%d\n", Solve(s, nb, ns, nc, pb, ps, pc, r))
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)
var input io.Reader

type qu struct {
	pos, old int
}

func main() {
	var (
		recipe string
		nb, ns, nc int64
		pb, ps, pc int64
		cb, cs, cc int64
		rub int64
	)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &recipe)
	fmt.Fscan(input, &nb, &ns, &nc)
	fmt.Fscan(input, &pb, &ps, &pc)
	fmt.Fscan(input, &rub)

	for i := 0; i < len(recipe); i++ {
		switch recipe[i] {
		case 'B': cb++
		case 'S': cs++
		case 'C': cc++
		}
	}
	discont := int64(0)
	if cb > 0 {
		discont += nb*pb
	}
	if cs > 0 {
		discont += ns*ps
	}
	if cc > 0 {
		discont += nc*pc
	}
	l, r := int64(0), int64(1e12 + 1000)
	for l < r {
		mid := l + (r - l) / 2
		cost := mid*(cb*pb + cs*ps + cc*pc)
		if cost - discont <= rub {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(r - 1)
}


package main

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

var input io.Reader

type qu struct {
	pos, old int
}

func main() {
	var (
		recipe     string
		nb, ns, nc int64
		pb, ps, pc int64
		cb, cs, cc int64
		rub        int64
	)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &recipe)
	fmt.Fscan(input, &nb, &ns, &nc)
	fmt.Fscan(input, &pb, &ps, &pc)
	fmt.Fscan(input, &rub)

	for i := 0; i < len(recipe); i++ {
		switch recipe[i] {
		case 'B':
			cb++
		case 'S':
			cs++
		case 'C':
			cc++
		}
	}
	l, r := int64(0), int64(1e12+1000)
	for l < r {
		mid := l + (r-l)/2
		var b, s, c int64
		if cb > 0 {
			b = nn(mid*cb*pb - nb*pb)
		}
		if cs > 0 {
			s = nn(mid*cs*ps - ns*ps)
		}
		if cc > 0 {
			c = nn(mid*cc*pc - nc*pc)
		}
		cost := b + s + c
		if cost <= rub {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(r - 1)
}

func nn(x int64) int64 {
	if x < 0 {
		return 0
	}
	return x
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/371/C

package main

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

const MaxBurgers = int64(1e13)

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

func p(burgers, cb, cs, cc, nb, ns, nc, pb, ps, pc int64) int64 {
	return max(0, cb*burgers-nb)*pb + max(0, cs*burgers-ns)*ps + max(0, cc*burgers-nc)*pc
}

func _Solve(left, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles int64) int64 {
	if !(left < right) {
		return left
	}
	m := (left + right + 1) / 2
	cost := p(m, cb, cs, cc, nb, ns, nc, pb, ps, pc)
	if cost <= rubles {
		return _Solve(m, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
	}
	return _Solve(left, m-1, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
}

func Solve(s string, nb, ns, nc, pb, ps, pc, r int64) int64 {
	cb := int64(strings.Count(s, "B"))
	cs := int64(strings.Count(s, "S"))
	cc := int64(strings.Count(s, "C"))
	return _Solve(0, MaxBurgers, cb, cs, cc, nb, ns, nc, pb, ps, pc, r)
}

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

	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	var nb, ns, nc int64
	fmt.Fscanf(reader, "%d %d %d\n", &nb, &ns, &nc)
	var pb, ps, pc int64
	fmt.Fscanf(reader, "%d %d %d\n", &pb, &ps, &pc)
	var r int64
	fmt.Fscanf(reader, "%d\n", &r)

	fmt.Fprintf(writer, "%d\n", Solve(s, nb, ns, nc, pb, ps, pc, r))
}


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

  _, m, a, b := getI(), getI(), getI(), getI()
  a--
  b--
  p, q := a%m, b%m
  result := 3
  if a/m == b/m || (p == 0 && q == m-1) {
    result = 1
  } else if a/m + 1 == b/m || p == 0 || q == m-1 {
    result = 2
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

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

var scanner *bufio.Scanner

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

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

  n, m, a, b := getI(), getI(), getI(), getI()
  a--
  b--
  p, q := a%m, b%m
  result := 3
  if a/m == b/m || (p == 0 && (q == m-1 || b == n-1)) {
    result = 1
  } else if a/m + 1 == b/m || p == 0 || q == m-1 || b == n-1 {
    result = 2
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

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

var scanner *bufio.Scanner

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

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

  n, m, a, b := getI(), getI(), getI(), getI()
  a--
  b--
  p, q := a%m, b%m
  result := 3
  if a/m == b/m || (p == 0 && (q == m-1 || b == n-1)) {
    result = 1
  } else if a/m + 1 == b/m || p == 0 || q == m-1 || b == n-1 || p == q+1 {
    result = 2
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

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

var res []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	solve(n, k)
	if len(res) == 0 {
		fmt.Println(-1)
		os.Exit(0)
	}
	check := 1
	for _, el := range res {
		check *= el
	}
	if check != n {
		fmt.Println(-1)
		os.Exit(0)
	}
	for i, el := range res {
		if i == len(res)-1 {
			fmt.Printf("%d\n", el)
			continue
		}
		fmt.Printf("%d ", el)
	}
}

func solve(n, k int) {
	if n == 1 {
		return
	}
	if k == 1 {
		res = append(res, n)
		return
	}
	for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
		if n%i == 0 {
			res = append(res, i)
			solve(n/i, k-1)
			return
		}
	}
}


package main

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

var res []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	solve(n, k)
	if len(res) == 0 {
		fmt.Println(-1)
		os.Exit(0)
	}
	for i, el := range res {
		if i == len(res)-1 {
			fmt.Printf("%d\n", el)
			continue
		}
		fmt.Printf("%d ", el)
	}
}

func solve(n, k int) {
	if k == 1 {
		res = append(res, n)
		return
	}
	for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
		if n%i == 0 {
			res = append(res, i)
			solve(n/i, k-1)
			return
		}
	}
}


// http://acm.timus.ru/problem.aspx?space=1&num=1741
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

const (
	MOD = 1e9 + 7
)

type (

)

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

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &n, &k)

	factors := make([]int, 0, 100000 + 1)

	for i := 2; i < n; i++ {
		for n % i == 0 {
			factors = append(factors, i)
			n /= i
		}
	}

	if len(factors) < k {
		fmt.Println(-1)
		return
	}

	for i := 0; i < k - 1; i++ {
		fmt.Println(factors[i])
	}

	if k < len(factors) {
		last := 1
		for i := k - 1; i < len(factors); i++ {
			last *= factors[i]
		}

		fmt.Println(last)
	}
}


// http://acm.timus.ru/problem.aspx?space=1&num=1741
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

const (
	MOD = 1e9 + 7
)

type (

)

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

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &n, &k)

	factors := make([]int, 0, 100000 + 1)

	for i := 2; i < n; i++ {
		for n % i == 0 {
			factors = append(factors, i)
			n /= i
		}
	}

	if n != 1 {
		factors = append(factors, n)
	}

	if len(factors) < k  {
		fmt.Println(-1)
		return
	}

	for i := 0; i < k - 1; i++ {
		fmt.Println(factors[i])
	}

	if k - 1 < len(factors) {
		last := 1
		for i := k - 1; i < len(factors); i++ {
			last *= factors[i]
		}

		fmt.Println(last)
	}
}


package main

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

func solve() {
	n := readInt()
	k := readInt()
	a := make([]int, k)
	if k == 1 {
		a[0] = n
		k = 0
	}
	for i := 2; i <= n && k > 1; i++ {
		for n%i == 0 {
			k--
			n /= i
			a[k] = i
			if k == 1 {
				if n != 1 {
					a[0] = n
					k--
				}
				break
			}
		}
	}
	if k == 0 {
		for i := 0; i < len(a); i++ {
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(a[i])
		}
	} else {
		fmt.Println(-1)
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import "fmt"

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

	p--
	var l = p / (2 * m)
	p %= 2 * m
	var s = p & 1
	p >>= 1

	if s == 0 {
		fmt.Println(l+1, p+1, "L")
	} else {
		fmt.Println(l+1, p+1, "R")
	}
}


package main

import (
	"fmt"
)

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

	lane := (k-1)/(2*m) + 1
	lane_start := (lane-1)*2*m + 1
	desk := (k-lane_start)/2 + 1
	var place string
	if (k-lane_start)%2 == 0 {
		place = "L"
	} else {
		place = "R"
	}

	fmt.Println(lane, desk, place)
}


package main

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

func solve() {
	readInt()
	m := readInt()
	k := readInt() - 1

	column := (k) / (m * 2)
	row := (k % (m * 2)) / 2
	row1 := (k % (m * 2)) % 2
	fmt.Printf("%d ", column+1)
	fmt.Printf("%d ", row+1)
	if row1 == 0 {
		fmt.Println("L")
	} else {
		fmt.Println("R")
	}
}

func getStats(str string) map[byte]int {
	stat := map[byte]int{}
	for _, v := range str {
		stat[byte(v)]++
	}
	return stat
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

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

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

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

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

func main() {
	defer writer.Flush()
	var n, a, b, p1, p2 int

	arr := [22]int{}
	scanf("%d %d %d\n", &n, &a, &b)
	for i := 0; i < n; i = i + 1 {
		scanf("%d ", &arr[i])
	}
	p2 = n - 1
	ans := 0
	for p1 <= p2 {

		if p1 == p2 {
			if arr[p1] == 2 {
				ans += min(a, b)
			}
			break
		}

		if arr[p1] == arr[p2] && arr[p1] == 2 {
			ans = ans + min(a, b)
		}
		if arr[p1]^arr[p2] == 1 {
			ans = -1
			break
		}
		if arr[p1] == 2 && arr[p2] == 1 {
			ans = ans + b
		}
		if arr[p2] == 2 && arr[p1] == 1 {
			ans = ans + b
		}
		if arr[p1] == 2 && arr[p2] == 0 {
			ans = ans + a
		}
		if arr[p2] == 2 && arr[p1] == 0 {
			ans = ans + a
		}
		p1++
		p2--
	}
	printf("%d", ans)

}


package main

import (
	"fmt"
)

func main() {
	var Arr [105] int
	var N,w,b int
	fmt.Scanf("%d %d %d \n",&N,&w,&b)
	for i:=1; i<N; i++ {
		fmt.Scanf("%d ",&Arr[i])
	}
	min := b
	if w < b {
		min = w
	}
	sum := 0
	i := 1
	j := N
	for ; i<=j ;{
	    if i == j {
	        if Arr[i] == 2 {
	            sum += min
	        }
		} else if Arr[i] == Arr[j] {
			if Arr[i] == 2 {
				sum += (min * 2)
			}
		} else {
			if Arr[i] + Arr[j] < 2 {
				fmt.Printf("-1")
				return
			} else {
				if Arr[i] == 2 {
					if Arr[j] == 0 {
						sum += w
					} else {
						sum += b
					}
				} else {
					if Arr[i] == 0 {
						sum += w
					} else {
						sum += b
					}
				}
			}
		}
		i++
		j--
	}
	fmt.Printf("%d",sum)
}


package main

import (
	"fmt"
)

func main() {
	var Arr [105] int
	var N,w,b int
	fmt.Scanf("%d %d %d \n",&N,&w,&b)
	for i:=1; i<=N; i++ {
		fmt.Scan(&Arr[i])
	}
	min := b
	if w < b {
		min = w
	}
	sum := 0
	i := 1
	j := N
	for ; i<=j ;{
	    if i == j {
	        if Arr[i] == 2 {
	            sum += min
	        }
		} else if Arr[i] == Arr[j] {
			if Arr[i] == 2 {
				sum += (min * 2)
			}
		} else {
			if Arr[i] + Arr[j] < 2 {
				fmt.Printf("-1")
				return
			} else {
				if Arr[i] == 2 {
					if Arr[j] == 0 {
						sum += w
					} else {
						sum += b
					}
				} else {
					if Arr[i] == 0 {
						sum += w
					} else {
						sum += b
					}
				}
			}
		}
		i++
		j--
	}
	fmt.Printf("%d",sum)
}


package main

import "fmt"

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

	min_price := a
	if b < min_price {
		min_price = b
	}
	//fmt.Println(c)
	ans := 0
	for i, _ := range c {
		ri := n - 1 - i
		if i > ri {
			break
		} else if i == ri {
			if c[i] == 2 {
				ans += min_price
			}
		} else {
			if c[i] != 2 && c[ri] != 2 {
				if c[i] != c[ri] {
					ans = -1
					break
				}
			} else if c[i] == 2 && c[ri] != 2 {
				if c[ri] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else if c[ri] == 2 && c[i] != 2 {
				if c[i] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else {
				ans += (min_price * 2)
			}
		}
	}

	fmt.Println(ans)
}


package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)
	dims := readInts(r, 3)
	n := dims[0]
	prices := [2]int{dims[1], dims[2]}

	if n == 0 {
		fmt.Print(0)
		return
	}

	minP := 0
	if prices[0] < prices[1] {
		minP = prices[0]
	} else {
		minP = prices[1]
	}

	colors := readInts(r, n)

	exp := 0
	for i := 0; i <= (len(colors) - 1) / 2; i++ {
		col := colors[i]
		contI := len(colors) - 1 - i
		contCol := colors[contI]
		if col == 2 && contCol == 2 {
			exp += minP
			if i != contI {
				exp += minP
			}
		} else if col == 2 {
			exp += prices[contCol]
		} else if contCol == 2 {
			exp += prices[col]
		} else if contCol != col {
			exp = -1
			break
		}
	}

	fmt.Print(exp)
}

func readInts(reader *bufio.Reader, n int) []int {
	tmpInts := strings.Split(readLine(reader), " ")

	var result []int
	for i := 0; i < n; i++ {
		tmpInt, err := strconv.ParseInt(tmpInts[i], 10, 64)
		checkError(err)
		result = append(result, int(tmpInt))
	}
	return result
}

func readString(reader *bufio.Reader, l int) string {
	sTemp := readLine(reader)
	if len(sTemp) < l {
		l = len(sTemp)
	}
	return sTemp[:l]
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF16C(in io.Reader, out io.Writer) {
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	var a, b, x, y int
	Fscan(in, &a, &b, &x, &y)
	g := gcd(x, y)
	x /= g
	y /= g
	k := a / x
	if b/y < k {
		k = b / y
	}
	if k > 0 {
		Fprint(out, x*k, y*k)
	} else {
		Fprint(out, 0, 0)
	}
}

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


// https://codeforces.com/contest/16/problem/C
package main

import (
	"fmt"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

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

	fmt.Scan(&a, &b, &x, &y)
	g := gcd(x, y)
	x /= g
	y /= g

	l := int64(1)
	r := int64(2e9)
	for l < r - 1 {
		mid := (l + (r - l) / 2)
		a1, b1 := x*mid, y*mid
		if a1 <= a && b1 <= b {
			l = mid
		} else {
			r = mid
		}
	}
	r--
	if x*r <= a && y*r <= b {
		fmt.Println(x*r, y*r)
	} else {
		fmt.Println(0, 0)
	}
}

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


package main

import (
	"fmt"
)

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

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

	for {
		l := len(a)
		if l == 0 || (a[0] > k && a[l-1] > k) {
			break
		}

		if a[0] <= k {
			a = a[1:]
		}

		l = len(a)
		if l > 0 && a[l-1] <= k {
			a = a[:l-1]
		}
	}

	fmt.Println(n - len(a))
}


package main

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

func Init() {
}

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

	cnt := 0
	for len(A) > 0 && A[0] <= K {
		cnt++
		A = A[1:]
	}
	for len(A) > 0 && A[len(A)-1] <= K {
		cnt++
		A = A[:len(A)-1]
	}
	io.Println(cnt)
}

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"
	"bytes"
	"io/ioutil"
	"os"
)

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

	var n, k int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	a := make([]int, n)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
	}
	var left, right int
	for ;left < n && a[left] <= k;left ++ {

	}
	for ;n - right - 1 > left && a[n - right - 1] <= k; right ++ {

	}
	fmt.Printf("%d", left + right)
}


package main

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

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

	i := 0
	for ; i < N; i++ {
		if A[i] > K {
			break
		}
	}
	j := N - 1
	for ; j > i; j-- {
		if A[j] > K {
			break
		}
	}
	fmt.Println(i + N - 1 - j)

}

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

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

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

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

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

	return mp
}

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


// cf999a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	c := 0
	l, r := 0, n-1
	for i := 0; i < n && l <= r; i++ {

		if m[l] <= s {
			c++
			l++
		}
		if m[r] <= s && l < r {
			c++
			r--
		}

	}
	fmt.Println(c)
}


//Nishant Arora

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	var n,k,p int
	ans := 0
  	fmt.Fscanf(in, "%d", &n)
  	fmt.Fscanf(in, "%d\n", &k)
//   	fmt.Println(n)
//   	fmt.Println(k)
  	var arr [105]int
  	for i := 0; i < n; i++ {
	  	fmt.Fscanf(in, "%d", &arr[i])
	  	// fmt.Println(arr[i])

  	}
  	for i := 0; i < n; i++ {
  		if(arr[i] <= k) {
  			ans++
  			p = i
  		} else {
  			p = i
  			break
  		}
  	}
//   	fmt.Println(ans)
    // fmt.Println(p)
  	for i := n-1 ; i > p ; i-- {
  		if(arr[i] <= k) {
  			ans++
  		} else {
  			break
  		}
  	}

  	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n, k, l int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for len(a) > 0 && a[0] <= k {
		l++
		a = a[1:]
	}
	for len(a) > 0 && a[len(a)-1] <= k {
		a = a[0 : len(a)-1]
		l++
	}
	fmt.Println(l)
}


package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ex := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ex[i])
	}
	ans := 0
	for i, j := 0, n-1; i <= j && (ex[i] <= k || ex[j] <= k) ; {
		if ex[i] <= k {
			i++
			ans++
			continue
		}
		if ex[j] <= k {
			ans++
			j--
		}
	}
	fmt.Print(ans)
}


package main

import "fmt"

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

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

	}

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

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


package main
import "fmt"
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	a := make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	r := 0
	for i:=0;i<n;i++ {
		if a[i]<=k {
			r++
		} else {
			break;
		}
	}
	if r < n {
		for i:=n-1;i>=0;i-- {
			if a[i]<=k {
				r++
			} else {
				break;
			}
		}
	}
	fmt.Print(r)
}


// cf999a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	c := 0
	l, r := 0, n-1
	for i := 0; i < n && l < r; i++ {

		if m[l] <= s {
			c++
			l++
		}
		if m[r] <= s && l < r {
			c++
			r--
		}

	}
	fmt.Println(c)
}


// cf999a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	c := 0
	l, r := 0, n-1
	for i := 0; i < n && l < r; i++ {

		if m[l] <= s {
			c++
			l++
		}
		if m[r] <= s {
			c++
			r--
		}

	}
	fmt.Println(c)
}


// cf999a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	c := 0
	l, r := 0, n-1
	for i := 0; i < n && l <= r; i++ {

		if m[l] <= s {
			c++
			l++
		}
		if m[r] <= s {
			c++
			r--
		}

	}
	fmt.Println(c)
}


package main

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

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

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

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

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

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

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

	fmt.Println(p)
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

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

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

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

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

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


package main

import "fmt"

func getCnt(n int64) int64 {
  var sum int64
  for k:= int64(2); k*k*k <= n; k++ {
    sum += n/(k*k*k)
  }
  return sum
}

func main() {
  var m int64
  fmt.Scan(&m)

  var lo, hi int64
  lo = 1
  hi = 100000000000
  for lo+1 < hi {
    mid := (lo+hi)/2
    sum := int64(0)
    for k:= int64(2); k*k*k <= mid; k++ {
      sum += mid/(k*k*k)
    }
    if sum >= m {
      hi = mid
    } else {
      lo = mid
    }
  }
  hiCnt := getCnt(hi)
  if hiCnt == m {
    fmt.Println(hi)
  } else {
    fmt.Println(-1)
  }
}


package main

import "fmt"

func getCnt(n int) int {
  sum := 0
  for k:= 2; k*k*k <= n; k++ {
    sum += n/(k*k*k)
  }
  return sum
}

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

  lo := 1
  hi := 10000000000000
  for lo+1 < hi {
    mid := (lo+hi)/2
    sum := 0
    for k:= 2; k*k*k <= mid; k++ {
      sum += mid/(k*k*k)
    }
    if sum >= m {
      hi = mid
    } else {
      lo = mid
    }
  }
  hiCnt := getCnt(hi)
  if hiCnt == m {
    fmt.Println(hi)
  } else {
    fmt.Println(-1)
  }
}


package main

import "fmt"

func getCnt(n int64) int64 {
  var sum int64
  for k:= int64(2); k*k*k <= n; k++ {
    sum += n/(k*k*k)
  }
  return sum
}

func main() {
  var m int64
  fmt.Scan(&m)

  var lo, hi int64
  lo = 1
  hi = 9223372036854775807
  for lo+1 < hi {
    mid := (lo+hi)/2
    sum := int64(0)
    for k:= int64(2); k*k*k <= mid; k++ {
      sum += mid/(k*k*k)
    }
    if sum >= m {
      hi = mid
    } else {
      lo = mid
    }
  }
  hiCnt := getCnt(hi)
  if hiCnt == m {
    fmt.Println(hi)
  } else {
    fmt.Println(-1)
  }
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF106C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	var maxW, n, a, b int
	Fscan(in, &maxW, &n)
	n++
	weights := make([]int, n)
	values := make([]int, n)
	stocks := make([]int, n)
	Fscan(in, &weights[0], &values[0])
	stocks[0] = maxW / weights[0]
	for i := 1; i < n; i++ {
		Fscan(in, &a, &b, &weights[i], &values[i])
		stocks[i] = a / b
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, maxW+1)
	}
	for i, vi := range values {
		wi := weights[i]
		for j := range dp[i] {
			for k := 0; k <= stocks[i] && k*wi <= j; k++ {
				dp[i+1][j] = max(dp[i+1][j], dp[i][j-k*wi]+vi*k)
			}
		}
	}
	Fprint(_w, dp[n][maxW])
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF106C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	var maxW, n, a, b int
	Fscan(in, &maxW, &n)
	n++
	weights := make([]int, n)
	values := make([]int, n)
	stocks := make([]int, n)
	Fscan(in, &weights[0], &values[0])
	stocks[0] = maxW / weights[0]
	for i := 1; i < n; i++ {
		Fscan(in, &a, &b, &weights[i], &values[i])
		stocks[i] = a / b
	}

	dp := make([]int, maxW+1)
	for i, v := range values {
		num, w := stocks[i], weights[i]
		for k := 1; num > 0; k <<= 1 {
			K := min(k, num)
			for j := maxW; j >= K*w; j-- {
				dp[j] = max(dp[j], dp[j-K*w]+K*v)
			}
			num -= K
		}
	}
	Fprint(out, dp[maxW])
}

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


package main

import "fmt"

var mmap = make(map[uint8][]string)

func recur(str string, l int) int {
	if l == 0 {
		return 1
	}
	if l < 0 {
		return 0
	}
	ret := 0
	for _, s := range mmap[str[0]] {
		ret += recur(s+str[1:], l-1)
	}
	return ret
}

func main() {
	var n, q int
	fmt.Scanf("%d %d\n", &n, &q)
	for i := 0; i < q; i++ {
		var k, v string
		fmt.Scanf("%s %s\n", &k, &v)
		ks := v[0]
		mmap[ks] = append(mmap[ks], k)
	}
	fmt.Print(recur("a", n-1))
}


package main

import (
	"os"
	"fmt"
)

func winpos(table [][]byte, startx, starty, deltax, deltay int) bool {
	if startx + 4*deltax >= 10 || starty + 4*deltay >= 10 {
		return false
	}

	ok := true
	x, y := startx, starty
	i := 0
	for ok && i < 5 {
		if table[x][y]!='X' {
			ok = false
			break ;
		}

		x+=deltax
		y+=deltay

		i++
	}

	return ok
}

func win(table [][]byte) bool {
	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) {
				return true
			}
		}
	}

	return false
}

func main() {
	table := make([][]byte,  10)
	for i := 0; i < 10; i++ {
		fmt.Scanf("%s", &table[i])
	}

	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if table[i][j]=='.' {
				table[i][j]='X'
				if win(table) {
					fmt.Println("YES")
					os.Exit(0)
				}

				table[i][j]='.'
			}
		}
	}

	fmt.Println("NO")
	os.Exit(0)
}


package main

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

func winpos(table [][]byte, sx, sy, dx, dy int) bool {
	x, y := sx, sy
	i := 0
	for i < 5 {
	    if  x>=10 || y>=10 {
	        return false
	    }

		if table[x][y]!='X' {
			return false
		}

		x += dx
		y += dy

		i++
	}

	return true
}

func win(table [][]byte) bool {
	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) {
				return true
			}
		}
	}

	return false
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
	table := make([][]byte,  10)
	for i := 0; i < 10; i++ {
		table[i], _, _ = stdin.ReadLine()

	}

	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if table[i][j]=='.' {
				table[i][j]='X'
				if win(table) {
					fmt.Println("YES")
					os.Exit(0)
				}

				table[i][j]='.'
			}
		}
	}

	fmt.Println("NO")
	os.Exit(0)
}


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n; i++ {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
			i--
		}
	}
	Fprint(out, "YES")
}

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


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n-1; {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n-1; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
			i++
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
	}
	Fprint(out, "YES")
}

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


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n; {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
			i++
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
	}
	Fprint(out, "YES")
}

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


package main

import "fmt"

func check(x int64, a int64, b int64, y int64) bool {
    if a == 0 {
        return x == y
    } else {
        var c = a/b
        return x == y ||
            check(x-c,c,b,y) ||
            check(x,c,b,y) ||
            check(x+c,c,b,y)
    }
}

func main() {

    var w,m int64
    fmt.Scanf("%v %v\n", &w, &m)

    if w <= 3 {
        fmt.Printf("YES\n")
    } else {
        var i,x,c int64 = 1,1,0
        for x < m && c <= 100 {
            i *= w
            x += i
            c++
        }
        if check(i,i,w,m) {
            fmt.Printf("YES\n")
        } else {
            fmt.Printf("NO\n")
        }
    }
}


package main

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

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

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)
	var w, m = NextInt64(), NextInt64()
	if w == 2 {
		fmt.Fprintln(out, "YES")
		return
	}
	a := make([]int64, 0)
	var p int64 = 1
	for p <= m {
		a = append(a, p)
		p *= w
	}

	// fmt.Fprintln(out, a)

	var n int = len(a)
	for mask := 0; mask < (1 << uint(n)); mask++ {
		var s int64 = m;
		for i := 0; i < n; i++ {
			if ((mask >> uint(i)) & 1) > 0 {
				s += a[i]
			}
		}

		var j uint = 0
		var ok bool = true
		for s > 0 {
			var rem int64 = s % w
			s /= w
			if rem != 0 && rem != 1 {
				ok = false
				break
			}
			if rem == 1 && ((mask >> uint(j)) & 1) > 0 {
				ok = false
				break
			}
			j++
		}
		if ok {
			fmt.Fprintln(out, "YES")
			return
		}
	}
	fmt.Fprintln(out, "NO")
}

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

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

func NextInt64() int64 {
	ret, _ := strconv.ParseInt(Next(), 10, 64)
	return ret
}


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c == w-1 {
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n; i++ {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			coef[i] = -1
			i--
		}
	}
	Fprint(out, "YES")
}

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


package main

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

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
}

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n int64
	var allNines = true
	fmt.Fscanf(in, "%d", &n)
	if n < 5 {
		fmt.Println(n * (n - 1) / 2)
		os.Exit(0)
	}
	sum := n + n - 1
	cnt := 0
	for ; sum > 0; sum /= 10 {
		x := sum % 10
		if x != 9 {
			allNines = false
		}
		cnt++
	}
	if allNines {
		fmt.Println(1)
		os.Exit(0)
	}
	numOfNines := cnt - 1
	var deg int64 = 1
	for i := 1;i <= numOfNines; i++ {
		deg = deg * 10
	}
	md := n % deg
	right := md
	mid := deg / 2 - 1
	less := n / deg
	more := less + 1
	if  right == 0 {
		fmt.Println(less * less * (mid + 1))
		os.Exit(0)
	}
	var ans int64
	if right != deg - 1 {
		ans = less * less
	} else {
		ans = less * more
	}
	if right <= mid {
		ans += right * more * less
		ans += (mid - right) * less * less
	} else {
		extra := right - mid - 1
		ans += extra * more * more
		ans += (mid - extra) * more * less
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"strconv"
)

//a,b <=n  && a+b==x
func count(n, x int64) (ans int64) {
	if n >= x {
		n = x - 1
	}
	ans = n - x/2
	if x%2 == 0 {
		ans++
	}
	if ans < 0 {
		ans = 0
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	if n < 5 {
		fmt.Println(n * (n - 1) / 2)
		return
	}
	var ans int64
	var max9 int64 = 9
	for max9 < n {
		max9 = max9*10 + 9
	}
	if max9/2+1 <= n {
		fmt.Println(count(n, max9))
		return
	}
	smax9 := fmt.Sprint(max9)
	for i := 0; i < len(smax9); i++ {
		tmp := []byte(smax9)
		for j := 0; j < 9; j++ {
			tmp[i] = byte(j) + '0'
			x, _ := strconv.ParseInt(string(tmp), 10, 64)
			ans += count(n, x)
			fmt.Println(count(n, x), x)
			tmp[i] = '9'
		}
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"strconv"
)

//a,b <=n  && a+b==x
func count(n, x int64) (ans int64) {
	if n >= x {
		n = x - 1
	}
	ans = n - x/2
	if x%2 == 0 {
		ans++
	}
	if ans < 0 {
		ans = 0
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	var ans int64
	var max9 int64 = 9
	for max9 < n {
		max9 = max9*10 + 9
	}
	if max9/2+1 <= n {
		fmt.Println(count(n, max9))
		return
	}
	smax9 := fmt.Sprint(max9)
	for i := 0; i < len(smax9); i++ {
		tmp := []byte(smax9)
		for j := 0; j < 9; j++ {
			tmp[i] = byte(j) + '0'
			x, _ := strconv.ParseInt(string(tmp), 10, 64)
			ans += count(n, x)
			//fmt.Println(count(n, x), x)
			tmp[i] = '9'
		}
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"strconv"
)

//a,b <=n  && a+b==x
func count(n, x int64) (ans int64) {
	if n >= x {
		n = x - 1
	}
	ans = n - x/2
	if x%2 == 0 {
		ans++
	}
	if ans < 0 {
		ans = 0
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	if n < 5 {
		fmt.Println(0)
		return
	}
	var ans int64
	var max9 int64 = 9
	for max9 < n {
		max9 = max9*10 + 9
	}
	if max9/2+1 <= n {
		fmt.Println(count(n, max9))
		return
	}
	smax9 := fmt.Sprint(max9)
	for i := 0; i < len(smax9); i++ {
		tmp := []byte(smax9)
		for j := 0; j < 9; j++ {
			tmp[i] = byte(j) + '0'
			x, _ := strconv.ParseInt(string(tmp), 10, 64)
			ans += count(n, x)
			//fmt.Println(count(n, x), x)
			tmp[i] = '9'
		}
	}
	fmt.Println(ans)
}


package main

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

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
}

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n int64
	var allNines = true
	fmt.Fscanf(in, "%d", &n)
	sum := n + n - 1
	cnt := 0
	for ; sum > 0; sum /= 10 {
		x := sum % 10
		if x != 9 {
			allNines = false
		}
		cnt++
	}
	if allNines {
		fmt.Println(1)
		os.Exit(0)
	}
	numOfNines := cnt - 1
	var deg int64 = 1
	for i := 1;i <= numOfNines; i++ {
		deg = deg * 10
	}
	md := n % deg
	right := md
	mid := deg / 2 - 1
	less := n / deg
	more := less + 1
	if  right == 0 {
		fmt.Println(less * less * (mid + 1))
		os.Exit(0)
	}
	var ans int64
	if right != deg - 1 {
		ans = less * less
	} else {
		ans = less * more
	}
	if right <= mid {
		ans += right * more * less
		ans += (mid - right) * less * less
	} else {
		extra := right - mid
		ans += extra * more * more
		ans += (mid - extra) * more * less
	}
	if n == deg - 1 {
		ans--
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"strconv"
)

//a,b <=n  && a+b==x
func count(n, x int64) (ans int64) {
	if n >= x {
		n = x - 1
	}
	ans = n - x/2
	if x%2 == 0 {
		ans++
	}
	if ans < 0 {
		ans = 0
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	if n < 5 {
		fmt.Println(n * (n - 1) / 2)
		return
	}
	var ans int64
	var max9 int64 = 9
	for max9 < n {
		max9 = max9*10 + 9
	}
	if max9/2+1 <= n {
		fmt.Println(count(n, max9))
		return
	}
	smax9 := fmt.Sprint(max9)
	//for i := 0; i < len(smax9); i++ {
	tmp := []byte(smax9)
	for j := 0; j < 9; j++ {
		tmp[0] = byte(j) + '0'
		x, _ := strconv.ParseInt(string(tmp), 10, 64)
		ans += count(n, x)
		//fmt.Println(count(n, x), x)
		tmp[0] = '9'
	}
	//}
	fmt.Println(ans)
}


package main

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

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
}

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n int64
	var allNines = true
	fmt.Fscanf(in, "%d", &n)
	if n < 5 {
		fmt.Println(n * (n - 1) / 2)
		os.Exit(0)
	}
	sum := n + n - 1
	cnt := 0
	for ; sum > 0; sum /= 10 {
		x := sum % 10
		if x != 9 {
			allNines = false
		}
		cnt++
	}
	if allNines {
		fmt.Println(1)
		os.Exit(0)
	}
	numOfNines := cnt - 1
	var deg int64 = 1
	for i := 1;i <= numOfNines; i++ {
		deg = deg * 10
	}
	md := n % deg
	right := md
	mid := deg / 2 - 1
	less := n / deg
	more := less + 1
	if  right == 0 {
		fmt.Println(less * less * (mid + 1))
		os.Exit(0)
	}
	var ans int64
	if right != deg - 1 {
		ans = less * less
	} else {
		ans = less * more
	}
	if right <= mid {
		ans += right * more * less
		ans += (mid - right) * less * less
	} else {
		extra := right - mid
		if right == deg - 1 {
			extra--
		}
		ans += extra * more * more
		ans += (mid - extra) * more * less
	}
	fmt.Println(ans)
}


package main

import "fmt"

const maxn = 51

func main() {
	var n, k int64
	fmt.Scan(&n, &k)
	fib := make([]int64, maxn)
	fib[0], fib[1] = 1, 1
	for i := int64(2); i < maxn; i++ {
		fib[i] = fib[i-1] + fib[i-2]
	}
	sum := int64(1)
	for i := int64(1); i <= n; i++ {
		if n-i >= 0 && sum+fib[n-i] <= k {
			sum += fib[n-i]
			fmt.Printf("%d %d ", i+1, i)
			i++
		} else {
			fmt.Printf("%d ", i)
		}
	}
}


package main

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

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

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

	var la, ra, ta, lb, rb, tb int64
	fmt.Fscanf(reader, "%d %d %d\n", &la, &ra, &ta)
	fmt.Fscanf(reader, "%d %d %d", &lb, &rb, &tb)

	factor := gcd(ta, tb)

	var ans1, ans2 int64

	// Bob first, Alice after
	// (la - lb) + (ka * ta) - (kb * tb) = diff > 0
	diff1 := (la - lb) % factor
	if diff1 < 0 {
		diff1 += factor
	}
	if rb - lb + 1 < diff1 {
		ans1 = 0
	} else if rb - lb + 1 > diff1 + (ra - la + 1) {
		ans1 = ra - la + 1
	} else {
		ans1 = rb - lb + 1 - diff1
	}

	diff2 := (lb - la) % factor
	if diff2 < 0 {
		diff2 += factor
	}
	if ra - la + 1 < diff2 {
		ans2 = 0
	} else if ra - la + 1 > diff2 + (rb - lb + 1) {
		ans2 = rb - lb + 1
	} else {
		ans2 = ra - la + 1 - diff2
	}
	if ans1 > ans2 {
		fmt.Printf("%d", ans1)
	} else {
		fmt.Printf("%d", ans2)
	}

}


package main

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

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

	var n1, n2, k1, k2 int
	Fscan(in, &n1, &n2, &k1, &k2)

	const mod = 1e8
	cache := map[string]int{}
	var f func(left1, left2, c1, c2 int) int
	f = func(left1, left2, c1, c2 int) (sum int) {
		if left1 == 0 {
			if left2+c2 <= k2 {
				return 1
			}
			return 0
		}
		if left2 == 0 {
			if left1+c1 <= k1 {
				return 1
			}
			return 0
		}
		hash := Sprintf("%d;%d;%d;%d", left1, left2, c1, c2)
		if val, ok := cache[hash]; ok {
			return val
		}
		if c1 < k1 {
			sum += f(left1-1, left2, c1+1, 0)
		}
		if c2 < k2 {
			sum += f(left1, left2-1, 0, c2+1)
		}
		sum %= mod
		cache[hash] = sum
		return
	}
	Fprintln(out, f(n1, n2, 0, 0))
}

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


package main

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

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

	var n1, n2, k1, k2 int
	Fscan(in, &n1, &n2, &k1, &k2)

	const mod = int64(1e8)
	cache := make(map[string]int64, 1e6)
	var f func(left1, left2, c1, c2 int) int64
	f = func(left1, left2, c1, c2 int) (sum int64) {
		if left1 == 0 {
			if left2+c2 <= k2 {
				return 1
			}
			return 0
		}
		if left2 == 0 {
			if left1+c1 <= k1 {
				return 1
			}
			return 0
		}
		hash := Sprintf("%d;%d;%d;%d", left1, left2, c1, c2)
		if val, ok := cache[hash]; ok {
			return val
		}
		if c1 < k1 {
			sum += f(left1-1, left2, c1+1, 0)
		}
		if c2 < k2 {
			sum += f(left1, left2-1, 0, c2+1)
		}
		sum %= mod
		cache[hash] = sum
		return
	}
	Fprintln(out, f(n1, n2, 0, 0))
}

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


package main

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

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

	var n1, n2, k1, k2 int
	Fscan(in, &n1, &n2, &k1, &k2)

	const mod = int64(1e8)
	cache := map[string]int64{}
	var f func(left1, left2, c1, c2 int) int64
	f = func(left1, left2, c1, c2 int) (sum int64) {
		if left1 == 0 {
			if left2+c2 <= k2 {
				return 1
			}
			return 0
		}
		if left2 == 0 {
			if left1+c1 <= k1 {
				return 1
			}
			return 0
		}
		hash := Sprintf("%d;%d;%d;%d", left1, left2, c1, c2)
		if val, ok := cache[hash]; ok {
			return val
		}
		if c1 < k1 {
			sum += f(left1-1, left2, c1+1, 0)
		}
		if c2 < k2 {
			sum += f(left1, left2-1, 0, c2+1)
		}
		sum %= mod
		cache[hash] = sum
		return
	}
	Fprintln(out, f(n1, n2, 0, 0))
}

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


package main

import (
	. "fmt"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
const mod int64 = 1e9 + 7
func A(n, m int) int64 {
	if m > n { return 0 }
	x := int64(1)
	for i := 0; i < m; i++ {
		x = x * int64(n-i) % mod
	}
	return x
}
func main() {
	var n, x, p, l, g int
	Scan(&n, &x, &p)
	sort.Search(n, func(m int) bool {
		if m < p {l++} else if m > p {g++}
		return m > p
	})
	m:=n-1-l-g
	Print(A(x-1,l)*A(n-x,g)%mod*A(m,m)%mod)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod int64 = 1e9 + 7 // todo

	f := func(n, m int) int64 {

		if m > n {
			return 0
		}
		ans := int64(1)
		for c := 0; c < m; c++ {
			ans = ans * int64(n-c) % mod
		}
		return ans
	}

	var n, x, pos int
	Fscan(in, &n, &x, &pos)
	if n == 1 {
		// todo
	}

	cntLess, cntGr := 0, 0
	sort.Search(n, func(mid int) bool {
		if mid < pos {
			cntLess++
		} else if mid > pos {
			cntGr++
		}
		return mid > pos
	})

	//Println(cntLess, cntGr)

	ans := int64(1)
	right := f(n-x, cntGr)
	left := f(x-1, cntLess)

	ans = ans * right % mod
	ans = ans * left % mod

	other := n - 1 - cntLess - cntGr
	fo := f(other, other)
	ans = ans * fo % mod

	Fprint(out, ans)

}

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


package main

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

var rw = NewFastIO(os.Stdin, os.Stdout)

const mod = 1e9 + 7

func main() {
	defer rw.Flush()
	n, x, pos := rw.NextInt(), rw.NextInt(), rw.NextInt()
	lo, hi := 0, n
	smol, bigg := int64(x-1), int64(n-x)
	var ans int64 = 1
	for lo < hi {
		md := (lo + hi) / 2
		if md == pos {
			lo = md + 1
		} else if md < pos {
			lo = md + 1
			ans *= smol
			ans %= mod
			smol--
		} else {
			hi = md
			ans *= bigg
			ans %= mod
			bigg--
		}
	}
	smol += bigg
	for smol > 0 {
		ans *= smol
		ans %= mod
		smol--
	}
	rw.Println(ans)
}

func tCase() {

}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}
func (f *FastIO) NextInt64() int64 {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := int64(0)
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int64(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}


package main

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

func calc(m, l, x, n int64) int64 {
	if l > x-1 {
		return 0
	}
	if m > n-x {
		return 0
	}
	res := int64(1)
	magic := int64(1000000007)
	for i := int64(0); i < l; i++ {
		res = (res * (x - i - 1)) % magic
	}
	for i := int64(0); i < m; i++ {
		res = (res * (n - x - i)) % magic
	}
	for i := int64(1); i <= n-m-l-1; i++ {
		res = (res * i) % magic
	}
	return res
}

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

	var n, x, pos int64

	fmt.Fscan(io, &n, &x, &pos)

	m := int64(0)
	l := int64(0)

	left := int64(0)
	right := n
	median := int64(0)
	for left < right {
		median = (left + right) / 2
		if median > pos {
			right = median
			m++
		} else if median < pos {
			left = median + 1
			l++
		} else if median == pos {
			left = median + 1
		}
	}

	fmt.Print(calc(m, l, x, n))
}


package main

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

func calc(m, l, x, n int) int {
	if l > x-1 {
		return 0
	}
	if m > n-x {
		return 0
	}
	res := 1
	magic := 1000000007
	for i := 0; i < l; i++ {
		res = (res * (x - i - 1)) % magic
	}
	for i := 0; i < m; i++ {
		res = (res * (n - x - i)) % magic
	}
	for i := 1; i <= n-m-l-1; i++ {
		res = (res * i) % magic
	}
	return res
}

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

	var n, x, pos int

	fmt.Fscan(io, &n, &x, &pos)

	m := 0
	l := 0

	left := 0
	right := n
	median := 0
	for left < right {
		median = (left + right) / 2
		if median > pos {
			right = median
			m++
		} else if median < pos {
			left = median + 1
			l++
		} else if median == pos {
			left = median + 1
		}
	}

	fmt.Print(calc(m, l, x, n))
}


package main

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

func solve() {
	divs := []int{130816, 32640, 8128, 2016, 496, 120, 28, 6, 1}
	n := readInt()
	for _, k := range divs {
		if n%k == 0 {
			fmt.Println(k)
			return
		}
	}
}

var scanner *bufio.Scanner

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

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

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

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


package main

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

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	mx := 0
	for k := uint(1); ; k++ {
		l := ((1 << k) - 1) * (1 << (k - 1))
		if l > N {
			break
		}
		if N%l == 0 {
			mx = l
		}
	}
	fmt.Println(mx)

}

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

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

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

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

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

	return mp
}

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


package main

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

var a [9]int64
var helper SHelper

func main() {
	helper.Init()

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

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

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

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

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


package main

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

func main() {
	inp := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	is, err := inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l1 := strings.Split(is, " ")
	if len(l1) != 2 {
		out.WriteString("-1")
		out.Flush()
		return
	}
	n, err := strconv.Atoi(l1[0])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	w, err := strconv.Atoi(l1[1])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is, err = inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l2 := strings.Split(is, " ")
	if len(l2) != n {
		out.WriteString("-1")
		out.Flush()
		return
	}
	avol := make([]int, n)
	afact := make([]int, n)
	minv := 0
	for i := 0; i < n; i++ {
		avol[i], err = strconv.Atoi(l2[i])
		if err != nil {
			out.WriteString("-1")
			out.Flush()
			return
		}
		cv := (avol[i] + 1) / 2
		if cv < minv {
			cv = minv
		} else {
			minv = cv
		}
		afact[i] = cv
		w -= cv
		if w <= 0 {
			out.WriteString("-1")
			out.Flush()
			return
		}
	}
	maxv := avol[n-1]
	for i := n - 1; i >= 0; i-- {
		add := 0
		if avol[i] > maxv {
			add = maxv - afact[i]
		} else {
			add = avol[i] - afact[i]
			maxv = avol[i]
		}
		if add < w {
			afact[i] += w
			break
		} else {
			afact[i] += add
			w -= add
		}
	}

	if w > 0 {
		out.WriteString("-1")
		out.Flush()
	} else {
		for _, v := range afact {
			out.WriteString(strconv.Itoa(v))
		}
	}
	out.Flush()
}


package main

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

type fs struct {
	data  []int
	index []int
}

func (a *fs) Len() int {
	return len(a.data)
}

func (a *fs) Less(i, j int) bool {
	return a.data[i] > a.data[j]
}

func (a *fs) Swap(i, j int) {
	t := a.index[i]
	a.index[i] = a.index[j]
	a.index[j] = t
}

func main() {
	inp := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	is, err := inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l1 := strings.Split(is, " ")
	if len(l1) != 2 {
		out.WriteString("-1")
		out.Flush()
		return
	}
	n, err := strconv.Atoi(l1[0])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	w, err := strconv.Atoi(l1[1])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is, err = inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l2 := strings.Split(is, " ")
	if len(l2) != n {
		out.WriteString("-1")
		out.Flush()
		return
	}

	avol := make([]int, n)
	afact := make([]int, n)
	index := make([]int, n)
	for i := 0; i < n; i++ {
		avol[i], err = strconv.Atoi(l2[i])
		if err != nil {
			out.WriteString("-1")
			out.Flush()
			return
		}
		afact[i] = (avol[i] + 1) / 2
		w -= afact[i]
		if w < 0 {
			out.WriteString("-1")
			out.Flush()
			return
		}
		index[i] = i
	}

	//fmt.Printf("%v\n", afact)
	fss := fs{
		data:  avol,
		index: index,
	}
	sort.Sort(&fss)
	//fmt.Printf("%v\n", fss.index)

	for _, idx := range fss.index {
		add := avol[idx] - afact[idx]
		if w < add {
			add = w
		}
		afact[idx] += add
		w -= add
	}

	if w > 0 {
		out.WriteString("-1")
		out.Flush()
	} else {
		for _, v := range afact {
			out.WriteString(strconv.Itoa(v))
			out.WriteString(" ")
		}
	}
	out.Flush()
}


package main

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

func main() {
	inp := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	is, err := inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l1 := strings.Split(is, " ")
	if len(l1) != 2 {
		out.WriteString("-1")
		out.Flush()
		return
	}
	n, err := strconv.Atoi(l1[0])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	w, err := strconv.Atoi(l1[1])
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is, err = inp.ReadString('\n')
	if err != nil {
		out.WriteString("-1")
		out.Flush()
		return
	}
	is = strings.TrimRight(is, "\n\r\t ")
	l2 := strings.Split(is, " ")
	if len(l2) != n {
		out.WriteString("-1")
		out.Flush()
		return
	}

	avol := make([]int, n)
	afact := make([]int, n)
	minv := 0
	for i := 0; i < n; i++ {
		avol[i], err = strconv.Atoi(l2[i])
		if err != nil {
			out.WriteString("-1")
			out.Flush()
			return
		}
		cv := (avol[i] + 1) / 2
		if cv < minv {
			cv = minv
		} else {
			minv = cv
		}
		afact[i] = cv
		w -= cv
		if w <= 0 {
			out.WriteString("-1")
			out.Flush()
			return
		}
	}
	maxv := avol[n-1]
	for i := n - 1; i >= 0; i-- {
		add := 0
		if avol[i] > maxv {
			add = maxv - afact[i]
		} else {
			add = avol[i] - afact[i]
			maxv = avol[i]
		}
		if add >= w {
			afact[i] += w
			w = 0
			break
		} else {
			afact[i] += add
			w -= add
		}
		fmt.Println(i, avol[i], afact[i], w)
	}

	if w > 0 {
		out.WriteString("-1")
		out.Flush()
	} else {
		for _, v := range afact {
			out.WriteString(strconv.Itoa(v))
			out.WriteString(" ")
		}
	}
	out.Flush()
}


package main

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

var R0, R1 string

func solve(S string) {
	var pos [26]int
	for i := 0; i < 26; i++ {
		pos[i] = -1
	}
	for i, c := range S {
		idx := int(c) - int('A')
		if pos[idx] == -1 {
			pos[idx] = i
			continue
		}
		x := i - pos[idx] - 1
		if x == 0 {
			fmt.Println("Impossible")
			return
		}
		for j := 0; j < 27; j++ {
			if i == j {
				continue
			}
			if j <= pos[idx]+x/2 {
				R1 += string(S[j])
			} else {
				R0 = string(S[j]) + R0
			}
		}
		for len(R0) > len(R1) {
			R1 = string(R0[0]) + R1
			R0 = R0[1:]
		}
		for len(R1) > len(R0) {
			R0 = string(R1[0]) + R0
			R1 = R1[1:]
		}
		fmt.Println(R0)
		fmt.Println(R1)
		break
	}
}
func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	solve(S)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

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

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

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


package main

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

func solve() {
    s, cur, was := readString(), []int{}, make(map[rune]bool)
    for _, ch := range s {
        if !was[ch] {
            cur = append(cur, int(ch))
            was[ch] = true
        }
    }

    var d [5][16]int
    for t := 0; t < 13*2; t++ {
        for j := 0; j < 13; j++ {
            d[1][j+1] = cur[j]
            d[2][13-j] = cur[j+13]
        }

        curI, curJ, found := t/13 + 2, t%13 + 2, true
        for _, ch := range s {
            ok := false
            for _, di := range []int{-1, 0, 1} {
                for _, dj := range []int{-1, 0, 1} {
                    posI, posJ := curI+di, curJ+dj
                    if !ok && (di != 0 || dj != 0) && int(ch) == d[posI][posJ] {
                        curI, curJ, ok = posI, posJ, true
                    }
                }
            }
            if !ok {
                found = false
            }
        }

        if found {
            for i := 0; i < 2; i++ {
                for j := 0; j < 13; j++ {
                    fmt.Print(string(d[i+1][j+1]))
                }
                fmt.Println()
            }

            return
        }
        cur = append(cur[len(cur)-1:], cur[:len(cur)-1]...)
    }

    fmt.Println("Impossible")
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

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

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

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

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

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

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


package main

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

var R0, R1 string

func solve(S string) {
	var pos [26]int
	for i := 0; i < 26; i++ {
		pos[i] = -1
	}
	for i, c := range S {
		idx := int(c) - int('A')
		if pos[idx] == -1 {
			pos[idx] = i
			continue
		}
		x := i - pos[idx] - 1
		if x == 0 {
			fmt.Println("Impossible")
			return
		}
		for j := 0; j < 27; j++ {
			if i == j {
				continue
			}
			if j <= pos[idx]+x/2 {
				R1 += string(S[j])
			} else {
				R0 = string(S[j]) + R0
			}
		}
		fmt.Println(R0)
		fmt.Println(R1)
		break
	}
}
func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	solve(S)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

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

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

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


package main

import (
	"fmt"
)

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

	var (
		size     int
		ballSize map[int]bool = make(map[int]bool)
	)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &size)
		ballSize[size] = true
	}

	var ok1, ok2 bool
	for size, _ = range ballSize {
		_, ok1 = ballSize[size+1]
		_, ok2 = ballSize[size+2]
		if ok1 && ok2 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	if a == 9 && b == 1 {
		fmt.Printf("9 10\n")
	} else if a == b {
		fmt.Printf("%d1 %d2", a, b)
	} else if a+1 == b {
		fmt.Printf("%d %d", a, b)
	} else {
		fmt.Printf("-1")
	}
}


package main

import "fmt"

func main() {

	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	if a == b {
		fmt.Printf("%d0 %d1", a, b)
	} else if a == b-1 {
		fmt.Printf("%d9 %d0", a, b)
	} else if a == 9 && b == 1 {
		fmt.Println("9 10")
	} else {
		fmt.Println(-1)
	}
}


package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	var a, b int

	fmt.Fscanf(reader, "%d %d\n", &a, &b)
	if a == 9 && b == 1 {
		fmt.Println(9, 10)
		return
	}
	if b-a > 1 || a > b {
		fmt.Println(-1)
		return
	}

	if a == b {
		fmt.Println(a*10, b*10+1)
	} else {
		fmt.Println(b*100-1, b*100)
	}
}