package main

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

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
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int) {
	var m int
	I(&m, "\n")
	o := 0
	ans := 1
	for i := 0; i < n; i++ {
		var t int
		s := " "
		if i == n-1 {
			s = "\n"
		}
		I(&t, s)
		if o+t <= m {
			o += t
		} else {
			i--
			ans++
			o = 0
		}
	}
	O(ans, "\n")
}


package main

import "fmt"

func main() {
	var l, r, x, y, k int64
	fmt.Scan(&l, &r, &x, &y, &k)
	if x*k < l {
		x = (l + k - 1) / k
	}
	if y*k > r {
		y = r / k
	}
	if x > y {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


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, tot int
	scanf("%d\n", &n)
	arr := []int{}
	ans := []int{}
	ans = append(ans, 1)
	for i := 0; i < n; i++ {
		var t int
		scanf("%d", &t)
		tot += t
		arr = append(arr, t)
	}
	cur := arr[0]
	for i := 1; i < n; i++ {
		if arr[i]*2 <= arr[0] {
			cur += arr[i]
			ans = append(ans, i+1)
		}
	}
	if cur > tot-cur {

		printf("%d\n", len(ans))
		for i := 0; i < len(ans); i++ {
			printf("%d ", ans[i])
		}
	} else {
		printf("0")
	}
}


package main
import "fmt"

func main() {
    var a, b, x int64
    x = 1

    fmt.Scan(&a, &b);

    for i := a + 1; i <= b; i++ {
        x = (x * i % 10) % 10
    }

    fmt.Println(x);
}


package main

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()

	var a,b int64
	scanf("%d %d\n", &a, &b)

	var ans = (a+1) % int64(10)

	for i:=a+2;i<=b && ans != 0; i++ {
		ans = (ans * (i % int64(10)) % int64(10) )
	}

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


package main

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

var (
	in  *bufio.Reader
	out *bufio.Writer
)

func init() {
	in = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
}

type prop struct {
	hp, atk, def int
}

func live(hp, dmg int) int {
	if dmg <= 0 {
		return 1000000000
	}
	return (hp + dmg - 1) / dmg
}

func main() {
	defer out.Flush()
	var (
		y, m prop
		h, a, d int
	)
	fmt.Fscan(in, &y.hp, &y.atk, &y.def)
	fmt.Fscan(in, &m.hp, &m.atk, &m.def)
	fmt.Fscan(in, &h, &a, &d)
	ans := 205 * h + 205 * a + 205 * d
	for bh := 0; bh <= 205; bh++ {
		for ba := 0; ba <= 205; ba++ {
			for bd := 0; bd <= 205; bd++ {
				pr := bh * h + ba * a + bd * d
				if pr >= ans {
					continue
				}
				if live(y.hp + bh, m.atk - (y.def + bd)) > live(m.hp, (y.atk + ba) - m.def) {
					ans = pr
				}
			}
		}
	}
	fmt.Fprintln(out, ans)
}


package main

import "fmt"

func getCategories(x int) string {
	return map[int]string{1: "A", 3: "B", 2: "C", 0: "D"}[x%4]
}

func main() {
	var x, a int
	fmt.Scan(&x)
	if getCategories(x+1) < getCategories(x+a) {
		a = 1
	}
	if getCategories(x+2) < getCategories(x+a) {
		a = 2
	}
	fmt.Println(a, getCategories(x+a))
}


package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scanf("%d", &x)
	i := x % 4
	switch i {
	case 1:
		fmt.Println("0 A")
		break
	case 3:
		fmt.Println("2 A")
		break
	case 2:
		fmt.Println("1 B")
		break
	case 0:
		fmt.Println("1 A")
	default:
		return
	}
}


package main

import "fmt"

func main() {
	fmt.Println("enter text")
	var input int
	fmt.Scanln(&input)
	var remainder = input % 4
	if remainder == 0 {
		fmt.Println("1 A")
	} else if remainder == 1 {
		fmt.Println("0 A")
	} else if remainder == 2 {
		fmt.Println("1 B")
	} else if remainder == 3 {
		fmt.Println("2 A")
	}
}


package main

import "fmt"

func main() {
	var n, m, z int

	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &m)
	fmt.Scanf("%d", &z)

	// kill them all
	kill_count := 0

	if n == m {
		fmt.Println(z)
		return
	}

	for i := 1; i <= z; i++ {
		if (i)%m == 0 && (i)%n == 0 {
			kill_count += 1
		}
	}

	fmt.Println(kill_count)

	return
}


package main

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

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

    return a
}

func getLine(s *bufio.Scanner) (int,int,int) {
    s.Scan()
    ab := strings.Fields(s.Text())
    a, _ := strconv.Atoi(ab[0])
    b, _ := strconv.Atoi(ab[1])
    c, _ := strconv.Atoi(ab[2])

    return a,b,c
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    n, m, z:= getLine(scanner)
    a := 0
    if GCD(n,m) == 1 {
        a = n*m
    } else {
        a = m
    }
    fmt.Println(z / a)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, m, z, cnt int

	fmt.Fscanln(reader, &n, &m, &z)

	for i := 1; i*m <= z; i++ {
		if (i*m)%n == 0 {
			cnt++
		}
	}

	fmt.Println(cnt)
}


