The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times.The head of the SSU OPTC is recently gathering teams to participate in the world championship. Each team must consist of exactly three people, at that, any person cannot be a member of two or more teams. What maximum number of teams can the head make if he wants each team to participate in the world championship with the same members at least k times?

NoteIn the first sample only one team could be made: the first, the fourth and the fifth participants.In the second sample no teams could be created.In the third sample two teams could be created. Any partition into two teams fits.

package main

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

func main() {
	var n, k int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &k)
	a := make([]int, n)
	count := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
		a[i] += k
		if a[i] <= 5 {
			count++
		}
	}
	fmt.Println(count / 3)
}

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	count := 0
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if x <= 5 - k {
			count++
		}
	}
	fmt.Println(count / 3)
}

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)

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

	count := 0
	y := 0

	for i:=0; i<n; i++ {
		y = nextInt()
		if 5 - y >= k {
			count++
		}
	}

	println(count/3)
}

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

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

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

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

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

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

package main
import (
	"fmt"
)
func main() {
	var n,k,y int
	a:=0
	fmt.Scan(&n,&k)
	for i:=1;i<=n;i++ {
		fmt.Scan(&y)
		if 5-y>=k {
			a++
		}
	}
	fmt.Println(a/3)

}

package main

import "fmt"

func main() {
    var n,k,a int
    fmt.Scan(&n,&k)
    ans, cnt := 0, 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        a = 5-a
        if a >= k { cnt++ }
        if cnt == 3 { ans++; cnt = 0 }
    }
    fmt.Println(ans)
}

package main

import (
	"fmt"
)

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

func main() {
	var n, k, t int
	fmt.Scanf("%d %d \n", &n, &k)
	count := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &t)
		if t+k <= 5 {
			count++
		}
	}
	fmt.Print(count / 3)
}

package main

import (
	"bufio"
	"errors"
	"flag"
	"fmt"
	"log"
	"os"
	"strconv"
	"time"
	"sort"
)

// ******************************** CODE STARTS ********************************

var ()

func solve() {
	n := readInt()
	k := readInt()

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

	sort.Ints(array)

	ans := 0
	for i := 0; i + 2 < n; i += 3 {
		if array[i + 2] + k <= 5 {
			ans++
		}
	}
	printInt(ans)
	printLine()
}

// ********************************* CODE ENDS *********************************

// IO.

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
	logger  *log.Logger
)

func main() {
	local := flag.Bool("local", false, "Equals true, if run is local.")
	flag.Parse()

	var (
		input  *os.File
		output *os.File
	)

	if *local {
		startTime := time.Now()
		defer func() {
			println(fmt.Sprintf("Time: %.5fs", time.Since(startTime).Seconds()))
		}()
		input, _ = os.Open("/home/outside/coding/workspace/go/io/input.txt")
		output, _ = os.Create("/home/outside/coding/workspace/go/io/output.txt")
		logger = log.New(output, "log: ", 0)
	} else {
		input = os.Stdin
		output = os.Stdout
		// input, _ = os.Open("")
		// output, _ = os.Create("")
	}
	defer input.Close()
	defer output.Close()

	scanner = bufio.NewScanner(input)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(output)
	defer writer.Flush()

	solve()
}

// Read.

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

func readLine() string {
	scanner.Split(bufio.ScanLines)
	defer scanner.Split(bufio.ScanWords)
	return readString()
}

func readInt() int {
	ans, _ := strconv.ParseInt(readString(), 10, 0)
	return int(ans)
}

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

func readFloat64() float64 {
	ans, _ := strconv.ParseFloat(readString(), 64)
	return ans
}

// Write.

func printString(value string) {
	writer.WriteString(value)
}

func printLine() {
	printString("\n")
}

func printInt(value int) {
	printString(strconv.FormatInt(int64(value), 10))
}

func printInt64(value int64) {
	printString(strconv.FormatInt(value, 10))
}

func printFLoat64(value float64) {
	printString(strconv.FormatFloat(value, 'f', 20, 64))
}

// Log.

func logln(value ...interface{}) {
	writer.Flush()
	logger.Println(value...)
}
func logf(format string, value ...interface{}) {
	writer.Flush()
	logger.Printf(format, value...)
}

// Tuple

type Tuple struct {
	a, b int
}

func (p Tuple) Equals(key Key) bool {
	return p.a == key.(Tuple).a
}

func (p Tuple) Less(key Key) bool {
	return p.a < key.(Tuple).a
}

type TupleSlice []Tuple

func (p TupleSlice) Len() int {
	return len(p)
}

func (p TupleSlice) Less(j, i int) bool {
	return p[j].a < p[i].a
}

func (p TupleSlice) Swap(j, i int) {
	p[j], p[i] = p[i], p[j]
}

// Min, max, abs.

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

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

func absInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

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

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

func absInt64(a int64) int64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

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

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

func absFloat64(a float64) float64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

// Set Key interface implementations.

type Int int

func (p Int) Equals(key Key) bool {
	return int(p) == int(key.(Int))
}

func (p Int) Less(key Key) bool {
	return int(p) < int(key.(Int))
}

// Set.

type Key interface {
	Equals(key Key) bool
	Less(key Key) bool
}

type node struct {
	key   Key
	left  *node
	right *node
}

func newNode(key Key) *node {
	return &node{key, nil, nil}
}

type SplayTree struct {
	root *node
	tmp  *node
	len  int
}

func NewSplayTree() *SplayTree {
	return &SplayTree{nil, newNode(nil), 0}
}

func rotateLeft(x, p *node) {
	p.right = x.left
	x.left = p
}

func rotateRight(x, p *node) {
	p.left = x.right
	x.right = p
}

func (p *SplayTree) splay(x *node, key Key) *node {
	if x == nil {
		return nil
	}

	left := p.tmp
	right := p.tmp

	for {
		if key.Less(x.key) {
			y := x.left
			if y == nil {
				break
			}
			if key.Less(y.key) { // zig-zig
				rotateRight(y, x)
				x = y
				if x.left == nil {
					break
				}
			}
			// link right
			right.left = x
			right = x
			// move left
			x = x.left
		} else if x.key.Less(key) {
			y := x.right
			if y == nil {
				break
			}
			if y.key.Less(key) { // zig-zig
				rotateLeft(y, x)
				x = y
				if x.right == nil {
					break
				}
			}
			// link left
			left.right = x
			left = x
			// move right
			x = x.right
		} else {
			break
		}
	}

	left.right = x.left
	right.left = x.right
	x.left = p.tmp.right
	x.right = p.tmp.left

	return x
}

// left <= key < right
func (p *SplayTree) split(key Key) (left, right *node) {
	p.root = p.splay(p.root, key)
	if p.root.key.Equals(key) || p.root.key.Less(key) {
		right := p.root.right
		p.root.right = nil
		return p.root, right
	} else {
		left := p.root.left
		p.root.left = nil
		return left, p.root
	}
}

// keys from left tree must be less then keys from right tree
func (p *SplayTree) join(left, right *node) *node {
	if left == nil {
		return right
	} else if right == nil {
		return left
	}
	left = p.splay(left, right.key)
	left.right = right
	return left
}

type Set interface {
	Len() int
	Insert(key Key) error
	Find(key Key) bool
	Remove(key Key) error
}

func NewSet() Set {
	return Set(NewSplayTree())
}

func (p *SplayTree) Len() int {
	return p.len
}

func (p *SplayTree) Insert(key Key) error {
	if p.root == nil {
		p.root = newNode(key)
		p.len++
	} else {
		p.root = p.splay(p.root, key)
		if p.root.key.Equals(key) {
			return errors.New("Such key already exists")
		} else {
			left, right := p.split(key)
			p.root = newNode(key)
			p.root.left = left
			p.root.right = right
			p.len++
		}
	}
	return nil
}

func (p *SplayTree) Find(key Key) bool {
	if p.root == nil {
		return false
	}
	p.root = p.splay(p.root, key)
	return p.root.key.Equals(key)
}

func (p *SplayTree) Remove(key Key) error {
	p.root = p.splay(p.root, key)
	if p.root == nil || !p.root.key.Equals(key) {
		return errors.New("Such key doesn't exist")
	}
	p.root = p.join(p.split(key))
	return nil
}

package main

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

var reader = bufio.NewReader(os.Stdin)

func scan(f string, v ...interface{}) { fmt.Fscanf(reader, f, v...) }

func merge(l, r []int) []int {
	var out = make([]int, len(l)+len(r))
	var i, j, k int
	for j < len(l) && k < len(r) {
		if l[j] < r[k] {
			out[i] = l[j]
			j++
		} else if l[j] >= r[k] {
			out[i] = r[k]
			k++
		}
		i++
	}
	if j == len(l) {
		for ; i < len(out); i++ {
			out[i] = r[k]
			k++
		}
	} else {
		for ; i < len(out); i++ {
			out[i] = l[j]
			j++
		}
	}
	return out
}

func sort(arr []int) []int {
	n := len(arr)
	if n == 1 {
		return arr
	}
	mid := n / 2
	l := sort(arr[:mid])
	r := sort(arr[mid:])
	return merge(l, r)
}

func main() {
	var n, k, t int
	scan("%d %d\n", &n, &k)
	py := make([]int, n)
	for i := 0; i < n; i++ {
		scan("%d", &t)
		py[i] = t
	}
	scan("\n")

	spy := sort(py)
	var total int
	for i := 0; i < n; i += 3 {
		if i+3 > n {
			break
		}
		var big int
		for _, v := range spy[i : i+3] {
			if v > big {
				big = v
			}
		}
		if (5 - big) >= k {
			total++
		}
	}
	fmt.Print(total)
}

