Toad Rash has a binary string $$$s$$$. A binary string consists only of zeros and ones.Let $$$n$$$ be the length of $$$s$$$.Rash needs to find the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$.Find this number of pairs for Rash.

The first line contains the string $$$s$$$ ($$$1 \leq |s| \leq 300\,000$$$), consisting of zeros and ones.

Output one integer: the number of such pairs of integers $$$l$$$, $$$r$$$ that $$$1 \leq l \leq r \leq n$$$ and there is at least one pair of integers $$$x$$$, $$$k$$$ such that $$$1 \leq x, k \leq n$$$, $$$l \leq x < x + 2k \leq r$$$, and $$$s_x = s_{x+k} = s_{x+2k}$$$.

NoteIn the first example, there are three $$$l$$$, $$$r$$$ pairs we need to count: $$$1$$$, $$$6$$$; $$$2$$$, $$$6$$$; and $$$1$$$, $$$5$$$.In the second example, there are no values $$$x$$$, $$$k$$$ for the initial string, so the answer is $$$0$$$.

package main

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

func solveAll(jam Jam) {
	s, l, ui, f, d, p, pf := jam.Str, jam.Long, jam.Int, jam.Float, jam.D, jam.P, jam.PF
	//	Live Templates: for0l for1l for0ui for1ui forr vl0 vln vui0 vuin ; Casts: l i

	noTriples := make(map[string]bool)
	noTriples["00"], noTriples["01"], noTriples["10"], noTriples["11"] = true, true, true, true

	added := true
	ln := 2
	for added {
		added = false

		for k := range noTriples {
			if len(k) != ln {
				continue
			}
			for _, suff := range [2]rune{'0', '1'} {
				test := k + string([]rune{suff})
				noTriplesInTest := true
				for k := 1; 2*k < len(test) && noTriplesInTest; k++ {
					for x := 0; x < len(test) - 2*k && noTriplesInTest; x++ {
						if test[x] == test[x+k] && test[x+k] == test[x+2*k] {
							noTriplesInTest = false
						}
					}
				}
				if noTriplesInTest {
					//d("%s ", test)
					noTriples[test] = true
					added = true
				}
			}
		}
		ln += 1
		//d("\n")
	}

	noTriples[""], noTriples["0"], noTriples["1"] = true, true, true

	str := s()
	pairs := uint64(len(str))*uint64(len(str)-1)/2
	//d("INIT: %d\n", pairs)
	buf := ""
	for _, r := range []rune(str) {
		buf = buf + string([]rune{r})
		//d("%s %s", string([]rune{r}), buf)
		for !noTriples[buf] {
			buf = buf[1:]
			//d(" :%s", buf)
		}
		if noTriples[buf] {
			//d(" -%d", len(buf)-1)
			pairs -= uint64(len(buf)-1)
		}
		//d("\n")
	}

	p("%d", pairs)

	if false { d("%v", []interface{}{s, l, ui, f, d, p, pf}) }
}

//	TODO wipe unused shorthand methods for math
type Uint32Sort []uint32
func (s Uint32Sort) Len() int           { return len(s) }
func (s Uint32Sort) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s Uint32Sort) Less(i, j int) bool { return s[i] < s[j] }

func t(b bool, t, f int64) int64 { if b {return t};return f }
func min(a, b int64) int64 { if a < b {return a}; return b }
func max(a, b int64) int64 { if a > b {return a}; return b }
func abs(a int64) int64 { if a < 0 { return -a }; return a }
func ti(b bool, t, f uint32) uint32 { if b {return t};return f }
func mini(a, b uint32) uint32 { if a < b { return a }; return b }
func maxi(a, b uint32) uint32 { if a > b { return a }; return b }

func round(x float64) float64 { //	https://www.cockroachlabs.com/blog/rounding-implementations-in-go/
	const (
		mask     = 0x7FF
		shift    = 64 - 11 - 1
		bias     = 1023

		signMask = 1 << 63
		fracMask = (1 << shift) - 1
		halfMask = 1 << (shift - 1)
		one      = bias << shift
	)

	bits := math.Float64bits(x)
	e := uint(bits>>shift) & mask
	switch {
	case e < bias:
		// Round abs(x)<1 including denormals.
		bits &= signMask // +-0
		if e == bias-1 {
			bits |= one // +-1
		}
	case e < bias+shift:
		// Round any abs(x)>=1 containing a fractional component [0,1).
		e -= bias
		bits += halfMask >> e
		bits &^= fracMask >> e
	}
	return math.Float64frombits(bits)
}

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

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

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

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

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

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

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

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

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

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

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

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

	return j.sc.Text()
}

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

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

	return res
}

func (j *jam) Int() uint32 {
	return uint32(j.Long())
}

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

func (j *jam) D(format string, values ...interface{}) {
	_ /*bytesWritten*/, err := fmt.Fprintf(os.Stderr, format, values...)
	if err != nil {
		panic(err)
	}
}

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

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

package main

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

func (io *IO) Solve() {
	io.setBuffer()
	s := io.Bytes()
	n := len(s)
	arr := make([]int, n+1)
	arr[n] = n
	var res int64
	for i := n - 1; i >= 0; i-- {
		arr[i] = arr[i+1]
		for k := 1; i+2*k < arr[i]; k++ {
			if s[i] == s[i+k] && s[i] == s[i+2*k] {
				arr[i] = i + 2*k
			}
		}
		res += int64(n - arr[i])
	}
	io.Print(res)
}

func main() {
	NewIO().Solve()
}

type IO struct {
	scanner *bufio.Scanner
	writer  io.Writer
}

func NewIO() *IO {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return &IO{scanner, os.Stdout}
}

func (io *IO) Skip() {
	io.scanner.Scan()
}

func (io *IO) Int32() (n int32) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int32(v-'0')
	}
	return
}

func (io *IO) Int() (n int) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

func (io *IO) Bytes() []byte {
	io.scanner.Scan()
	return io.scanner.Bytes()
}

func (io *IO) IntArray(n int) (arr []int) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = io.Int()
	}
	return
}

func (io *IO) Print(a interface{}) {
	fmt.Fprint(io.writer, a)
}

func (io *IO) Printf(format string, a interface{}) {
	fmt.Fprintf(io.writer, format, a)
}

func (io *IO) setBuffer() {
	io.scanner.Buffer(make([]byte, 4096), 512*1024)
}

// tag(s): lower search
package main

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

const N = 300005
var s string
var n int

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

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

	fmt.Fscanf(reader, "%s", &s)

	n = len(s)
	var ret = int64(n) * int64(n + 1) / 2
	var last = 0
	for i := 1; i <= n; i++ {
		var pos = last

		for j := 1; i - 2 * j >= max(i - 20, 1); j++ {
			if s[i - 1] == s[i - j - 1] && s[i - j - 1] == s[i - 2 * j - 1] {
				pos = max(i - 2 * j, last)
				break
			}
		}

		ret -= int64(i - pos)
		last = pos
	}

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

package main

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

func (io *IO) Solve() {
	io.setBuffer()
	s := io.Bytes()
	n := len(s)
	arr := make([]int, n+1)
	arr[n] = n
	res := 0
	for i := n - 1; i >= 0; i-- {
		arr[i] = arr[i+1]
		for k := 1; i+2*k < arr[i]; k++ {
			if s[i] == s[i+k] && s[i] == s[i+2*k] {
				arr[i] = i + 2*k
			}
		}
		res += n - arr[i]
	}
	io.Print(res)
}

func main() {
	NewIO().Solve()
}

type IO struct {
	scanner *bufio.Scanner
	writer  io.Writer
}

func NewIO() *IO {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return &IO{scanner, os.Stdout}
}

func (io *IO) Skip() {
	io.scanner.Scan()
}

func (io *IO) Int32() (n int32) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int32(v-'0')
	}
	return
}

func (io *IO) Int() (n int) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

func (io *IO) Bytes() []byte {
	io.scanner.Scan()
	return io.scanner.Bytes()
}

func (io *IO) IntArray(n int) (arr []int) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = io.Int()
	}
	return
}

func (io *IO) Print(a interface{}) {
	fmt.Fprint(io.writer, a)
}

func (io *IO) Printf(format string, a interface{}) {
	fmt.Fprintf(io.writer, format, a)
}

func (io *IO) setBuffer() {
	io.scanner.Buffer(make([]byte, 4096), 512*1024)
}

package main

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

func (io *IO) Solve() {
	s := io.Bytes()
	n := len(s)
	arr := make([]int, n+1)
	arr[n] = n
	res := 0
	for i := n - 1; i >= 0; i-- {
		arr[i] = arr[i+1]
		for k := 1; i+2*k < arr[i]; k++ {
			if s[i] == s[i+k] && s[i] == s[i+2*k] {
				arr[i] = i + 2*k
			}
		}
		res += n - arr[i]
	}
	io.Print(res)
}

func main() {
	NewIO().Solve()
}

type IO struct {
	scanner *bufio.Scanner
	writer  io.Writer
}

func NewIO() *IO {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return &IO{scanner, os.Stdout}
}

func (io *IO) Skip() {
	io.scanner.Scan()
}

func (io *IO) Int32() (n int32) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int32(v-'0')
	}
	return
}

func (io *IO) Int() (n int) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