package main

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

func main() {
	var n, p, l int

	input := bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &n)

	for i := 0; i < n; i++ {
			p = l
		fmt.Fscan(input, &l)
	}

	if n == 1 {
		if l == 15 {
			fmt.Println("DOWN")
		} else if l == 0 {

			fmt.Println("UP")
		} else {
			fmt.Println(-1)
		}

	return
}
	if p > l {
		if l == 1 {
			fmt.Println("UP")
			return
		}
		fmt.Println("DOWN")
	} else {
		if l == 15 {
			fmt.Println("DOWN")
			return
		}
		fmt.Println("UP")
	}

}


package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

	if a[n-1] == 0 {
		fmt.Fprintf(bufout, "UP\n")
	} else if a[n-1] == 15 {
		fmt.Fprintf(bufout, "DOWN\n")
	} else if n == 1 {
		fmt.Fprintf(bufout, "-1\n")
	} else if a[n-2] < a[n-1] {
		fmt.Fprintf(bufout, "UP\n")
	} else {
		fmt.Fprintf(bufout, "DOWN\n")
	}
}


package main

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

var k_cf702d, a_cf702d, b_cf702d, t_cf702d int

func startCar(d int64) float64 {
	if d <= int64(k_cf702d) {
		return float64(int64(a_cf702d)*d)
	}
	return float64(a_cf702d*k_cf702d) + math.Min(float64(float64(t_cf702d) + startCar(d-int64(k_cf702d))), float64(int64(b_cf702d)*(d-int64(k_cf702d))))
}

func main() {

	//fmt.Printf("%f\n", math.MaxFloat64)
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Buffer([]byte{}, int(math.Pow(10,8)))

	scanner.Scan()
	dkabtStr := scanner.Text()
	dkabtStrArr := strings.Split(dkabtStr, " ")
	d, _ := strconv.ParseInt(dkabtStrArr[0], 10, 64)
	k_cf702d, _ = strconv.Atoi(dkabtStrArr[1])
	a_cf702d, _ = strconv.Atoi(dkabtStrArr[2])
	b_cf702d, _ = strconv.Atoi(dkabtStrArr[3])
	t_cf702d, _ = strconv.Atoi(dkabtStrArr[4])

	var resp float64
	if d <= int64(k_cf702d) {
		resp = float64(int64(a_cf702d) * d)
	} else {
		resp = float64(a_cf702d*k_cf702d)
		carAvg := (float64(t_cf702d)/float64(k_cf702d)) + float64(a_cf702d)
		if  carAvg <= float64(b_cf702d) {
			resp += float64(d - int64(k_cf702d)) * carAvg
		} else {
			resp += float64((d - int64(k_cf702d)) * int64(b_cf702d))
		}
	}

	//resp := math.Min(float64(int64(b_cf702d)*d), startCar(d))

	fmt.Printf("%f\n", math.Ceil(resp))
}


package main

import (
	"fmt"
)

func solve(n int, is []int) {
	sum := 0
	for _, v := range is {
		sum += v
	}
	n = n % sum

	for i, v := range is {
		if n-v <= 0 {
			fmt.Println(i + 1)
			return
		}
		n -= v
	}

}

func main() {
	var n, tmp int

	_, err := fmt.Scan(&n)
	if err != nil {
		panic(err)
	}
	is := make([]int, 0, 7)
	for i := 0; i < 7; i++ {
		fmt.Scan(&tmp)
		if err != nil {
			panic(err)
		}
		is = append(is, tmp)
	}
	solve(n, is)
}


package main

import (
	"bufio"
	"os"
	"fmt"
)
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 readLine()(string,error) 			{ return reader.ReadString('\n') }

func main() {
	defer writer.Flush()
	var n, v int
	scanf("%d %d", &n, &v)
	var c int;
	if (n < v) {
		c = n - 1
	} else {
		c = v
		for i := 2; i <= n-v; i++ {
			c +=  i
		}
	}
	printf("%d\n" ,c)
}


package main

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

func main() {
	var i, tmp int
	var arr1, arr2 []int
	var arr3 [4]int
	var flag bool
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	line, _ := reader.ReadString('\n')
	arrS := strings.Split(strings.TrimSpace(line), " ")
	for i := range arrS {
		tmp, _ = strconv.Atoi(arrS[i])
		arr3[i] = tmp
	}
	line, _ = reader.ReadString('\n')
	arrS = strings.Split(strings.TrimSpace(line), " ")
	for i := range arrS {
		tmp, _ = strconv.Atoi(arrS[i])
		arr3[i+2] = tmp
	}
	i = 0
	for i != 6000 {
		arr1 = append(arr1, arr3[1]+(i*arr3[0]))
		arr2 = append(arr2, arr3[3]+(i*arr3[2]))
		i++
	}
	i = 0
	for j := range arr1 {
		x := arr1[j]
		i := sort.Search(len(arr2), func(i int) bool { return arr2[i] >= x })
		if i < len(arr2) && arr2[i] == x {
			writer.WriteString(strconv.Itoa(x))
			flag = true
			break
		}
	}
	if !flag {
		writer.WriteString("-1")
	}
	writer.Flush()
}


package main

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