package main

import (
	"fmt"
)

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

	if n < 3 {
		fmt.Println(0)
		return
	}

	var student int
	cnt := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d%c", &student)
		if student+k <= 5 {
			cnt++
		}
	}

	fmt.Println(cnt / 3)
}

package main

import (
	"fmt"
)

func main() {
	var n, k int
	var y [2000]int
	fmt.Scan(&n)
	fmt.Scan(&k)
	for i := 0; i < n; i++ {
		fmt.Scan(&y[i])
	}
	count := 0
	for i := 0; i < n; i++ {
		if y[i] <= 5-k {
			count++
		}
	}
	fmt.Println(count / 3)
}

package main

import "fmt"

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

	v := 0
	c := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		if v <= 5-k {
			c += 1
		}
	}

	fmt.Println(c / 3)
}

package main

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

var reader *bufio.Reader

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

var n, k int

func main() {
	fmt.Fscan(reader, &n, &k)
	ans := 0
	for ; n != 0; n-- {
		var a int
		fmt.Fscan(reader, &a)
		if a+k <= 5 {
			ans++
		}
	}
	fmt.Println(ans / 3)
}

package main

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

func main() {
	var n, k, t, c uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &k)
	for i := uint16(0); i < n; i++ {
		fmt.Fscanf(in, "%d", &t)
		if 5-t >= k {
			c++
		}
	}
	fmt.Println(c / 3)

}

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	n := readi()
	k := readi()
	y := make([]int, n)
	for i := range y {
		y[i] = readi()
	}

	var ans int
	for i := range y {
		if y[i]+k <= 5 {
			ans++
		}
	}

	println(ans / 3)
}

package main

import (
    "fmt"
    )

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

    count := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&yn)
        if yn + k <= 5 {
            count++
        }
    }

    fmt.Println(count / 3)
}

package main

import "fmt"

func main() {
	var n, k, res int
	fmt.Scan(&n, &k)
	for n > 0 {
		var tmp int
		fmt.Scan(&tmp)
		if tmp <= (5 - k) {
			res++
		}
		n--
	}

	fmt.Println(int(res / 3))
}

package main

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

// https://codeforces.com/problemset/problem/432/A
// A. Choosing Teams
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times.

// The head of the SSU OPTC is recently gathering teams to participate in the world championship. Each team must consist of exactly three people, at that, any person cannot be a member of two or more teams. What maximum number of teams can the head make if he wants each team to participate in the world championship with the same members at least k times?
// Input

// The first line contains two integers, n and k (1 ≤ n ≤ 2000; 1 ≤ k ≤ 5). The next line contains n integers: y1, y2, ..., yn (0 ≤ yi ≤ 5), where yi shows the number of times the i-th person participated in the ACM ICPC world championship.
// Output

// Print a single number — the answer to the problem.

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

	var n, k int
	_, _ = fmt.Fscan(bufStdin, &n, &k)

	ys := make([]int, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscan(bufStdin, &ys[i])
	}

	var nEligible int
	for _, y := range ys {
		if y+k <= 5 {
			nEligible++
		}
	}

	_, _ = fmt.Print(nEligible / 3)
}

package main

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

// https://codeforces.com/problemset/problem/432/A
// комментарии к решению
// Отбрасываем участников, которые не могут поучаствовать k раз.
// Из остальных формируем команды
func taskSolution(a []byte, k int) int {
	members := map[byte]int{0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
	for _, c := range a {
		if c >= '0' && c <= '5' {
			members[c-'0'] += 1
		}
	}

	membersCount := 0
	for i := 0; i < len(members)-k; i += 1 {
		membersCount += members[byte(i)]
	}
	return membersCount / 3
}

func main() {
	var n, k int
	if _, err := fmt.Scan(&n, &k); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw, k))
}

package main

import "fmt"

func solve(a int64) int64 {
	ret := (a + 1) / 2
	if a % 2 != 0 {
		ret = -ret
	}
	return ret
}

func main() {
	var a int64
	fmt.Scan(&a)
	fmt.Println(solve(a))
}

package main
import (
	"fmt"
)
func main() {
	var n,k,y int
	a:=0
	fmt.Scan(&n,&k)
	for i:=1;i<k;i++ {
		fmt.Scan(&y)
		if 5-y>=k {
			a++
		}
	}
	fmt.Println(a/3)

}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	e:=make([]int,3)
	t :=0
	for k:=0;k<n;k++ {
		fmt.Scan(&t)
		e[k%3]+=t
	}
	if e[0] > e[1] && e[0] > e[2] {
		fmt.Println("chest")
	} else if e[1] > e[2] {
		fmt.Println("biceps")
	} else {fmt.Println("back")}

}

package main

import (
	"bufio"
	"errors"
	"flag"
	"fmt"
	"log"
	"os"
	"strconv"
	"time"
	"sort"
)

// ******************************** CODE STARTS ********************************

var ()

func solve() {
	n := readInt()
	k := readInt()

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

	sort.Ints(array)

	ans := 0
	for i := 0; i + 2 < n; i++ {
		if array[i + 2] + k <= 5 {
			ans++
		}
	}
	printInt(ans)
	printLine()
}

// ********************************* CODE ENDS *********************************

// IO.

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
	logger  *log.Logger
)

func main() {
	local := flag.Bool("local", false, "Equals true, if run is local.")
	flag.Parse()

	var (
		input  *os.File
		output *os.File
	)

	if *local {
		startTime := time.Now()
		defer func() {
			println(fmt.Sprintf("Time: %.5fs", time.Since(startTime).Seconds()))
		}()
		input, _ = os.Open("/home/outside/coding/workspace/go/io/input.txt")
		output, _ = os.Create("/home/outside/coding/workspace/go/io/output.txt")
		logger = log.New(output, "log: ", 0)
	} else {
		input = os.Stdin
		output = os.Stdout
		// input, _ = os.Open("")
		// output, _ = os.Create("")
	}
	defer input.Close()
	defer output.Close()

	scanner = bufio.NewScanner(input)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(output)
	defer writer.Flush()

	solve()
}

// Read.

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

func readLine() string {
	scanner.Split(bufio.ScanLines)
	defer scanner.Split(bufio.ScanWords)
	return readString()
}

func readInt() int {
	ans, _ := strconv.ParseInt(readString(), 10, 0)
	return int(ans)
}

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

func readFloat64() float64 {
	ans, _ := strconv.ParseFloat(readString(), 64)
	return ans
}

// Write.

func printString(value string) {
	writer.WriteString(value)
}

func printLine() {
	printString("\n")
}

func printInt(value int) {
	printString(strconv.FormatInt(int64(value), 10))
}

func printInt64(value int64) {
	printString(strconv.FormatInt(value, 10))
}

func printFLoat64(value float64) {
	printString(strconv.FormatFloat(value, 'f', 20, 64))
}

// Log.

func logln(value ...interface{}) {
	writer.Flush()
	logger.Println(value...)
}
func logf(format string, value ...interface{}) {
	writer.Flush()
	logger.Printf(format, value...)
}

// Tuple

type Tuple struct {
	a, b int
}

func (p Tuple) Equals(key Key) bool {
	return p.a == key.(Tuple).a
}

func (p Tuple) Less(key Key) bool {
	return p.a < key.(Tuple).a
}

type TupleSlice []Tuple

func (p TupleSlice) Len() int {
	return len(p)
}

func (p TupleSlice) Less(j, i int) bool {
	return p[j].a < p[i].a
}

func (p TupleSlice) Swap(j, i int) {
	p[j], p[i] = p[i], p[j]
}

// Min, max, abs.

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

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

func absInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

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

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

func absInt64(a int64) int64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

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

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

func absFloat64(a float64) float64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

// Set Key interface implementations.

type Int int

func (p Int) Equals(key Key) bool {
	return int(p) == int(key.(Int))
}

func (p Int) Less(key Key) bool {
	return int(p) < int(key.(Int))
}

// Set.

type Key interface {
	Equals(key Key) bool
	Less(key Key) bool
}

type node struct {
	key   Key
	left  *node
	right *node
}

func newNode(key Key) *node {
	return &node{key, nil, nil}
}

type SplayTree struct {
	root *node
	tmp  *node
	len  int
}

func NewSplayTree() *SplayTree {
	return &SplayTree{nil, newNode(nil), 0}
}

func rotateLeft(x, p *node) {
	p.right = x.left
	x.left = p
}

func rotateRight(x, p *node) {
	p.left = x.right
	x.right = p
}

func (p *SplayTree) splay(x *node, key Key) *node {
	if x == nil {
		return nil
	}

	left := p.tmp
	right := p.tmp

	for {
		if key.Less(x.key) {
			y := x.left
			if y == nil {
				break
			}
			if key.Less(y.key) { // zig-zig
				rotateRight(y, x)
				x = y
				if x.left == nil {
					break
				}
			}
			// link right
			right.left = x
			right = x
			// move left
			x = x.left
		} else if x.key.Less(key) {
			y := x.right
			if y == nil {
				break
			}
			if y.key.Less(key) { // zig-zig
				rotateLeft(y, x)
				x = y
				if x.right == nil {
					break
				}
			}
			// link left
			left.right = x
			left = x
			// move right
			x = x.right
		} else {
			break
		}
	}

	left.right = x.left
	right.left = x.right
	x.left = p.tmp.right
	x.right = p.tmp.left

	return x
}