func (io *IO) Bytes() []byte {
	io.scanner.Scan()
	return io.scanner.Bytes()
}

func (io *IO) IntArray(n int) (arr []int) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = io.Int()
	}
	return
}

func (io *IO) Print(a interface{}) {
	fmt.Fprint(io.writer, a)
}

func (io *IO) Printf(format string, a interface{}) {
	fmt.Fprintf(io.writer, format, a)
}

package main

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

const N = 300005
var s string
var n int

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

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

	fmt.Fscanf(reader, "%s", &s)

	n = len(s)
	var ret = int64(n) * int64(n + 1) / 2
	var last = 0
	for i := 1; i <= n; i++ {
		var pos = last

		for j := 1; i - j - j >= max(i - 20, 1); j++ {
			if s[i - 1] == s[i - j - 1] && s[i - j - 1] == s[i - 2 * j - 1] {
				pos = max(i - 2 * j, last)
				break
			}
		}

		ret -= int64(i - pos)
	}

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


Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be. In order to make sure that he's right and restore the correct order of keys, Santa typed his favorite patter looking only to his keyboard.You are given the Santa's favorite patter and the string he actually typed. Determine which pairs of keys could be mixed. Each key must occur in pairs at most once.

The input consists of only two strings s and t denoting the favorite Santa's patter and the resulting string. s and t are not empty and have the same length, which is at most 1000. Both strings consist only of lowercase English letters.

If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print «-1» (without quotes). Otherwise, the first line of output should contain the only integer k (k ≥ 0) — the number of pairs of keys that should be swapped. The following k lines should contain two space-separated letters each, denoting the keys which should be swapped. All printed letters must be distinct. If there are several possible answers, print any of them. You are free to choose the order of the pairs and the order of keys in a pair. Each letter must occur at most once. Santa considers the keyboard to be fixed if he can print his favorite patter without mistakes.

package main

import "fmt"

func main() {
	var correct, current string
	fmt.Scanln(&correct)
	fmt.Scanln(&current)

	var mp = make(map[byte]byte)
	var n = len(correct)

	for i := 0; i < n; i++ {
		var k1, k2 byte = correct[i], current[i]
		var _, ok1 = mp[k1]
		var _, ok2 = mp[k2]
		if !ok1 && !ok2 {
			if k1 != k2 {
				mp[k1] = k2
				mp[k2] = k1
			} else {
				mp[k1] = k1
			}

		} else {
			if mp[k1] != k2 || mp[k2] != k1 {
				fmt.Println(-1)
				return
			}
		}
	}

	var found = 0
	for k, v := range mp {
		if k < v {
			found++
		}
	}
	fmt.Println(found)
	for k, v := range mp {
		if k < v {
			fmt.Println(string(k), string(v))
		}
	}
}

package main

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