var scanner *bufio.Scanner

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

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

  s := getS()
  chars := []byte{ s[0] }
  for i := 1; i < len(s); i++ {
    if s[i] != '/' || s[i-1] != '/' {
      chars = append(chars, s[i])
    }
  }
  if len(chars) > 1 && chars[len(chars)-1] == '/' {
    chars = chars[:len(chars)-1]
  }
  writer.WriteString(fmt.Sprintf("%s\n", string(chars)))
}


// 402A-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var k, a, b, v, hasil int
    fmt.Scan(&k, &a, &b, &v)
    for a > 0 {
        if b >= k-1 {
            b -= (k - 1)
            a -= v * k
            hasil++
        } else if b != 0 {
            a -= v * (b + 1)
            hasil++
            b = 0
        } else {
            a -= v
            hasil++
        }
    }
    fmt.Println(hasil)
}


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

var n, m, mod int64
var matrix [][]int

func multiply(one, two [][]int) [][]int {
	res := make([][]int, m)
	for i := 0; i < int(m); i++ {
		res[i] = make([]int, m)
	}
	for i := 0; i < int(m); i++ {
		for j := 0; j < int(m); j++ {
			for k := 0; k < int(m); k++ {
				res[i][j] += int(int64(one[i][k]) * int64(two[k][j]) % mod)
				res[i][j] %= int(mod)
			}
		}
	}
	return res
}

func power(exp int64, base [][]int) [][]int {

	if exp == 1 {
		return base
	}

	res := power(exp/2, base)
	res = multiply(res, res)
	if exp&1 == 1 {
		res = multiply(res, base)
	}
	return res
}

func main() {
	defer writer.Flush()
	mod = 1000000007
	scanf("%d %d\n", &n, &m)
	if n < m {
		printf("1")
		return
	}
	if n == m {
		printf("2")
		return
	}
	matrix = make([][]int, m)
	for i := 0; i < int(m); i++ {
		matrix[i] = make([]int, m)
	}
	matrix[0][0] = 1
	matrix[0][m-1] = 1
	for i := 1; i < int(m); i++ {
		matrix[i][i-1] = 1
	}

	fmt.Println(power(n, matrix)[0][0])

}


package main

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

func isSubsequence(s, t string) bool {
	if len(s) < len(t) {
		return false
	}

	for _, c := range t {
		if !strings.Contains(s, string(c)) {
			return false
		}
	}
	return true
}

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

func main() {
	var (
		s, t string
	)

	// file, err := os.Open("input.txt")
	// if err != nil {
	// 	panic(err)
	// }

	reader := bufio.NewReader(os.Stdin)

	fmt.Fscanf(reader, "%s\n", &s)
	fmt.Fscanf(reader, "%s\n", &t)

	var maxLen = -1
	for l := 0; l < len(s); l++ {
		for r := l; r < len(s); r++ {
			arr := []string{string(s[:l]), string(s[r+1:])}
			newS := strings.Join(arr, "")

			if isSubsequence(newS, t) {
				maxLen = max(r-l+1, maxLen)
			}
		}
	}

	fmt.Println(maxLen)

}


package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	k := scanInt(scanner)
	scanner.Scan()
	s := scanner.Text()
	n := len(s)
	pal := make([]uint8, n)
	for i, ch := range s {
		pal[i] = uint8(ch)
	}
	for i := (n-1)/2; i >= 0; i-- {
		j := n-1-i
		if pal[i] == pal[j] {
			continue
		}
		if pal[i] == '?' {
			pal[i] = pal[j]
		} else if pal[j] == '?' {
			pal[j] = pal[i]
		} else {
			writer.WriteString("IMPOSSIBLE\n")
			return
		}
	}
	seen := map[uint8]bool{}
	for i := 0; i < k; i++ {
		seen['a'+uint8(i)] = false
	}
	for _, ch := range pal {
		if ch != '?' {
			seen[ch] = true
		}
	}
	need := []uint8{}
	for ch, ok := range seen {
		if !ok {
			need = append(need, ch)
		}
	}
	/*
	for _, ch := range pal {
		writer.WriteString(fmt.Sprintf("%c", ch))
	}
	writer.WriteString(fmt.Sprintf(" (k = %d)\n", k))
	writer.WriteString(fmt.Sprintf("need %d:", len(need)))
	for _, ch := range need {
		writer.WriteString(fmt.Sprintf(" %c", ch))
	}
	writer.WriteString("\n")
	*/
	nix := len(need)-1
	for i := (n-1)/2; i >= 0; i-- {
		if pal[i] != '?' {
			continue
		}
		j := n-1-i
		if nix == -1 {
			pal[i] = 'a'
			pal[j] = 'a'
		} else {
			pal[i] = need[nix]
			pal[j] = need[nix]
			nix--
		}
	}
	if nix != -1 {
		writer.WriteString("IMPOSSIBLE\n")
		return
	}
	for _, ch := range pal {
		writer.WriteString(fmt.Sprintf("%c", ch))
	}
	writer.WriteString("\n")
}


package main

import (
  "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 a, b, c int
  scanf("%d %d %d\n", &a, &b, &c)
  solve(a, b, c)
}