// left <= key < right
func (p *SplayTree) split(key Key) (left, right *node) {
	p.root = p.splay(p.root, key)
	if p.root.key.Equals(key) || p.root.key.Less(key) {
		right := p.root.right
		p.root.right = nil
		return p.root, right
	} else {
		left := p.root.left
		p.root.left = nil
		return left, p.root
	}
}

// keys from left tree must be less then keys from right tree
func (p *SplayTree) join(left, right *node) *node {
	if left == nil {
		return right
	} else if right == nil {
		return left
	}
	left = p.splay(left, right.key)
	left.right = right
	return left
}

type Set interface {
	Len() int
	Insert(key Key) error
	Find(key Key) bool
	Remove(key Key) error
}

func NewSet() Set {
	return Set(NewSplayTree())
}

func (p *SplayTree) Len() int {
	return p.len
}

func (p *SplayTree) Insert(key Key) error {
	if p.root == nil {
		p.root = newNode(key)
		p.len++
	} else {
		p.root = p.splay(p.root, key)
		if p.root.key.Equals(key) {
			return errors.New("Such key already exists")
		} else {
			left, right := p.split(key)
			p.root = newNode(key)
			p.root.left = left
			p.root.right = right
			p.len++
		}
	}
	return nil
}

func (p *SplayTree) Find(key Key) bool {
	if p.root == nil {
		return false
	}
	p.root = p.splay(p.root, key)
	return p.root.key.Equals(key)
}

func (p *SplayTree) Remove(key Key) error {
	p.root = p.splay(p.root, key)
	if p.root == nil || !p.root.key.Equals(key) {
		return errors.New("Such key doesn't exist")
	}
	p.root = p.join(p.split(key))
	return nil
}

package main

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

func main() {
	var n, k, t, c uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &k)
	for i := uint16(0); i < n-1; i++ {
		fmt.Fscanf(in, "%d", &t)
		if k > t {
			c++
		}
	}
	fmt.Fscanf(in, "%d\n", &t)
	if k > t {
		c++
	}
	if c%3 != 0 {
		fmt.Println(0)
	} else {
		fmt.Println(c / 3)
	}
}

package main

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

func main() {
	var n, k, t, c uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &k)
	for i := uint16(0); i < n-1; i++ {
		fmt.Fscanf(in, "%d", &t)
		if k >= t*k {
			c++
		}
	}
	fmt.Fscanf(in, "%d\n", &t)
	if k >= t*k {
		c++
	}
	fmt.Println(c / 3)

}


Monocarp has just learned a new card trick, and can't wait to present it to you. He shows you the entire deck of $$$n$$$ cards. You see that the values of cards from the topmost to the bottommost are integers $$$a_1, a_2, \dots, a_n$$$, and all values are different.Then he asks you to shuffle the deck $$$m$$$ times. With the $$$j$$$-th shuffle, you should take $$$b_j$$$ topmost cards and move them under the remaining $$$(n - b_j)$$$ cards without changing the order.And then, using some magic, Monocarp tells you the topmost card of the deck. However, you are not really buying that magic. You tell him that you know the topmost card yourself. Can you surprise Monocarp and tell him the topmost card before he shows it?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of cards in the deck. The second line contains $$$n$$$ pairwise distinct integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$) — the values of the cards. The third line contains a single integer $$$m$$$ ($$$1 \le m \le 2 \cdot 10^5$$$) — the number of shuffles. The fourth line contains $$$m$$$ integers $$$b_1, b_2, \dots, b_m$$$ ($$$1 \le b_j \le n - 1$$$) — the amount of cards that are moved on the $$$j$$$-th shuffle. The sum of $$$n$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$. The sum of $$$m$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$.

For each testcase, print a single integer — the value of the card on the top of the deck after the deck is shuffled $$$m$$$ times.

NoteIn the first testcase, each shuffle effectively swaps two cards. After three swaps, the deck will be $$$[2, 1]$$$.In the second testcase, the second shuffle cancels what the first shuffle did. First, three topmost cards went underneath the last card, then that card went back below the remaining three cards. So the deck remained unchanged from the initial one — the topmost card has value $$$3$$$.

package main

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

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

	var t int
	Fscan(in, &t)

	cards := make([]int, 200005)
	for i := 0; i < t; i++ {
		var n int
		Fscan(in, &n)
		for j := 0; j < n; j++ {
			Fscan(in, &cards[j])
		}

		var m int
		Fscan(in, &m)

		topCard := 0
		for j := 0; j < m; j++ {
			var s int
			Fscan(in, &s)
			topCard = (topCard + s) % n
		}

		Fprintln(out, cards[topCard])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T,N,M,A int
	var B,val int64
	fmt.Fscan(in, &T)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &N)
		var list []int
		for j := 0;j < N;j++{
			fmt.Fscan(in, &A)
			list = append(list,A)
		}
		fmt.Fscan(in, &M)
		for j := 0;j < M;j++{
			fmt.Fscan(in, &B)
			val += B
		}
		fmt.Println(list[val%int64(N)])
		val = 0
	}
}

package main

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

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

func CF1691B(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, m int64
		fmt.Fscan(r, &n)
		a := make([]int64, n)
		for i := int64(0); i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		val, total := 0, 0
		fmt.Fscan(r, &m)
		for i := int64(0); i < m; i++ {
			fmt.Fscan(r, &val)
			total += val
			total %= len(a)
		}
		fmt.Fprintln(w, a[total%len(a)])
	}
}

package main

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

type CF1682B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1682B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1682B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1682B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1682B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1682B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1682B
Date: 30/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1681/B
Problem: CF1682B
**/
func (in *CF1682B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		m := in.NextInt()
		top := 0
		for i := 0; i < m; i++ {
			bi := in.NextInt()
			top = ((bi % n) + (top % n)) % n
		}
		fmt.Println(a[(top)%n])
	}
}

func NewCF1682B(r *bufio.Reader) *CF1682B {
	return &CF1682B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1682B(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"math"
	"os"
)

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var T int
	Fscan(in, &T)

	for tt := 0; tt < T; tt++ {
		var n, m int

		Fscan(in, &n)
		a := make([]int, n)

		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}

		Fscan(in, &m)

		var x int

		ans := 0
		for i := 0; i < m; i++ {
			Fscan(in, &x)
			ans = (ans + x) % n
		}
		Fprintln(out, a[ans])

	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

type Void struct{}

var void Void

type HashSet struct {
	ma map[Int]Void
}

func NewHashSet() *HashSet {
	return &HashSet{
		ma: make(map[Int]Void),
	}
}

func (s *HashSet) add(x Int) bool {
	_, exists := s.ma[x]
	if !exists {
		s.ma[x] = void
		return true
	} else {
		return false
	}
}

func (s *HashSet) del(x Int) {
	delete(s.ma, x)
}

func (s *HashSet) exist(x Int) bool {
	_, exists := s.ma[x]
	return exists
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    Int // The value of the item; arbitrary.
	priority Int // The priority of the item in the queue.
	indices  Int
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func NewItem(value, priority Int) *Item {
	return &Item{
		value:    value,
		priority: priority,
		index:    -1,
	}

}

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, value Int, priority Int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

type SegTree struct {
	st []Segment
}

type Segment struct {
	l, r, val, add, minIndex Int
}

func newSegTree(n Int) SegTree {
	segTree := SegTree{make([]Segment, n<<2)}
	segTree.Build(1, 1, n)
	return segTree
}

func (segTree SegTree) Build(x, l, r Int) {
	segTree.st[x].l = l
	segTree.st[x].r = r
	if l == r {
		segTree.st[x].minIndex = l
		return
	}
	mid := (l + r) >> 1
	segTree.Build(x<<1, l, mid)
	segTree.Build(x<<1|1, mid+1, r)
}

func (segTree SegTree) push(x Int) {
	if segTree.st[x].add != 0 {
		segTree.modifyOne(x<<1, segTree.st[x].add)
		segTree.modifyOne(x<<1|1, segTree.st[x].add)
		segTree.st[x].add = 0
	}
}

func (segTree SegTree) update(x Int) {
	if segTree.st[x<<1].val < segTree.st[x<<1|1].val {
		segTree.st[x].val = segTree.st[x<<1].val
		segTree.st[x].minIndex = segTree.st[x<<1].minIndex
	} else {
		segTree.st[x].val = segTree.st[x<<1|1].val
		segTree.st[x].minIndex = segTree.st[x<<1|1].minIndex
	}
}

func (segTree SegTree) modifyOne(x, add Int) {
	segTree.st[x].val += add
	if segTree.st[x].l != segTree.st[x].r {
		segTree.st[x].add += add
	}
}

func (segTree SegTree) Modify(x, l, r, add Int) {
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		segTree.modifyOne(x, add)
		return
	}
	segTree.push(x)
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		segTree.Modify(x<<1, l, r, add)
	}
	if mid < r {
		segTree.Modify(x<<1|1, l, r, add)
	}
	segTree.update(x)
}

func updateRes(cRes, cIndex, res, index Int) (Int, Int) {
	if cRes > res {
		return res, index
	}
	return cRes, cIndex
}