func solve() {
	str1 := readString()
	str2 := readString()
	mm := map[rune]rune{}
	for i := 0; i < len(str1); i++ {
		v := rune(str1[i])
		rep := rune(str2[i])
		if prev, ok := mm[v]; !ok {
			mm[v] = rep
		} else if prev != rep {
			fmt.Println(-1)
			return
		}
		if prev, ok := mm[rep]; !ok {
			mm[rep] = v
		} else if prev != v {
			fmt.Println(-1)
			return
		}
	}
	visited := map[rune]int{}
	lines := []string{}
	for k, v := range mm {
		if k != v {
			if visited[k] == 0 && visited[v] == 0 {
				lines = append(lines, fmt.Sprintln(string(v), string(k)))
				visited[k]++
				visited[v]++
			}
		}
	}
	fmt.Println(len(lines))
	for i := 0; i < len(lines); i++ {
		fmt.Print(lines[i])
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	var s string
	var t string

	fmt.Scan(&s, &t)

	n := len(s)

	var m map[uint8]uint8
	m = make(map[uint8]uint8)

	good := true

	for i := 0; i < n; i++ {
		c1, c2 := s[i], t[i]

		v1, ok1 := m[c1]

		if ok1 {
			if v1 != c2 {
				good = false
			}
		}

		v2, ok2 := m[c2]

		if ok2 {
			if v2 != c1 {
				good = false
			}
		}

		if good == false {
			break
		} else {
			m[c1] = c2
			m[c2] = c1
		}
	}

	if good == false {
		fmt.Println(-1)
	} else {
		var mh map[uint8]uint8
		mh = make(map[uint8]uint8)

		for k, v := range m {
			_, ok1 := mh[k]
			_, ok2 := mh[v]

			if ok1 == false && ok2 == false && k != v {
				mh[k] = v
			}
		}

		fmt.Println(len(mh))
		for k, v := range mh {
			fmt.Println(string(k), string(v))
		}
	}
}

package main

import "fmt"

func main() {
	var correct, current string
	fmt.Scanln(&correct)
	fmt.Scanln(&current)

	var mp = make(map[byte]byte)
	var n = len(correct)

	for i := 0; i < n; i++ {
		var k1, k2 byte = correct[i], current[i]
		if k1 != k2 {
			var _, ok = mp[k1]
			if !ok {
				mp[k1] = k2
				mp[k2] = k1
			} else {
				if mp[k1] != k2 || mp[k2] != k1 {
					fmt.Println(-1)
					return
				}
			}
		}
	}

	var found = len(mp) >> 1
	fmt.Println(found)
	for k, v := range mp {
		if k < v {
			fmt.Println(string(k), string(v))
		}
	}
}

package main

import "fmt"

func main() {
	var correct, current string
	fmt.Scanln(&correct)
	fmt.Scanln(&current)

	var mp = make(map[byte]byte)
	var n = len(correct)

	for i := 0; i < n; i++ {
		var k1, k2 byte = correct[i], current[i]
		var _, ok1 = mp[k1]
		var _, ok2 = mp[k2]
		if !ok1 && !ok2 {
			mp[k1] = k2
			mp[k2] = k1
		} else {
			if mp[k1] != k2 || mp[k2] != k1 {
				fmt.Println(-1)
				return
			}
		}
	}

	var found = len(mp) >> 1
	fmt.Println(found)
	for k, v := range mp {
		if k < v {
			fmt.Println(string(k), string(v))
		}
	}
}

package main

import "fmt"

func main() {
	var correct, current string
	fmt.Scanln(&correct)
	fmt.Scanln(&current)

	var mp = make(map[byte]byte)
	var n = len(correct)

	var d = 0

	for i := 0; i < n; i++ {
		var k1, k2 byte = correct[i], current[i]
		var _, ok1 = mp[k1]
		var _, ok2 = mp[k2]
		if !ok1 && !ok2 {
			if k1 != k2 {
				mp[k1] = k2
				mp[k2] = k1
			} else {
				mp[k1] = k1
				d++
			}

		} else {
			if mp[k1] != k2 || mp[k2] != k1 {
				fmt.Println(-1)
				return
			}
		}
	}

	var found = len(mp) >> 1
	fmt.Println(found - d)
	for k, v := range mp {
		if k < v {
			fmt.Println(string(k), string(v))
		}
	}
}

package main

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

func solve() {
	str1 := readString()
	str2 := readString()
	mm := map[rune]rune{}
	for i := 0; i < len(str1); i++ {
		v := rune(str1[i])
		if prev, ok := mm[v]; !ok {
			mm[v] = rune(str2[i])
		} else if prev != rune(str2[i]) {
			fmt.Println(-1)
			return
		}
	}
	visited := map[rune]int{}
	lines := []string{}
	for k, v := range mm {
		if k != v {
			if visited[k] == 0 && visited[v] == 0 {
				lines = append(lines, fmt.Sprintln(string(v), string(k)))
				visited[k]++
				visited[v]++
			}
		}
	}
	fmt.Println(len(lines))
	for i := 0; i < len(lines); i++ {
		fmt.Print(lines[i])
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	str1 := readString()
	str2 := readString()
	a1 := []rune(str1)
	a2 := []rune(str2)
	mm := map[rune]rune{}
	for i := 0; i < len(a1); i++ {
		if a1[i] != a2[i] {
			rep := a2[i]
			if prev, ok := mm[rep]; !ok {
				mm[rep] = a1[i]
			} else if prev != a1[i] {
				fmt.Println(-1)
				return
			}
			for j := i; j < len(a1); j++ {
				if a1[j] == a1[i] && a2[j] != rep {
					fmt.Println(-1)
					return
				} else if a2[j] == rep && a1[j] != a1[i] {
					fmt.Println(-1)
					return
				}
				if a2[j] == rep {
					a2[j] = a1[i]
				} else if a2[j] == a1[i] {
					a2[j] = rep
				}
			}
		}
	}
	if string(a2) != str1 {
		fmt.Println(-1)
	} else {
		fmt.Println(len(mm))
		for k, v := range mm {
			fmt.Println(string(k), string(v))

		}
	}
}

func solve2() {
	str1 := readString()
	str2 := readString()
	mm := map[rune]rune{}
	for i := 0; i < len(str1); i++ {
		v := rune(str1[i])
		if prev, ok := mm[v]; !ok {
			mm[v] = rune(str2[i])
		} else if prev != rune(str2[i]) {
			fmt.Println(-1)
			return
		}
	}
	visited := map[rune]int{}
	lines := []string{}
	for k, v := range mm {
		if k != v {
			if visited[k] == 0 && visited[v] == 0 {
				lines = append(lines, fmt.Sprintln(string(v), string(k)))
				visited[k]++
				visited[v]++
			}
		}
	}
	fmt.Println(len(lines))
	for i := 0; i < len(lines); i++ {
		fmt.Print(lines[i])
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	str1 := readString()
	str2 := readString()
	a1 := []rune(str1)
	a2 := []rune(str2)
	mm := map[rune]rune{}
	for i := 0; i < len(a1); i++ {
		if a1[i] != a2[i] {
			rep := a2[i]
			if prev, ok := mm[rep]; !ok {
				mm[rep] = a1[i]
			} else if prev != a1[i] {
				fmt.Println(-1)
				return
			}
			for j := i; j < len(a1); j++ {
				if a2[j] == rep {
					a2[j] = a1[i]
				} else if a2[j] == a1[i] {
					a2[j] = rep
				}
			}
		}
	}
	if string(a2) != str1 {
		fmt.Println(-1)
	} else {
		fmt.Println(len(mm))
		for k, v := range mm {
			fmt.Println(string(k), string(v))

		}
	}
}

func solve2() {
	str1 := readString()
	str2 := readString()
	mm := map[rune]rune{}
	for i := 0; i < len(str1); i++ {
		v := rune(str1[i])
		if prev, ok := mm[v]; !ok {
			mm[v] = rune(str2[i])
		} else if prev != rune(str2[i]) {
			fmt.Println(-1)
			return
		}
	}
	visited := map[rune]int{}
	lines := []string{}
	for k, v := range mm {
		if k != v {
			if visited[k] == 0 && visited[v] == 0 {
				lines = append(lines, fmt.Sprintln(string(v), string(k)))
				visited[k]++
				visited[v]++
			}
		}
	}
	fmt.Println(len(lines))
	for i := 0; i < len(lines); i++ {
		fmt.Print(lines[i])
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	str1 := readString()
	str2 := readString()
	a1 := []rune(str1)
	a2 := []rune(str2)
	mm := map[rune]rune{}
	for i := 0; i < len(a1); i++ {
		if a1[i] != a2[i] {
			rep := a2[i]
			mm[a1[i]] = rep
			for j := i; j < len(a1); j++ {
				if a2[j] == rep {
					a2[j] = a1[i]
				} else if a2[j] == a1[i] {
					a2[j] = rep
				}
			}
		}
	}
	if string(a2) != str1 {
		fmt.Println(-1)
	} else {
		fmt.Println(len(mm))
		for k, v := range mm {
			fmt.Println(string(k), string(v))

		}
	}
}

func solve2() {
	str1 := readString()
	str2 := readString()
	mm := map[rune]rune{}
	for i := 0; i < len(str1); i++ {
		v := rune(str1[i])
		if prev, ok := mm[v]; !ok {
			mm[v] = rune(str2[i])
		} else if prev != rune(str2[i]) {
			fmt.Println(-1)
			return
		}
	}
	visited := map[rune]int{}
	lines := []string{}
	for k, v := range mm {
		if k != v {
			if visited[k] == 0 && visited[v] == 0 {
				lines = append(lines, fmt.Sprintln(string(v), string(k)))
				visited[k]++
				visited[v]++
			}
		}
	}
	fmt.Println(len(lines))
	for i := 0; i < len(lines); i++ {
		fmt.Print(lines[i])
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	var s string
	var t string

	fmt.Scan(&s, &t)

	n := len(s)

	var m map[uint8]uint8
	m = make(map[uint8]uint8)

	good := true

	for i := 0; i < n; i++ {
		c1, c2 := s[i], t[i]

		v1, ok1 := m[c1]

		if ok1 {
			if v1 != c2 {
				good = false
			}
		} else {
			m[c1] = c2
			m[c2] = c1
		}

		if good == false {
			break
		}
	}

	if good == false {
		fmt.Println(-1)
	} else {
		var mh map[uint8]uint8
		mh = make(map[uint8]uint8)

		for k, v := range m {
			_, ok1 := mh[k]
			_, ok2 := mh[v]

			if ok1 == false && ok2 == false && k != v {
				mh[k] = v
			}
		}

		fmt.Println(len(mh))
		for k, v := range mh {
			fmt.Println(string(k), string(v))
		}
	}
}


There is a road with length $$$l$$$ meters. The start of the road has coordinate $$$0$$$, the end of the road has coordinate $$$l$$$.There are two cars, the first standing at the start of the road and the second standing at the end of the road. They will start driving simultaneously. The first car will drive from the start to the end and the second car will drive from the end to the start.Initially, they will drive with a speed of $$$1$$$ meter per second. There are $$$n$$$ flags at different coordinates $$$a_1, a_2, \ldots, a_n$$$. Each time when any of two cars drives through a flag, the speed of that car increases by $$$1$$$ meter per second.Find how long will it take for cars to meet (to reach the same coordinate).

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$): the number of test cases. The first line of each test case contains two integers $$$n$$$, $$$l$$$ ($$$1 \leq n \leq 10^5$$$, $$$1 \leq l \leq 10^9$$$): the number of flags and the length of the road. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ in the increasing order ($$$1 \leq a_1 < a_2 < \ldots < a_n < l$$$). It is guaranteed that the sum of $$$n$$$ among all test cases does not exceed $$$10^5$$$.

For each test case print a single real number: the time required for cars to meet. Your answer will be considered correct, if its absolute or relative error does not exceed $$$10^{-6}$$$. More formally, if your answer is $$$a$$$ and jury's answer is $$$b$$$, your answer will be considered correct if $$$\frac{|a-b|}{\max{(1, b)}} \leq 10^{-6}$$$.

NoteIn the first test case cars will meet in the coordinate $$$5$$$.The first car will be in the coordinate $$$1$$$ in $$$1$$$ second and after that its speed will increase by $$$1$$$ and will be equal to $$$2$$$ meters per second. After $$$2$$$ more seconds it will be in the coordinate $$$5$$$. So, it will be in the coordinate $$$5$$$ in $$$3$$$ seconds.The second car will be in the coordinate $$$9$$$ in $$$1$$$ second and after that its speed will increase by $$$1$$$ and will be equal to $$$2$$$ meters per second. After $$$2$$$ more seconds it will be in the coordinate $$$5$$$. So, it will be in the coordinate $$$5$$$ in $$$3$$$ seconds.In the second test case after $$$1$$$ second the first car will be in the coordinate $$$1$$$ and will have the speed equal to $$$2$$$ meters per second, the second car will be in the coordinate $$$9$$$ and will have the speed equal to $$$1$$$ meter per second. So, they will meet after $$$\frac{9-1}{2+1} = \frac{8}{3}$$$ seconds. So, the answer is equal to $$$1 + \frac{8}{3} = \frac{11}{3}$$$.

package main

import (
	"bufio"
	"fmt"
	"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 scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

func solve() {
	n, l := nextInt(), nextInt()
	arr := make([]float64, n+2)
	for i := 1; i <= n; i++ {
		arr[i] = nextDouble()
	}
	arr[0], arr[n+1] = 0, float64(l)

	var curr float64 = 0
	for pow := float64(1 << 60); pow > 1e-10; pow /= 2 {
		tmp := curr + pow
		var x1, x2, t1, t2 float64 = 0, 0, tmp, tmp
		for i := 0; i <= n; i++ {
			if i == n || (arr[i+1]-arr[i])/float64(i+1) > t1 {
				x1 = arr[i] + t1*float64(i+1)
				break
			} else {
				t1 -= (arr[i+1] - arr[i]) / float64(i+1)
			}
		}
		for i := n + 1; i >= 0; i-- {
			if i == 0 || (arr[i]-arr[i-1])/float64(n-i+2) > t2 {
				x2 = arr[i] - t2*float64(n-i+2)
				break
			} else {
				t2 -= (arr[i] - arr[i-1]) / float64(n-i+2)
			}
		}
		if x1 < x2 {
			curr = tmp
		}
	}
	printf("%.9f\n", curr)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	name := "in"
	file1, err := os.Open(name + ".in")
	if err == nil {
		in = bufio.NewReaderSize(file1, 8192)
	}
	// file2, err := os.Create(name + ".out")
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// out = bufio.NewWriterSize(file2, 8192)
	defer out.Flush()
	// start := time.Now()

	for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
		// printf("Case #%d:\n", i)
		solve()
	}

	// printf("%v\n", time.Now().Sub(start))
}

package main

import "fmt"

func main() {
	test := 0
	fmt.Scan(&test)
	for test > 0 {
		n := 0
		k := 0
		fmt.Scan(&n)
		fmt.Scan(&k)
		v := 1.0
		v2 := 1.0
		t := 0.0
		t2 := 0.0
		d := 0.0
		d2 := float64(k)
		l := 0
		r := n - 1
		arr := []float64{}
		for n > 0 {
			var x float64
			fmt.Scan(&x)
			arr = append(arr, x)
			n--
		}
		for l <= r {
			if t+(arr[l]-d)/v < t2+(d2-arr[r])/v2 {
				t += (arr[l] - d) / v
				d = arr[l]
				v += 1.0
				l++
			} else {
				t2 += (d2 - arr[r]) / v2
				d2 = arr[r]
				v2 += 1.0
				r--
			}
		}
		if t > t2 {
			d2 -= v2 * (t - t2)
			t2 = t
		} else {
			d += v * (t2 - t)
			t = t2
		}
		fmt.Printf("%.7f\n", t+(d2-d)/(v+v2))
		test--
	}
}

package main

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

func ReadInt(scanner *bufio.Scanner) int {
	if !scanner.Scan() {
		fmt.Printf("cant scan int: %s", scanner.Err())
	}
	str := scanner.Text()
	n, _ := strconv.Atoi(str)
	return n
}

func ReadIntArray(scanner *bufio.Scanner) []int {
	if !scanner.Scan() {
		fmt.Printf("cant scan array: %s", scanner.Err())
	}
	str := scanner.Text()
	tokens := strings.Split(str, " ")
	result := make([]int, len(tokens))
	for index, token := range tokens {
		n, _ := strconv.Atoi(token)
		result[index] = n
	}
	return result
}

func PrintIntArray(arr []int, writer *bufio.Writer) {
	strArray := fmt.Sprint(arr)
	_, _ = writer.WriteString(strArray[1:len(strArray)-1])
	_, _ =writer.Write([]byte{'\n'})
}

func PrintInt(number int, writer *bufio.Writer) {
	_, _ = writer.WriteString(strconv.Itoa(number))
	_, _ = writer.Write([]byte{'\n'})
}

func PrintFloat(number float64, writer *bufio.Writer) {
	_, _ = writer.WriteString(fmt.Sprintf("%.9f", number))
	_, _ = writer.Write([]byte{'\n'})
}

type Times struct {
	t1 float64
	t2 float64
}

func Solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	tmp := ReadIntArray(scanner)
	l := tmp[1]
	a := ReadIntArray(scanner)
	b := make([]Times, len(a)+2)

	t0 := 0.0
	v0 := 1.0
	prevPoint := 0.0
	for i, point := range a {
		b[i+1].t1 = t0 + (float64(point) - prevPoint) / v0
		v0 += 1.0
		t0 = b[i+1].t1
		prevPoint = float64(point)
	}
	b[len(b)-1].t1 = t0 + (float64(l) - prevPoint) / v0

	t0 = 0.0
	v0 = 1.0
	prevPoint = float64(l)
	for i := len(a)-1; i >= 0; i-- {
		b[i+1].t2 = t0 + (prevPoint - float64(a[i])) / v0
		v0 += 1.0
		t0 = b[i+1].t2
		prevPoint = float64(a[i])
	}
	b[0].t2 = t0 + prevPoint / v0

	result := 0.0
	for i, time := range b {
		if time.t1 < time.t2 {
			continue
		}
		pTime := b[i - 1]
		v1 := float64(i)
		v2 := float64(len(b) - i)
		var ds float64
		if i == 1 {
			ds = float64(a[0])
		} else if i == len(b) - 1 {
			ds = float64(l - a[len(a)-1])
		} else {
			ds = float64(a[i-1] - a[i-2])
		}
		dt := time.t2 - pTime.t1
		newT1 := pTime.t1
		if dt > 0 {
			ds -= dt * v1
			newT1 += dt
		} else {
			ds += dt * v2
		}
		result = newT1 + ds / (v1 + v2)
		break
	}
	PrintFloat(result, writer)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 0, 256*1024)
	scanner.Buffer(buf, 1024*1024)
	writer := bufio.NewWriter(os.Stdout)
	t := ReadInt(scanner)
	for i := 0; i < t; i++ {
		Solve(scanner, writer)
	}
	_ = writer.Flush()
}

package main

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

func main() {
	t := ReadInt()
	for i := 0; i < t; i++ {
		n, l := ReadInt(), ReadInt()
		a := make([]float64, n)
		for i := 0; i < n; i++ {
			Scan(&a[i])
		}
		fmt.Printf("%9.15f\n", solve(n, l, a))
	}
}

func solve(n int, l_ int, a []float64) float64 {
	l := float64(l_)
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = l - a[n-i-1]
	}

	ps := make([]float64, n+1)
	prev := 0.
	for i := 0; i < n; i++ {
		ps[i+1] = ps[i] + (a[i]-prev)/(float64(i)+1)
		prev = a[i]
	}

	qs := make([]float64, n+1)
	prev = 0.
	for i := 0; i < n; i++ {
		qs[i+1] = qs[i] + (b[i]-prev)/(float64(i)+1)
		prev = b[i]
	}

	lo := 0.
	hi := l
	for isLarge(hi, lo) {
		c := (hi + lo) / 2
		p := calcTime(c, a, ps)
		q := calcTime(l-c, b, qs)
		if p < q {
			lo = c
		} else {
			hi = c
		}
	}

	pos := (lo + hi) / 2
	return calcTime(pos, a, ps)
}

func isLarge(hi, lo float64) bool {
	// hi-lo > 1e-7
	return (hi-lo)/Max(1.0, lo) > 1e-13
}

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

func calcTime(pos float64, a, ps []float64) float64 {
	flags := sort.Search(len(a), func(i int) bool { return a[i] > pos })

	if flags == 0 {
		return pos
	}

	ret := 0.
	ret += ps[flags]
	diff := (pos - a[flags-1]) / float64(1+flags)
	ret += diff
	return ret
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }

package main

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

func solve() {
	t := readInt()

	for j := 0; j < t; j++ {
		n := readInt()
		l := readInt()
		a := make([]int, 0)
		a = append(a, 0)
		for i := 0; i < n; i++ {
			a = append(a, readInt())
		}
		a = append(a, l)

		leftSpeed := 1
		rightSpeed := 1

		leftIndex := 0
		rightIndex := len(a) - 2
		leftAt := float64(0)
		rightAt := float64(0)

		for leftIndex < rightIndex {
			tmpLeftAt := leftAt + float64(a[leftIndex+1]-a[leftIndex])/float64(leftSpeed)
			tmpRightAt := rightAt + float64(a[rightIndex+1]-a[rightIndex])/float64(rightSpeed)
			if tmpLeftAt < tmpRightAt {
				leftIndex++
				leftSpeed++
				leftAt = tmpLeftAt
			} else {
				rightIndex--
				rightSpeed++
				rightAt = tmpRightAt
			}
		}
		curTime := max(leftAt, rightAt)
		dist := float64(a[leftIndex+1] - a[leftIndex])
		if leftAt < rightAt {
			dist -= float64(leftSpeed) * (rightAt - leftAt)
		} else {
			dist -= float64(rightSpeed) * (leftAt - rightAt)
		}
		curTime += dist / float64(rightSpeed+leftSpeed)
		fmt.Printf("%.8f\n", curTime)
	}
}

var scanner *bufio.Scanner

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

// IO

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

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

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

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

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

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

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

package main

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

func abs(a float64, b float64) float64 {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}

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

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

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var nt int
	fmt.Fscanf(reader, "%d\n", &nt)
	var n, L int
	for kk := 0; kk < nt; kk++ {
		fmt.Fscanf(reader, "%d %d\n", &n, &L)
		var a = make([]int, n + 2)
		for i := 1; i <= n; i++ {
			fmt.Fscanf(reader, "%d", &a[i])
		}

		fmt.Fscanf(reader, "\n")
		a[0] = 0
		a[n + 1] = L

		var timeL = make([]float64, n + 2)
		var timeR = make([]float64, n + 2)

		timeL[0] = 0
		for i := 1; i <= n + 1; i++ {
			timeL[i] = timeL[i - 1] + float64(a[i] - a[i - 1]) / float64(i)
		}

		timeR[n + 1] = 0
		for i := n; i >= 0; i-- {
			timeR[i] = timeR[i + 1] + float64(a[i + 1] - a[i]) / float64(n + 1 - i)
		}

		//fmt.Println(timeL)
		//fmt.Println(timeR)

		var ret = float64(L)

		for i := 0; i <= n; i++ {
			var fromLeft = timeL[i]
			var fromRight = timeR[i + 1]

			var speedLeft = i + 1
			var speedRight = n + 1 - i

			//fmt.Println("time: ", fromLeft, fromRight, "speed: ", speedLeft, speedRight)

			var delta = abs(fromLeft, fromRight)

			var leftPath = float64(a[i])
			var rightPath = float64(L - a[i + 1])

			if fromLeft < fromRight {
				leftPath += delta * float64(speedLeft)
			} else {
				rightPath += delta * float64(speedRight)
			}

			if leftPath + rightPath >= float64(L) {
				ret = min(ret, max(fromLeft, fromRight))
			} else {
				var remainPath = float64(L) - (leftPath + rightPath)
				ret = min(ret, max(fromLeft, fromRight) + remainPath / float64(speedLeft + speedRight))
			}
		}
		fmt.Fprintf(writer, "%f\n", ret)
	}
}