// a b c a c b a
func solve(a, b, c int) {
  min := a / 3
  if b/2 < min {
    min = b / 2
  }
  if c/2 < min {
    min = c / 2
  }
  a -= min * 3
  b -= min * 2
  c -= min * 2
  max := 0
  food := []int{0, 1, 2, 0, 2, 1, 0}
  for start := range food {
    temp := 0
    cur := start
    store := []int{a, b, c}
    for true {
      cur %= 7
      store[food[cur]]--
      if store[food[cur]] < 0 {
        break
      } else {
        temp++
      }
      cur++
    }
    if temp > max {
      max = temp
    }
  }
  printf("%d\n", max+7*min)
}


package main

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

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

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

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

	fmt.Println(packs)
}


package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

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

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	k := readll()
	n := readll()
	s := readll()
	p := readll()

	s2 := n / s
	if n%s != 0 {
		s2++
	}
	ans := k * s2 / p
	if s2%p != 0 {
		ans++
	}
	println(ans)
}


// 146A
package main

import (
	"fmt"
)

func main() {
	var n int
	var x string
	fmt.Scan(&n)
	fmt.Scan(&x)
	out := true
	firstSum, secondSum := 0, 0
	for k := 0; k < n; k++ {
		if out {
			if x[k] != 4 && x[k] != 7 {
				out = false
			}
			if k < (n / 2) {
				firstSum += int(x[k] - '0')
			} else {
				secondSum += int(x[k] - '0')
			}
		}
	}
	if firstSum != secondSum {
		out = false
	}
	if out {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
	fmt.Println(out)
}


package main

import "fmt"

var x, k, A, B, res int64

func main()  {
	fmt.Scanf("%d\n%d\n%d\n%d", &x, &k, &A, &B)
	for x > 1 {
		if (k == 1) || (x % k != 0) {
			x--
			res += A
		} else {
			d := x / k;
			if B > (x - d) * A {
				x--
				res += A
			} else {
				x /= k
				res += B
			}
		}
	}
	fmt.Println(res)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1618F(in io.Reader, out io.Writer) {
	var x, y uint64
	Fscan(in, &x, &y)
	if x == y {
		Fprintln(out, "YES")
		return
	}
	s := strconv.FormatUint(x, 2)
	t := strconv.FormatUint(y, 2)
	f := func() bool {
		r := regexp.MustCompile("^1*" + s + "1*$")
		return r.MatchString(t)
	}
	if f() {
		Fprintln(out, "YES")
		return
	}
	for s[len(s)-1] == '0' {
		s = s[:len(s)-1]
	}
	if f() {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

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


package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
	if b - a == c - b && c - b == d - c {
		fmt.Printf("%d", a + (b - a) * 4)
	} else if a != 0 && b != 0 && c != 0 && d != 0 && b * b == a * c && c * c == b * d && a != b {
		if d * d % c == 0 {
			fmt.Printf("%d", d * d / c)
		} else {
			fmt.Printf("42")
		}
	} else {
		fmt.Printf("42")
	}
}


package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanln(&a)
	b = 0
	for a != 0 {
		if a%8 == 1 {
			b++
		}
		a /= 8
	}
	fmt.Println(b)
}


package main

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

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

//Wrong
func main() {
	// defer func(start time.Time) {
	// 	fmt.Println(time.Since(start))
	// }(time.Now())

	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, p, k := nextInt(), nextInt(), nextInt()

	if p-k>1 {
		fmt.Fprint(writer, "<< ")
	}

	for i:=0; i<k; i++ {
		if p-k+i >= 1 {
			fmt.Fprint(writer, p-k+i, " ")
		}
	}

	fmt.Fprint(writer, "(", p, ") ")

	for i:=1; i<=k; i++ {
		if p+i <= n {
			fmt.Fprint(writer, p+i, " ")
		}
	}

	if p+k<n {
		fmt.Fprintln(writer, ">>")
	}
}

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

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


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"path/filepath"
	"runtime"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n uint64
	fmt.Fscanln(r, &n)
	fmt.Fprintln(w, int(math.Ceil(math.Log2(float64(n)))))
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{in: `2`, want: `1`},
		{in: `3`, want: `2`},
		{in: `4`, want: `2`},
		{in: `5`, want: `3`},
		{in: `6`, want: `3`},
		{in: `7`, want: `3`},
		{in: `8`, want: `3`},
		{in: `9`, want: `4`},
		{in: `10`, want: `4`},
		{in: `16`, want: `4`},
		{in: `17`, want: `5`},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(chomp(tt.in)), buf)
		if got, want := chomp(buf.String()), chomp(tt.want); got != want {
			fmt.Printf("%d: got %v, want %v\n", i, got, want)
		}
	}
}

func chomp(s string) string {
	return strings.Trim(s, "\n")
}

func assert(b bool) {
	if !b {
		_, file, line, ok := runtime.Caller(1)
		if ok {
			f, _ := os.Open(file)
			defer f.Close()
			s := bufio.NewScanner(f)
			lnum := 0
			for s.Scan() {
				lnum++
				if lnum == line {
					wd, _ := os.Getwd()
					fname, _ := filepath.Rel(wd, file)
					fmt.Printf("assertion fails: %s:%d: %v\n", fname, line, s.Text())
					break
				}
			}
		}
	}
}

func pow(a, b int) int {
	r := 1
	for i := 0; i < b; i++ {
		r *= a
	}
	return r
}


package main

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

type Vec [4]int