func (segTree SegTree) Query(x, l, r Int) (Int, Int) {
	res := Int(math.MaxInt64)
	resInd := -L1
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		res, resInd = updateRes(res, resInd, segTree.st[x].val, segTree.st[x].minIndex)
		return res, resInd
	}
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		sonRes, sonInd := segTree.Query(x<<1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	if mid < r {
		sonRes, sonInd := segTree.Query(x<<1|1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	return res, resInd
}

type Graph struct {
	nodeSize Int
	edges    []Edge
	head     []Int
	dis      []Int
	vis      []bool
	nCnt     Int
	ans      []Int
}

type Edge struct {
	u, v, c, indices, next Int
}

func NewGraph(nodeSize Int) *Graph {
	return &Graph{
		nodeSize: nodeSize,
		edges:    make([]Edge, (2e5+10)<<2),
		head:     make([]Int, nodeSize+100),
		dis:      make([]Int, nodeSize+100),
		vis:      make([]bool, nodeSize+100),
		nCnt:     L1,
		ans:      make([]Int, nodeSize),
	}
}

func (g *Graph) addEdge(u Int, v Int, cost Int, indices Int) {
	g.nCnt++
	g.edges[g.nCnt] = Edge{u, v, cost, indices, g.head[u]}
	g.head[u] = g.nCnt
}

func (g *Graph) Dijkstra(begin Int) {
	for i := L1; i <= g.nodeSize; i++ {
		g.dis[i] = math.MaxInt64
	}
	pq := make(PriorityQueue, 0)
	heap.Init(&pq)

	g.dis[begin] = 0
	heap.Push(&pq, &Item{begin, 0, -1, -1})

	id := L0

	for len(pq) > 0 {
		it := heap.Pop(&pq).(*Item)
		u := it.value
		if g.vis[u] {
			continue
		}
		g.vis[u] = true

		if it.indices != -1 && id < g.nodeSize-1 {
			g.ans[id] = it.indices
			id++
		}

		for i := g.head[u]; i != 0; i = g.edges[i].next {
			v := g.edges[i].v
			if g.dis[v] > g.dis[u]+g.edges[i].c {
				g.dis[v] = g.dis[u] + g.edges[i].c

				heap.Push(&pq, &Item{v, g.dis[v], g.edges[i].indices, -1})
			}
		}
	}
}

package main

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

func Solve() {
	n := ri()
	var a, b []int
	for i := 0; i < n; i++ {
		a = append(a, ri())
	}
	m := ri()
	for i := 0; i < m; i++ {
		b = append(b, ri())
	}
	x := 0
	for _, y := range b {
		x = (x + y) % n
	}
	println(a[x])
}

func main() {
	T := 0 // 如果是单组样例，请讲 T := 0 改为 T := 1
	in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	if T == 0 {
		scan(&T)
	}
	for t := 0; t < T; t++ {
		Solve()
	}
	out.Flush()
}

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

// ri 将直接读入并返回一个 int
func ri() (x int) {
	scan(&x)
	return x
}

//rs 将直接读入并返回一个 string
func rs() (s string) {
	scan(&s)
	return s
}

//scan 用法与 fmt.scan() 相似，可以传入多个变量的地址进行读入操作
func scan(a ...interface{}) { Fscan(in, a...) }

//print 用法与 fmt.print() 相似，可以传入多个变量进行输出。注意，这个函数不会换行，多个变量之间有空格
func print(a ...interface{}) { Fprint(out, a...) }

//println 用法与 fmt.println() 相似，可以传入多个变量进行输出。这个函数会换行，多个变量之间有空格
func println(a ...interface{}) { Fprintln(out, a...) }

//min 可以传入多个 int 变量，求出这些变量的最小值
func min(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ans {
			ans = a[i]
		}
	}
	return ans
}

//max 可以传入多个 int 变量，求出这些变量的最大值
func max(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ans {
			ans = a[i]
		}
	}
	return ans
}

//sum 可以传入多个 int 变量，求出这些变量的总和，并返回总和。
//你可以使用 ... 运算符打散数组，使得 sum 函数可以求出数组的和。
func sum(a ...int) int {
	ans := 0
	for _, x := range a {
		ans += x
	}
	return ans
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		a:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&a[j])
		}
		var m,sum int
		fmt.Fscan(in,&m)
		for j:=0;j<m;j++{
			var x int
			fmt.Fscan(in,&x)
			sum += x
		}
		fmt.Fprintln(out,a[sum%n])
	}
}

package main

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

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

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

	var T int
	var n int
	var m int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a, b := []int{}, []int{}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a = append(a, x)
		}
		Fscan(in, &m)
		for i := 0; i < m; i++ {
			Fscan(in, &x)
			b = append(b, x)
		}

		s := 0
		for _, v := range b {
			s += v
			s %= n
		}

		Fprintln(out, a[s])

	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	var m int
	fmt.Fscan(r, &m)
	ans := 0
	for i:=0;i<m;i++ {
		var b int
		fmt.Fscan(r, &b)
		ans += b
		ans %= n
	}
	fmt.Fprintln(w, nums[ans])
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	for t := io.ReadInt(); t > 0; t-- {
		n := io.ReadInt()
		a := io.ReadIntSlice(n)
		m := io.ReadInt()
		b := io.ReadIntSlice(m)

		sum := 0
		for _, v := range b {
			sum += v
			sum %= len(a)
		}

		fmt.Println(a[sum])
	}
}


There is a badminton championship in which $$$n$$$ players take part. The players are numbered from $$$1$$$ to $$$n$$$. The championship proceeds as follows: player $$$1$$$ and player $$$2$$$ play a game, then the winner and player $$$3$$$ play a game, and then the winner and player $$$4$$$ play a game, and so on. So, $$$n-1$$$ games are played, and the winner of the last game becomes the champion. There are no draws in the games.You want to find out the result of championship. Currently, you only know the following information:  Each player has either won $$$x$$$ games or $$$y$$$ games in the championship. Given $$$n$$$, $$$x$$$, and $$$y$$$, find out if there is a result that matches this information.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. The only line of each test case contains three integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$2 \le n \le 10^5$$$, $$$0 \le x, y < n$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

Print the answer for each test case, one per line. If there is no result that matches the given information about $$$n$$$, $$$x$$$, $$$y$$$, print $$$-1$$$. Otherwise, print $$$n-1$$$ space separated integers, where the $$$i$$$-th integer is the player number of the winner of the $$$i$$$-th game.  If there are multiple valid results, print any.

NoteIn the first test case, player $$$1$$$ and player $$$4$$$ won $$$x$$$ times, player $$$2$$$ and player $$$3$$$ won $$$y$$$ times.In the second, third, and fifth test cases, no valid result exists.

package main

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

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

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

	var T int
	var n int
	var x int
	var y int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &x)
		Fscan(in, &y)

		if x == 0 && y == 0 || x*y != 0 {
			Fprintln(out, -1)
		} else {
			if x == 0 {
				x = y
			}
			if (n-1)%x != 0 {
				Fprintln(out, -1)
			} else {
				w := 0
				c := 0
				for i := 1; i < n; i++ {
					if i > 0 {
						Fprintf(out, " ")
					}
					Fprintf(out, "%d", w+1)

					c++
					if c == x {
						w = i+1
						c = 0
					}
				}
				Fprintln(out, "")
			}
		}
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, x, y int
)

func solve(n, x, y int) string {
	if (x == 0 && y == 0) || (x > 0 && y > 0) {
		return "-1"
	}
	if x == 0 {
		return solve(n, y, x)
	}
	if (n-1)%x > 0 {
		return "-1"
	}
	b := ""
	for i := 2; i <= n; i += x {
		b = b + strings.Repeat(fmt.Sprint(i)+" ", x)
	}
	return b
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &x, &y)

		fmt.Println(solve(n, x, y))
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, x, y int
)

func solve(n, x, y int) string {
	if (x == 0 && y == 0) || (x > 0 && y > 0) {
		return "-1"
	}
	if x == 0 {
		return solve(n, y, x)
	}
	if (n-1)%x > 0 {
		return "-1"
	}
	var b []int
	for i := 2; i <= n; i += x {
		var u = make([]int, x)
		for j := range u {
			u[j] = i
		}
		b = append(b, u...)
	}
	return strings.Trim(fmt.Sprint(b), "[]")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &x, &y)

		fmt.Println(solve(n, x, y))
	}
}

package main

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

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

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

		if x < y {
			x, y = y, x
		}
		if y != 0 || (x == 0 && y == 0) || (n-1)%x != 0 {
			fmt.Fprintln(out, -1)
			continue
		}

		cur := 1
		var c int
		for i := 0; i < n-1; i++ {
			if c == x {
				c = 0
				cur = i + 2
			}
			fmt.Fprintf(out, "%d ", cur)
			c++
		}
		fmt.Fprintln(out)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	txt, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(txt))
	for i := 0; i < t; i++ {
		txt, _ = reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(txt), " ")
		n, _ := strconv.Atoi(arr[0])
		x, _ := strconv.Atoi(arr[1])
		y, _ := strconv.Atoi(arr[2])
		if x != 0 && y != 0 {
			fmt.Println(-1)
			continue
		}
		gamesCnt := n - 1
		res := make([]int, 0)
		if y > 0 {
			x = y
		}
		if x > 0 && gamesCnt%x == 0 {
			step := 1
			for len(res) != gamesCnt {
				for j := 0; j < x; j++ {
					if step == 1 {
						res = append(res, 1)
					} else {
						ind := x*(step-1) + j
						if step == 2 {
							res = append(res, res[ind-x]+x+1)
						} else {
							res = append(res, res[ind-x]+x)
						}

					}
				}
				step++
			}
		}
		if len(res) == 0 {
			fmt.Println(-1)
		} else {
			for _, r := range res {
				fmt.Printf("%d ", r)
			}
			fmt.Println()
		}
	}
}

