package main

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

type seg struct {
	l int
	r int
}

type deque[T any] struct {
	q []T
}

func (q *deque[T]) emplace(n T) {
	q.q = append(q.q, n)
}

func (q deque[T]) empty() bool {
	return len(q.q) == 0
}

func (q deque[T]) back() T {
	if q.empty() {
		panic("back() performed on empty deque")
	}
	return q.q[len(q.q)-1]
}

func (q *deque[T]) popback() T {
	if q.empty() {
		panic("popback() performed on empty deque")
	}
	res := q.back()
	q.q = q.q[:len(q.q)-1]
	return res
}

func (q deque[T]) front() T {
	if q.empty() {
		panic("front() performed on empty deque")
	}
	return q.q[0]
}

func (q *deque[T]) popfront() T {
	if q.empty() {
		panic("popfront() performed on empty deque")
	}
	res := q.front()
	q.q = q.q[1:]
	return res
}

func getdeque[T any](capacity int) deque[T] {
	return deque[T]{ make([]T, 0, capacity) }
}

func max(a, b int) int {
	return -min(-a, -b)
}

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n int
		fmt.Fscan(r, &n)

		p := make([]int, n)
		for i := range p { fmt.Fscan(r, &p[i]) }

		stk := getdeque[seg](n)
		for _, v := range p {
			if stk.empty() {
				stk.emplace(seg{ v, v })
			} else {
				t := stk.back()
				if v > t.r {
					stk.emplace(seg{ v, v })
				} else if v < t.l {
					stk.popback()
					t.l = v
					stk.emplace(t)
				}
			}
		}

		var cnt, pl, pr int
		pl = n+1
		for ! stk.empty() {
			t := stk.popback()

			if t.r < pl {
				cnt++
			}

			pl = min(pl, t.l)
			pr = max(pr, t.r)
		}

		fmt.Fprintln(w, cnt)
	}

}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			arr[i] = v - 1 - i
		}

		var c, sum int
		for i := 0; i < n; i++ {
			sum += arr[i]
			if sum == 0 {
				c++
			}
		}
		fmt.Fprintln(out, c)
	}
}