func (v Vec) max() int {
	max := -999
	for i := 0;i < len(v);i ++ {
		if v[i] > max {
			max = v[i]
		}
	}
	return max
}

func (v Vec) min() int {
	min := 999
	for i := 0;i < len(v);i ++ {
		if v[i] < min {
			min = v[i]
		}
	}
	return min
}

func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}
func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var ax, ay, bx, by Vec
	fmt.Fscanf(reader, "%d %d %d %d %d %d %d %d\n", &ax[0], &ay[0], &ax[1], &ay[1], &ax[2], &ay[2], &ax[3], &ay[3])
	fmt.Fscanf(reader, "%d %d %d %d %d %d %d %d\n", &bx[0], &by[0], &bx[1], &by[1], &bx[2], &by[2], &bx[3], &by[3])

	axMax, axMin, ayMax, ayMin := ax.max(), ax.min(), ay.max(), ay.min()
	bxMax, bxMin, byMax, byMin := bx.max(), bx.min(), by.max(), by.min()
	bxAvg, byAvg := (bxMax + bxMin) / 2, (byMax + byMin) / 2
	dist := bxMax - bxAvg

	for x := -100; x <= 100; x ++ {
		for y := -100; y <= 100; y ++ {
			if (axMin <= x && x <= axMax && ayMin <= y && y <= ayMax) {
				if (abs(x - bxAvg) + abs(y - byAvg) <= dist) {
					fmt.Printf("YES")
					return
				}
			}
		}
	}
	fmt.Printf("NO")
	return
}


package main

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

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

func ReadString(scanner *bufio.Scanner) string {
  scanner.Scan()
  ans := scanner.Text()
  return ans
}

func PrintInt(writer *bufio.Writer, value int) {
  writer.WriteString(strconv.Itoa(value))
  writer.WriteByte(' ')
}

func PrintInts(writer *bufio.Writer, ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
  writer.WriteByte('\n')
}

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

  n, k := ReadInt32(scanner), ReadInt32(scanner)
  hn := n / 2
  total := n * (n - 1) / 2

  if k >= hn {
    k = hn
    PrintInt(writer, total)
    return
  }
  PrintInts(writer, n, k, hn)

  total -= (n - k) * (n - k - 1) / 2
  total += k * (n - 2 * k)
  total += k * (k - 1) / 2

  PrintInt(writer, total)
  writer.WriteByte('\n')
}


package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	userInput, _ := in.ReadString('\n')
	userInputArray := strings.Split(userInput, " ")

	var n, _ = strconv.Atoi(userInputArray[0])
	var t, _ = strconv.Atoi(userInputArray[1])
	var k, _ = strconv.Atoi(userInputArray[2])
	var d, _ = strconv.Atoi(strings.TrimRight(userInputArray[3], "\n"))
	numberOfTrials := (n + k - 1) / k;
	ovenOneStart := 0
	ovenTwoStart := d;
	for i := 0; i < numberOfTrials; i++ {
		if ovenOneStart <= ovenTwoStart {
			ovenOneStart += t
		} else {
			ovenTwoStart += t
		}
	}

	if Max(ovenOneStart, ovenTwoStart) < (numberOfTrials * t) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


package main

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

const modVal = 1e9 + 7

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int64
	fmt.Fscan(in, &n)
	var fact = int64(1)
	var pow = int64(1)

	for i := int64(1); i < n; i++ {
		fact *= i
		pow *= 2

		fact %= modVal
		pow %= modVal
	}
	fact *= n

	v := fact - pow
	v %= modVal
	fmt.Println(v)
}


package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	const mod = int64(1e9 + 7)

	n := int64(io.NextInt())
	p, f := (mod+1)/2, int64(1)
	for i := int64(1); i <= n; i++ {
		f = f * i % mod
		p = p * 2 % mod
	}
	ans := (f - p + mod) % mod
	io.Println(ans)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, 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()
}


package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()
	var n, m, k int
	fmt.Fscanf(bufin, "%d %d %d\n", &n, &m, &k)
	p := 2 * m
	lane := (k + p - 1) / p
	k -= p * (lane - 1)
	desk := (k + 1) / 2
	pos := 'L'
	if k%2 == 0 {
		pos = 'R'
	}
	fmt.Fprintf(bufout, "%d %d %c\n", lane, desk, pos)
}


package main

import (
	. "fmt"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var x string
	Scan(&x)
	n := len(x)
	if n == 1 {
		Print(x)
		return
	}
	data := []byte(x)
	sum := 0
	for _, c := range x {
		sum += int(c - '0')
	}
	if x[1] == '9' {
		data[1] = '8'
		x9 := strings.Repeat("9", n-2)
		if newSum := int(data[0]-'0') + 8 + 9*(n-2); newSum <= sum {
			Print(x)
			return
		}
		Print(string(data[0]) + "8" + x9)
		return
	}
	data[0]--
	x9 := strings.Repeat("9", n-1)
	if newSum := int(data[0]-'0') + 9*(n-1); newSum <= sum {
		Print(x)
		return
	}
	if data[0] == '0' {
		Print(x9)
	} else {
		Print(string(data[0]) + x9)
	}
}


package main

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

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

func ReadString(scanner *bufio.Scanner) string {
  scanner.Scan()
  ans := scanner.Text()
  return ans
}