package main

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

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

func main() {

	defer out.Flush()

	t := 0
	if _, err := fmt.Fscan(in, &t); err != nil {
		return
	}

	for ; t > 0; t-- {

		n, x, y := 0, 0, 0
		fmt.Fscan(in, &n, &x, &y)

		if (x == 0 && y == 0) || (x != 0 && y != 0) {
			fmt.Fprintln(out, -1)
			continue
		}

		if x == 0 {
			x, y = y, x
		}

		if (n-1)%x != 0 {
			fmt.Fprintln(out, -1)
			continue
		}

		idx := 2
		for i := 1; i < n; i++ {
			fmt.Fprint(out, idx, " ")
			if i%x == 0 {
				idx += x
			}
		}

		fmt.Fprintln(out)

	}
}

package main

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

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

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

func ans() {
	var n int
	var x int
	var y int
	Fscan(in, &n, &x, &y)
	if x > 0 && y > 0 || x == 0 && y == 0 {
		Fprintln(out, -1)
		return
	}
	var max int = max(x, y)
	if (n - 1) % max != 0 {
		Fprintln(out, -1)
		return
	}
	var winner int = 1
	for match := 2; match <= n; match++ {
		Fprint(out, winner, " ")
		if (match - 1) % max == 0 {
			winner = match + 1
		}
	}
	Fprintln(out)
}

func main() {
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

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

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

func Print(a ...interface{})   { _, _ = fmt.Fprint(writer, a...) }
func Println(a ...interface{}) { _, _ = fmt.Fprintln(writer, a...) }

func main() {
	defer func() {
		_ = writer.Flush()
	}()

	T := ReadInt()
	for t := 0; t < T; t++ {
		Solve()
	}
}

func Solve() {
	n, x, y := ReadInt()-1, ReadInt(), ReadInt()
	x, y = Max(x, y), Min(x, y)
	if x == 0 || y > 0 || n%x != 0 {
		Println(-1)
		return
	}
	for i := 0; i < n; i++ {
		Print(i/x*x + 2)
		if i == n-1 {
			Println()
		} else {
			Print(" ")
		}
	}
}

func ReadInt() (value int) {
	_, _ = fmt.Fscan(reader, &value)
	return
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Float interface {
	~float32 | ~float64
}

type Ordered interface {
	Integer | Float | ~string
}

func Max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

func Min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, x, y int
		fmt.Fscan(in, &n, &x, &y)
		if (x+y) == 0 || ((x != 0 && y != 0) || (n-1)%(x+y) != 0) {
			fmt.Fprintln(out, "-1")
		} else {
			num := 1
			flag := x
			cur := 0
			for i := 1; i < n; i++ {
				if cur < flag {
					cur++
				} else {
					num = i + 1
					cur = 1
					if flag == x {
						flag = y
					} else {
						flag = x
					}
					if flag == 0 {
						if flag == x {
							flag = y
						} else {
							flag = x
						}
					}
				}
				fmt.Fprintf(out, "%d ", num)
			}
			fmt.Fprintln(out, "")
		}
	}
}

package main

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

var (
	input  = bufio.NewReaderSize(os.Stdin, 55000)
	output = bufio.NewWriterSize(os.Stdout, 55000)
)

func main() {
	var t int
	fmt.Fscan(input, &t)
	for t > 0 {
		var n, x, y int
		fmt.Fscan(input, &n, &x, &y)
		if y > x {
			temp := x
			x = y
			y = temp
		}
		if y > 0 || x == 0 || (n-1)%x != 0 {
			fmt.Println(-1)
		} else {
			player := 1
			win := 0
			for i := 2; i <= n; i++ {
				if win == x {
					player = i
					win = 1
				} else {
					win++
				}
				fmt.Printf("%d ", player)
			}
			fmt.Println()
		}
		t--
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func numDigit(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		n /= 10
	}
	return cnt
}
func solve() {
	var n, x, y int
	scan(&n, &x, &y)
	if x > 0 && y > 0 {
		printf("-1\n")
		return
	}
	x = x + y
	if x == 0 || (n-1)%x != 0 {
		printf("-1\n")
		return
	}
	// inc := (n - 1) / x
	for i := 2; i <= n; i += x {
		for j := 0; j < x; j++ {
			printf("%d ", i)
		}
	}
	printf("\n")
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

var a [105]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)
	for cs := 0; cs < T; cs++ {
		var n, x, y int
		fmt.Fscan(in, &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		if x == y || x != 0 || (n-1)%y != 0 {
			fmt.Fprintln(out, -1)
			continue
		}
		for i := 0; i < n-2; i++ {
			fmt.Fprintf(out, "%d ", i/y*y+2)
		}
		fmt.Fprintln(out, (n-2)/y*y+2)
	}
}

package main

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

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

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

	var T int
	var n int
	var x int
	var y int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &x)
		Fscan(in, &y)

		if x == 0 && y == 0 || x*y != 0 {
			Fprintln(out, -1)
		} else {
			if x == 0 {
				x = y
			}
			if (n-1)%x != 0 {
				Fprintln(out, -1)
			} else {
				w := 0
				c := 0
				for i := 1; i < n; i++ {
					if i > 0 {
						Fprintf(out, " ")
					}
					Fprintf(out, "%d", w+1)

					c++
					if c == x {
						w = i
						c = 0
					}
				}
				Fprintln(out, "")
			}
		}
	}
}

package main

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

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

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

	var T int
	var n int
	var x int
	var y int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &x)
		Fscan(in, &y)

		if x == 0 && y == 0 || x*y != 0 {
			Fprintln(out, -1)
		} else {
			if x == 0 {
				x = y
			}
			if (n-1)%x != 0 {
				Fprintln(out, -1)
			} else {
				p := 0
				for i := 1; i < n; i++ {
					if i > 0 {
						Fprintf(out, " ")
					}
					if i%x == 1 {
						p = i
					}
					Fprintf(out, "%d", p+1)
				}
				Fprintln(out, "")
			}
		}
	}
}

package main

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

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

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

	var T int
	var n int
	var x int
	var y int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &x)
		Fscan(in, &y)

		if x == 0 && y == 0 || x*y != 0 {
			Fprintln(out, -1)
		} else {
			if x == 0 {
				x = y
			}
			if (n-1)%x != 0 {
				Fprintln(out, -1)
			} else {
				for i := 0; i < n-1; i++ {
					if i > 0 {
						Fprintf(out, " ")
					}
					Fprintf(out, "%d", i/x +1)
				}
				Fprintln(out, "")
			}
		}
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, x, y int
)

func solve(n, x, y int) string {
	if (x == 0 && y == 0) || (x > 0 && y > 0) {
		return "-1"
	}
	if x == 0 {
		return solve(n, y, x)
	}
	if (n-1)%x > 0 {
		return "-1"
	}
	var b []int
	for i := 2; i < n; i += x {
		var u = make([]int, x)
		for j := range u {
			u[j] = i
		}
		b = append(b, u...)
	}
	return strings.Trim(fmt.Sprint(b), "[]")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &x, &y)

		fmt.Println(solve(n, x, y))
	}
}