package main
import("bufio";."fmt";"os")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T, n, v int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans := int64(0)
		for i, s := int64(1), int64(0); i <= n; i++ {
			Fscan(in, &v)
			s += v
			if s == i*(i+1)/2 {
				ans++
			}
		}
		Fprintln(out, ans)
	}
}

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		p := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			a[i]--
			p[a[i]] = i
		}
		ans, mi := 0, n
		for i := n - 1; i >= 0; i-- {
			if a[p[i]] >= 0 {
				if a[p[i]] < mi {
					ans++
				}
				for j := p[i]; j < n && a[j] >= 0; j++ {
					if a[j] < mi {
						mi = a[j]
					}
					a[j] = -1
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

var a [1e5 + 5]int

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	var t, n, top, x int
	for t = read(); t > 0; t-- {
		n = read()
		top = 0
		for i := 0; i < n; i++ {
			x = read()
			if top == 0 {
				top++
				a[top] = x
				continue
			}
			if x > a[top] {
				top++
				a[top] = x
			} else {
				tmp := a[top]
				for top > 0 && x < a[top] {
					top--
				}
				top++
				a[top] = tmp
			}
		}
		Fprintln(out, top)
	}
}

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

package main

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

/*
1
4
3 1 2 4
---
2
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	type pair struct {
		min, max int
	}

	stack := make([]pair, 0)

	for i := 0; i < n; i++ {
		var p int
		scanf("%d", &p)

		stack = append(stack, pair{p, p})

		for len(stack) > 1 {
			top1 := stack[len(stack)-1]
			top2 := stack[len(stack)-2]
			stack = stack[:len(stack)-2]

			if top1.min > top2.max {
				stack = append(stack, top2)
				stack = append(stack, top1)
				break
			} else {
				newTop := pair{min(top1.min, top2.min), max(top1.max, top2.max)}
				stack = append(stack, newTop)
			}
		}
	}
	scanf("\n")

	fmt.Fprintln(writer, len(stack))
}

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

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

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

//goland:noinspection GoUnusedFunction
func findSet(parent []int, v int) int {
	if v == parent[v] {
		return v
	}

	parent[v] = findSet(parent, parent[v])

	return parent[v]
}

//goland:noinspection GoUnusedFunction
func unionSets(parent []int, v, u int) {
	v = findSet(parent, v)
	u = findSet(parent, u)

	if v != u {
		parent[v] = u
	}
}

package main

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

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

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		stack := make([][2]int, 0, n)
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			stack = append(stack, [2]int{v, v})
			for len(stack) > 1 {
				ln := len(stack)
				if stack[ln-1][1] < stack[ln-2][0] {
					stack[ln-2][0] = max(stack[ln-1][0], stack[ln-2][0])
					stack[ln-2][1] = min(stack[ln-1][1], stack[ln-2][1])
					stack = stack[:len(stack)-1]
				} else {
					break
				}
			}
		}
		Fprintln(out, len(stack))
		// Fprintln(out, stack)
		// out.Flush()
	}
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func main() {
	CF1638C(os.Stdin, os.Stdout)
}

//nolint
package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, n, tp int
	scan(&t)
	for ; t > 0; t-- {
		scan(&n)
		s := new(Stack)
		for i := 0; i < n; i++ {
			scan(&tp)
			s.Push(NewEqualPair(tp))
		}
		println(s.Result())
	}
}

type Pair struct {
	max, min int
}

func NewEqualPair(a int) Pair {
	return Pair{
		max: a,
		min: a,
	}
}

type Stack struct {
	arr []*Pair
}

func (s *Stack) Push(p Pair) {
	s.arr = append(s.arr, &p)
	for len(s.arr) >= 2 {
		l := len(s.arr)
		p1 := s.arr[l-1]
		p2 := s.arr[l-2]
		if p2.max > p1.min {
			if p1.max > p2.max {
				p2.max = p1.max
			}
			if p1.min < p2.min {
				p2.min = p1.min
			}
			s.arr = s.arr[:l-1]
		} else {
			break
		}
	}
}

func (s *Stack) Result() int {
	return len(s.arr)
}

//C

package main

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

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

	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		nums := make([]int, n)
		var curMax int
		var cnt int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
			if nums[i] == i+1 {
				if curMax == i {
					curMax = nums[i]
					cnt++
				} else {
					continue
				}
			} else if nums[i] < i+1 {
				continue
			} else {
				if curMax < i+1 {
					cnt++
				}
				if nums[i] > curMax {
					curMax = nums[i]
				}
			}
		}
		fmt.Fprintln(out, cnt)
	}
}

package main
import("bufio";."fmt";"os")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans := 0
		for i, s := 1, 0; i <= n; i++ {
			Fscan(in, &v)
			s += v
			if s == i*(i+1)/2 {
				ans++
			}
		}
		Fprintln(out, ans)
	}
}

package main

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

var a [1e5 + 5]int

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	var t, n, top, x int
	for t = read(); t > 0; t-- {
		n = read()
		top = 0
		for i := 0; i < n; i++ {
			x = read()
			if top == 0 {
				top++
				a[top] = x
				continue
			}
			if x > a[top] {
				top++
				a[top] = x
			} else {
				tmp := a[top]
				for top > 0 && x < a[top] {
					top--
				}
				a[top] = tmp
			}
		}
		Fprintln(out, top)
	}
}

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


package main

import (
	"fmt"
)

func main() {
	var l, r int64
	fmt.Scan(&l, &r)
	fmt.Println("YES")
	for l < r {
		fmt.Println(l, l+1)
		l += 2
	}
}

package main

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

func main() {
	sc := NewScanner()
	l, r := sc.NextInt64(), sc.NextInt64()
	fmt.Println("YES")
	for ; l < r; l += 2 {
		fmt.Println(l, l+1)
	}

}

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

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

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

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

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

	return mp
}

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

package main

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

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

const ISDEBUG = false

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

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

func readUint64() uint64 {
	r.Scan()
	x, _ := strconv.ParseUint(r.Text(), 10, 64)
	return x
}

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

func B() {
	l, r := readUint64(), readUint64()
	var k uint64 = (r - l + 1) / 2

	w.WriteString("YES\n")

	var i uint64 = 0
	for i = 0; i < k; i++ {
		w.WriteString(fmt.Sprintf("%v %v\n", l+i*2, l+i*2+1))
	}
}

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

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

	B()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() int {
	var ch byte
	var err error
	for {
		ch, err = reader.ReadByte()
		if err != nil {
			return 0
		}
		if unicode.IsDigit(rune(ch)) {
			break
		}
	}
	result := int(ch & 0xf)
	for {
		ch, err = reader.ReadByte()
		if err != nil || !unicode.IsDigit(rune(ch)) {
			return result
		}
		result = result*10 + int(ch&0xf)
	}
	return result
}

func main() {
	l, r := readInt(), readInt()
	fmt.Println("YES")
	for ; l < r; l += 2 {
		fmt.Println(l, l+1)
	}

}

package main

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

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

const ISDEBUG = false

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

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

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

func B() {
	l, r := int64(readInt()), int64(readInt())
	var k int64 = (r - l + 1) / 2

	w.WriteString("YES\n")

	var i int64 = 0
	for i = 0; i < k; i++ {
		w.WriteString(fmt.Sprintf("%d %d\n", l+i*2, l+i*2+1))
	}
}

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

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

	B()
}

package main

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

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

const ISDEBUG = false

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

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

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

func B() {
	l, r := readInt(), readInt()
	k := (r - l + 1) / 2

	w.WriteString("YES\n")

	for i := 0; i < k; i++ {
		w.WriteString(fmt.Sprintf("%d %d\n", l+i*2, l+i*2+1))
	}
}

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

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

	B()
}


// 355B
package main

import (
	"fmt"
)

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

func main() {
	var n1, n2, n3, n4, n, m, a, b, A, B int
	fmt.Scan(&n1, &n2, &n3, &n4)
	fmt.Scan(&n, &m)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		a = min(n2, a*n1)
		A += a
	}
	A = min(A, n3)
	for i := 0; i < m; i++ {
		fmt.Scan(&b)
		b = min(n2, b*n1)
		B += b
	}
	B = min(B, n3)
	fmt.Println(min(n4, A+B))
}

// 355B-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var c1, c2, c3, c4, i, m, n, suma, sumb, sum int
    var a, b [1000]int
    fmt.Scan(&c1, &c2, &c3, &c4, &n, &m)
    for i = 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    for i = 0; i < m; i++ {
        fmt.Scan(&b[i])
    }

    for i = 0; i < n; i++ {
        if (a[i] * c1) > c2 {
            suma += c2
        } else {
            suma += (a[i] * c1)
        }
    }

    for i = 0; i < m; i++ {
        if (b[i] * c1) > c2 {
            sumb += c2
        } else {
            sumb += (b[i] * c1)
        }
    }

    if suma > c3 {
        suma = c3
    }

    if sumb > c3 {
        sumb = c3
    }

    if (suma + sumb) > c4 {
        sum = c4
    } else {
        sum = suma + sumb
    }

    fmt.Println(sum)

}

package main

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

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

func main(){
	var c [4]int
	var n, m int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	for i:=0; i<4; i++ {
		r.Scan()
		c[i], _ = strconv.Atoi(r.Text())
	}
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	a := make([]int, n)
	b := make([]int, m)
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.Atoi(r.Text())
	}
	for i:=0; i<m; i++ {
		r.Scan()
		b[i], _ = strconv.Atoi(r.Text())
	}

	bus, tro := 0, 0

	for i:=0; i<n; i++ {
		bus += min(c[0]*a[i], c[1])
	}
	for j:=0; j<m; j++ {
		tro += min(c[0]*b[j], c[1])
	}

	if bus > c[2] {
		bus = c[2]
	}
	if tro > c[2] {
		tro = c[2]
	}
	w.WriteString(strconv.Itoa(min(bus+tro, c[3]))+"\n")
	w.Flush()

}

package main

import "fmt"

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

func main() {
    var c1,c2,c3,c4,n,m,a int
    fmt.Scan(&c1,&c2,&c3,&c4)
    fmt.Scan(&n,&m)
    tn := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        tn += min(c1*a,c2)
    }
    tn = min(tn,c3)
    tm := 0
    for i := 0; i < m; i++ {
        fmt.Scan(&a)
        tm += min(c1*a,c2)
    }
    tm = min(tm,c3)
    fmt.Println(min(tn+tm,c4))
}


package main

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

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

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var s string

	scanf("%s", &s)

	arr := []byte(s)

	has := false
	for i := 1; i < len(arr)/2; i++ {
		has = has || arr[i] != arr[i-1]
	}
	if !has {
		printf("Impossible\n")
		return
	}

outer:
	for i := 1; i < len(arr); i++ {
		res := append(arr[i:], arr[:i]...)
		for j := 0; j < len(res)/2; j++ {
			if res[j] != res[len(res)-1-j] {
				continue outer
			}
		}

		for x, y := range res {
			if y != arr[x] {
				printf("1\n")
				return
			}
		}
	}
	printf("2\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...) }

var dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	wcnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		if i == len(s)/2 {
			continue
		}
		wcnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		for i := len(s) / 2; i > 1; i = i / 2 {
			if i%2 == 1 {
				if isPalin(0, i-1) == false {
					fmt.Println("2")
					return
				} else if len(wcnt) > 1 {
					fmt.Println("2")
					return
				} else {
					fmt.Println("Impossible")
					return
				}
			}
			if !isPalin(0, i-1) {
				fmt.Println("2")
				return
			}
		}
		fmt.Println("Impossible")
		return
	}
	for i := len(s) / 2; i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("2")

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	s := ""
	fmt.Fscanf(in, "%s\n", &s)
	n := len(s)
	//fmt.Println(s)
	if len(s)%2 == 0 {
		chMap := make(map[byte]bool)
		for i := 0; i < n; i++ {
			chMap[byte(s[i])] = true
		}
		if len(chMap) < 2 {
			fmt.Fprintf(out, "Impossible\n")
			return
		}
	} else {
		chMap := make(map[byte]bool)
		for i := 0; i < n; i++ {
			if i != n/2 {
				chMap[byte(s[i])] = true
			}
		}
		if len(chMap) < 2 {
			fmt.Fprintf(out, "Impossible\n")
			return
		}
	}
	canOne := false
	for i := 1; i < n; i++ {
		newS := s[i:] + s[:i]
		if pali(newS) && newS != s {
			canOne = true
			break
		}
	}
	if canOne {
		fmt.Fprintf(out, "1\n")
	} else {
		fmt.Fprintf(out, "2\n")
	}
	return
}

func pali(s string) bool {
	n := len(s)
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-1-i] {
			return false
		}
	}
	return true
}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		for i := len(s) / 2; i > 1; i = i / 2 {
			if i%2 == 1 {
				if isPalin(0, i-1) == false {
					fmt.Println("2")
					return
				} else if len(cnt) > 2 {
					fmt.Println("4")
					return
				} else {
					fmt.Println("Impossible")
					return
				}
			}
			if !isPalin(0, i-1) {
				fmt.Println("2")
				return
			}
		}
		fmt.Println("Impossible")
		return
	}
	for i := len(s) / 2; i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("2")

}

package main

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

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

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var s string

	scanf("%s", &s)

	arr := []byte(s)

	has := false
	for i, v := range arr {
		if i != 0 && v != arr[i-1] {
			has = true
		}
	}
	if !has {
		printf("Impossible\n")
		return
	}

	printf("%d\n", len(arr)%2+1)
}

package main

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

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

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var s string

	scanf("%s", &s)

	arr := []byte(s)

	has := false
	for i := 1; i < len(arr)/2; i++ {
		has = has || arr[i] != arr[i-1]
	}
	if !has {
		printf("Impossible\n")
		return
	}

	if len(arr)%2 == 1 {
		printf("2\n")
		return
	}

	printf("%d\n", len(arr)%2+1)
}

package main

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

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

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var s string

	scanf("%s", &s)

	arr := []byte(s)

	has := false
	for i, v := range arr {
		if i != 0 && (len(arr)%2 == 0 || i-1 == (len(arr)+1)/2) && v != arr[i-1] {
			has = true
		}
	}
	if !has {
		printf("Impossible\n")
		return
	}

	printf("%d\n", len(arr)%2+1)
}

package main

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

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

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var s string

	scanf("%s", &s)

	arr := []byte(s)

	has := false
	for i := 1; i < len(arr)/2; i++ {
		has = has || arr[i] != arr[i-1]
	}
	if !has {
		printf("Impossible\n")
		return
	}

outer:
	for i := 1; i < len(arr); i++ {
		res := append(arr[i:], arr[:i]...)
		for j := 0; j < len(res)/2; j++ {
			if res[j] != res[len(res)-1-j] {
				continue outer
			}
		}

		printf("1\n")
		return
	}
	printf("2\n")
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	s := ""
	fmt.Fscanf(in, "%s\n", &s)
	n := len(s)
	//fmt.Println(s)
	if len(s)%2 == 0 {
		chMap := make(map[byte]bool)
		for i := 0; i < n; i++ {
			chMap[byte(s[i])] = true
		}
		if len(chMap) < 2 {
			fmt.Fprintf(out, "Impossible\n")
			return
		}
	} else {
		chMap := make(map[byte]bool)
		for i := 0; i < n; i++ {
			if i != n/2 {
				chMap[byte(s[i])] = true
			}
		}
		if len(chMap) < 2 {
			fmt.Fprintf(out, "Impossible\n")
			return
		}
	}
	canOne := false
	for i := 1; i < n; i++ {
		newS := s[i:] + s[:i]
		if pali(newS) {
			canOne = true
			break
		}
	}
	if canOne {
		fmt.Fprintf(out, "1\n")
	} else {
		fmt.Fprintf(out, "2\n")
	}
	return
}

func pali(s string) bool {
	n := len(s)
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-1-i] {
			return false
		}
	}
	return true
}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		fmt.Println("2")
		return
	}
	for i := len(s); i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("2")

}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		fmt.Println("2")
		return
	}
	for i := len(s); i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("Impossible")

}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		for i := len(s) / 2; i > 1; i = i / 2 {
			if i%2 == 1 {
				if isPalin(0, i-1) == false {
					fmt.Println("2")
					return
				} else if len(cnt) > 2 {
					fmt.Println("4")
					return
				} else {
					fmt.Println("2")
					return
				}
			}
			if !isPalin(0, i-1) {
				fmt.Println("2")
				return
			}
		}
		fmt.Println("Impossible")
		return
	}
	for i := len(s) / 2; i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("2")

}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		for i := len(s) / 2; i > 1; i = i / 2 {
			if i%2 == 1 {
				if isPalin(0, i-1) == false {
					fmt.Println("2")
					return
				} else if len(cnt) > 2 {
					fmt.Println("4")
					return
				} else {
					fmt.Println("Impossible")
					return
				}
			}
			if !isPalin(0, i-1) {
				fmt.Println("2")
				return
			}
		}
		fmt.Println("2")
		return
	}
	for i := len(s) / 2; i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("2")

}

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 dp [5001][5001]bool = [5001][5001]bool{}
var vis [5001][5001]bool = [5001][5001]bool{}
var s string

func isPalin(a, b int) bool {
	if b < a || b == a {
		return true
	}

	if s[a] != s[b] {
		return false
	}
	if vis[a][b] {
		return dp[a][b]
	}

	vis[a][b] = true

	dp[a][b] = isPalin(a+1, b-1)

	return dp[a][b]
}

func main() {
	defer writer.Flush()
	scanf("%s", &s)
	cnt := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		cnt[s[i]]++
	}
	if len(cnt) == 1 {
		fmt.Println("Impossible")
		return
	}
	if len(s)%2 == 1 {
		for i := len(s) / 2; i > 1; i = i / 2 {
			if i%2 == 1 {
				if isPalin(0, i-1) == false {
					fmt.Println("2")
					return
				} else if len(cnt) > 2 {
					fmt.Println("4")
					return
				} else {
					fmt.Println("Impossible")
					return
				}
			}
			if !isPalin(0, i-1) {
				fmt.Println("2")
				return
			}
		}
		fmt.Println("Impossible")
		return
	}
	for i := len(s) / 2; i > 1; i = i / 2 {
		if i%2 == 1 {
			if isPalin(0, i-1) == false {
				fmt.Println("1")
				return
			} else {
				fmt.Println("2")
				return
			}
		}
		if !isPalin(0, i-1) {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("Impossible")

}


package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func main() {
	defer writer.Flush()
	n, m := sint64(), sint64()
	a, b := sstring(), sstring()
	printf("%d\n", sol(n, m, a, b))
}

func sol(n, m int64, a, b string) int64 {
	dp := make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, m+1)
	}
	maxSoFar := int64(0)
	for i := 1; i < len(dp); i++ {
		for j := 1; j < len(dp[i]); j++ {
			if a[i-1] == b[j-1] {
				dp[i][j] = dp[i-1][j-1] + 2
				maxSoFar = max(dp[i][j], max(maxSoFar, dp[i][j]))
			} else {
				dp[i][j] = max(dp[i][j], max(dp[i-1][j]-1, dp[i][j-1]-1))
			}
		}
	}
	return maxSoFar
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}
	var n, m int
	var s1, s2 []byte
	Fscan(in, &n, &m, &s1, &s2)
	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, m+1)
	}
	for i, b1 := range s1 {
		for j, b2 := range s2 {
			if b1 == b2 {
				dp[i+1][j+1] = dp[i][j] + 2
			} else {
				dp[i+1][j+1] = max(0, max(dp[i][j+1], dp[i+1][j])-1)
			}
		}
	}
	ans := 0
	for i, row := range dp {
		for j, v := range row {
			_, _ = i, j
			ans = max(ans, v)
		}
	}
	Fprintln(out, ans)
}

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

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

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

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	printf("%d\n", sol(sint64(), sint64(), sstring(), sstring()))
}

type Res struct {
	LCS int64
	C   string
	D   string
}

func (r Res) Score() int64 {
	return r.LCS*4 - int64(len(r.C)) - int64(len(r.D))
}

func (r Res) Len() int64 {
	return int64(len(r.C) + len(r.D))
}

func sol(n, m int64, c, d string) int64 {
	table := make([][]Res, n+1)
	for i := range table {
		table[i] = make([]Res, m+1)
		for j := range table[i] {
			table[i][j] = Res{
				LCS: 0,
				C:   "",
				D:   "",
			}
		}
	}
	maxSoFar := int64(0)
	for i := 1; i < len(table); i++ {
		for j := 1; j < len(table[i]); j++ {
			if c[i-1] == d[j-1] {
				table[i][j] = Res{
					LCS: table[i-1][j-1].LCS + 1,
					C:   table[i-1][j-1].C + c[i-1:i],
					D:   table[i-1][j-1].D + d[j-1:j],
				}
			} else {
				if table[i-1][j].Len() <= table[i][j-1].Len() {
					table[i][j] = Res{
						LCS: table[i-1][j].LCS,
						C:   table[i-1][j].C + c[i-1:i],
						D:   table[i-1][j].D,
					}
				} else {
					table[i][j] = Res{
						LCS: table[i][j-1].LCS,
						C:   table[i][j-1].C,
						D:   table[i][j-1].D,
					}
				}
			}
			maxSoFar = max(maxSoFar, table[i][j].Score())
		}
	}
	return maxSoFar
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

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

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	printf("%d\n", sol(sint64(), sint64(), sstring(), sstring()))
}

type Res struct {
	LCS int64
	C   string
	D   string
}

func (r Res) Score() int64 {
	return r.LCS*4 - int64(len(r.C)) - int64(len(r.D))
}

func (r Res) Len() int64 {
	return int64(len(r.C) + len(r.D))
}

func sol(n, m int64, c, d string) int64 {
	table := make([][]Res, n+1)
	for i := range table {
		table[i] = make([]Res, m+1)
	}
	maxSoFar := int64(0)
	for i := 1; i < len(table); i++ {
		for j := 1; j < len(table[i]); j++ {
			if c[i-1] == d[j-1] {
				table[i][j] = Res{
					LCS: table[i-1][j-1].LCS + 1,
					C:   table[i-1][j-1].C + c[i-1:i],
					D:   table[i-1][j-1].D + d[j-1:j],
				}
			} else {
				if table[i-1][j].LCS > table[i][j-1].LCS {
					table[i][j] = Res{
						LCS: table[i-1][j].LCS,
						C:   table[i-1][j].C + c[i-1:i],
						D:   table[i-1][j].D,
					}
				} else if table[i][j-1].LCS > table[i-1][j].LCS {
					table[i][j] = Res{
						LCS: table[i][j-1].LCS,
						C:   table[i][j-1].C,
						D:   table[i][j-1].D + d[j-1:j],
					}
				} else {
					if table[i-1][j].Len() <= table[i][j-1].Len() {
						table[i][j] = Res{
							LCS: table[i-1][j].LCS,
							C:   table[i-1][j].C + c[i-1:i],
							D:   table[i-1][j].D,
						}
					} else {
						table[i][j] = Res{
							LCS: table[i][j-1].LCS,
							C:   table[i][j-1].C,
							D:   table[i][j-1].D + d[j-1:j],
						}
					}
				}
			}
			maxSoFar = max(maxSoFar, table[i][j].Score())
		}
	}
	return maxSoFar
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

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

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	printf("%d\n", sol(sint64(), sint64(), sstring(), sstring()))
}

type Res struct {
	LCS int64
	C   string
	D   string
}

func (r Res) Score() int64 {
	return r.LCS*4 - int64(len(r.C)) - int64(len(r.D))
}

func sol(n, m int64, a, b string) int64 {
	table := make([][]Res, n+1)
	for i := range table {
		table[i] = make([]Res, m+1)
	}
	maxSoFar := int64(0)
	for i := 1; i < len(table); i++ {
		for j := 1; j < len(table[i]); j++ {
			if a[i-1] == b[j-1] {
				table[i][j] = Res{
					LCS: table[i-1][j-1].LCS + 1,
					C:   table[i-1][j-1].C + a[i-1:i],
					D:   table[i-1][j-1].D + b[j-1:j],
				}
			} else {
				if table[i-1][j].LCS > table[i][j-1].LCS {
					table[i][j] = Res{
						LCS: table[i-1][j].LCS,
						C:   table[i-1][j].C + a[i-1:i],
						D:   table[i-1][j].D,
					}
				} else if table[i][j-1].LCS > table[i-1][j].LCS {
					table[i][j] = Res{
						LCS: table[i][j-1].LCS,
						C:   table[i][j-1].C,
						D:   table[i][j-1].D + b[j-1:j],
					}
				} else { // same LCS, take greater score
					if table[i-1][j].Score() >= table[i][j-1].Score() {
						table[i][j] = Res{
							LCS: table[i-1][j].LCS,
							C:   table[i-1][j].C + a[i-1:i],
							D:   table[i-1][j].D,
						}
					} else {
						table[i][j] = Res{
							LCS: table[i][j-1].LCS,
							C:   table[i][j-1].C,
							D:   table[i][j-1].D + b[j-1:j],
						}
					}
				}
			}
			maxSoFar = max(maxSoFar, table[i][j].Score())
		}
	}
	// for _, t := range table {
	// 	printf("%v\n", t)
	// }
	return maxSoFar
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func main() {
	defer writer.Flush()
	n, m := sint64(), sint64()
	a, b := sstring(), sstring()
	printf("%d\n", sol(n, m, a, b))
}

type Res struct {
	LCS int64
	C   string
	D   string
}

func (r Res) Score() int64 {
	return 4*r.LCS - int64(len(r.C)) - int64(len(r.D))
}

func sol(n, m int64, a, b string) int64 {
	dp := make([][]Res, n+1)
	for i := range dp {
		dp[i] = make([]Res, m+1)
	}
	maxSoFar := int64(0)
	for i := 1; i < len(dp); i++ {
		for j := 1; j < len(dp[i]); j++ {
			if a[i-1] == b[j-1] {
				dp[i][j] = Res{
					LCS: dp[i-1][j-1].LCS + 1,
					C:   dp[i-1][j-1].C + string(a[i-1]),
					D:   dp[i-1][j-1].D + string(b[j-1]),
				}
				maxSoFar = max(maxSoFar, dp[i][j].Score())
			} else {
				// look up or left
				if dp[i-1][j].LCS == dp[i][j-1].LCS {
					if dp[i-1][j].Score() > dp[i][j-1].Score() {
						dp[i][j] = Res{
							LCS: dp[i-1][j].LCS,
							C:   dp[i-1][j].C + string(a[i-1]),
							D:   dp[i-1][j].D,
						}
					} else {
						dp[i][j] = Res{
							LCS: dp[i][j-1].LCS,
							C:   dp[i][j-1].C,
							D:   dp[i][j-1].D + string(b[j-1]),
						}
					}
				} else if dp[i-1][j].LCS > dp[i][j-1].LCS {
					dp[i][j] = Res{
						LCS: dp[i-1][j].LCS,
						C:   dp[i-1][j].C + string(a[i-1]),
						D:   dp[i-1][j].D,
					}
				} else if dp[i][j-1].LCS > dp[i-1][j].LCS {
					dp[i][j] = Res{
						LCS: dp[i][j-1].LCS,
						C:   dp[i][j-1].C,
						D:   dp[i][j-1].D + string(b[j-1]),
					}
				}
			}
		}
	}
	return maxSoFar
}

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

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

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

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	printf("%d\n", sol(sint64(), sint64(), sstring(), sstring()))
}

type Res struct {
	LCS int64
	C   string
	D   string
}

func (r Res) Score() int64 {
	return r.LCS*4 - int64(len(r.C)) - int64(len(r.D))
}

func (r Res) Len() int64 {
	return int64(len(r.C) + len(r.D))
}

func sol(n, m int64, c, d string) int64 {
	table := make([][]Res, n+1)
	for i := range table {
		table[i] = make([]Res, m+1)
	}
	maxSoFar := int64(0)
	for i := 1; i < len(table); i++ {
		for j := 1; j < len(table[i]); j++ {
			if c[i-1] == d[j-1] {
				table[i][j] = Res{
					LCS: table[i-1][j-1].LCS + 1,
					C:   table[i-1][j-1].C + c[i-1:i],
					D:   table[i-1][j-1].D + d[j-1:j],
				}
			} else {
				if table[i-1][j].Len() <= table[i][j-1].Len() {
					table[i][j] = Res{
						LCS: table[i-1][j].LCS,
						C:   table[i-1][j].C + c[i-1:i],
						D:   table[i-1][j].D,
					}
				} else {
					table[i][j] = Res{
						LCS: table[i][j-1].LCS,
						C:   table[i][j-1].C,
						D:   table[i][j-1].D + d[j-1:j],
					}
				}
			}
			maxSoFar = max(maxSoFar, table[i][j].Score())
		}
	}
	return maxSoFar
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1101D(_r io.Reader, _w io.Writer) {
	const mx int = 2e5
	divisors := [mx + 1][]int{}
	for i := 2; i <= mx; i++ {
		if len(divisors[i]) == 0 {
			for j := i; j <= mx; j += i {
				divisors[j] = append(divisors[j], i)
			}
		}
	}

	var n, v, w, ans int
	in := bufio.NewReader(_r)
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	var f func(v, fa int) map[int][2]int
	f = func(v, fa int) map[int][2]int {
		res := map[int][2]int{}
		for _, p := range divisors[a[v]] {
			res[p] = [2]int{}
		}
		for _, w := range g[v] {
			if w != fa {
				sub := f(w, v)
				for p, dis := range res {
					d := sub[p][0]
					if d <= dis[1] {
						continue
					}
					if d > dis[0] {
						dis[0], d = d, dis[0]
					}
					dis[1] = d
					res[p] = dis
				}
			}
		}
		for p, dis := range res {
			if v := dis[0] + dis[1] + 1; v > ans {
				ans = v
			}
			dis[0]++
			res[p] = dis
		}
		return res
	}
	f(0, -1)
	Fprint(_w, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1101D(_r io.Reader, _w io.Writer) {
	const mx int = 2e5
	divisors := [mx + 1][]int{}
	for i := 2; i <= mx; i++ {
		if len(divisors[i]) == 0 {
			for j := i; j <= mx; j += i {
				divisors[j] = append(divisors[j], i)
			}
		}
	}

	var n, v, w, ans int
	in := bufio.NewReader(_r)
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	// 特殊: a[v]==1
	var f func(v, fa int) map[int][2]int
	f = func(v, fa int) map[int][2]int {
		res := map[int][2]int{}
		for _, d := range divisors[a[v]] {
			res[d] = [2]int{}
		}
		for _, w := range g[v] {
			if w != fa {
				sub := f(w, v, )
				for p, dis := range res {
					d := sub[p][0]
					if d <= dis[1] {
						continue
					}
					if d > dis[0] {
						dis[0], d = d, dis[0]
					}
					dis[1] = d
					res[p] = dis
				}
			}
		}
		for p, dis := range res {
			if v := dis[0] + dis[1] + 1; v > ans {
				ans = v
			}
			dis[0]++
			res[p] = dis
		}
		return res
	}
	f(0, -1)
	Fprint(_w, ans)
}

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


package main

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

func Sol257C(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, x, y int
	Fscan(in, &n)
	if n == 1 {
		Fprintln(out, 0)
		return
	}

	degs := make([]float64, n*2)
	for i := 0; i < n; i++ {
		Fscan(in, &x, &y)
		deg := math.Atan2(float64(y), float64(x)) * 180.0 / math.Pi
		if deg < 0 {
			deg = 360.0 + deg
		}
		degs[i] = deg
		degs[n+i] = 360.0 + deg
	}
	sort.Float64s(degs)

	minAngle := 360.0
	for i := 0; i < n; i++ {
		angle := degs[n-1+i] - degs[i]
		minAngle = math.Min(minAngle, angle)
	}
	Fprintln(out, minAngle)
}

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

package main

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

// https://codeforces.com/contest/257/problem/C

func minF(a, b float64) float64 {
	if a <= b {
		return a
	}
	return b
}

func Sol257C(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, x, y int
	Fscan(in, &n)
	if n == 1 {
		Fprintln(out, 0)
		return
	}

	degs := make([]float64, n*2)
	for i := 0; i < n; i++ {
		Fscan(in, &x, &y)
		deg := math.Atan2(float64(y), float64(x)) * 180.0 / math.Pi
		if deg < 0 {
			deg = 360.0 + deg
		}
		degs[i] = deg
		degs[i+n] = 360.0 + deg
	}
	sort.Float64s(degs)

	minAngle := 360.0
	for i := 0; i < n; i++ {
		angle := degs[n-1+i] - degs[i]
		minAngle = minF(minAngle, angle)
	}
	Fprintln(out, minAngle)
}

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

package main

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

func minF(a, b float64) float64 {
	if a <= b {
		return a
	}
	return b
}

func maxF(a, b float64) float64 {
	if a >= b {
		return a
	}
	return b
}

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

	var n, x, y int
	Fscan(in, &n)
	if n == 1 {
		Fprintln(out, 0)
		return
	}

	degs := make([]float64, n*2)
	for i := 0; i < n; i++ {
		Fscan(in, &x, &y)
		deg := math.Atan2(float64(y), float64(x)) * 180.0 / math.Pi
		if deg < 0 {
			deg = 360.0 + deg
		}
		degs[i] = deg
		degs[i+n] = 360.0 + deg
	}
	sort.Float64s(degs)

	minAngle := 360.0
	for i := 0; i < n; i++ {
		angle := degs[n-1+i] - degs[i]
		minAngle = minF(minAngle, angle)
	}
	Fprintln(out, minAngle)
}


package main

import (
	"fmt"
)

func diff(a []int) int {
	var h, l int
	for i := 0; i < len(a); i++ {
		if a[i] < a[l] {
			l = i
		}
		if a[i] > a[h] {
			h = i
		}
	}
	return a[h] - a[l]
}

func flattern(a []int, k int) int {
	added := make([]bool, len(a))
	for i := 0; i < k; i++ {
		var h, l int
		for j := 0; j < len(a); j++ {
			if a[j] < a[l] {
				l = j
			}
			if a[j] > a[h] {
				h = j
			}
		}
		added[l] = true
		if added[h] {
			return i
		}
		a[l]++
		a[h]--
	}
	return k
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
	copy(b, a)
	m := flattern(b, k)
	s := diff(b)
	fmt.Println(s, m)
	for i := 0; i < m; i++ {
		var h, l int
		for j := 0; j < n; j++ {
			if a[j] < a[l] {
				l = j
			}
			if a[j] > a[h] {
				h = j
			}
		}
		a[h]--
		a[l]++
		fmt.Println(h+1, l+1)
	}
}

package main

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

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

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

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

	if n == 1 {
		println(0, 0)
		return
	}

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

	max, min := pos(a)
	m := 0
	move := make([]byte, 0, 10)

	if a[max] - a[min] > 1 {
		for ; k > 0; k-- {
			max, min = pos(a)

			if a[max] == a[min] || a[max] - a[min] == 1 {
				break
			}
			// println(a[max]-a[min], m)
			// println(a)

			a[max]--
			a[min]++
			m++
			move = append(move, fmt.Sprintln(max+1, min+1)...)
			// println()
		}
	}

	max, min = pos(a)

	// println()
	println(a[max] - a[min], m)
	println(string(move))
}

func pos(a []int) (int, int) {
	max, min := 0, 0

	for i := 1; i < len(a); i++ {
		if a[i] > a[max] {
			max = i
		}

		if a[i] < a[min] {
			min = i
		}
	}

	return max, min
}

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

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

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

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

package main

import "fmt"

func main() {
    var ans, i, j, n, m, mi, mx int
    var a[1001] int
    var f[1001] int
    var r[1001] int

    fmt.Scan( &n, &m )
    for i = 1; i <= n; i++ {
        fmt.Scan( &a[i] )
    }
    ans = 0
    for i = 1; i <= m; i++ {
        mx = 1
        mi = 1
        for j := 2; j <= n; j++ {
            if( a[j] > a[mx] ) {
                mx = j
            }
            if( a[j] < a[mi] ) {
                mi = j
            }
        }
        if( a[mx] - a[mi] > 1 ) {
            f[i] = mx
            r[i] = mi
            a[mx]--
            a[mi]++
            ans++
        } else {
            break
        }
    }
    mx = 1
    mi = 1
    for j = 2; j <= n; j++ {
        if( a[j] > a[mx] ) {
            mx = j
        }
        if( a[j] < a[mi] ) {
            mi = j
        }
    }
    fmt.Printf( "%d %d\n", a[mx] - a[mi], ans )
    for i := ans; i > 0; i-- {
        fmt.Printf( "%d %d\n", f[i], r[i] )
    }
}

package main

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

type Pair struct {
	a int
	b int
}

type Vector struct {
	items []Pair
}

func (v Vector) Len() int {
	return len(v.items)
}

func (v Vector) Less(i, j int) bool {
	return v.items[i].a < v.items[j].a
}

func (v Vector) Swap(i, j int) {
	var t = v.items[i]
	v.items[i] = v.items[j]
	v.items[j] = t
}

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

func echo(v *Vector) {
	for i := 0; i < v.Len(); i++ {
		fmt.Printf("%d ", v.items[i])
	}
	fmt.Println()
}

func solve(a []Pair, k int) {
	var v = Vector{a}
	var backup = append([]Pair(nil), a...)

	var n = v.Len()
	if n == 1 {
		fmt.Printf("0 0\n")
		return
	}

	sort.Sort(v)
	var best = v.items[n-1].a - v.items[0].a
	for i := 0; i < k; i++ {
		v.items[n-1].a--
		v.items[0].a++
		sort.Sort(v)
		best = min(best, v.items[n-1].a-v.items[0].a)
	}

	var steps = make([]Pair, 0)
	v = Vector{backup}
	sort.Sort(v)
	for i := 0; i < k; i++ {
		var diff = v.items[n-1].a - v.items[0].a
		if diff == best {
			break
		}
		steps = append(steps, Pair{v.items[n-1].b, v.items[0].b})
		v.items[n-1].a--
		v.items[0].a++
		sort.Sort(v)
	}

	fmt.Printf("%d %d\n", best, len(steps))
	for _, s := range steps {
		fmt.Printf("%d %d\n", s.a, s.b)
	}
}

func main() {
	var n, k int
	if _, err := fmt.Scanf("%d %d\n", &n, &k); err != nil {
		fmt.Printf("Error reading input: %s", err)
		os.Exit(0)
	}

	var a = make([]Pair, 0, n)
	for i := 0; i < n; i++ {
		var x int
		if _, err := fmt.Scanf("%d", &x); err != nil {
			fmt.Printf("Error: %s", err)
			os.Exit(0)
		}
		a = append(a, Pair{x, i + 1})
	}
	solve(a, k)
}

package main

import "fmt"

func main() {
    var ans, i, j, n, m, mi, mx int
    var a[1001] int
    var f[1001] int
    var r[1001] int

    fmt.Scan( &n, &m )

    for i = 1; i <= n; i++ {
        fmt.Scan( &a[i] )
    }
    ans = 0
    for i = 1; i <= n; i++ {
        mx = 1
        mi = 1
        for j := 2; j <= n; j++ {
            if( a[j] > a[mx] ) {
                mx = j
            }
            if( a[j] < a[mi] ) {
                mi = j
            }
        }
        if( a[mx] - a[mi] > 1 ) {
            f[i] = mx
            r[i] = mi
            a[mx]--
            a[mi]++
            ans++
        } else {
            break
        }
    }
    mx = 1
    mi = 1
    for j = 2; j <= n; j++ {
        if( a[j] > a[mx] ) {
            mx = j
        }
        if( a[j] < a[mi] ) {
            mi = j
        }
    }
    fmt.Printf( "%d %d\n", a[mx] - a[mi], ans )
    for i := ans; i > 0; i-- {
        fmt.Printf( "%d %d\n", f[i], r[i] )
    }
}

package main

import (
	"fmt"
	"log"
	"os"
	"sort"
)

type Pair struct {
	a int
	b int
}

type Vector struct {
	items []Pair
}

func (v Vector) Len() int {
	return len(v.items)
}

func (v Vector) Less(i, j int) bool {
	return v.items[i].a < v.items[j].a
}

func (v Vector) Swap(i, j int) {
	var t = v.items[i]
	v.items[i] = v.items[j]
	v.items[j] = t
}

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

func echo(v *Vector) {
	for i := 0; i < v.Len(); i++ {
		fmt.Printf("%d ", v.items[i])
	}
	fmt.Println()
}

func solve(a []Pair, k int) {
	var v = Vector{a}
	var backup = append([]Pair(nil), a...)

	var n = v.Len()
	if n == 1 {
		fmt.Printf("0 0\n")
		return
	}

	sort.Sort(v)
	var best = v.items[n-1].a - v.items[0].a
	for i := 0; i < k; i++ {
		v.items[n-1].a--
		v.items[0].a++
		sort.Sort(v)
		best = min(best, v.items[n-1].a-v.items[0].a)
	}

	var steps = make([]Pair, 0)
	v = Vector{backup}
	sort.Sort(v)
	for i := 0; i < k; i++ {
		var diff = v.items[n-1].a - v.items[0].a
		if diff == best {
			break
		}
		steps = append(steps, Pair{v.items[n-1].b, v.items[0].b})
		v.items[n-1].a--
		v.items[0].a++
		sort.Sort(v)
	}

	fmt.Printf("%d %d\n", best, len(steps))
	for _, s := range steps {
		fmt.Printf("%d %d\n", s.a, s.b)
	}
}

func main() {
	var n, k int
	if _, err := fmt.Scanf("%d %d", &n, &k); err != nil {
		log.Printf("Error reading input: %s", err)
		os.Exit(0)
	}

	var a = make([]Pair, 0, n)
	for i := 0; i < n; i++ {
		var x int
		if _, err := fmt.Scanf("%d", &x); err != nil {
			log.Printf("Error: %s", err)
			os.Exit(0)
		}
		a = append(a, Pair{x, i + 1})
	}
	solve(a, k)
}

package main

import (
	"fmt"
)

func diff(a []int) int {
	var h, l int
	for i := 0; i < len(a); i++ {
		if a[i] < a[l] {
			l = i
		}
		if a[i] > a[h] {
			h = i
		}
	}
	return a[h] - a[l]
}

func flattern(a []int, k int) int {
	added := make([]bool, len(a))
	for i := 0; i < k; i++ {
		var h, l int
		for j := 0; j < len(a); j++ {
			if a[j] < a[l] {
				l = j
			}
			if a[j] > a[h] {
				h = j
			}
		}
		added[l] = true
		if added[h] {
			return i
		}
		a[l]++
		a[h]--
	}
	return k
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, n)
	copy(b, a)
	m := flattern(b, k)
	s := diff(b)
	fmt.Println(s, m)
	for i := 0; i < m; i++ {
		var h, l int
		for j := 0; j < n; j++ {
			if a[j] < a[l] {
				l = j
			}
			if a[j] > a[h] {
				h = j
			}
		}
		a[h]--
		a[l]++
		fmt.Println(l+1, h+1)
	}
}


package main

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

// 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() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numCases, _ := strconv.Atoi(scanner.Text())
	for numCases > 0 {
		// calculate all divisors
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		if x == 1 {
			fmt.Println(0)
		} else if x == 2 {
			fmt.Println(1)
		} else if x == 3 {
			fmt.Println(2)
		} else if x%2 == 0 {
			fmt.Println(2)
		} else {
			fmt.Println(3)
		}

		numCases--

	}

}

package main

import (
	"fmt"
)

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

	for tc := 1; tc <= t; tc++ {
		var n int
		fmt.Scan(&n)
		if n <= 3 {
			fmt.Println(n - 1)
		} else {
			if (n-3)%2 == 0 {
				fmt.Println(3)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	var n []int64
	for t != 0 {
		var j int64
		fmt.Scanln(&j)
		n = append(n, j)
		t--
	}
	for _, k := range n {
		compute(k, 0)
	}
}

func compute(n, steps int64) {
	if n == 1 {
		fmt.Printf("%d\n", steps)
	} else {
		steps++
		n = action(n)
		compute(n, steps)
	}
}
func action(n int64) int64 {
	if n == 2 || n%2 != 0 {
		return n - 1
	}
	return 2
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	var n []int64
	for t != 0 {
		var j int64
		fmt.Scanln(&j)
		n = append(n, j)
		t--
	}
	for _, k := range n {
		compute(k, 0)
	}
}

func compute(n, steps int64) {
	if n == 1 {
		fmt.Printf("%d\n", steps)
	} else {
		steps++
		s := smallestFactor(n)
		if s == n {
			n--
		} else {
			n = s
		}
		compute(n, steps)
	}
}
func smallestFactor(n int64) int64 {
	if n%2 == 0 {
		return 2
	}
	return n - 1
}

package main

import (
	"fmt"
	"bufio"
	"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 solveA() {
	var n int
	scanf("%d\n", &n)
	ans := 0
	if n % 2 == 0 {
		if n >= 4 {
			ans = 2
		} else if n == 2 {
			ans = 1
		}
	} else {
		if n >= 5 {
			ans = 3
		} else if n == 3 {
			ans = 2
		}
	}
	printf("%d\n", ans)
}

type point struct {
	left int
	right int
}

func solveB() {
	var n, q int
	scanf("%d %d\n", &n, &q)
	var s string
	scanf("%s\n", &s)
	var P0, P1 point = point{n, -1}, point{n, -1}
	for i := 0; i < n; i++ {
		if s[i] == '0' {
			P0.right = i
		} else {
			P1.right = i
		}
	}

	for i := n - 1; i >= 0; i-- {
		if s[i] == '0' {
			P0.left = i
		} else {
			P1.left = i
		}
	}

	for ; q > 0; q-- {
		var l, r int
		scanf("%d %d\n", &l, &r)
		l--
		r--
		ans := "NO"
		if (s[l] == '0' && P0.left < l || s[l] == '1' && P1.left < l) ||
			(s[r] == '0' && P0.right > r || s[r] == '1' && P1.right > r) {
			ans = "YES"
		}

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

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solveA()
	}
}

package main
import (
	"os"
	"fmt"
	"bufio"
)
var rd = bufio.NewReader(os.Stdin)
func main() {
	q := 0
	fmt.Fscan(rd, &q)
	for tc := 0; tc < q; tc++ {
		n := 0
		fmt.Fscan(rd, &n)
		if n <= 3 {
			fmt.Println(n - 1)
		} else {
			fmt.Println(2 + n % 2)
		}
	}
}

package main

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

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

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

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

func main() {

	var T, i, n, temp uint32
	out := []uint32{}

	scanf("%d \n", &T)

	for i=0; i<T; i++ {
		scanf("%d \n", &n)
		temp = 0
		for ;n > 1; {
			if n == 2 {
				n = n / 2
				temp++
				continue
			}
			if n % 2 == 0 {
				n = n / (n / 2)
				temp++
			}else {
				n = n - 1
				temp++
			}

		}
		out = append(out, temp)
	}

	for i=0; i<T; i++ {
		fmt.Println(out[i])
	}

}

package main

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

// 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 divisor(n int) int {
	for i := 3; i*i <= n; i = i + 2 {
		if n%i == 0 {
			return i
		}

	}
	return n
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numCases, _ := strconv.Atoi(scanner.Text())
	for numCases > 0 {
		// calculate all divisors
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		solution := 0
		for x > 1 {
			//fmt.Println("Current start: ", x)
			if x == 2 {
				solution = solution + 1
				break
			}
			if x == 3 {
				solution = solution + 2
				break
			}
			if x%2 == 0 {
				solution = solution + 1
				x = 2
				continue
			} else {
				//check for perfect squares
				test := math.Sqrt(float64(x))
				f := math.Floor(test)
				if x-int(f) == 0 {
					//found a match
					solution = solution + 1
					x = int(test)
				} else {
					choice := divisor(x)
					if choice == x {
						x = x - 1
						solution = solution + 1
						//fmt.Println("Choice == x")
						//	fmt.Println(x)
					} else {
						//fmt.Println("Alt Choice:", choice)
						//fmt.Println("Alt X:", x)
						temp := int(x / choice)
						//fmt.Println("Temp ", temp)
						x = int(math.Min(float64(temp), float64(choice)))
						//x = x / choice
						solution = solution + 1
					}
				}
			}
		}
		numCases--
		fmt.Println(solution)
	}

}

package main

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

// 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() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numCases, _ := strconv.Atoi(scanner.Text())
	for numCases > 0 {
		// calculate all divisors
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		if x == 1 {
			fmt.Println(0)
		} else if x == 2 {
			fmt.Println(1)
		} else if x%2 == 0 {
			fmt.Println(2)
		} else {
			fmt.Println(3)
		}

		numCases--

	}

}

package main

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

// 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() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numCases, _ := strconv.Atoi(scanner.Text())
	for numCases > 0 {
		// calculate all divisors
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		if x == 1 {
			fmt.Println(0)
			numCases--
			continue
		}
		if x == 2 {
			fmt.Println(1)
			numCases--
			continue
		}
		if x%2 == 0 {
			//even
			fmt.Println(2)
			numCases--
			continue
		} else {
			//odd
			fmt.Println(3)
			numCases--
			continue
		}

	}

}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	var n []int64
	for i := 0; i < t; i++ {
		var j int64
		fmt.Scanln(&j)
		n = append(n, j)
	}
	for _, k := range n {
		compute(k, 0)
	}
}

func compute(n, steps int64) {
	if n == 1 {
		fmt.Printf("%d\n", steps)
	} else {
		steps++
		s := smallestFactor(n)
		if s == n {
			n--
		} else {
			n = s
		}
		compute(n, steps)
	}
}
func smallestFactor(n int64) int64 {
	if n%2 == 0 {
		return 2
	}
	var i int64
	for i = 3; i*i <= n; i += 2 {
		if n%i == 0 {
			return i
		}
	}
	return n
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	var n []int64
	for i := 0; i < t; i++ {
		var j int64
		fmt.Scanln(&j)
		n = append(n, j)
	}
	for _, k := range n {
		compute(k, 0)
	}
}

func compute(n, steps int64) {
	if n == 1 {
		fmt.Printf("%d\n", steps)
	} else {
		s := smallestFactor(n)
		if s == n {
			n--
			steps++
		} else {
			n = s
			steps++
		}
		compute(n, steps)
	}
}
func smallestFactor(n int64) int64 {
	if n%2 == 0 {
		return 2
	}
	var i int64
	for i = 3; i*i <= n; i += 2 {
		if n%i == 0 {
			return i
		}
	}
	return n
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)
	var n []int64
	for t != 0 {
		var j int64
		fmt.Scanln(&j)
		n = append(n, j)
		t--
	}
	for _, k := range n {
		compute(k, 0)
	}
}

func compute(n, steps int64) {
	if n == 1 {
		fmt.Printf("%d\n", steps)
	} else {
		steps++
		s := smallestFactor(n)
		if s == n {
			n--
		} else {
			n = s
		}
		compute(n, steps)
	}
}
func smallestFactor(n int64) int64 {
	if n%2 == 0 {
		return 2
	}
	// this goddamn thing is special case
	if n%5 == 0 {
		return n - 1
	}
	var i int64
	for i = 3; i*i <= n; i += 2 {
		if n%i == 0 {
			return i
		}
	}
	return n
}


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

package main

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

func Solve(n int) []string {
	steps := []string{}
	if n >= 4 && n%2 == 0 {
		steps = append(steps, "4 * 3 = 12")
		steps = append(steps, "12 * 2 = 24")
		steps = append(steps, "24 * 1 = 24")
	} else if n >= 4 && n%2 == 1 {
		steps = append(steps, "1 + 5 = 6")
		steps = append(steps, "6 * 4 = 24")
		steps = append(steps, "3 - 2 = 1")
		steps = append(steps, "24 * 1 = 24")
	}
	if n > 4 {
		x := n
		y := n - 1
		for y > 4 {
			s := fmt.Sprintf("%d - %d = 1", x, y)
			steps = append(steps, s)
			steps = append(steps, "24 * 1 = 24")
			x -= 2
			y -= 2
		}
	}
	return steps
}

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

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

	steps := Solve(n)
	if len(steps) > 0 {
		fmt.Fprintf(writer, "YES\n")
		for _, step := range steps {
			fmt.Fprintf(writer, "%s\n", step)
		}
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
}

package main

import (
	"fmt"
)

func print_4() {
	fmt.Println("1 * 2 = 2")
	fmt.Println("2 * 3 = 6")
	fmt.Println("4 * 6 = 24")
}

func print_5() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("5 + -1 = 4")
	fmt.Println("4 + 4 = 8")
	fmt.Println("8 * 3 = 24")
}

func print_6() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 - 6 = -7")
	fmt.Println("-7 - 5 = -12")
	fmt.Println("4 * 3 = 12")
	fmt.Println("12 - -12 = 24")
}

func print_7() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 - 7 = -8")
	fmt.Println("-8 - 6 = -14")
	fmt.Println("3 - 5 = -2")
	fmt.Println("-14 * -2 = 28")
	fmt.Println("28 - 4 = 24")
}

func main() {
	var n, i int
	fmt.Scanf("%d\n", &n)
	if n < 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		switch n {
		case 4:
			print_4()
			break
		case 5:
			print_5()
			break
		case 6:
			print_6()
			break
		case 7:
			print_7()
			break
		default:
			q := 0
			for i = n; i > 7; i -= 4 {
				fmt.Printf("%d - %d = 1\n", i, i-1)
				fmt.Printf("%d - %d = -1\n", i-3, i-2)
				fmt.Printf("1 + -1 = 0\n")
				q++
			}
			switch i {
			case 4:
				print_4()
				break
			case 5:
				print_5()
				break
			case 6:
				print_6()
				break
			case 7:
				print_7()
				break
			}
			for i = 0; i < q; i++ {
				fmt.Printf("0 + 24 = 24\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func print_4() {
	fmt.Println("1 * 2 = 2")
	fmt.Println("2 * 3 = 6")
	fmt.Println("4 * 6 = 24")
}

func print_5() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("5 + -1 = 4")
	fmt.Println("4 + 4 = 8")
	fmt.Println("8 + 3 = 24")
}

func print_6() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -6 = -7")
	fmt.Println("-7 + -5 = -12")
	fmt.Println("4 * 3 = 12")
	fmt.Println("12 - -12 = 24")
}

func print_7() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -7 = -8")
	fmt.Println("-8 + -6 = -14")
	fmt.Println("3 - 5 = -2")
	fmt.Println("-14 * -2 = 28")
	fmt.Println("28 - 4 = 24")
}

func main() {
	var n, i int
	fmt.Scanf("%d\n", &n)
	if n < 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		switch n {
		case 4:
			print_4()
			break
		case 5:
			print_5()
			break
		case 6:
			print_6()
			break
		case 7:
			print_7()
			break
		default:
			q := 0
			for i = n; i > 7; i -= 4 {
				fmt.Printf("%d - %d = 1\n", i, i-1)
				fmt.Printf("%d - %d = -1\n", i-2, i-3)
				fmt.Printf("1 + -1 = 0\n")
				q++
			}
			switch i {
			case 4:
				print_4()
				break
			case 5:
				print_5()
				break
			case 6:
				print_6()
				break
			case 7:
				print_7()
				break
			}
			for i = 0; i < q; i++ {
				fmt.Printf("0 + 24 = 24\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func print_4() {
	fmt.Println("1 * 2 = 2")
	fmt.Println("2 * 3 = 6")
	fmt.Println("4 * 6 = 24")
}

func print_5() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("5 + -1 = 4")
	fmt.Println("4 + 4 = 8")
	fmt.Println("8 + 3 = 24")
}

func print_6() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -6 = -7")
	fmt.Println("-7 + -5 = -12")
	fmt.Println("4 * 3 = 12")
	fmt.Println("12 - -12 = 24")
}

func print_7() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -7 = -8")
	fmt.Println("-8 + -6 = -14")
	fmt.Println("3 - 5 = -2")
	fmt.Println("-14 * -2 = 28")
	fmt.Println("28 - 4 = 24")
}

func main() {
	var n, i int
	fmt.Scanf("%d\n", &n)
	if n < 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		switch n {
		case 4:
			print_4()
			break
		case 5:
			print_5()
			break
		case 6:
			print_6()
			break
		case 7:
			print_7()
			break
		default:
			q := 0
			for i = n; i > 7; i -= 4 {
				fmt.Printf("%d - %d = 1\n", i, i-1)
				fmt.Printf("%d - %d = -1\n", i-3, i-2)
				fmt.Printf("1 + -1 = 0\n")
				q++
			}
			switch i {
			case 4:
				print_4()
				break
			case 5:
				print_5()
				break
			case 6:
				print_6()
				break
			case 7:
				print_7()
				break
			}
			for i = 0; i < q; i++ {
				fmt.Printf("0 + 24 = 24\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func print_4() {
	fmt.Println("1 * 2 = 2")
	fmt.Println("2 * 3 = 6")
	fmt.Println("4 * 6 = 24")
}

func print_5() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("5 + -1 = 4")
	fmt.Println("4 + 4 = 8")
	fmt.Println("8 * 3 = 24")
}

func print_6() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 - 6 = -7")
	fmt.Println("-7 - 5 = -12")
	fmt.Println("4 * 3 = 12")
	fmt.Println("12 - -12 = 24")
}

func print_7() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -7 = -8")
	fmt.Println("-8 + -6 = -14")
	fmt.Println("3 - 5 = -2")
	fmt.Println("-14 * -2 = 28")
	fmt.Println("28 - 4 = 24")
}

func main() {
	var n, i int
	fmt.Scanf("%d\n", &n)
	if n < 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		switch n {
		case 4:
			print_4()
			break
		case 5:
			print_5()
			break
		case 6:
			print_6()
			break
		case 7:
			print_7()
			break
		default:
			q := 0
			for i = n; i > 7; i -= 4 {
				fmt.Printf("%d - %d = 1\n", i, i-1)
				fmt.Printf("%d - %d = -1\n", i-3, i-2)
				fmt.Printf("1 + -1 = 0\n")
				q++
			}
			switch i {
			case 4:
				print_4()
				break
			case 5:
				print_5()
				break
			case 6:
				print_6()
				break
			case 7:
				print_7()
				break
			}
			for i = 0; i < q; i++ {
				fmt.Printf("0 + 24 = 24\n")
			}
		}
	}
}

package main

import (
	"fmt"
)

func print_4() {
	fmt.Println("1 * 2 = 2")
	fmt.Println("2 * 3 = 6")
	fmt.Println("4 * 6 = 24")
}

func print_5() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("5 + -1 = 4")
	fmt.Println("4 + 4 = 8")
	fmt.Println("8 + 3 = 24")
}

func print_6() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 - 6 = -7")
	fmt.Println("-7 - 5 = -12")
	fmt.Println("4 * 3 = 12")
	fmt.Println("12 - -12 = 24")
}

func print_7() {
	fmt.Println("1 - 2 = -1")
	fmt.Println("-1 + -7 = -8")
	fmt.Println("-8 + -6 = -14")
	fmt.Println("3 - 5 = -2")
	fmt.Println("-14 * -2 = 28")
	fmt.Println("28 - 4 = 24")
}

func main() {
	var n, i int
	fmt.Scanf("%d\n", &n)
	if n < 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		switch n {
		case 4:
			print_4()
			break
		case 5:
			print_5()
			break
		case 6:
			print_6()
			break
		case 7:
			print_7()
			break
		default:
			q := 0
			for i = n; i > 7; i -= 4 {
				fmt.Printf("%d - %d = 1\n", i, i-1)
				fmt.Printf("%d - %d = -1\n", i-3, i-2)
				fmt.Printf("1 + -1 = 0\n")
				q++
			}
			switch i {
			case 4:
				print_4()
				break
			case 5:
				print_5()
				break
			case 6:
				print_6()
				break
			case 7:
				print_7()
				break
			}
			for i = 0; i < q; i++ {
				fmt.Printf("0 + 24 = 24\n")
			}
		}
	}
}


package main
import (
	"bufio"
	. "fmt"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		r := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			r[i] = (i + 1) % n
		}
		q := []int{}
		for i, v := range a {
			if gcd(v, a[r[i]]) == 1 {
				q = append(q, i)
			}
		}
		p := []interface{}{}
		b := make([]bool, n)
		for len(q) > 0 {
			i := q[0]
			q = q[1:]
			if b[i] {
				continue
			}
			if !b[r[i]] {
				p = append(p, r[i]+1)
				b[r[i]] = true
			}
			r[i] = r[r[i]]
			if gcd(a[i], a[r[i]]) == 1 {
				q = append(q, i)
			}
		}
		Fprint(out, len(p), " ")
		Fprintln(out, p...)
	}
}
func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1483B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	type node struct {
		next *node
		v, i int
	}
	type lst struct{ h, t *node }

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ls := []lst{}
		for i, cur := 0, (&node{}); i < n; {
			h := &node{v: a[i], i: i + 1}
			t := h
			cur.next = t
			cur = t
			for i++; i < n && gcd(a[i], a[i-1]) > 1; i++ {
				t = &node{v: a[i], i: i + 1}
				cur.next = t
				cur = t
			}
			ls = append(ls, lst{h, t})
		}
		ans := []interface{}{}
		for len(ls) > 1 {
			tmp := ls
			ls = nil
			cd := false
			for i, n := 0, len(tmp); i < n; {
				p := tmp[i]
				for i++; i < n && gcd(tmp[i-1].t.v, tmp[i].h.v) > 1; i++ {
					tmp[i-1].t.next = tmp[i].h
					p.t = tmp[i].t
				}
				ls = append(ls, p)
				if i < n {
					p := tmp[i]
					ans = append(ans, p.h.i)
					if p.h != p.t {
						tmp[i].h = p.h.next
					} else {
						i++
						if i == n {
							cd = true
						}
					}
				}
			}
			if len(ls) == 1 {
				break
			}
			if cd {
				continue
			}
			if p := ls[0]; gcd(ls[len(ls)-1].t.v, p.h.v) == 1 {
				ans = append(ans, p.h.i)
				if p.h != p.t {
					ls[0].h = p.h.next
				} else {
					ls = ls[1:]
				}
			}
		}
		for h, t := ls[0].h, ls[0].t; gcd(h.v, t.v) == 1; h = h.next {
			ans = append(ans, h.i)
			if h == t {
				break
			}
		}
		Fprint(out, len(ans), " ")
		Fprintln(out, ans...)
	}
}

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


/*
URL:
https://codeforces.com/problemset/problem/1195/D1
*/

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
	MOD          = int64(998244353)
	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 int
	A []string
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		str := ReadString()
		str = string(Reverse([]rune(str)))
		A = append(A, str)
	}

	l := int64(len(A[0]))

	ans := int64(0)
	for i := 0; i < n; i++ {
		left, right := int64(0), int64(0)

		S := A[i]
		for j := int64(0); j < l; j++ {
			d := int64(S[j] - '0')
			left += d * modpow(10, int64(2*j+1), MOD)
			left %= MOD
			right += d * modpow(10, int64(2*j), MOD)
			right %= MOD
		}

		// PrintfDebug("left : %v\n", left)
		// PrintfDebug("right: %v\n", right)

		left *= int64(n)
		left %= MOD
		right *= int64(n)
		right %= MOD

		ans += left + right
		ans %= MOD
	}
	fmt.Println(ans)
}