func PrintInt(writer *bufio.Writer, value int) {
  writer.WriteString(strconv.Itoa(value))
  writer.WriteByte(' ')
}

func PrintInts(writer *bufio.Writer, ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
  writer.WriteByte('\n')
}

func ReadPazzle(scanner *bufio.Scanner) string {
  r1 := ReadString(scanner)
  r2 := ReadString(scanner)

  return r1 + r2[1:] + r2[0:1]
}

func Compare(p1, p2 string) bool {
  if p1 == p2 {
    return true
  }
  p1 = p1 + p1 + p1 + p1
  return strings.Contains(p1, p2)
}

func Shift(p string) string {
  l := len(p)

  p = p[l-2:l-1] + p[0:l-1]
  return p
}

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

  pz1 := ReadPazzle(scanner)
  pz2 := ReadPazzle(scanner)

  pz1 = strings.Replace(pz1, "X", "", 1)
  pz2 = strings.Replace(pz2, "X", "", 1)

  if Compare(pz1, pz2) {
    writer.WriteString("YES")
  } else {
    writer.WriteString("NO")
  }
  writer.WriteByte('\n')
  // writer.WriteByte('\n')
}


package main

import (
	"bufio"
	"os"
)

func main() {
	var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
	var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	scanner.Scan()
	s1 := scanner.Text()
	scanner.Scan()
	s11 := scanner.Text()
	scanner.Scan()
	s2 := scanner.Text()
	scanner.Scan()
	s22 := scanner.Text()

	se := make([]byte, 0, 3)
	sb := make([]byte, 0, 3)
	for i := 0; i < 2; i++ {
		if s1[i] != 'X' {
			se = append(se, s1[i])
		}
		if s2[i] != 'X' {
			sb = append(sb, s2[i])
		}
	}
	for i := 1; i >= 0; i-- {
		if s11[i] != 'X' {
			se = append(se, s11[i])
		}
		if s22[i] != 'X' {
			sb = append(sb, s22[i])
		}
	}
	ec := 0
	eb := 0
	gse := string(se)
	gsb := string(sb)

	if gse == "ABC" || gse == "CAB" || gse == "BCA" {
		ec = 1
	}
	if gsb == "ABC" || gsb == "CAB" || gsb == "BCA" {
		eb = 1
	}
	if ec == eb {
		writer.WriteString("YES")
	} else {
		writer.WriteString("NO")
	}
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d\n", &a[i])
	}
	b := make([]int, n)
	find := false
	for i := 0; i < 1<<uint(n); i++ {
		cur := 0
		q := i
		for j := 0; j < n; j++ {
			b[j] = q % 2
			q /= 2
			if b[j] == 0 {
				cur += a[j]
			} else {
				cur -= a[j]
			}
		}
		if cur%360 == 0 {
			find = true
		}
	}
	if find {
		fmt.Fprintf(out, "YES\n")
	} else {
		fmt.Fprintf(out, "NO\n")
	}
	return
}


package main

import "fmt"

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

func main() {
	var a, b, x, y uint64
	fmt.Scanf("%d %d %d %d", &a, &b, &x, &y)

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

	if a/x > b/y {
		fmt.Println(b / y)
		return
	}

	fmt.Println(a / x)
}


package main

import (
	"fmt"
)

func main() {

	var n, c int
	fmt.Scanf("%d%d", &n, &c)
	var prev, max int = -1000, -1000
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		if prev-x > max {
			max = prev - x
		}
		prev = x
	}
	if max > c {
		max = max - c
	} else {
		max = 0
	}
	fmt.Println(max)
}


package main

import (
	"fmt"
)

func main() {
	var n, c int

	fmt.Scan(&n, &c)

	xi := make([]int, n)

	for i := range xi {
		fmt.Scan(&xi[i])
	}

	max, dif := 0, 0

	for i:=0; i<n-1; i++ {
		dif = xi[i] - xi[i+1]
		if dif > max {
			max = dif
		}
	}

	if max == 0 || max <= c {
		fmt.Println(0)
	} else {
		fmt.Println(max - c)
	}
}


package main

import "fmt"