package main

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

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

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

		if x < y {
			x, y = y, x
		}
		if y != 0 || (x == 0 && y == 0) || (n-1)%x != 0 {
			fmt.Fprintln(out, -1)
			continue
		}

		var cur, c int
		for i := 0; i < n-1; i++ {
			if c == 0 {
				cur = i + x
			}
			fmt.Fprintf(out, "%d ", cur)
			c++
			if c == x {
				c = 0
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

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

func main() {

	defer out.Flush()

	t := 0
	if _, err := fmt.Fscan(in, &t); err != nil {
		return
	}

	for ; t > 0; t-- {

		n, x, y := 0, 0, 0
		fmt.Fscan(in, &n, &x, &y)

		if (x == 0 && y == 0) || (x != 0 && y != 0) {
			fmt.Fprintln(out, -1)
			continue
		}

		if x == 0 {
			x, y = y, x
		}

		if (n-1)%x != 0 {
			fmt.Fprintln(out, -1)
			continue
		}

		for i := 1; i < n; i++ {
			for j := 0; j < x; j++ {
				fmt.Fprint(out, i, " ")
			}
			i += x
		}

		fmt.Fprintln(out)

	}
}


Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the people who haven't ranked in the top k in their semifinal but got to the n - 2k of the best among the others.The tournament organizers hasn't yet determined the k value, so the participants want to know who else has any chance to get to the finals and who can go home.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifinals, correspondingly. All results are distinct. Sequences a1, a2, ..., an and b1, b2, ..., bn are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.

Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-th semifinal has any chances to advance to the finals, otherwise it should equal a "0".

NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090.  If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals.  If k = 1, the winners from both semifinals move to the finals (with results 9840 and 9920), and the other places are determined by the time (these places go to the sportsmen who run the distance in 9860 and 9930 milliseconds).  If k = 2, then first and second places advance from each seminfial, these are participants with results 9840, 9860, 9920 and 9980 milliseconds.

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

func main() {
	var n,k,i int
	var a,b,c,d [100005]int
	input := bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	fmt.Scan(&n)
	for i=1;i<=n;i++ {
		input.Scan()
		aa,_:=strconv.Atoi(input.Text())
		a[i]=aa
		input.Scan()
		bb,_:=strconv.Atoi(input.Text())
		b[i]=bb
	}
	out := bufio.NewWriter(os.Stdout)
	for k=0;k<=n/2;k++ {
		c[k]=1
		d[k]=1
	}
	for i=1;i<=n;i++ {
		if a[i]<b[n+1-i] {
			c[i]=1
		}
		if b[i]<a[n+1-i] {
			d[i]=1
		}
	}
	for i=1;i<=n;i++ {
		out.WriteString(strconv.Itoa(c[i]))
	}
	out.WriteString("\n")
	for i=1;i<=n;i++ {
		out.WriteString(strconv.Itoa(d[i]))
	}
	out.Flush()
}

package main

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

func main() {
	var a[100005]int64
	var b[100005]int64
	var c[100005]int64
	var d[100005]int64
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.ParseInt(r.Text(), 0, 64)
		r.Scan()
		b[i], _ = strconv.ParseInt(r.Text(), 0, 64)
		c[i]=0
		d[i]=0
	}
	i:=0
	j:=0
	for cnt:=0; cnt!=n; cnt++ {
		if a[i]<b[j] {
			c[i]=1
			i++
		} else {
			d[j]=1
			j++
		}
	}
	for i:=0; i<n; i++ {
		if i<n/2 {
			fmt.Printf("1")
		} else {
			fmt.Printf("%d", c[i])
		}
	}
	fmt.Println()
	for i:=0; i<n; i++ {
		if i<n/2 {
			fmt.Printf("1")
		} else {
			fmt.Printf("%d", d[i])
		}
	}
	fmt.Println()
}

//378B
package main

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

func main() {
	var e[100005]int64
	var f[100005]int64
	var g[100005]int64
	var h[100005]int64
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	for i:=0; i<n; i++ {
		r.Scan()
		e[i], _ = strconv.ParseInt(r.Text(), 0, 64)
		r.Scan()
		f[i], _ = strconv.ParseInt(r.Text(), 0, 64)
		g[i]=0
		h[i]=0
	}
	i:=0
	j:=0
	for cnt:=0; cnt!=n; cnt++ {
		if e[i]<f[j] {
			g[i]=1
			i++
		} else {
			h[j]=1
			j++
		}
	}
	for i:=0; i<n; i++ {
		if i<n/2 {
			fmt.Printf("1")
		} else {
			fmt.Printf("%d", g[i])
		}
	}
	fmt.Println()
	for i:=0; i<n; i++ {
		if i<n/2 {
			fmt.Printf("1")
		} else {
			fmt.Printf("%d", h[i])
		}
	}
	fmt.Println()
}

package main

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

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

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n int
    ScanInts(&n)
    a, b, c := make([]int,n), make([]int,n), make([]int,0,2*n)
    for i := 0; i < n; i++ {
        ScanInts(&a[i],&b[i])
        c = append(c,a[i],b[i])
    }
    sort.Ints(c)
    f := make(map[int]bool)
    for i := 0; i < n; i++ { f[c[i]] = true }
    for i := 0; i < n; i++ {
        if ((i+1)*2 <= n) || (f[a[i]]) { writer.WriteRune('1') } else { writer.WriteRune('0') }
    }
    writer.WriteRune('\n')
    for i := 0; i < n; i++ {
        if ((i+1)*2 <= n) || (f[b[i]]) { writer.WriteRune('1') } else { writer.WriteRune('0') }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

// 378B-mic
package main

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

func main() {
	var n, i int
	z := bufio.NewWriter(os.Stdout)
	c := bufio.NewReader(os.Stdin)
	var A, B [100010]rune
	var C, D [100010]int
	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Fscan(c, &C[i], &D[i])
	}

	for i = 0; i < n/2; i++ {
		A[i] = '1'
		B[i] = A[i]
	}

	for i = n / 2; i < n; i++ {
		A[i] = '0'
		B[i] = A[i]
	}

	a := 0
	b := 0
	for i = 0; i < n; i++ {
		if C[a] < D[b] {
			A[a] = '1'
			a++
		} else {
			B[b] = '1'
			b++
		}
	}
	for i := 0; i < n; i++ {
		z.WriteRune(A[i])
	}
	z.WriteRune('\n')
	for i := 0; i < n; i++ {
		z.WriteRune(B[i])
	}
	z.Flush()
	fmt.Println()
}

package main

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

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

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n int
    ScanInts(&n)
    a, b, c := make([]int,n), make([]int,n), make([]int,0,2*n)
    for i := 0; i < n; i++ {
        ScanInts(&a[i],&b[i])
        c = append(c,a[i],b[i])
    }
    sort.Ints(c)
    f := make(map[int]bool)
    for i := 0; i < n; i++ { f[c[i]] = true }
    for i := 0; i < n; i++ {
        if (i*2 < n) || (f[a[i]]) { writer.WriteRune('1') } else { writer.WriteRune('0') }
    }
    writer.WriteRune('\n')
    for i := 0; i < n; i++ {
        if (i*2 < n) || (f[b[i]]) { writer.WriteRune('1') } else { writer.WriteRune('0') }
    }
    writer.WriteRune('\n')
    writer.Flush()
}


One night, Mark realized that there is an essay due tomorrow. He hasn't written anything yet, so Mark decided to randomly copy-paste substrings from the prompt to make the essay.More formally, the prompt is a string $$$s$$$ of initial length $$$n$$$. Mark will perform the copy-pasting operation $$$c$$$ times. Each operation is described by two integers $$$l$$$ and $$$r$$$, which means that Mark will append letters $$$s_l s_{l+1} \ldots s_r$$$ to the end of string $$$s$$$. Note that the length of $$$s$$$ increases after this operation.Of course, Mark needs to be able to see what has been written. After copying, Mark will ask $$$q$$$ queries: given an integer $$$k$$$, determine the $$$k$$$-th letter of the final string $$$s$$$.

The first line contains a single integer $$$t$$$ ($$$1\leq t\leq 1000$$$) — the number of test cases. The first line of each test case contains three integers $$$n$$$, $$$c$$$, and $$$q$$$ ($$$1\leq n\leq 2\cdot 10^5$$$, $$$1\leq c\leq 40$$$, and $$$1\leq q\leq 10^4$$$) — the length of the initial string $$$s$$$, the number of copy-pasting operations, and the number of queries, respectively. The second line of each test case contains a single string $$$s$$$ of length $$$n$$$. It is guaranteed that $$$s$$$ only contains lowercase English letters. The following $$$c$$$ lines describe the copy-pasting operation. Each line contains two integers $$$l$$$ and $$$r$$$ ($$$1\leq l\leq r\leq 10^{18}$$$). It is also guaranteed that $$$r$$$ does not exceed the current length of $$$s$$$. The last $$$q$$$ lines of each test case describe the queries. Each line contains a single integer $$$k$$$ ($$$1\leq k\leq 10^{18}$$$). It is also guaranteed that $$$k$$$ does not exceed the final length of $$$s$$$. It is guaranteed that the sum of $$$n$$$ and $$$q$$$ across all test cases does not exceed $$$2\cdot 10^5$$$ and $$$10^4$$$, respectively.

For each query, print the $$$k$$$-th letter of the final string $$$s$$$.

NoteIn the first test case, the copy-paste process is as follows.   The first step is pasting string $$$\texttt{mark}$$$ at the end, yielding the string $$$\texttt{mark}\color{red}{\texttt{mark}}$$$.  The second step is pasting string $$$\texttt{mar}$$$ at the end, yielding the string $$$\texttt{markmark}\color{red}{\texttt{mar}}$$$.  The third step is pasting string $$$\texttt{rkmark}$$$ at the end, yielding the string $$$\texttt{markmarkmar}\color{red}{\texttt{rkmark}}$$$. In the second test case, the copy-paste process is as follows.   The first step is pasting string $$$\texttt{re}$$$ at the end, yielding the string $$$\texttt{creamii}\color{red}{\texttt{re}}$$$.  The second step is pasting string $$$\texttt{ea}$$$ at the end, yielding the string $$$\texttt{creamiire}\color{red}{\texttt{ea}}$$$.  The third step is pasting string $$$\texttt{reamiire}$$$ at the end, yielding the string $$$\texttt{creamiireea}\color{red}{\texttt{reamiire}}$$$.

package main

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

type pair struct {
	from, diff int64
}

func solve() {
	n := get64()
	c := get()
	q := get()
	s := []rune(gets())
	a := make([]pair, c)

	{
		prev := n
		for i := range a {
			l := get64() - 1
			r := get64()

			a[i] = pair{
				from: prev,
				diff: prev - l,
			}

			prev += r - l
		}
	}

	for q > 0 {
		k := get64() - 1
		i := 0
		for i < c && k >= a[i].from {
			i++
		}
		i--

		if k >= n {
			for {
				k -= a[i].diff
				if k < n {
					break
				}
				for i >= 0 && k < a[i].from {
					i--
				}
			}
		}

		putc(s[k])
		line()

		q--
	}
}

const (
	once       = false
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

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

	if once {
		solve()
		return
	}

	t := get()
	for t > 0 {
		solve()
		t--
	}
}

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func gets() string {
	in.Scan()
	return in.Text()
}

func putc(c rune) {
	out.WriteRune(c)
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func puts(s string) {
	out.WriteString(s)
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES")
	line()
}

func no() {
	puts("NO")
	line()
}

//func putf(x float64) {
//	out.WriteString(strconv.FormatFloat(x))
//}

func line() {
	out.WriteRune('\n')
}

func space() {
	out.WriteRune(' ')
}

package main

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

const MOD int64 = 1000000007

var n, c, q  int

var s string

var ops [][2]int64

var qu []int64

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

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

		fmt.Fscan(read, &n, &c, &q)

		fmt.Fscan(read, &s)

		ops = make([][2]int64, c)
		for i := 0; i < c; i++ {
			fmt.Fscan(read, &ops[i][0], &ops[i][1])
			ops[i][0]--
			ops[i][1]--
		}

		qu = make([]int64, q)

		for i := 0; i < q; i++ {
			fmt.Fscan(read, &qu[i])
			qu[i]--
		}

		solve()
		fmt.Println()
	}
}