You are given a tree consisting of $$$n$$$ vertices. A number is written on each vertex; the number on vertex $$$i$$$ is equal to $$$a_i$$$.Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let's say that a tree is good if no simple path has weight $$$0$$$.You can apply the following operation any number of times (possibly, zero): select a vertex of the tree and replace the value written on it with an arbitrary positive integer. What is the minimum number of times you have to apply this operation in order to make the tree good?

The first line contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of vertices. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i < 2^{30}$$$) — the numbers written on vertices. Then $$$n - 1$$$ lines follow, each containing two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, y \le n; x \ne y$$$) denoting an edge connecting vertex $$$x$$$ with vertex $$$y$$$. It is guaranteed that these edges form a tree.

Print a single integer — the minimum number of times you have to apply the operation in order to make the tree good.

NoteIn the first example, it is enough to replace the value on the vertex $$$1$$$ with $$$13$$$, and the value on the vertex $$$4$$$ with $$$42$$$.

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)
	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(n, E, A)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, E [][]int, A []int) int {

	g := NewGraph(n, 2*n)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	B := make([]int, n)

	var init func(p int, u int)

	init = func(p int, u int) {
		B[u] = A[u]
		if p >= 0 {
			B[u] ^= B[p]
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				init(u, v)
			}
		}
	}
	init(-1, 0)

	vals := make([]map[int]bool, n)
	for i := 0; i < n; i++ {
		vals[i] = make(map[int]bool)
	}

	var res int

	var dfs func(p int, u int)
	dfs = func(p int, u int) {
		vals[u][B[u]] = true
		bad := false
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v {
				continue
			}

			dfs(u, v)

			if len(vals[u]) < len(vals[v]) {
				vals[u], vals[v] = vals[v], vals[u]
			}
			for x := range vals[v] {
				if vals[u][x^A[u]] {
					bad = true
				}
			}
			for x := range vals[v] {
				vals[u][x] = true
			}
		}

		if bad {
			res++
			vals[u] = make(map[int]bool)
		}
	}

	dfs(-1, 0)

	return res
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, 3+e)
	to := make([]int, 3+e)
	var cur int
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)
	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(n, E, A)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, E [][]int, A []int) int {

	g := NewGraph(n, 2*n)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	cnt := make([]map[int]bool, n)

	var dfs func(p int, u int)

	var res int

	ok := make([]bool, n)

	dfs = func(p int, u int) {
		ok[u] = true

		big := -1
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v {
				continue
			}
			dfs(u, v)
			if ok[v] && (big < 0 || len(cnt[big]) < len(cnt[v])) {
				big = v
			}
		}

		if big < 0 {
			// a leaf node
			cnt[u] = make(map[int]bool)
			cnt[u][A[u]] = true
			return
		}

		if cnt[big][A[u]] {
			// change A[u]
			res++
			ok[u] = false
			return
		}

		cnt[u] = make(map[int]bool)
		cnt[u][A[u]] = true
		for x := range cnt[big] {
			cnt[u][x^A[u]] = true
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v || big == v || !ok[v] {
				continue
			}
			if cnt[v][A[u]] {
				res++
				ok[u] = false
				return
			}
			for x := range cnt[v] {
				if cnt[u][x] {
					res++
					ok[u] = false
					return
				}
				cnt[u][x^A[u]] = true
			}
		}
	}

	dfs(0, 0)

	return res
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, 3+e)
	to := make([]int, 3+e)
	var cur int
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)
	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(n, E, A)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, E [][]int, A []int) int {

	g := NewGraph(n, 2*n)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	cnt := make([]map[int]bool, n)

	var dfs func(p int, u int)

	var res int

	ok := make([]bool, n)

	dfs = func(p int, u int) {
		ok[u] = true

		big := -1
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v {
				continue
			}
			dfs(u, v)
			if ok[v] && (big < 0 || len(cnt[big]) < len(cnt[v])) {
				big = v
			}
		}

		if big < 0 {
			// a leaf node
			cnt[u] = make(map[int]bool)
			cnt[u][A[u]] = true
			return
		}

		if cnt[big][A[u]] {
			// change A[u]
			res++
			ok[u] = false
			return
		}

		cnt[u] = make(map[int]bool)

		for x := range cnt[big] {
			cnt[u][x^A[u]] = true
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v || big == v || !ok[v] {
				continue
			}
			if cnt[v][A[u]] {
				res++
				ok[u] = false
				return
			}
			for x := range cnt[v] {
				if cnt[big][x^A[u]] {
					res++
					ok[u] = false
					return
				}
				cnt[big][x] = true
				cnt[u][x^A[u]] = true
			}
		}
	}

	dfs(0, 0)

	return res
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, 3+e)
	to := make([]int, 3+e)
	var cur int
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)
	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(n, E, A)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, E [][]int, A []int) int {

	g := NewGraph(n, 2*n)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	cnt := make([]map[int]bool, n)

	var dfs func(p int, u int) bool

	var res int

	dfs = func(p int, u int) bool {
		big := -1
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v {
				continue
			}
			vk := dfs(u, v)
			if vk && (big < 0 || len(cnt[big]) < len(cnt[v])) {
				big = v
			}
		}

		if big < 0 {
			// a leaf node
			cnt[u] = make(map[int]bool)
			cnt[u][A[u]] = true
			return true
		}

		if cnt[big][A[u]] {
			// change A[u]
			res++
			return false
		}

		cnt[u] = make(map[int]bool)

		for x := range cnt[big] {
			cnt[u][x^A[u]] = true
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v || big == v {
				continue
			}
			if cnt[v][A[u]] {
				res++
				return false
			}
			for x := range cnt[v] {
				if cnt[big][x^A[u]] {
					res++
					return false
				}
				cnt[big][x] = true
				cnt[u][x^A[u]] = true
			}
		}

		return true
	}

	dfs(0, 0)

	return res
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, 3+e)
	to := make([]int, 3+e)
	var cur int
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}