func main() {
	s := make([]string, 4)
	for i := range s {
		fmt.Scanln(&s[i])
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			cnt := 0
			if s[i][j] == '.' {
				cnt++
			}
			if s[i+1][j] == '.' {
				cnt++
			}
			if s[i][j+1] == '.' {
				cnt++
			}
			if s[i+1][j+1] == '.' {
				cnt++
			}
			if cnt != 2 {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


package main

import "fmt"

func check(x [4]string, a int, b int) bool {
    cnt := 0
    for i := a; i < (a+2); i++ {
        for j := b; j < (b+2); j++ {
            if x[i][j] != x[a][b] { cnt++ }
        }
    }
    if cnt <= 1 { return true } else { return false }
}

func main() {
    var x [4]string
    for i := 0; i < 4; i++ {
        fmt.Scan(&x[i])
    }
    ans := false
    for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
            if check(x,i,j) {
                ans = true
                break
            }
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


package main

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

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
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int) {
	var m int
	I(&m, "\n")
	mm := map[int]int{
		1:  31,
		2:  28,
		3:  31,
		4:  30,
		5:  31,
		6:  30,
		7:  31,
		8:  31,
		9:  30,
		10: 31,
		11: 30,
		12: 31,
	}
	ans := (mm[n] + m - 1) / 7
	if (mm[n]+m-1)%7 != 0 {
		ans++
	}
	O(ans, "\n")
}


package main

import (
	"fmt"
	"os"
)

var sharp = "#"[0]

// Start from the top-left point, the only point that we can not paint is [1, 1]
var penDirs = [8][2]int{
	[2]int{0, 0},
	[2]int{0, 1},
	[2]int{0, 2},
	[2]int{1, 0},
	[2]int{1, 2},
	[2]int{2, 0},
	[2]int{2, 1},
	[2]int{2, 2},
}

func main() {
	r, c := 0, 0
	fmt.Scan(&r, &c)
	p := make([][]int, r)
	for i := 0; i < r; i++ {
		l := ""
		fmt.Scan(&l)
		p[i] = make([]int, c)
		for j := 0; j < len(l); j++ {
			if l[j] == sharp {
				p[i][j] = 1
			}
		}
	}

	for i := 0; i < (r - 2); i++ {
		for j := 0; j < (c - 2); j++ {
			usePen := true
			for _, v := range penDirs {
				if p[i+v[0]][j+v[1]] == 0 {
					usePen = false
				}
			}
			if !usePen {
				continue
			}
			for _, v := range penDirs {
				p[i+v[0]][j+v[1]] = 2
			}
		}
	}

	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			if p[i][j] == 1 {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}
	fmt.Println("YES")
}


package main

import "fmt"

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

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


package main

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

var scanner *bufio.Scanner
var t [1e6 + 1]bool

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

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

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

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

func divides(x int, s []int) bool {
	for _, i := range s {
		if x%i == 0 {
			return true
		}
	}
	return false
}

func main() {
	init_scanner()
	p, y := readInt(), readInt()

	var s []int
	for i := 2; i <= int(math.Min(float64(p), math.Floor(math.Sqrt(float64(y))))); i++ {
		if is_prime(i) {
			s = append(s, i)
		}
	}

	ans := -1
	for i := y; i > int(math.Max(float64(p), float64(y-100000))); i-- {
		if !divides(i, s) {
			ans = i
			break
		}
	}

	fmt.Println(ans)
}


package main

import (
        "fmt"
)

var num int

func main() {
        fmt.Scan(&num)
        cvs := make([]int, num)
        var tmp int
        count := 0
        for i := 0; i < num; i++ {
                fmt.Scan(&tmp)
                cvs[i] = tmp
                if tmp == 1 {
                        count++
                }
        }
        ans := count
        zeros := 0
        for _, val := range cvs {
                if val == 0 {
                        zeros++
                } else {
                        count--
                }
                res := count + zeros
                if res > ans {
                        ans = res
                }
        }
        fmt.Println(ans)
}


package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
    stdout = bufio.NewWriter(os.Stdout)
}

func check(grid [][]int, row1, row2, col1, col2 int) int {
	count := 0
	for i := row1; i <= row2; i++ {
		for j := col1; j <= col2; j++ {
			count += grid[i][j]
		}
	}
	return count
}

func main() {

	r, c, n, k := 0, 0, 0, 0
	fmt.Fscanf(stdin, "%d%d%d%d\n", &r, &c, &n, &k)

	grid := make([][]int, r)
	for i := 0; i < r; i++ {
		grid[i] = make([]int, c)
	}

	for i := 0; i < n; i++ {
		x, y := 0, 0
		fmt.Fscanf(stdin, "%d%d\n", &x, &y)
		grid[x - 1][y - 1] = 1;
	}

	count := 0

	for r1 := 0; r1 < r; r1++ {
		for r2 := r1; r2 < r; r2++ {
			for c1 := 0; c1 < c; c1++ {
				for c2 := c1; c2 < c; c2++ {
					if check(grid, r1, r2, c1, c2) >= k {
						count++
					}
				}
			}
		}
	}

	fmt.Fprintf(stdout, "%d\n", count)

    stdout.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"log"
	"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, index := scanInt(), scanInt()-1
	c := make([]bool, n)
	for i := 0; i < n; i++ {
		c[i] = scanInt() == 1
	}

	total := 0
	if c[index] {
		total = 1
	}
	for i := 1; i < 100; i++ {
		l, r := index-i, index+i
		if (l < 0) && (r >= n) {
			break
		}
		if (l >= 0) && (r < n) && c[l] && c[r] {
			total += 2
		}
		if (l >= 0) && (r >= n) && c[l] {
			total++
		}
		if (l < 0) && (r < n) && c[r] {
			total++
		}
	}
	fmt.Println(total)
}


package main

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

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

	Div2 := 0
	Div5 := 0
	tmp := N
	for tmp%2 == 0 {
		tmp /= 2
		Div2++
	}

	for tmp%5 == 0 {
		tmp /= 5
		Div5++
	}
	for i := 0; i < K-Div2; i++ {
		N *= 2
	}
	for i := 0; i < K-Div5; i++ {
		N *= 5

	}

	fmt.Println(N)

}

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

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

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

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

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

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

	return mp
}

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