type pair struct {
	v int
	idx []int
}

func solve() {

	for i := 0; i < q; i++ {
		qq := qu[i]

		var totlen = int64(n)
		if qq < totlen {
			fmt.Println(string(s[qq]))
			continue
		}

		for j := 0; j < c; j++ {

			st := totlen

			totlen += ops[j][1] - ops[j][0] + 1

			if qq < totlen {
				totlen -= ops[j][1] - ops[j][0] + 1
				rel := qq - st

				rr := ops[j][0] + rel

				if rr < int64(n) {
					fmt.Println(string(s[rr]))
					break
				}

				for i := j - 1; i >= 0; i-- {
					totlen -= ops[i][1] - ops[i][0] + 1

					if rr >= totlen {
						st := totlen

						rel := rr - st

						rr = ops[i][0] + rel

						if rr < int64(n) {
							fmt.Println(string(s[rr]))
							break
						}

					}
				}

				break
			}
		}
	}
}

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

package main

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

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

func CF1705C(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, c, q int64
		fmt.Fscan(r, &n, &c, &q)
		s := make([]byte, n)
		fmt.Fscan(r, &s)
		left, right := make([]int64, c+1), make([]int64, c+1)
		sum := make([]int64, c+1)
		sum[0] = int64(n)
		for i := int64(1); i <= c; i++ {
			fmt.Fscan(r, &left[i], &right[i])
			sum[i] = sum[i-1] + right[i] - left[i] + 1
		}
		for i := int64(0); i < q; i++ {
			var k int64
			fmt.Fscan(r, &k)
			now := int64(0)
			for sum[now] < k {
				now++
			}
			for now > 0 {
				k -= sum[now] - right[now]
				for now > 0 && sum[now-1] >= k {
					now--
				}
			}
			fmt.Fprintln(w, string(s[k-1]))
		}

	}
}

package main

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

type LL int64

func main() {
    defer writer.Flush()
	var (
		t, i, j LL
		n, c, q LL
		s       string
		l, r, k LL
	)
	scanf("%d\n", &t)

	i = 0
	for i < t {
		scanf("%d %d %d\n", &n, &c, &q) // n, c, q
		scanf("%s\n", &s)

		sLeft, sRight, sDiff := make([]LL, c+1), make([]LL, c+1), make([]LL, c+1)
		sLeft[0] = 0
		sRight[0] = n

		j = 1
		for j <= c {
			scanf("%d %d\n", &l, &r)
			l--
			r--
			sLeft[j] = sRight[j-1]
			sRight[j] = sLeft[j] + (r - l + 1)
			sDiff[j] = sLeft[j] - l
			j++
		}

		for q > 0 {
			scanf("%d\n", &k)
			k--
			for idx := c; idx > 0; idx-- {
				if k < sLeft[idx] {
					continue
				} else {
					k -= sDiff[idx]
				}
			}
			printf("%s\n", string(s[k]))
			q--
		}
		i++
	}
}

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

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

type entry struct {
	l int64
	diff int64
}

func slove() {
	var c ,q int
	var n int64
	fmt.Fscan(rr, &n, &c, &q)
	data := make([]entry, 0)
	data = append(data, entry{0, 0})
	var s string
	fmt.Fscan(rr, &s)
	for i:=0;i<c;i++ {
		var a, b int64
		fmt.Fscan(rr, &a, &b)
		data = append(data, entry{n, n-a+1})
		n += b-a+1
	}
	outer:
	for i:=0;i<q;i++ {
		var a int64
		fmt.Fscan(rr, &a)
		a -= 1
		for {
			j := sort.Search(len(data), func(i int) bool {
				return data[i].l > a
			})
			j--
			if j == 0 {
				fmt.Fprintln(ww, s[a:a+1])
				continue outer
			}
			a -= data[j].diff
		}
	}
}

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m, k := readThreeNums(reader)
		s := readString(reader)
		s = s[:n]
		ops := make([][]int64, m)
		for i := 0; i < m; i++ {
			ops[i] = readNInt64s(reader, 2)
		}
		ques := make([]int64, k)
		for i := 0; i < k; i++ {
			ques[i] = readNInt64s(reader, 1)[0]
		}

		res := solve(n, s, ops, ques)

		for _, x := range res {
			buf.WriteString(fmt.Sprintf("%c\n", x))
		}
	}

	fmt.Print(buf.String())
}

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 readNInt64s(reader *bufio.Reader, n int) []int64 {
	res := make([]int64, n)
	s, _ := reader.ReadBytes('\n')

	var pos int

	for i := 0; i < n; i++ {
		pos = readInt64(s, pos, &res[i]) + 1
	}

	return res
}

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

func solve(n int, s string, ops [][]int64, ques []int64) []byte {
	// 生成完整的字符串S肯定是不行的
	// 需要知道每个位置在原始s中的位置即可
	str := NewStr(s)

	for _, op := range ops {
		l, r := op[0], op[1]
		l--
		r--
		str = str.copy_paste(l, r)
	}

	res := make([]byte, len(ques))

	for i, k := range ques {
		res[i] = str.get_at(k)
	}

	return res
}

type Str struct {
	base     string
	delegate *Str
	length   int64
	left     int64
}

func NewStr(s string) *Str {
	return &Str{s, nil, int64(len(s)), 0}
}

func (s *Str) copy_paste(l, r int64) *Str {
	length := r - l + 1
	return &Str{s.base, s, s.length + length, l}
}

func (s *Str) get_at(k int64) byte {
	if k <= int64(len(s.base)) {
		return s.base[int(k-1)]
	}
	if k <= s.delegate.Len() {
		return s.delegate.get_at(k)
	}
	k -= s.delegate.Len()
	k += s.left
	return s.delegate.get_at(k)
}

func (s *Str) Len() int64 {
	if s == nil {
		return 0
	}
	return s.length
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}
}

func solve() {
	var n, c, q int
	var s string
	fmt.Fscan(in, &n, &c, &q, &s)
	length := make([]int64, c)
	ops := make([][]int64, c)
	for i := 0; i < c; i++ {
		ops[i] = make([]int64, 2)
		fmt.Fscan(in, &ops[i][0], &ops[i][1])
		if i == 0 {
			length[i] = int64(len(s)) + ops[i][1] - ops[i][0] + 1
		} else {
			length[i] = length[i-1] + ops[i][1] - ops[i][0] + 1
		}
	}
	// fmt.Println(length)

	var k int64
	for i := 0; i < q; i++ {
		fmt.Fscan(in, &k)
		for k > int64(len(s)) {
			lo := 0
			hi := c - 1
			for lo < hi {
				mid := (lo + hi) / 2
				if length[mid] < k {
					lo = mid + 1
				} else {
					hi = mid
				}
			}
			// fmt.Println(k, lo, length[lo])

			k = k - (length[lo] - (ops[lo][1] - ops[lo][0] + 1))
			k = ops[lo][0] + k - 1
		}

		fmt.Fprintln(out, string(s[k-1]))
	}
}

// 00
package main

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

type Pair struct {
	l, r int64
}

func bisect_right(a []int64, x int64) int {
	lo := 0
	hi := len(a)
	for lo < hi {
		mid := (lo + hi) / 2
		if x < a[mid] {
			hi = mid
		} else {
			lo = mid + 1
		}
	}
	return lo
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, c, q int
		var s string
		fmt.Fscan(reader, &n, &c, &q, &s)
		pairs := make([]Pair, c)
		csum := make([]int64, 0)
		csum = append(csum, int64(len(s)))
		for i := 0; i < c; i++ {
			var l, r int64
			fmt.Fscan(reader, &l, &r)
			pairs[i] = Pair{l: l - 1, r: r - 1}
			csum = append(csum, csum[len(csum)-1]+(r-l+1))
		}

		// fmt.Println(csum)
		var k int64
		for i := 0; i < q; i++ {
			fmt.Fscan(reader, &k)
			k--
			index := bisect_right(csum, k)
			for index != 0 {
				// fmt.Println("searching for ", k, index)
				k = pairs[index-1].l + (k - csum[index-1])
				index = bisect_right(csum, k)
			}
			fmt.Printf("%c\n", s[k])
		}

	}
}

package main

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

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

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

		aa := make([]int64, c+1)
		bb := make([]int64, c+1)
		dd := make([]int64, c+1)
		bb[0] = int64(n)
		for i := 1; i <= c; i++ {
			var a, b int64
			fmt.Fscan(in, &a, &b)
			a--
			b--
			aa[i] = bb[i-1]
			bb[i] = aa[i] + (b - a + 1)
			dd[i] = aa[i] - a
		}

		for i := 0; i < q; i++ {
			var k int64
			fmt.Fscan(in, &k)
			k--
			for i := c; i >= 1; i-- {
				if k < aa[i] {
					continue
				}
				k -= dd[i]
			}
			fmt.Fprintln(out, string(s[k]))
		}
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n, c, q int
		fmt.Fscan(r, &n, &c, &q)
		var s string
		fmt.Fscan(r, &s)
		b := make([][2]int64, c)
		for i := range b {
			fmt.Fscan(r, &b[i][0], &b[i][1])
		}

		k := make([]int64, q)
		for i := range k {
			fmt.Fscan(r, &k[i])
		}
		w1 := do(n, c, q, s, b, k)
		for _, c := range w1 {
			fmt.Fprintf(w, "%c\n", c)
		}
	}
}