package main

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

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

	n := readNum(reader)
	A := readNNums(reader, n)
	E := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		E[i] = readNNums(reader, 2)
	}
	res := solve(n, E, A)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, E [][]int, A []int) int {

	g := NewGraph(n, 2*n)

	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		g.AddEdge(u, v)
		g.AddEdge(v, u)
	}

	cnt := make([]map[int]bool, n)

	merge := func(u int, v int) bool {
		if cnt[u] == nil {
			cnt[u] = make(map[int]bool)
			for x := range cnt[v] {
				cnt[u][x^A[u]] = true
			}
			cnt[u][A[u]] = true
			return true
		}

		if len(cnt[u]) < len(cnt[v]) {
			cnt[u], cnt[v] = cnt[v], cnt[u]
		}
		// len(cnt[u]) >= len(cnt[v])
		for x := range cnt[v] {
			if cnt[u][x] {
				return false
			}
			cnt[u][x^A[u]] = true
		}
		return true
	}

	var dfs func(p int, u int) bool

	var res int

	dfs = func(p int, u int) bool {
		leaf := true
		ok := true
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p == v {
				continue
			}
			vk := dfs(u, v)
			if vk && ok {
				leaf = false
				if cnt[v][A[u]] || !merge(u, v) {
					// just change u, and drop result from sub-tree of u
					ok = false
				}
			}
		}

		if !ok {
			res++
		} else if leaf {
			cnt[u] = make(map[int]bool)
			cnt[u][A[u]] = true
		}

		return ok
	}

	dfs(0, 0)

	return res
}

type Graph struct {
	nodes []int
	next  []int
	to    []int
	cur   int
}

func NewGraph(n int, e int) *Graph {
	nodes := make([]int, n)
	next := make([]int, 3+e)
	to := make([]int, 3+e)
	var cur int
	return &Graph{nodes, next, to, cur}
}

func (g *Graph) AddEdge(u, v int) {
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
}


A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left).  Alice and Bob play dice. Alice has built a tower from n dice. We know that in this tower the adjacent dice contact with faces with distinct numbers. Bob wants to uniquely identify the numbers written on the faces of all dice, from which the tower is built. Unfortunately, Bob is looking at the tower from the face, and so he does not see all the numbers on the faces. Bob sees the number on the top of the tower and the numbers on the two adjacent sides (on the right side of the picture shown what Bob sees).Help Bob, tell whether it is possible to uniquely identify the numbers on the faces of all the dice in the tower, or not.

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of dice in the tower. The second line contains an integer x (1 ≤ x ≤ 6) — the number Bob sees at the top of the tower. Next n lines contain two space-separated integers each: the i-th line contains numbers ai, bi (1 ≤ ai, bi ≤ 6; ai ≠ bi) — the numbers Bob sees on the two sidelong faces of the i-th dice in the tower. Consider the dice in the tower indexed from top to bottom from 1 to n. That is, the topmost dice has index 1 (the dice whose top face Bob can see). It is guaranteed that it is possible to make a dice tower that will look as described in the input.

Print "YES" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print "NO" (without the quotes).

package main
import (
	"fmt"
)

func main() {
	var n,x int
	k:=0
	fmt.Scan(&n,&x)
	a:=make([]int,200)
	for i:=0;i<2*n;i++ {
		fmt.Scan(&a[i])
		if (a[i]==x) || (a[i]==(7-x)) {
			k++
		}
	}
	if k>0{
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

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

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

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

	n := scanInt(scanner)
	above := 7 - scanInt(scanner)
	_, _ = scanInt(scanner), scanInt(scanner)
	for i := 1; i < n; i++ {
		a, b := scanInt(scanner), scanInt(scanner)
		no := make([]bool, 7)
		no[a] = true
		no[b] = true
		no[7-a] = true
		no[7-b] = true
		no[above] = true
		count := 0
		for j := 1; j < 7; j++ {
			if !no[j] {
				count++
				above = j
			}
		}
		if count != 1 {
			writer.WriteString("NO\n")
			return
		}
	}
	writer.WriteString("YES\n")
}

package main

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

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

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

	n := scanInt(scanner)
	above := 7 - scanInt(scanner)
	_, _ = scanInt(scanner), scanInt(scanner)
	for i := 1; i < n; i++ {
		a, b := scanInt(scanner), scanInt(scanner)
		no := make([]bool, 7)
		no[a] = true
		no[b] = true
		no[7-a] = true
		no[7-b] = true
		no[above] = true
		count, last := 0, -1
		for j := 1; j < 7; j++ {
			if !no[j] {
				count++
				last = j
			}
		}
		if count != 1 {
			writer.WriteString("NO\n")
			return
		}
		above = last
	}
	writer.WriteString("YES\n")
}