package main

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

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

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

	bubble_sort(a, n)

	length := int64(a[0])
	for i := 1; i < n; i++ {
		if a[i] <= 0 {
			break
		}
		if a[i] >= a[i-1] {
			a[i] = a[i-1] - 1
		}
		length += int64(a[i])
	}
	fmt.Println(length)
}

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

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


package main

import (
	"fmt"
)

func main() {
	var b, res int64
	fmt.Scan(&b)
	for i := int64(1); i <= b; i++ {
		if b%i == 0 {

			res++
		}
	}
	fmt.Println(res)
}


package main

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

var reader SReader
var helper SHelper

func main() {
	reader.Init()
	n := reader.ReadInt()
	a := reader.ReadInt()
	b := reader.ReadInt()

	a2 := helper.Max(a, b)
	b2 := helper.Min(a, b)

	for x := Int(0); x <= n / a2; x++ {
		y := (n - x * a2) / b2
		if (x * a2 + y * b2) == n {
			fmt.Println("YES")
			if a > b {
				fmt.Println(x, y)
			} else {
				fmt.Println(y, x)
			}
			return
		}
	}

	fmt.Println("NO")
}

// type
type Int int32
type Uint uint32

// reader
type SReader struct {
	file *os.File
	scanner *bufio.Scanner
}

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

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

// min/max
type SHelper struct {}

func (*SHelper) Max(a, b Int) Int {
	if a > b {
		return a
	} else {
		return b
	}
}

func (*SHelper) Min(a, b Int) Int {
	if a < b {
		return a
	} else {
		return b
	}
}


/*
URL:
https://codeforces.com/problemset/problem/735/D
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n int64
)

func main() {
	n = ReadInt64()

	if IsPrime(n) {
		fmt.Println(1)
		return
	}

	if n%2 == 0 {
		fmt.Println(2)
		return
	}

	if IsPrime(n - 2) {
		fmt.Println(2)
		return
	}

	fmt.Println(3)
}

// func main() {
// 	n = readInt64()

// 	// ans := 0
// 	A := []int64{}
// 	for {
// 		// ans++
// 		if IsPrime(n) {
// 			A = append(A, n)
// 			break
// 		}

// 		p := sub(n - 2)
// 		n -= p
// 		A = append(A, p)
// 	}
// 	// fmt.Println(ans)
// 	fmt.Println(len(A))
// }

// n以下の最大の素数を返す
func sub(n int64) int64 {
	for i := n; i >= 2; i-- {
		if IsPrime(i) {
			return i
		}
	}
	return 1
}

// IsPrime judges whether an argument integer is a prime number or not.
func IsPrime(n int64) bool {
	var i int64

	if n == 1 {
		return false
	}

	for i = 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


package main

import "fmt"

var n, m, a, b int

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

func main() {
    fmt.Scan(&n, &m, &a, &b)
    if n % m == 0 {
        fmt.Println("0")
    } else {
        c := n / m
        ans := min((c * m + m - n) * a, (n - c * m) * b)
        fmt.Println(ans)
    }
}


package main

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

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

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

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

	nx := x << (nlen - xlen)

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

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

	return res
}

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

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

	return res
}

func main() {
	defer writer.Flush()

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

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

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

	println(x)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


package main

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

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

	var n int
	fmt.Fscan(r, &n)
	fmt.Fprintln(w, 2*n + 1)
}


package main
import "fmt"

func main() {
	sdeck := make([]string, 8)
	for i := 0; i < 8; i++{
		fmt.Scan(&sdeck[i])
	}
	var deck [8][8]int
	count := 0
	for i, s := range sdeck{
		for j, c := range s{
			if c == 'B'{
				deck[i][j] = 1
			}else{
				deck[i][j] = 0
			}
		}
	}
	for i := 0; i < 8; i++{
		sum := 0
		for j := 0; j < 8; j++ {
			if deck[i][j] == 1{
				sum++
			}
		}
		if sum == 8 {
			count++
		}
	}
	for i := 0; i < 8; i++{
		if count == 8{
			break
		}
		sum := 0
		for j := 0; j < 8; j++ {
			if deck[j][i] == 1{
				sum++
			}
		}
		if sum == 8 {
			count++
		}
	}
	fmt.Print(count)
}


package main

import "fmt"

var mod int64 = 1000000007

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

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF978G(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ i, d int }

	var n, m, s, d int
	Fscan(in, &n, &m)
	pr := make([]int, m)
	todo := make([][]pair, n+1)
	has := make([]bool, n+1)
	for i := range pr {
		Fscan(in, &s, &d, &pr[i])
		for j := s; j < d; j++ {
			todo[j] = append(todo[j], pair{i, d})
		}
		if has[d] {
			Fprint(out, -1)
			return
		}
		has[d] = true
	}
	var ans []interface{}
o:
	for i := 1; i <= n; i++ {
		if has[i] {
			ans = append(ans, m+1)
			continue
		}
		sort.Slice(todo[i], func(j, k int) bool { return todo[i][j].d < todo[i][k].d })
		for _, p := range todo[i] {
			if pr[p.i] > 0 {
				pr[p.i]--
				ans = append(ans, p.i+1)
				continue o
			}
		}
		ans = append(ans, 0)
	}
	for _, left := range pr {
		if left > 0 {
			Fprint(out, -1)
			return
		}
	}
	Fprint(out, ans...)
}

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