func do(ni, c, q int, s string, b [][2]int64, k []int64) string {
	n := int64(ni)
	t := make([]int64, c+2)
	t[0] = 0
	t[1] = n
	for i, v := range b {
		t[i+2] = t[i+1] + v[1] - v[0] + 1
	}
	// log.Print(t)
	ans := make([]byte, q)
	for i, v := range k {
		for v > n {
			j := bs(t, v)
			// log.Print("bs=", v, j)
			v = v - (t[j-1] + 1) + b[j-2][0]
		}
		ans[i] = s[v-1]
	}
	return string(ans)
}

func bs(t []int64, v int64) int {
	l := 0
	r := len(t)
	for l < r {
		m := (l + r) / 2
		if t[m] < v {
			l = m + 1
		} else {
			r = m
		}
	}
	return l
}

package main

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

type pair struct {
	from, diff int64
}

func solve() {
	n := get64()
	c := get()
	q := get()
	s := []rune(gets())
	a := make([]pair, c)

	{
		prev := n
		for i := range a {
			l := get64() - 1
			r := get64()

			a[i] = pair{
				from: prev,
				diff: prev - l,
			}

			prev += r - l
		}
	}

	for q > 0 {
		k := get64() - 1
		i := 0
		for i < c && k >= a[i].from {
			i++
		}
		i--

		for k >= n {
			k -= a[i].diff
			if k < n {
				break
			}
			for i >= 0 && k < a[i].from {
				i--
			}
			i++
		}

		if use {
			putc(s[k])
			line()
		}

		q--
	}
}

const (
	once       = false
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
	use       = false
)

func main() {
	defer func() {
		err := recover()
		if err != nil {
			puts(fmt.Sprint(err))
			puts("\nHey\n")
		}
		out.Flush()
	}()

	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

	out = bufio.NewWriter(os.Stdout)
	//defer out.Flush()

	if once {
		solve()
		return
	}

	t := get()
	if t == 2 {
		use = true
	}
	for t > 0 {
		solve()
		t--
	}
}

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func gets() string {
	in.Scan()
	return in.Text()
}

func putc(c rune) {
	out.WriteRune(c)
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func puts(s string) {
	out.WriteString(s)
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES")
	line()
}

func no() {
	puts("NO")
	line()
}

//func putf(x float64) {
//	out.WriteString(strconv.FormatFloat(x))
//}

func line() {
	out.WriteRune('\n')
}

func space() {
	out.WriteRune(' ')
}

package main

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

type pair struct {
	from, diff int64
}

func solve() {
	n := get64()
	c := get()
	q := get()
	s := []rune(gets())
	a := make([]pair, c)

	{
		prev := n
		for i := range a {
			l := get64() - 1
			r := get64()

			a[i] = pair{
				from: prev,
				diff: prev - l,
			}

			prev += r - l
		}
	}

	for q > 0 {
		k := get64() - 1
		i := 0
		for i < c && k >= a[i].from {
			i++
		}
		i--

		for k >= n {
			k -= a[i].diff
			if k < n {
				break
			}
			for i >= 0 && k < a[i].from {
				i--
			}
			i++
		}

		if use {
			putc(s[k])
			line()
		}

		q--
	}
}

const (
	once       = false
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
	use       = false
)

func main() {
	defer func() {
		err := recover()
		if err != nil {
			puts(fmt.Sprint(err))
		}
		out.Flush()
	}()

	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

	out = bufio.NewWriter(os.Stdout)
	//defer out.Flush()

	if once {
		solve()
		return
	}

	t := get()
	if t == 2 {
		use = true
	}
	for t > 0 {
		solve()
		t--
	}
}

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func gets() string {
	in.Scan()
	return in.Text()
}

func putc(c rune) {
	out.WriteRune(c)
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func puts(s string) {
	out.WriteString(s)
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES")
	line()
}

func no() {
	puts("NO")
	line()
}

//func putf(x float64) {
//	out.WriteString(strconv.FormatFloat(x))
//}

func line() {
	out.WriteRune('\n')
}

func space() {
	out.WriteRune(' ')
}

package main

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

type pair struct {
	from, diff int64
}

func solve() {
	n := get64()
	c := get()
	q := get()
	s := []rune(gets())
	a := make([]pair, c)

	{
		prev := n
		for i := range a {
			l := get64() - 1
			r := get64()

			a[i] = pair{
				from: prev,
				diff: prev - l,
			}

			prev += r - l
		}
	}

	for q > 0 {
		k := get64() - 1
		i := 0
		for i < c && k >= a[i].from {
			i++
		}
		i--

		for k >= n {
			k -= a[i].diff
			if k < n {
				break
			}
			for i >= 0 && k < a[i].from {
				i--
			}
			i++
		}

		if use {
			putc(s[k])
			line()
		}

		q--
	}
}

const (
	once       = false
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
	use = false
)

func main() {
	defer func() {
		err := recover()
		if err != nil {
			puts(fmt.Sprint(err))
		}
	}()

	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

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

	if once {
		solve()
		return
	}

	t := get()
	if t == 2 {
		use = true
	}
	for t > 0 {
		solve()
		t--
	}
}

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func gets() string {
	in.Scan()
	return in.Text()
}

func putc(c rune) {
	out.WriteRune(c)
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func puts(s string) {
	out.WriteString(s)
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES")
	line()
}

func no() {
	puts("NO")
	line()
}

//func putf(x float64) {
//	out.WriteString(strconv.FormatFloat(x))
//}

func line() {
	out.WriteRune('\n')
}

func space() {
	out.WriteRune(' ')
}

package main

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

type pair struct {
	from, diff int64
}

func solve() {
	n := get64()
	c := get()
	q := get()
	s := []rune(gets())
	a := make([]pair, c)

	{
		prev := n
		for i := range a {
			l := get64() - 1
			r := get64()

			a[i] = pair{
				from: prev,
				diff: prev - l,
			}

			prev += r - l
		}
	}

	for q > 0 {
		k := get64() - 1
		i := 0
		for i < c && k >= a[i].from {
			i++
		}
		i--

		for k >= n {
			k -= a[i].diff
			if k < n {
				break
			}
			for i >= 0 && k < a[i].from {
				i--
			}
			i++
		}

		putc(s[k])
		line()

		q--
	}
}

const (
	once       = false
	maxBufSize = 10000000
)

var splitFunc = bufio.ScanWords

func main() {
	defer func() {
		err := recover()
		if err != nil {
			puts(fmt.Sprint(err))
		}
	} ()

	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

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

	if once {
		solve()
		return
	}

	t := get()
	for t > 0 {
		solve()
		t--
	}
}

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

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func gets() string {
	in.Scan()
	return in.Text()
}

func putc(c rune) {
	out.WriteRune(c)
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func puts(s string) {
	out.WriteString(s)
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES")
	line()
}

func no() {
	puts("NO")
	line()
}

//func putf(x float64) {
//	out.WriteString(strconv.FormatFloat(x))
//}

func line() {
	out.WriteRune('\n')
}

func space() {
	out.WriteRune(' ')
}

package main

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

const MOD int64 = 1000000007

var n, c, q  int

var s string

var ops [][2]int64

var qu []int64

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

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

		fmt.Fscan(read, &n, &c, &q)

		fmt.Fscan(read, &s)

		ops = make([][2]int64, c)
		for i := 0; i < c; i++ {
			fmt.Fscan(read, &ops[i][0], &ops[i][1])
			ops[i][0]--
			ops[i][1]--
		}

		qu = make([]int64, q)

		for i := 0; i < q; i++ {
			fmt.Fscan(read, &qu[i])
			qu[i]--
		}

		solve()
		fmt.Println()
	}
}

type pair struct {
	v int
	idx []int
}

func solve() {

	for i := 0; i < q; i++ {
		qq := qu[i]

		var totlen = int64(n)
		if qq < totlen {
			fmt.Println(string(s[qq]))
			continue
		}

		for j := 0; j < c; j++ {

			st := totlen

			totlen += ops[j][1] - ops[j][0] + 1

			if qq < totlen {
				totlen -= ops[j][1] - ops[j][0] + 1
				rel := qq - st

				rr := ops[j][0] + rel

				if rr < int64(n) {
					fmt.Println(string(s[rr]))
					break
				}

				for i := j - 1; i >= 0; i-- {
					totlen -= ops[i][1] - ops[i][0] + 1

					if rr >= totlen {
						st := totlen

						rel := rr - st

						rr := ops[i][0] + rel

						if rr < int64(n) {
							fmt.Println(string(s[rr]))
							break
						}

					}
				}

				break
			}
		}
	}
}

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

package main

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

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

func CF1043C(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, c, q int64
		fmt.Fscan(r, &n, &c, &q)
		s := make([]byte, n)
		fmt.Fscan(r, &s)
		for i := int64(0); i < c; i++ {
			var left, right int64
			fmt.Fscan(r, &left, &right)
			s = append(s, s[left-1:right]...)
			fmt.Println(string(s))
		}
		for i := int64(0); i < q; i++ {
			var idx int64
			fmt.Fscan(r, &idx)
			fmt.Fprintln(w, string(s[idx-1]))
		}
	}
}