package main

import "fmt"

func main() {
    var n,x,a,b int
    fmt.Scan(&n)
    fmt.Scan(&x)
    ans := true
    for i := 0; i < n; i++ {
        fmt.Scan(&a,&b)
        if (x == a) || ((x+a) == 7) || (x == b) || ((x+b) == 7) {
            ans = false
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}

package main

import "fmt"

func main() {
    var n,x,a,b int					// variabel n,x,a,b dengan jenis int
    fmt.Scan(&n)					// mengambil input
    fmt.Scan(&x)					// mengambil input
    ans := true						// variabel ans sama dengan true
    for i := 0; i < n; i++ {		// looping
        fmt.Scan(&a,&b)				// mengambil input kedua
        if (x == a) || ((x+a) == 7) || (x == b) || ((x+b) == 7) {  // jika x sama dengan a  atau x+a sama dengan 7 atau x sama dengan b atau x+b sama dengan 7
            ans = false				// ans sama dengan false
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }  // jika ans maka cetak YES ,lainnya cetak NO
}

// 225A-mic
package main

import (
    "fmt"
)

func main() {
    var n, k, x, y int
    fmt.Scan(&n, &k)
    flag := true
    k = 7 - k
    for i := 1; i <= n; i++ {
        fmt.Scan(&x, &y)
        if x == k || x == 7-k || y == k || y == 7-k {
            flag = false
            break
        }
    }
    if flag {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }

}

// 225A-mic
package main

import (
	"fmt"
)

func main() {
	var n, k, x, y int
	fmt.Scan(&n, &k)
	flag := true
	for i := 1; i <= n; i++ {
		fmt.Scan(&x, &y)
		if x == k || x == y || x+k == 7 || x+y == 7 {
			flag = false
			break
		}
	}
	if flag {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.In this game, the phone's screen is divided into four vertical strips. Each second, a black square appears on some of the strips. According to the rules of the game, Jury must use this second to touch the corresponding strip to make the square go away. As Jury is both smart and lazy, he counted that he wastes exactly ai calories on touching the i-th strip.You've got a string s, describing the process of the game and numbers a1, a2, a3, a4. Calculate how many calories Jury needs to destroy all the squares?

// A. Black Square
/*
Quite recently, a very smart student named Jury decided that lectures are
boring, so he downloaded a game called "Black Square" on his super cool
touchscreen phone.

In this game, the phone's screen is divided into four vertical strips.
Each second, a black square appears on some of the strips. According to the
rules of the game, Jury must use this second to touch the corresponding strip
to make the square go away. As Jury is both smart and lazy, he counted that
he wastes exactly ai calories on touching the i-th strip.

You've got a string s, describing the process of the game and numbers a1, a2,
a3, a4. Calculate how many calories Jury needs to destroy all the squares?

Input
The first line contains four space-separated integers a1, a2, a3, a4
(0 ≤ a1, a2, a3, a4 ≤ 104).

The second line contains string s (1 ≤ |s| ≤ 105), where the і-th character
of the string equals "1", if on the i-th second of the game the square appears
on the first strip, "2", if it appears on the second strip, "3", if it appears
on the third strip, "4", if it appears on the fourth strip.

Output
Print a single integer — the total number of calories that Jury wastes.

Examples
Input
1 2 3 4
123214

Output
13

Input
1 5 3 2
11221

Output
13
*/
package main

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

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

	input2, _ := reader.ReadString('\n')
	s := strings.TrimSpace(input2)

	total := 0
	for _, v := range s {
		i, _ := strconv.Atoi(string(v))

		a, _ := strconv.Atoi(arr[i-1])
		total += a
	}
	fmt.Print(total)
}

package main

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

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

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

	a := make([]int, 4)

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

	s := ""

	fmt.Scan(&s)

	calories := 0

	for i:=0; i<len(s); i++ {
		calories += a[s[i] - '0' - 1]
	}

	println(calories)
}

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

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

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

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

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

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

package main

import "fmt"

func main() {
	dic := map[rune]int{}

	for i := range make([]struct{}, 4) {
		var a int
		fmt.Scan(&a)
		dic[rune('0'+i+1)] = a
	}

	var s string
	fmt.Scan(&s)
	cnt := 0
	for _, v := range s {
		cnt += dic[v]
	}

	fmt.Println(cnt)
}

package main

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

func main() {
	io := newIo()
	dic := map[rune]int{}

	for i := range make([]struct{}, 4) {
		a := io.nextInt()
		dic[rune('0'+i+1)] = a
	}

	s := io.next()
	cnt := 0
	for _, v := range s {
		cnt += dic[v]
	}

	fmt.Println(cnt)
}

type _io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

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

package main
import (
	"fmt"
	"unicode/utf8"
)
func main() {
	var a [5]int
	var str string
	fmt.Scan(&a[1],&a[2],&a[3],&a[4])
	fmt.Scan(&str)
	s :=0
	len:=utf8.RuneCountInString(str)
	for i:=0; i<len; i++ {
		s1:=int(str[i]-'0')
		//fmt.Println(s1)
		s+=a[s1]
	}
	fmt.Println(s)
}

package main

import "fmt"

func main() {
    var a [4]int
    var s string
    for i := 0; i < 4; i++ { fmt.Scan(&a[i]) }
    fmt.Scan(&s)
    ans := 0
    for _, v := range s {
        in := int(v-'1')
        ans += a[in]
    }
    fmt.Println(ans)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var calories [4]int
	fmt.Scanf("%d %d %d %d\n", &calories[0], &calories[1], &calories[2], &calories[3])
	// fmt.Println(calories)
	var s string
	fmt.Scanf("%s\n", &s)
	var totalCalories int
	for _, i := range s {
		x, _ := strconv.Atoi(string(i))
		// fmt.Println(i, x)

		totalCalories += calories[x-1]
	}
	fmt.Println(totalCalories)
}

package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, cals int
	fmt.Scanf("%d %d %d %d\n", &a, &b, &c, &d)
	var input string
	fmt.Scan(&input)
	var i int64
	for i = 0; i < int64(len(input)); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

import "fmt"

func main() {

    for {

        a := make([]int, 4)
        _, err := fmt.Scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
        if err != nil {
            //fmt.Println(err);
            break;
        }
        var b string
        var result int
        result = 0
        fmt.Scanf("%s", &b)
        fmt.Scanf("%s", &b)
        for _, i := range b {
            num := int(i - '0')
            result += a[num - 1]
        }
        fmt.Println(result);
    }
}

package main

import (
	"fmt"
)

func main() {
	var a [4]int
	for i := range a {
		fmt.Scan(&a[i])
	}
	var s string
	fmt.Scan(&s)
	z := 0
	for _, c := range s {
		z += a[int(c-'1')]
	}
	fmt.Println(z)
}

package main

import "fmt"

var cost [5]int

func main() {
	fmt.Scan(&cost[1], &cost[2], &cost[3], &cost[4])
	var game string
	fmt.Scan(&game)

	sum := 0
	for _, c := range game {
		id := c - '0'
		sum += cost[id]
	}

	fmt.Println(sum)
}

package main

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

func main() {
	var n1, n2, n3, n4 int16
	var sum uint32
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d %d %d\n", &n1, &n2, &n3, &n4)
	fmt.Fscanf(in, "%s\n", &s)
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "1" {
			sum += uint32(n1)
		} else if string(s[i]) == "2" {
			sum += uint32(n2)
		} else if string(s[i]) == "3" {
			sum += uint32(n3)
		} else if string(s[i]) == "4" {
			sum += uint32(n4)
		}
	}
	fmt.Println(sum)
}

package main
import "fmt"
func main() {
  var a[4] int
  fmt.Scanf("%d%d%d%d\n",&a[0],&a[1],&a[2],&a[3])
  var s string
  fmt.Scanln(&s)

  r := 0
  for _, c := range s {
    r += a[c-'1']
  }
  fmt.Println(r)
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func solve(cMap []int, s string) {
	var sum int
	cs := strings.Split(s, "")
	for _, v := range cs {
		i, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			panic(err)
		}
		sum += cMap[i-1]
	}

	fmt.Println(sum)
}

func main() {
	var s string
	k := make([]int, 0, 4)

	var tmp int
	for i := 0; i < 4; i++ {
		fmt.Scan(&tmp)
		k = append(k, tmp)
	}

	_, err := fmt.Scan(&s)
	if err != nil {
		panic(err)
	}

	solve(k, s)
}

package main

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

func main() {
	fourSquare := make([]int, 4)
	reader := bufio.NewReader(os.Stdin)
	for index := 0; index < 4; index++ {
		fmt.Fscan(reader, &fourSquare[index])
	}
	var valuesString string
	var result int
	fmt.Fscan(reader, &valuesString)
	for index := 0; index < len(valuesString); index++ {
		n, _ := strconv.Atoi(string(valuesString[index]))
		result += fourSquare[n-1]
	}
	fmt.Println(result)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	strips:=make(map[int]int,4)
	var squares string
	var calories int
	for i:=0;i<4;i++{
		var cal int
		fmt.Scan(&cal)
		strips[i+1]=cal
	}
	fmt.Scan(&squares)

	for i,k:=range squares{
		toInt,_:=strconv.Atoi(string(k))
		calories+=strips[toInt]
		_=i
	}
	fmt.Println(calories)
}

package main

import ("fmt")

type set map[byte]bool
type long int64
type fl float64

func main(){
	var sum long
	a := make(map[string]int)
	var a1, a2, a3, a4 int
	scan(&a1, &a2, &a3, &a4)
	a["1"] = a1; a["2"] = a2; a["3"] = a3; a["4"] = a4
	var t string
	scan(&t)
	for _,v := range t{
		sum += long(a[string(v)])
	}
	sout(sum)
}

func scan(in ... interface{}){
	for _,k := range in{
		fmt.Scan(k)
	}
}

func sout(obj ... interface{}){
	for _, k := range obj{
		fmt.Print(k)
	}
	fmt.Println()
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	caloriesPerStrips := []int{}
	for index := 0; index < 4; index++ {
		var element int
		fmt.Scan(&element)
		caloriesPerStrips = append(caloriesPerStrips, element)
	}
	var noOfCalories int
	var stringOfMoves string
	fmt.Scan(&stringOfMoves)

	for _, element := range stringOfMoves {
		element,_ := strconv.Atoi(string(element))
		noOfCalories = noOfCalories + caloriesPerStrips[element-1]
	}

	fmt.Print(noOfCalories)
}

package main

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

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

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

	a := make([]int, 4)

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

	s := ""

	fmt.Scan(&s)

	calories := 0

	for i:=0; i<len(s); i++ {
		calories += a[s[i] - '0' - 1]
	}

	println(calories)
}

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

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

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

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

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

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

package main
import (
	"fmt"
	"unicode/utf8"
)
func main() {
	var a [5]int
	var str string
	fmt.Scan(&a[1],&a[2],&a[3],&a[4])
	fmt.Scan(&str)
	s :=0
	len:=utf8.RuneCountInString(str)
	for i:=0; i<len; i++ {
		s1:=int(str[i]-'0')
		fmt.Println(s1)
		s+=a[s1]
	}
	fmt.Println(s)
}

package main

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

func main() {
	var a, b, c, d, cals int64

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

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	scanner.Scan()
	input := scanner.Text()

	for i := 0; i < len(input); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

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

func main() {
	var a, b, c, d, cals int64

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

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	scanner.Scan()
	input := scanner.Text()
	var i int64
	for i = 0; i < int64(len(input)); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

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

func main() {
	var a, b, c, d, cals int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(scanner.Bytes(), math.MaxInt32)

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	var input string
	fmt.Scan(&input)

	for i := 0; i < len(input); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

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

func main() {
	var a, b, c, d, cals int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	var input string
	fmt.Scan(&input)

	for i := 0; i < len(input); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

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

func main() {
	var a, b, c, d, cals int

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

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	scanner.Scan()
	input := scanner.Text()

	for i := 0; i < len(input); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

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

func main() {
	var a, b, c, d, cals int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a = toInt(scanner.Bytes())

	scanner.Scan()
	b = toInt(scanner.Bytes())

	scanner.Scan()
	c = toInt(scanner.Bytes())

	scanner.Scan()
	d = toInt(scanner.Bytes())

	var input string
	fmt.Scan(&input)
	var i int64
	for i = 0; i < int64(len(input)); i++ {
		switch string(input[i]) {
		case "1":
			cals += a
		case "2":
			cals += b
		case "3":
			cals += c
		case "4":
			cals += d
		}
	}
	fmt.Println(cals)
}

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

package main

import "fmt"

func main() {

    for {

        a := make([]int, 4)
        _, err := fmt.Scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
        if err != nil {
            //fmt.Println(err);
            break;
        }
        var b string
        var result int
        result = 0
        fmt.Scanf("%s", &b)
        for _, i := range b {
            num := int(i - '0')
            result += a[num - 1]
        }
        fmt.Println(result);
    }
}

package main

import "fmt"

func main() {

    for {

        a := make([]int, 4)
        _, err := fmt.Scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
        if err != nil {
            fmt.Println(err);
            break;
        }
        //fmt.Printf("%d %d %d %d", a[0], a[1], a[2], a[3]);

        var b string
        var result int
        result = 0
        fmt.Scanf("%s", &b)
        //for _, i := range b {
         //   fmt.Println(i);
       // }
        for _, i := range b {
            num := int(i - '0')
         //   fmt.Println(result, num)
            result += a[num - 1]
        }
        fmt.Println(result);
       // fmt.Println(a,b)
    }
}

package main

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

func main() {
	var n1, n2, n3, n4, sum int16
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d %d %d\n", &n1, &n2, &n3, &n4)
	fmt.Fscanf(in, "%s\n", &s)
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "1" {
			sum += n1
		} else if string(s[i]) == "2" {
			sum += n2
		} else if string(s[i]) == "3" {
			sum += n3
		} else if string(s[i]) == "4" {
			sum += n4
		}
	}
	fmt.Println(sum)
}

package main
import "fmt"
func main() {
  var a[4] int
  fmt.Scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])
  var s string
  fmt.Scanln(&s)

  r := 0
  for _, c := range s {
    r += a[c-'1']
  }
  fmt.Println(r)
}


A student's life is fraught with complications. Some Berland University students know this only too well. Having studied for two years, they contracted strong antipathy towards the chairperson of some department. Indeed, the person in question wasn't the kindest of ladies to begin with: prone to reforming groups, banning automatic passes and other mean deeds. At last the students decided that she just can't get away with all this anymore...The students pulled some strings on the higher levels and learned that the next University directors' meeting is going to discuss n orders about the chairperson and accept exactly p of them. There are two values assigned to each order: ai is the number of the chairperson's hairs that turn grey if she obeys the order and bi — the displeasement of the directors if the order isn't obeyed. The students may make the directors pass any p orders chosen by them. The students know that the chairperson will obey exactly k out of these p orders. She will pick the orders to obey in the way that minimizes first, the directors' displeasement and second, the number of hairs on her head that turn grey.The students want to choose p orders in the way that maximizes the number of hairs on the chairperson's head that turn grey. If there are multiple ways to accept the orders, then the students are keen on maximizing the directors' displeasement with the chairperson's actions. Help them.

The first line contains three integers n (1 ≤ n ≤ 105), p (1 ≤ p ≤ n), k (1 ≤ k ≤ p) — the number of orders the directors are going to discuss, the number of orders to pass and the number of orders to be obeyed by the chairperson, correspondingly. Each of the following n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109), describing the corresponding order.

Print in an arbitrary order p distinct integers — the numbers of the orders to accept so that the students could carry out the revenge. The orders are indexed from 1 to n in the order they occur in the input. If there are multiple solutions, you can print any of them.

NoteIn the first sample one of optimal solutions is to pass orders 1, 2, 3. In this case the chairperson obeys orders number 1 and 2. She gets 10 new grey hairs in the head and the directors' displeasement will equal 3. Note that the same result can be achieved with order 4 instead of order 3.In the second sample, the chairperson can obey all the orders, so the best strategy for the students is to pick the orders with the maximum sum of ai values. The chairperson gets 58 new gray hairs and the directors' displeasement will equal 0.

package main

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

type Scanner struct {
  r            io.Reader
  split        bufio.SplitFunc
  maxTokenSize int
  token, buf   []byte
  start, end   int
}

func NewScanner(r io.Reader) *Scanner {
  return &Scanner{
    r:            r,
    split:        bufio.ScanWords,
    maxTokenSize: 16777216,
    buf:          make([]byte, 4096),
  }
}

func (s *Scanner) advance(n int) bool {
  if n < 0 || n > s.end-s.start {
    return false
  }
  s.start += n
  return true
}

func (s *Scanner) Text() string {
  return string(s.token)
}

func (s *Scanner) Scan() bool {
  for {
    if s.end > s.start {
      advance, token, err := s.split(s.buf[s.start:s.end], false)
      if err != nil || !s.advance(advance) {
        return false
      }
      s.token = token
      if token != nil {
        return true
      }
    }
    if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
      copy(s.buf, s.buf[s.start:s.end])
      s.end -= s.start
      s.start = 0
    }
    if s.end == len(s.buf) {
      if len(s.buf) >= s.maxTokenSize {
        return false
      }
      newSize := len(s.buf) * 2
      if newSize > s.maxTokenSize {
        newSize = s.maxTokenSize
      }
      newBuf := make([]byte, newSize)
      copy(newBuf, s.buf[s.start:s.end])
      s.buf = newBuf
      s.end -= s.start
      s.start = 0
      continue
    }
    for loop := 0; ; {
      n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
      s.end += n
      if n > 0 {
        break
      }
      loop++
      if loop > 100 {
        break
      }
    }
  }
}

func (s *Scanner) Split(split bufio.SplitFunc) {
  s.split = split
}

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var sc *Scanner = NewScanner(os.Stdin)

func next() string { sc.Scan(); return sc.Text() }

func ni32() int {
  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())
  return n
}