func Reverse(A []rune) []rune {
	res := []rune{}

	n := len(A)
	for i := n - 1; i >= 0; i-- {
		res = append(res, A[i])
	}

	return res
}

// ModInv returns $a^{-1} mod m$ by Fermat's little theorem.
// O(1), but C is nearly equal to 30 (when m is 1000000000+7).
func ModInv(a, m int64) int64 {
	return modpow(a, m-2, m)
}

func modpow(a, e, m int64) int64 {
	if e == 0 {
		return 1
	}

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

	return a * modpow(a, e-1, m) % m
}

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

/*********** 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 (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

const mod = 998244353

func solve() {

	tens := make([]int64, 21)
	tens[1] = 1
	for i := 2; i <= 20; i++ {
		tens[i] = (10 * tens[i-1]) % mod
	}

	n := readInt()
	a := make([]int64, n)
	l := make([]int64, 11)

	for i := 0; i < n; i++ {
		v := readInt64()
		a[i] = v
		cnt := 0
		for ; v > 0; v /= 10 {
			cnt++
		}
		l[cnt]++
	}

	ans := int64(0)

	for i := 0; i < n; i++ {

		for v, idx := a[i], 1; v > 0; v, idx = v/10, idx+1 {

			digit := v % 10

			for k := 1; k <= 10; k++ {

				if k >= idx {
					ans = (ans + (digit*l[k]*tens[idx*2])%mod) % mod
				} else {
					ans = (ans + (digit*l[k]*tens[k+idx])%mod) % mod
				}

				if k >= idx-1 {
					ans = (ans + (digit*l[k]*tens[idx*2-1])%mod) % mod
				} else {
					ans = (ans + (digit*l[k]*tens[k+idx])%mod) % mod
				}

			}

		}

	}

	printInt64(ans)

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

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

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

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

package main

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

const (
	MAXN = int(1e5 + 7)
	MOD  = int64(998244353)
)

var a [MAXN]int64

func main() {
	input, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		return
	}
	inputReader := bytes.NewReader(input)
	var N int
	_, _ = fmt.Fscanf(inputReader, "%d\n", &N)
	for i := 1; i < N; i++ {
		_, _ = fmt.Fscanf(inputReader, "%d ", &a[i])
		//fmt.Println(a[i])
	}
	_, _ = fmt.Fscanf(inputReader, "%d\n", &a[N])
	var ans  int64 = 0
	length:=0
	for t:=a[1];t>0;t/=10{
		length++
	}
	power:= func(a,b int)int64 {
		var ans int64=1
		for i:=0;i<b;i++{
			ans*=int64(a)
		}
		return ans
	}

	for i:=1;i<=N;i++ {
		var digit,val int64
		digit,val=1,a[i]
		var constVal =digit+digit*power(10,1)
		for val>0 {
			//fmt.Println(constVal)
			num:=val%10
			ans=(ans+int64(N)*constVal%MOD*num%MOD)%MOD
			val/=10
			constVal=constVal*100%MOD
		}
	}
	fmt.Println(ans)
}

package main

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

var (
	arr [100005]int64
)

const (
	mod = 998244353
)

func modMultiply(a int64, b int64) int64 {
	return ((a % mod) * (b % mod)) % mod
}

func modAdd(a int64, b int64) int64 {
	return ((a % mod) + (b % mod)) % mod
}

func sumOfNumber(n int64, num int64) int64 {
	var v, d, sum int64
	sum = 0
	for v = 1; num > 0; num, v = num/10, v*100 {
		d = num % 10
		sum = modAdd(sum, modMultiply(modMultiply(d, n), v))
		sum = modAdd(sum, modMultiply(modMultiply(modMultiply(d, n), v), 10))
	}
	return sum
}

func main() {
	var n, i int64

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
	}

	var ans int64
	for i = 0; i < n; i++ {
		ans = modAdd(ans, sumOfNumber(n, arr[i]))
	}

	fmt.Println(ans)
}

package main

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

var (
	// mod int64
	arr [100005]int64
	mod int64
)

// const (
// 	mod = 998244353
// )

func modMultiply(a int64, b int64) int64 {
	return ((a % mod) * (b % mod)) % mod
}

func modAdd(a int64, b int64) int64 {
	return ((a % mod) + (b % mod)) % mod
}

func sumOfNumber(n int64, num int64) int64 {
	var v, d, sum int64
	sum = 0
	for v = 1; num > 0; num, v = num/10, v*100 {
		d = num % 10
		sum = modAdd(sum, modMultiply(modMultiply(d, n), v))
		sum = modAdd(sum, modMultiply(modMultiply(modMultiply(d, n), v), 10))
	}
	return sum
}

func main() {
	var n, i int64

	mod = 998244353
	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
	}

	var ans int64
	for i = 0; i < n; i++ {
		ans = modAdd(ans, sumOfNumber(n, arr[i]))
	}

	fmt.Println(ans)
}

package main

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

const (
	mod = 998244353
)

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", &a[i])
	}
	fmt.Fscanf(in, "\n")
	sort.Ints(a)
	sum := int64(0)
	for i := 0; i < n; i++ {
		sum += (second(a[i]) + first(a[i])) * int64(n)
		sum %= mod
	}
	fmt.Fprintf(out, "%d\n", sum)
}

func first(a int) int64 {
	ans := int64(0)
	base := int64(10)
	for a > 0 {
		tail := int64(a % 10)
		a /= 10
		ans += base * tail
		base *= 100
		ans %= mod
		base %= mod
	}
	return ans
}

func second(a int) int64 {
	ans := int64(0)
	base := int64(1)
	for a > 0 {
		tail := int64(a % 10)
		a /= 10
		ans += base * tail
		base *= 100
		ans %= mod
		base %= mod
	}
	return ans
}

package main

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

func getD(x, y int64) int64 {
	return ((x % (y * 10)) - x%y) / y
}
func tranR(p, mod int64) int64 {
	y := int64(1)
	z := int64(1)
	res := int64(0)
	for x := 1; x <= 10; x++ {
		res = (res + getD(p, y)*z) % mod
		y = (y * 10)
		z = (z * 100) % mod
	}
	return res
}

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

	n := int64(0)
	x := int64(0)
	mod := int64(998244353)
	fmt.Fscanf(input, "%d\n", &n)
	ans := int64(0)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(input, "%d", &x)
		ans = ((((tranR(x, mod)*n)%mod)*11)%mod + ans) % mod
	}
	fmt.Println(ans)
}

package main

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

var (
	// mod int64
	arr [100005]int64
)

const (
	mod = 998244353
)

func modMultiply(a int64, b int64) int64 {
	return (a * b) % mod
}

func modAdd(a int64, b int64) int64 {
	return (a + b) % mod
}

func sumOfNumber(n int64, num int64) int64 {
	var v, d, sum int64
	sum = 0
	for v = 1; num > 0; num, v = num/10, v*100 {
		d = num % 10
		sum = modAdd(sum, modMultiply(modMultiply(d, n), v))
		sum = modAdd(sum, modMultiply(modMultiply(modMultiply(d, n), v), 10))
	}
	return sum
}

func main() {
	var n, i int64
	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
	}

	var ans int64
	for i = 0; i < n; i++ {
		ans = modAdd(ans, sumOfNumber(n, arr[i]))
	}

	fmt.Println(ans)
}