func ni64() int64 {
  sc.Scan()
  n, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return n
}

func pri32(i ...int) {
  for _, ii := range i {
    w.WriteString(strconv.Itoa(ii))
    sp()
  }
}
func pri64(i ...int64) {
  for _, ii := range i {
    w.WriteString(strconv.FormatInt(ii, 10))
    sp()
  }
}
func sp()   { w.WriteByte(' ') }
func endl() { w.WriteByte('\n') }

var a, b []int

type PQKey []int
type PriorityQueue []PQKey

func (h PriorityQueue) Len() int           { return len(h) }
func (h PriorityQueue) Less(i, j int) bool { return h[i][0] < h[j][0] }
func (h PriorityQueue) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func NewPriorityQueue() *PriorityQueue {
  h := &PriorityQueue{}
  n := h.Len()
  for i := n/2 - 1; i >= 0; i-- {
    h.down(i, n)
  }
  return h
}

func (h *PriorityQueue) Push(x PQKey) {
  *h = append(*h, x)
  h.up(h.Len() - 1)
}

func (h *PriorityQueue) Pop() PQKey {
  n := h.Len() - 1
  h.Swap(0, n)
  h.down(0, n)
  oldh := *h
  x := oldh[len(oldh)-1]
  newh := oldh[0 : len(oldh)-1]
  *h = newh
  return x
}

func (h *PriorityQueue) Remove(i int) PQKey {
  n := h.Len() - 1
  if n != i {
    h.Swap(i, n)
    h.down(i, n)
    h.up(i)
  }
  return h.Pop()
}

func (h *PriorityQueue) up(j int) {
  for {
    i := (j - 1) / 2
    if i == j || !h.Less(j, i) {
      break
    }
    h.Swap(i, j)
    j = i
  }
}

func (h *PriorityQueue) down(i, n int) {
  for {
    j1 := 2*i + 1
    if j1 >= n || j1 < 0 {
      break
    }
    j := j1
    if j2 := j1 + 1; j2 < n && !h.Less(j1, j2) {
      j = j2
    }
    if !h.Less(j, i) {
      break
    }
    h.Swap(i, j)
    i = j
  }
}

type Data []int

var data Data

func (d Data) Len() int { return len(d) }
func (d Data) Less(i, j int) bool {
  return b[d[i]] < b[d[j]] || (b[d[i]] == b[d[j]] && a[d[i]] > a[d[j]])
}
func (d Data) Swap(i, j int) { d[i], d[j] = d[j], d[i] }

func main() {
  n, p, k := ni32(), ni32(), ni32()
  a, b = make([]int, n), make([]int, n)
  for i := 0; i < n; i++ {
    a[i], b[i] = ni32(), ni32()
  }
  data = make([]int, n)
  for i := 0; i < n; i++ {
    data[i] = i
  }
  sort.Sort(data)
  sum := make([]int64, n)
  max := NewPriorityQueue()
  for i := n - 1; i >= 0; i-- {
    sum[i] = int64(a[data[i]])
    if i < n-1 {
      sum[i] += sum[i+1]
    }
    max.Push(PQKey{a[data[i]], data[i]})
    if max.Len() > k {
      t := max.Pop()
      sum[i] -= int64(t[0])
    }
  }
  im := n - 1
  for i := n - 2; i >= p-k; i-- {
    if sum[i] > sum[im] {
      im = i
    }
  }
  min := NewPriorityQueue()
  for i := n - 1; i >= im; i-- {
    min.Push(PQKey{-a[data[i]], data[i]})
  }
  for i := 0; i < k; i++ {
    pri32(min.Pop()[1] + 1)
  }
  for i := 0; i < p-k; i++ {
    pri32(data[im-1-i] + 1)
  }
  endl()
  w.Flush()
}


Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:  either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);  or the girl in the dancing pair must dance for the first time. Help Fox Ciel to make a schedule that they can dance as many songs as possible.

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.

In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.

NoteIn test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).And in test case 2, we have 2 boys with 2 girls, the answer is 3.

package main
import (
	"fmt"
	//"unicode/utf8"
	//"strconv"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	fmt.Println(n+m-1)
	for i:=1;i<=m;i++ {
		fmt.Printf("1 %d\n",i)
	}

	for i:=2;i<=n;i++ {
		fmt.Printf("%d 1\n",i)
	}
}

package main

import "fmt"

func main(){
        var a, b int
        fmt.Scan(&a, &b)
        fmt.Println(a+b-1)
        for i:=1; i<=b; i++ {
                fmt.Println(1, i)
        }
        for i:=2; i<=a; i++ {
                fmt.Println(i, 1)
        }
}

package main

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

var scanner *bufio.Scanner

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

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

  n, m := getI(), getI()
  total := n+m-1
  writer.WriteString(fmt.Sprintf("%d\n", total))
  for i := 1; i <= m; i++ {
    writer.WriteString(fmt.Sprintf("1 %d\n", i))
  }
  for i := 2; i <= n; i++ {
    writer.WriteString(fmt.Sprintf("%d 1\n", i))
  }
}

package main

import "fmt"

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    fmt.Println(n+m-1)
    for i := 1; i <= m; i++ {
        fmt.Println("1",i)
    }
    for i := 2; i <= n; i++ {
        fmt.Println(i,"1")
    }
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = false

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	n, m := getLine2Int2()
	printf("%d\n", m+n-1)
	for i := 1; i <= m; i++ {
		printf("%d %d\n", 1, i)
	}
	for i := 2; i <= n; i++ {
		printf("%d %d\n", i, m)
	}
}

// 322A
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	fmt.Println(n + m - 1)
	for i := 1; i <= m; i++ {
		fmt.Println("1 ", i)
	}
	for i := 2; i <= n; i++ {
		fmt.Println(i, " 1")
	}
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

func next() string {
  sc.Scan()
  return sc.Text()
}

func Max(i, j int) int {
  if i >= j {
    return i
  }
  return j
}

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n, m := ni(), ni()
  a, b := make([]int, 0), make([]int, 0)

  if n <= m {
    for i := 0; i < m; i++ {
      a = append(a, 1)
      b = append(b, i+1)
    }
    for i := 1; i < n; i++ {
      a = append(a, i+1)
      b = append(b, 1)
    }
  } else {
    for i := 0; i < n; i++ {
      a = append(a, i+1)
      b = append(b, 1)
    }
    for i := 1; i < m; i++ {
      a = append(a, 1)
      b = append(b, i+1)
    }
  }
  pri(len(a))
  endl()
  for i := 0; i < len(a); i++ {
    pri(a[i])
    sp()
    pri(b[i])
    endl()
  }
  w.Flush()
}

// 38A-mic
package main

import (
    "fmt"
)

func main() {
    var n, m int
    j := 1
    fmt.Scan(&n, &m)
    fmt.Println(n + m - 1)
    for i := 1; i <= n; i++ {
        for ; j <= m; j++ {
            fmt.Print(i)
            fmt.Print(" ")
            fmt.Print(j)
            fmt.Println()
            if j >= m {
                break
            }
        }
    }
}

package main

import (
    "fmt"
)

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

    fmt.Println(n + m - 1)

    for i := 1; i <= n; i++ {
        fmt.Printf("%d 1\n", i)
    }

    for i := 2; i <= m; i++ {
        fmt.Printf("1 %d\n", i)
    }
}

package main

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

type Cacher struct {
	buf []byte
	cnt int
	w   io.Writer
}

func (c *Cacher) Write(b []byte) (n int, err error) {
	if b == nil {
		n, err = fmt.Fprintf(c.w, "%d\n%s", c.cnt, c.buf)
		return
	} else {
		c.buf = append(c.buf, b...)
		c.cnt++
		return 0, nil
	}
}

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

	c := &Cacher{w: os.Stdout}

	for i := 1; i <= n; i++ {
		fmt.Fprintf(c, "%d 1\n", i)
	}

	for i := 2; i <= m; i++ {
		fmt.Fprintf(c, "1 %d\n", i)
	}
	c.Write(nil)
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = false

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	n, m := getLine2Int2()
	printf("%d\n", m+n+1)
	for i := 1; i <= m; i++ {
		printf("%d %d\n", 1, i)
	}
	for i := 2; i <= n; i++ {
		printf("%d %d\n", i, m)
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = false

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func d(p, a, b byte) (bool, byte) {
	return p >= a && p <= b, p - a
}

func main() {
	defer writer.Flush()

	n := getLine2Int()
	if n <= 0 {
		return
	}
	s := getLine()
	var c [26]bool
	for i := 0; i < len(s); i++ {
		if ok, t := d(s[i], 'a', 'z'); ok {
			c[t] = ok
		}
		if ok, t := d(s[i], 'A', 'Z'); ok {
			c[t] = ok
		}
	}
	ok := true
	for i := 0; ok && i < len(c); i++ {
		if !c[i] {
			ok = false
		}
	}

	if ok {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}