Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead.The first task he faced is to check whether the king is in check. Anton doesn't know how to implement this so he asks you to help.Consider that an infinite chess board contains one white king and the number of black pieces. There are only rooks, bishops and queens, as the other pieces are not supported yet. The white king is said to be in check if at least one black piece can reach the cell with the king in one move. Help Anton and write the program that for the given position determines whether the white king is in check.Remainder, on how do chess pieces move:   Bishop moves any number of cells diagonally, but it can't "leap" over the occupied cells.  Rook moves any number of cells horizontally or vertically, but it also can't "leap" over the occupied cells.  Queen is able to move any number of cells horizontally, vertically or diagonally, but it also can't "leap".

The first line of the input contains a single integer n (1 ≤ n ≤ 500 000) — the number of black pieces. The second line contains two integers x0 and y0 ( - 109 ≤ x0, y0 ≤ 109) — coordinates of the white king. Then follow n lines, each of them contains a character and two integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — type of the i-th piece and its position. Character 'B' stands for the bishop, 'R' for the rook and 'Q' for the queen. It's guaranteed that no two pieces occupy the same position.

The only line of the output should contains "YES" (without quotes) if the white king is in check and "NO" (without quotes) otherwise.

NotePicture for the first sample:    White king is in check, because the black bishop can reach the cell with the white king in one move. The answer is "YES".Picture for the second sample:    Here bishop can't reach the cell with the white king, because his path is blocked by the rook, and the bishop cant "leap" over it. Rook can't reach the white king, because it can't move diagonally. Hence, the king is not in check and the answer is "NO".

package main

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

type Piece struct {
	x, y int
	s    string
}

type Score func(p Piece) (bool, string)

func solve() {

	scoreCalcs := []Score{
		func(p Piece) (bool, string) {
			return p.y == 0, "R"
		}, func(p Piece) (bool, string) {
			return p.x == 0, "R"
		}, func(p Piece) (bool, string) {
			return p.x == p.y, "B"
		}}

	n, dx, dy := readInt(), readInt(), readInt()
	a := make([]Piece, n)
	for i := 0; i < n; i++ {
		s, x, y := readString(), readInt()-dx, readInt()-dy
		a[i] = Piece{x, y, s}
	}

	ans := "NO"
	for _, mul := range [][]int{[]int{1, 1}, []int{-1, 1}, []int{1, -1}, []int{-1, -1}} {
		for _, calc := range scoreCalcs {
			var bestP *Piece = nil
			needS := "Q"
			for _, piece := range a {
				p := Piece{piece.x * mul[0], piece.y * mul[1], piece.s}
				if p.x >= 0 && p.y >= 0 {
					ok, s := calc(p)
					needS = s
					if ok && (bestP == nil || bestP.x >= p.x && bestP.y >= p.y) {
						bestP = &p
					}
				}
			}

			if bestP != nil && (bestP.s == needS || bestP.s == "Q") {
				ans = "YES"
			}
		}
	}

	fmt.Println(ans)
}

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

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

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

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

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

// IO

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

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

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

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

package main

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

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

const queen = 'Q'
const rook = 'R'
const bishop = 'B'

func checkRook(n, kx, ky int, p []byte, x, y []int) bool {
	imax := -1
	imin := -1

	for i := 0; i < n; i++ {
		if x[i] == kx {
			if y[i] < ky {
				if (imax == -1) || (y[imax] < y[i]) {
					imax = i
				}
			} else {
				if (imin == -1) || (y[imin] > y[i]) {
					imin = i
				}
			}
		}
	}

	if imax != -1 {
		c := p[imax]
		if (c == queen) || (c == rook) {
			return true
		}
	}

	if imin != -1 {
		c := p[imin]
		if (c == queen) || (c == rook) {
			return true
		}
	}

	return false
}

func checkBishop1(n, kx, ky int, p []byte, x, y []int) bool {
	imin := -1
	imax := -1

	for i := 0; i < n; i++ {
		if x[i]-y[i] == kx-ky {
			if x[i] < kx {
				if (imax == -1) || (y[imax] < y[i]) {
					imax = i
				}
			} else {
				if (imin == -1) || (y[imin] > y[i]) {
					imin = i
				}
			}
		}
	}

	if imax != -1 {
		c := p[imax]
		if (c == queen) || (c == bishop) {
			return true
		}
	}

	if imin != -1 {
		c := p[imin]
		if (c == queen) || (c == bishop) {
			return true
		}
	}

	return false
}

func checkBishop2(n, kx, ky int, p []byte, x, y []int) bool {
	imin := -1
	imax := -1

	for i := 0; i < n; i++ {
		if x[i]+y[i] == kx+ky {
			if x[i] > kx {
				if (imax == -1) || (y[imax] < y[i]) {
					imax = i
				}
			} else {
				if (imin == -1) || (y[imin] > y[i]) {
					imin = i
				}
			}
		}
	}

	if imax != -1 {
		c := p[imax]
		if (c == queen) || (c == bishop) {
			return true
		}
	}

	if imin != -1 {
		c := p[imin]
		if (c == queen) || (c == bishop) {
			return true
		}
	}

	return false
}

func check(n, kx, ky int, p []byte, x, y []int) bool {
	if checkRook(n, kx, ky, p, x, y) {
		return true
	}

	if checkRook(n, ky, kx, p, y, x) {
		return true
	}

	if checkBishop1(n, kx, ky, p, x, y) {
		return true
	}

	if checkBishop2(n, kx, ky, p, x, y) {
		return true
	}

	return false
}

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

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

	p := make([]byte, n)
	x := make([]int, n)
	y := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%c %d %d\n", &p[i], &x[i], &y[i])
	}

	if check(n, kx, ky, p, x, y) {
		fmt.Fprintf(bufout, "YES\n")
	} else {
		fmt.Fprintf(bufout, "NO\n")
	}
}

package main

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

type Tup struct {
	typ byte
	x   int64
	y   int64
}

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	x0, y0 := sc.NextInt64(), sc.NextInt64()
	tuples := make([]Tup, N)
	for i := 0; i < N; i++ {
		tuples[i] = Tup{byte(sc.Next()[0]), sc.NextInt64(), sc.NextInt64()}
	}

	checkA := func(t int, i int) bool {
		switch t {
		case 0:
			return tuples[i].x < x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 1:
			return tuples[i].x > x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 2:
			return tuples[i].x < x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 3:
			return tuples[i].x > x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 4:
			return tuples[i].x == x0 && tuples[i].y < y0
		case 5:
			return tuples[i].x == x0 && tuples[i].y > y0
		case 6:
			return tuples[i].y == y0 && tuples[i].x < x0
		case 7:
			return tuples[i].y == y0 && tuples[i].x > x0
		}
		return false
	}

	mmnn := func(t int, i int) int64 {
		switch t {
		case 0, 1, 2, 3:
			return tuples[i].x - x0
		case 4:
			return tuples[i].y - y0
		case 5:
			return tuples[i].y - y0
		case 6:
			return tuples[i].x - x0
		case 7:
			return tuples[i].x - x0
		}
		return 0
	}

	checks := func(t int) bool {
		mn := int64(-1)
		index := -1
		for i := 0; i < N; i++ {
			if checkA(t, i) {
				if mn == -1 || mn > abs(mmnn(t, i)) {
					mn = abs(mmnn(t, i))
					index = i
				}
			}
		}
		if index >= 0 {
			if tuples[index].typ == 'Q' {
				return true
			}
			if t < 4 {
				if tuples[index].typ == 'B' {
					return true
				}
			}
			if t >= 4 {
				if tuples[index].typ == 'R' {
					return true
				}
			}
		}
		return false
	}

	for i := 0; i < 8; i++ {
		if checks(i) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")

}

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

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

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

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

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

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

	return mp
}

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

package main

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

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

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

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

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

func main() {
	defer w.Flush()
	var n int
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	var x, y, xx, yy int64
	I(&x, " ")
	I(&y, "\n")
	var res [8]string
	var re [8]int64
	for i := 0; i < 8; i++ {
		re[i] = 1e10
	}
	var s string
	for i := 0; i < n; i++ {
		I(&s, " ")
		I(&xx, " ")
		I(&yy, "\n")
		if x == xx {
			if y < yy {
				if re[0] > yy-y {
					re[0] = yy - y
					res[0] = s
				}
			} else if y > yy {
				if re[1] > y-yy {
					re[1] = y - yy
					res[1] = s
				}
			}
		}
		if y == yy {
			if x < xx {
				if re[2] > xx-x {
					re[2] = xx - x
					res[2] = s
				}
			} else if x > xx {
				if re[3] > x-xx {
					re[3] = x - xx
					res[3] = s
				}
			}
		}
		if abs(yy-y) == abs(x-xx) {
			if y < yy && x < xx {
				if re[4] > yy-y+xx-x {
					re[4] = yy - y + xx - x
					res[4] = s
				}
			} else if y > yy && x > xx {
				if re[5] > y-yy+x-xx {
					re[5] = y - yy + x - xx
					res[5] = s
				}
			} else if x > xx && y < yy {
				if re[6] > yy-y+x-xx {
					re[6] = yy - y + x - xx
					res[6] = s
				}
			} else if x < xx && y > yy {
				if re[7] > y-yy+xx-x {
					re[7] = y - yy + xx - x
					res[7] = s
				}
			}
		}
	}
	for i := 0; i < 4; i++ {
		if res[i] == "Q" || res[i] == "R" {
			O("YES", "\n")
			return
		}
	}
	for i := 4; i < 8; i++ {
		if res[i] == "Q" || res[i] == "B" {
			O("YES", "\n")
			return
		}
	}
	O("NO", "\n")
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

package main

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

type Tup struct {
	typ byte
	x   int
	y   int
}

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	x0, y0 := sc.NextInt(), sc.NextInt()
	tuples := make([]Tup, N)
	for i := 0; i < N; i++ {
		tuples[i] = Tup{byte(sc.Next()[0]), sc.NextInt(), sc.NextInt()}
	}

	checkA := func(t int, i int) bool {
		switch t {
		case 0:
			return tuples[i].x < x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 1:
			return tuples[i].x > x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 2:
			return tuples[i].x < x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 3:
			return tuples[i].x > x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 4:
			return tuples[i].x == x0 && tuples[i].y < y0
		case 5:
			return tuples[i].x == x0 && tuples[i].y > y0
		case 6:
			return tuples[i].x == y0 && tuples[i].x < x0
		case 7:
			return tuples[i].x == y0 && tuples[i].x > x0
		}
		return false
	}

	mmnn := func(t int, i int) int {
		switch t {
		case 0, 1, 2, 3:
			return tuples[i].x - x0
		case 4:
			return tuples[i].y - y0
		case 5:
			return tuples[i].y - y0
		case 6:
			return tuples[i].x - x0
		case 7:
			return tuples[i].x - x0
		}
		return 0
	}

	checks := func(t int) bool {
		mn := -1
		index := -1
		for i := 0; i < N; i++ {
			if checkA(t, i) {
				if mn == -1 || mn > abs(mmnn(t, i)) {
					mn = abs(mmnn(t, i))
					index = i
				}
			}
		}
		if index >= 0 {
			if t < 4 {
				if tuples[index].typ == 'B' {
					return true
				}
			}
			if t >= 4 {
				if tuples[index].typ == 'R' {
					return true
				}
			}
		}
		return false
	}

	for i := 0; i < 8; i++ {
		if checks(i) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")

}

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

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

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

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

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

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

	return mp
}

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

package main

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

type Tup struct {
	typ byte
	x   int64
	y   int64
}

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	x0, y0 := sc.NextInt64(), sc.NextInt64()
	tuples := make([]Tup, N)
	for i := 0; i < N; i++ {
		tuples[i] = Tup{byte(sc.Next()[0]), sc.NextInt64(), sc.NextInt64()}
	}

	checkA := func(t int, i int) bool {
		switch t {
		case 0:
			return tuples[i].x < x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 1:
			return tuples[i].x > x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 2:
			return tuples[i].x < x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 3:
			return tuples[i].x > x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 4:
			return tuples[i].x == x0 && tuples[i].y < y0
		case 5:
			return tuples[i].x == x0 && tuples[i].y > y0
		case 6:
			return tuples[i].x == y0 && tuples[i].x < x0
		case 7:
			return tuples[i].x == y0 && tuples[i].x > x0
		}
		return false
	}

	mmnn := func(t int, i int) int64 {
		switch t {
		case 0, 1, 2, 3:
			return tuples[i].x - x0
		case 4:
			return tuples[i].y - y0
		case 5:
			return tuples[i].y - y0
		case 6:
			return tuples[i].x - x0
		case 7:
			return tuples[i].x - x0
		}
		return 0
	}

	checks := func(t int) bool {
		mn := int64(-1)
		index := -1
		for i := 0; i < N; i++ {
			if checkA(t, i) {
				if mn == -1 || mn > abs(mmnn(t, i)) {
					mn = abs(mmnn(t, i))
					index = i
				}
			}
		}
		if index >= 0 {
			if t < 4 {
				if tuples[index].typ == 'B' {
					return true
				}
			}
			if t >= 4 {
				if tuples[index].typ == 'R' {
					return true
				}
			}
		}
		return false
	}

	for i := 0; i < 8; i++ {
		if checks(i) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")

}

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

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

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

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

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

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

	return mp
}

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

package main

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

type Tup struct {
	typ byte
	x   int64
	y   int64
}

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	x0, y0 := sc.NextInt64(), sc.NextInt64()
	tuples := make([]Tup, N)
	for i := 0; i < N; i++ {
		tuples[i] = Tup{byte(sc.Next()[0]), sc.NextInt64(), sc.NextInt64()}
	}

	checkA := func(t int, i int) bool {
		switch t {
		case 0:
			return tuples[i].x < x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 1:
			return tuples[i].x > x0 && tuples[i].x - x0 == tuples[i].y - y0
		case 2:
			return tuples[i].x < x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 3:
			return tuples[i].x > x0 && tuples[i].x - x0 == -(tuples[i].y - y0)
		case 4:
			return tuples[i].x == x0 && tuples[i].y < y0
		case 5:
			return tuples[i].x == x0 && tuples[i].y > y0
		case 6:
			return tuples[i].y == y0 && tuples[i].x < x0
		case 7:
			return tuples[i].y == y0 && tuples[i].x > x0
		}
		return false
	}

	mmnn := func(t int, i int) int64 {
		switch t {
		case 0, 1, 2, 3:
			return tuples[i].x - x0
		case 4:
			return tuples[i].y - y0
		case 5:
			return tuples[i].y - y0
		case 6:
			return tuples[i].x - x0
		case 7:
			return tuples[i].x - x0
		}
		return 0
	}

	checks := func(t int) bool {
		mn := int64(-1)
		index := -1
		for i := 0; i < N; i++ {
			if checkA(t, i) {
				if mn == -1 || mn > abs(mmnn(t, i)) {
					mn = abs(mmnn(t, i))
					index = i
				}
			}
		}
		if index >= 0 {
			if t < 4 {
				if tuples[index].typ == 'B' {
					return true
				}
			}
			if t >= 4 {
				if tuples[index].typ == 'R' {
					return true
				}
			}
		}
		return false
	}

	for i := 0; i < 8; i++ {
		if checks(i) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")

}

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

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

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

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

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

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

	return mp
}

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

package main

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

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

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

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

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

func main() {
	defer w.Flush()
	var n int
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	var x, y, xx, yy int
	I(&x, " ")
	I(&y, "\n")
	var res [8]string
	var re [8]int
	for i := 0; i < 8; i++ {
		re[i] = 1e9*2 + 1
	}
	var s string
	for i := 0; i < n; i++ {
		I(&s, " ")
		I(&xx, " ")
		I(&yy, "\n")
		if x == xx {
			if y < yy {
				if re[0] > yy-y {
					re[0] = yy - y
					res[0] = s
				}
			} else if y > yy {
				if re[1] > y-yy {
					re[1] = y - yy
					res[1] = s
				}
			}
		}
		if y == yy {
			if x < xx {
				if re[2] > xx-x {
					re[2] = xx - x
					res[2] = s
				}
			} else if x > xx {
				if re[3] > x-xx {
					re[3] = x - xx
					res[3] = s
				}
			}
		}
		if abs(yy-y) == abs(x-xx) {
			if y < yy && x < xx {
				if re[4] > yy-y+xx-x {
					re[4] = yy - y + xx - x
					res[4] = s
				}
			} else if y > yy && x > xx {
				if re[5] > y-yy+x-xx {
					re[5] = y - yy + x - xx
					res[5] = s
				}
			} else if x > xx && y < yy {
				if re[6] > yy-y+x-xx {
					re[6] = yy - y + x - xx
					res[6] = s
				}
			} else if x < xx && y > yy {
				if re[7] > y-yy+xx-x {
					re[7] = y - yy + xx - x
					res[7] = s
				}
			}
		}
	}
	for i := 0; i < 4; i++ {
		if res[i] == "Q" || res[i] == "R" {
			O("YES", "\n")
			return
		}
	}
	for i := 4; i < 8; i++ {
		if res[i] == "Q" || res[i] == "B" {
			O("YES", "\n")
			return
		}
	}
	O("NO", "\n")
}

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

package main

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

type Piece struct {
	x, y int
	s    string
}

type Score func(p Piece) (bool, string)

func solve() {

	scoreCalcs := []Score{
		func(p Piece) (bool, string) {
			return p.y == 0, "R"
		}, func(p Piece) (bool, string) {
			return p.x == 0, "R"
		}, func(p Piece) (bool, string) {
			return p.x == p.y, "B"
		}}

	n, dx, dy := readInt(), readInt(), readInt()
	a := make([]Piece, n)
	for i := 0; i < n; i++ {
		s, x, y := readString(), readInt()-dx, readInt()-dy
		a[i] = Piece{x, y, s}
	}

	ans := "NO"
	for _, mul := range [][]int{[]int{1, 1}, []int{-1, 1}, []int{1, -1}, []int{-1, -1}} {
		for _, calc := range scoreCalcs {
			var bestP *Piece = nil
			needS := "Q"
			for _, piece := range a {
				p := Piece{piece.x * mul[0], piece.y * mul[1], piece.s}
				if p.x >= 0 && p.y >= 0 {
					ok, s := calc(p)
					needS = s
					if ok && (bestP == nil || bestP.x+bestP.y > p.x+p.y) {
						bestP = &p
					}
				}
			}

			if bestP != nil && (bestP.s == needS || bestP.s == "Q") {
				ans = "YES"
			}
		}
	}

	fmt.Println(ans)
}

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

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

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

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

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

// IO

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

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

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

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


You are given a permutation $$$a$$$ of length $$$n$$$. Recall that permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order.You have a strength of $$$s$$$ and perform $$$n$$$ moves on the permutation $$$a$$$. The $$$i$$$-th move consists of the following:   Pick two integers $$$x$$$ and $$$y$$$ such that $$$i \leq x \leq y \leq \min(i+s,n)$$$, and swap the positions of the integers $$$x$$$ and $$$y$$$ in the permutation $$$a$$$. Note that you can select $$$x=y$$$ in the operation, in which case no swap will occur. You want to turn $$$a$$$ into another permutation $$$b$$$ after $$$n$$$ moves. However, some elements of $$$b$$$ are missing and are replaced with $$$-1$$$ instead. Count the number of ways to replace each $$$-1$$$ in $$$b$$$ with some integer from $$$1$$$ to $$$n$$$ so that $$$b$$$ is a permutation and it is possible to turn $$$a$$$ into $$$b$$$ with a strength of $$$s$$$. Since the answer can be large, output it modulo $$$998\,244\,353$$$.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$; $$$1 \leq s \leq n$$$) — the size of the permutation and your strength, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of $$$a$$$. All elements of $$$a$$$ are distinct. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le b_i \le n$$$ or $$$b_i = -1$$$) — the elements of $$$b$$$. All elements of $$$b$$$ that are not equal to $$$-1$$$ are distinct. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output a single integer — the number of ways to fill up the permutation $$$b$$$ so that it is possible to turn $$$a$$$ into $$$b$$$ using a strength of $$$s$$$, modulo $$$998\,244\,353$$$.

NoteIn the first test case, $$$a=[2,1,3]$$$. There are two possible ways to fill out the $$$-1$$$s in $$$b$$$ to make it a permutation: $$$[3,1,2]$$$ or $$$[3,2,1]$$$. We can make $$$a$$$ into $$$[3,1,2]$$$ with a strength of $$$1$$$ as follows: $$$$$$[2,1,3] \xrightarrow[x=1,\,y=1]{} [2,1,3] \xrightarrow[x=2,\,y=3]{} [3,1,2] \xrightarrow[x=3,\,y=3]{} [3,1,2].$$$$$$ It can be proven that it is impossible to make $$$[2,1,3]$$$ into $$$[3,2,1]$$$ with a strength of $$$1$$$. Thus only one permutation $$$b$$$ satisfies the constraints, so the answer is $$$1$$$.In the second test case, $$$a$$$ and $$$b$$$ the same as the previous test case, but we now have a strength of $$$2$$$. We can make $$$a$$$ into $$$[3,2,1]$$$ with a strength of $$$2$$$ as follows: $$$$$$[2,1,3] \xrightarrow[x=1,\,y=3]{} [2,3,1] \xrightarrow[x=2,\,y=3]{} [3,2,1] \xrightarrow[x=3,\,y=3]{} [3,2,1].$$$$$$ We can still make $$$a$$$ into $$$[3,1,2]$$$ using a strength of $$$1$$$ as shown in the previous test case, so the answer is $$$2$$$. In the third test case, there is only one permutation $$$b$$$. It can be shown that it is impossible to turn $$$a$$$ into $$$b$$$, so the answer is $$$0$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
const MOD int64 = 998244353
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); S := gi(); A := gis(N); for i:=0;i<N;i++ { A[i]-- }; B := gis(N); for i:=0;i<N;i++ { B[i]-- }
		Aloc := ia(N); for i,a := range A { Aloc[a] = i }
		// Figure out which elements of B are left
		sb := make([]bool,N); for _,b := range B { if b >= 0 { sb[b] = true } }
		// Check B to make sure that things are possible
		good := true
		for i,b := range B { if b >= 0 && A[i] > b+S { good = false } }
		ans := int64(1)
		if !good {
			ans = 0
		} else {
			amoves := ia(0); for i := 0;i<N;i++ { if B[i] < 0 { amoves = append(amoves,A[i]) } }
			bmoves := ia(0); for i := 0;i<N;i++ { if !sb[i]   { bmoves = append(bmoves,i) } }
			sort.Slice(amoves,func(i,j int) bool { return amoves[i] < amoves[j] } )
			avail := 0; aidx := 0;
			for _,b := range bmoves {
				for aidx < len(amoves) && amoves[aidx] <= b+S { avail++; aidx++ }
				ans *= int64(avail); ans %= MOD; avail--
			}
		}
		fmt.Fprintln(wrtr,ans)
	}
}


You are playing a strange game with Li Chen. You have a tree with $$$n$$$ nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from $$$1$$$ to $$$n$$$. Neither of you know the other's labelling of the tree.You and Li Chen each chose a subtree (i.e., a connected subgraph) in that tree. Your subtree consists of the vertices labeled $$$x_1, x_2, \ldots, x_{k_1}$$$ in your labeling, Li Chen's subtree consists of the vertices labeled $$$y_1, y_2, \ldots, y_{k_2}$$$ in his labeling. The values of $$$x_1, x_2, \ldots, x_{k_1}$$$ and $$$y_1, y_2, \ldots, y_{k_2}$$$ are known to both of you.   The picture shows two labelings of a possible tree: yours on the left and Li Chen's on the right. The selected trees are highlighted. There are two common nodes. You want to determine whether your subtrees have at least one common vertex. Luckily, your friend Andrew knows both labelings of the tree. You can ask Andrew at most $$$5$$$ questions, each of which is in one of the following two forms:   A x: Andrew will look at vertex $$$x$$$ in your labeling and tell you the number of this vertex in Li Chen's labeling.  B y: Andrew will look at vertex $$$y$$$ in Li Chen's labeling and tell you the number of this vertex in your labeling. Determine whether the two subtrees have at least one common vertex after asking some questions. If there is at least one common vertex, determine one of your labels for any of the common vertices.

NoteFor the first sample, Li Chen's hidden permutation is $$$[2, 3, 1]$$$, and for the second, his hidden permutation is $$$[5, 3, 2, 4, 1, 6]$$$ for both cases.In the first sample, there is a tree with three nodes in a line. On the top, is how you labeled the tree and the subtree you chose, and the bottom is how Li Chen labeled the tree and the subtree he chose:   In the first question, you ask Andrew to look at node $$$1$$$ in your labelling and tell you the label of it in Li Chen's labelling. Andrew responds with $$$2$$$. At this point, you know that both of your subtrees contain the same node (i.e. node $$$1$$$ according to your labeling), so you can output "C 1" and finish. However, you can also ask Andrew to look at node $$$2$$$ in Li Chen's labelling and tell you the label of it in your labelling. Andrew responds with $$$1$$$ (this step was given with the only reason — to show you how to ask questions).For the second sample, there are two test cases. The first looks is the one from the statement:   We first ask "B 2", and Andrew will tell us $$$3$$$. In this case, we know $$$3$$$ is a common vertex, and moreover, any subtree with size $$$3$$$ that contains node $$$3$$$ must contain node $$$1$$$ as well, so we can output either "C 1" or "C 3" as our answer.In the second case in the second sample, the situation looks as follows:   In this case, you know that the only subtree of size $$$3$$$ that doesn't contain node $$$1$$$ is subtree $$$4,5,6$$$. You ask Andrew for the label of node $$$1$$$ in Li Chen's labelling and Andrew says $$$5$$$. In this case, you know that Li Chen's subtree doesn't contain node $$$1$$$, so his subtree must be consist of the nodes $$$4,5,6$$$ (in your labelling), thus the two subtrees have no common nodes.

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func solve() int {
	var n int
	fmt.Fscan(in, &n)
	edges := make([][]int, n+1)
	for i := 1; i < n; i++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}
	x := readLabels()
	y := readLabels()
	oneHis := 0
	for oneHis = range y {
		break
	}
	fmt.Println("B", oneHis)
	var hisInMine int
	fmt.Fscan(in, &hisInMine)
	if x[hisInMine] {
		return hisInMine
	}

	st := []int{hisInMine}
	visited := make([]bool, n+1)
	visited[hisInMine] = true
	for {
		v := st[0]
		if x[v] {
			break
		}
		st = st[1:]
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			st = append(st, u)
		}
	}
	mine := st[0]
	fmt.Println("A", mine)
	var mineInHis int
	fmt.Fscan(in, &mineInHis)
	if y[mineInHis] {
		return mine
	}
	return -1
}

func readLabels() map[int]bool {
	var k int
	fmt.Fscan(in, &k)
	m := make(map[int]bool, k)
	for i := 0; i < k; i++ {
		var x int
		fmt.Fscan(in, &x)
		m[x] = true
	}
	return m
}

func main() {
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Println("C", solve())
	}
}


Alice lives on a flat planet that can be modeled as a square grid of size $$$n \times n$$$, with rows and columns enumerated from $$$1$$$ to $$$n$$$. We represent the cell at the intersection of row $$$r$$$ and column $$$c$$$ with ordered pair $$$(r, c)$$$. Each cell in the grid is either land or water.  An example planet with $$$n = 5$$$. It also appears in the first sample test. Alice resides in land cell $$$(r_1, c_1)$$$. She wishes to travel to land cell $$$(r_2, c_2)$$$. At any moment, she may move to one of the cells adjacent to where she is—in one of the four directions (i.e., up, down, left, or right).Unfortunately, Alice cannot swim, and there is no viable transportation means other than by foot (i.e., she can walk only on land). As a result, Alice's trip may be impossible.To help Alice, you plan to create at most one tunnel between some two land cells. The tunnel will allow Alice to freely travel between the two endpoints. Indeed, creating a tunnel is a lot of effort: the cost of creating a tunnel between cells $$$(r_s, c_s)$$$ and $$$(r_t, c_t)$$$ is $$$(r_s-r_t)^2 + (c_s-c_t)^2$$$.For now, your task is to find the minimum possible cost of creating at most one tunnel so that Alice could travel from $$$(r_1, c_1)$$$ to $$$(r_2, c_2)$$$. If no tunnel needs to be created, the cost is $$$0$$$.

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 50$$$) — the width of the square grid. The second line contains two space-separated integers $$$r_1$$$ and $$$c_1$$$ ($$$1 \leq r_1, c_1 \leq n$$$) — denoting the cell where Alice resides. The third line contains two space-separated integers $$$r_2$$$ and $$$c_2$$$ ($$$1 \leq r_2, c_2 \leq n$$$) — denoting the cell to which Alice wishes to travel. Each of the following $$$n$$$ lines contains a string of $$$n$$$ characters. The $$$j$$$-th character of the $$$i$$$-th such line ($$$1 \leq i, j \leq n$$$) is 0 if $$$(i, j)$$$ is land or 1 if $$$(i, j)$$$ is water. It is guaranteed that $$$(r_1, c_1)$$$ and $$$(r_2, c_2)$$$ are land.

Print an integer that is the minimum possible cost of creating at most one tunnel so that Alice could travel from $$$(r_1, c_1)$$$ to $$$(r_2, c_2)$$$.

NoteIn the first sample, a tunnel between cells $$$(1, 4)$$$ and $$$(4, 5)$$$ should be created. The cost of doing so is $$$(1-4)^2 + (4-5)^2 = 10$$$, which is optimal. This way, Alice could walk from $$$(1, 1)$$$ to $$$(1, 4)$$$, use the tunnel from $$$(1, 4)$$$ to $$$(4, 5)$$$, and lastly walk from $$$(4, 5)$$$ to $$$(5, 5)$$$.In the second sample, clearly a tunnel between cells $$$(1, 3)$$$ and $$$(3, 1)$$$ needs to be created. The cost of doing so is $$$(1-3)^2 + (3-1)^2 = 8$$$.

package main

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

var g [][]int
var ans []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	g = make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}
	r1, c1, r2, c2 := 0, 0, 0, 0
	fmt.Fscanf(in, "%d %d\n", &r1, &c1)
	fmt.Fscanf(in, "%d %d\n", &r2, &c2)
	r1--
	c1--
	r2--
	c2--
	for i := 0; i < n; i++ {
		tmp := ""
		fmt.Fscanf(in, "%s\n", &tmp)
		for j := 0; j < n; j++ {
			g[i][j] = int(tmp[0] - '0')
			tmp = tmp[1:]
		}
		//fmt.Println(g[i])
	}

	ans = make([]int, 0)
	find(r1, c1, n)
	if g[r2][c2] == 1 {
		fmt.Fprintf(out, "%d\n", 0)
		return
	}
	tmpAns := ans
	ans = make([]int, 0)
	find(r2, c2, n)
	finalA := (r2-r1)*(r2-r1) + (c2-c1)*(c2-c1)
	for i := 0; i < len(tmpAns); i++ {
		for j := 0; j < len(ans); j++ {
			x1, y1 := tmpAns[i]/n, tmpAns[i]%n
			x2, y2 := ans[j]/n, ans[j]%n
			if (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < finalA {
				finalA = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
			}
		}
	}
	fmt.Fprintf(out, "%d\n", finalA)
	return
}

func find(x, y int, n int) {
	if x < 0 || x >= n || y < 0 || y >= n {
		return
	}
	if g[x][y] == 1 {
		return
	}
	g[x][y] = 1
	ans = append(ans, x*n+y)
	find(x-1, y, n)
	find(x+1, y, n)
	find(x, y-1, n)
	find(x, y+1, n)
}

package main

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

var checked [][]bool
var m [][]bool

var shiftX []int
var shiftY []int

var xs, ys int
var xf, yf int

type Coord struct {
	X, Y int
}

func (c Coord) Dist(o Coord) int {
	return int((c.X-o.X)*(c.X-o.X) + (c.Y-o.Y)*(c.Y-o.Y))
}

func init() {
	in := bufio.NewReader(os.Stdin)
	// in, _ := os.Open("./542/c/4")
	// defer in.Close()
	shiftX = []int{1, 0, -1, 0}
	shiftY = []int{0, 1, 0, -1}
	n := 0
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		checked = append(checked, make([]bool, n, n))
	}
	fmt.Fscan(in, &xs, &ys)
	fmt.Fscan(in, &xf, &yf)
	ys--
	xs--
	yf--
	xf--
	for i := 0; i < n; i++ {
		s := ""
		fmt.Fscan(in, &s)
		m = append(m, make([]bool, n, n))
		for j := 0; j < n; j++ {
			m[i][j] = s[j] == '0'
		}
	}
}

func dfs(x, y int) []Coord {
	checked[x][y] = true
	coords := []Coord{{x, y}}
	for i := 0; i < 4; i++ {
		if x+shiftX[i] < 0 || y+shiftY[i] < 0 || y+shiftY[i] >= len(m) || x+shiftX[i] >= len(m[0]) {
			continue
		}
		if !m[x][y] {
			panic("Fuck")
		}
		if !m[x+shiftX[i]][y+shiftY[i]] {
			continue
		}
		if checked[x+shiftX[i]][y+shiftY[i]] {
			continue
		}
		coords = append(coords, dfs(x+shiftX[i], y+shiftY[i])...)
	}
	return coords
}

func main() {
	coordsStart := dfs(xs, ys)
	coordsFinish := dfs(xf, yf)
	if len(coordsFinish) == 0 {
		fmt.Println(0)
		return
	}
	bestDist := 1000 * 1000
	for _, cS := range coordsStart {
		for _, cF := range coordsFinish {
			newDist := cS.Dist(cF)
			if bestDist > newDist {
				bestDist = newDist
			}
		}
	}
	fmt.Println(bestDist)
}

package main

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

var g [][]int
var ans []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([][]int, (n+1)*(n+1))
	g = make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < (n+1)*(n+1); i++ {
		a[i] = make([]int, (n+1)*(n+1))
	}
	r1, c1, r2, c2 := 0, 0, 0, 0
	fmt.Fscanf(in, "%d %d\n", &r1, &c1)
	fmt.Fscanf(in, "%d %d\n", &r2, &c2)
	r1--
	c1--
	r2--
	c2--
	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Fscanf(in, "%d\n", &tmp)
		for j := n - 1; j >= 0; j-- {
			g[i][j] = tmp % 10
			tmp /= 10
		}
	}
	//fmt.Println(g[0])
	// for i := 0; i < n*n; i++ {
	// 	x1, y1 := i/n, i%n
	// 	for j := 0; j < n*n; j++ {
	// 		a[i][j] = -1
	// 		x2, y2 := j/n, j%n
	// 		if g[x1][y1] == 1 || g[x2][y2] == 1 {
	// 			continue
	// 		}
	// 		if (x1 == x2 && (y1-y2)*(y1-y2) == 1) || (y1 == y2 && (x1-x2)*(x1-x2) == 1) {
	// 			//fmt.Println(i, j)
	// 			a[i][j] = 0
	// 		} else {
	// 			//fmt.Println(i, j)
	// 			a[i][j] = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)
	// 		}
	// 	}
	// }
	used := make(map[int]bool)
	dis := make([]int, n*n)
	from := r1*n + c1
	//fmt.Println(r1, c1, r2, c2, from, to)
	for i := 0; i < n*n; i++ {
		dis[i] = a[from][i]
	}
	used[from] = true
	// for true {
	// 	if used[to] {
	// 		fmt.Fprintf(out, "%d\n", dis[to])
	// 		return
	// 	}
	// 	chosen := -1
	// 	for i := 0; i < n*n; i++ {
	// 		if used[i] == false && dis[i] != -1 {
	// 			if chosen == -1 || dis[i] < dis[chosen] {
	// 				chosen = i
	// 			}
	// 		}
	// 	}
	// 	fmt.Println(dis, chosen)

	// 	used[chosen] = true
	// 	for i := 0; i < n*n; i++ {
	// 		//fmt.Println(chosen, i)
	// 		if a[chosen][i] != -1 {
	// 			if dis[i] != -1 && dis[chosen]+a[chosen][i] < dis[i] {
	// 				dis[i] = dis[chosen] + a[chosen][i]
	// 			}
	// 		}
	// 	}
	// }
	ans = make([]int, 0)
	find(r1, c1, n)
	if g[r2][c2] == 1 {
		fmt.Fprintf(out, "%d\n", 0)
		return
	}
	tmpAns := ans
	ans = make([]int, 0)
	find(r2, c2, n)
	finalA := (r2-r1)*(r2-r1) + (c2-c1)*(c2-c1)
	for i := 0; i < len(tmpAns); i++ {
		for j := 0; j < len(ans); j++ {
			x1, y1 := tmpAns[i]/n, tmpAns[i]%n
			x2, y2 := ans[j]/n, ans[j]%n
			if (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < finalA {
				finalA = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
			}
		}
	}
	fmt.Fprintf(out, "%d\n", finalA)
	return
}

func find(x, y int, n int) {
	if x < 0 || x >= n || y < 0 || y >= n {
		return
	}
	if g[x][y] == 1 {
		return
	}
	g[x][y] = 1
	ans = append(ans, x*n+y)
	find(x-1, y, n)
	find(x+1, y, n)
	find(x, y-1, n)
	find(x, y+1, n)
}

package main

import (
	"fmt"
)

var checked [][]bool
var m [][]bool

var shiftX []int
var shiftY []int

var xs, ys int
var xf, yf int

type Coord struct {
	X, Y int
}

func (c Coord) Dist(o Coord) int {
	return int((c.X-o.X)*(c.X-o.X) + (c.Y-o.Y)*(c.Y-o.Y))
}

func init() {
	shiftX = []int{1, 0, -1, 0}
	shiftY = []int{0, 1, 0, -1}
	n := 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		checked = append(checked, make([]bool, n, n))
	}
	fmt.Scan(&ys, &xs)
	fmt.Scan(&yf, &xf)
	ys--
	xs--
	yf--
	xf--
	for i := 0; i < n; i++ {
		s := ""
		fmt.Scan(&s)
		m = append(m, make([]bool, n, n))
		for j := 0; j < n; j++ {
			m[i][j] = s[j] == '0'
		}
	}
}

func dfs(x, y int) []Coord {
	checked[x][y] = true
	coords := []Coord{{x, y}}
	for i := 0; i < 4; i++ {
		if x+shiftX[i] < 0 || y+shiftY[i] < 0 || y+shiftY[i] >= len(m) || x+shiftX[i] >= len(m[0]) {
			continue
		}
		if !m[x+shiftX[i]][y+shiftY[i]] {
			continue
		}
		if checked[x+shiftX[i]][y+shiftY[i]] {
			continue
		}
		coords = append(coords, dfs(x+shiftX[i], y+shiftY[i])...)
	}
	return coords
}

func main() {
	coordsStart := dfs(xs, ys)
	coordsFinish := dfs(xf, yf)
	if len(coordsFinish) == 0 {
		fmt.Println(0)
		return
	}
	bestDist := 1000 * 1000
	for _, cS := range coordsStart {
		for _, cF := range coordsFinish {
			newDist := cS.Dist(cF)
			if bestDist > newDist {
				bestDist = newDist
			}
		}
	}
	fmt.Println(bestDist)
}


Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:   +  ai — add non-negative integer ai to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer.   -  ai — delete a single occurrence of non-negative integer ai from the multiset. It's guaranteed, that there is at least one ai in the multiset.  ? s — count the number of integers in the multiset (with repetitions) that match some pattern s consisting of 0 and 1. In the pattern, 0 stands for the even digits, while 1 stands for the odd. Integer x matches the pattern s, if the parity of the i-th from the right digit in decimal notation matches the i-th from the right digit of the pattern. If the pattern is shorter than this integer, it's supplemented with 0-s from the left. Similarly, if the integer is shorter than the pattern its decimal notation is supplemented with the 0-s from the left. For example, if the pattern is s = 010, than integers 92, 2212, 50 and 414 match the pattern, while integers 3, 110, 25 and 1030 do not.

The first line of the input contains an integer t (1 ≤ t ≤ 100 000) — the number of operation Sonya has to perform. Next t lines provide the descriptions of the queries in order they appear in the input file. The i-th row starts with a character ci — the type of the corresponding operation. If ci is equal to '+' or '-' then it's followed by a space and an integer ai (0 ≤ ai < 1018) given without leading zeroes (unless it's 0). If ci equals '?' then it's followed by a space and a sequence of zeroes and onse, giving the pattern of length no more than 18. It's guaranteed that there will be at least one query of type '?'. It's guaranteed that any time some integer is removed from the multiset, there will be at least one occurrence of this integer in it.

For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time.

NoteConsider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input.   1 and 241.  361.  101 and 361.  361.  4000.

package main

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

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

type Node struct {
	val   int
	child [2]*Node
}

func create(v int) *Node {
	r := &Node{
		val:   v,
		child: [2]*Node{nil, nil},
	}
	return r
}

func add(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	if node.child[bit] == nil {
		node.child[bit] = create(0)
	}
	node.child[bit].val++
	add(x/10, i-1, node.child[bit])
}

func del(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	node.child[bit].val--
	del(x/10, i-1, node.child[bit])
}

func query(bits string, i int, node *Node) int {
	if i < 0 {
		return node.val
	}
	bit := bits[i] - '0'
	if node.child[bit] != nil {
		return query(bits, i-1, node.child[bit])
	}
	return 0
}

const maxbit = 30

var root *Node

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

	var n int
	var x int64
	var op, s string

	root = create(0)
	fmt.Fscanf(bufin, "%d\n", &n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%s\n", &op)
		if op == "+" {
			fmt.Fscanf(bufin, "%d\n", &x)
			add(x, maxbit, root)
		} else if op == "-" {
			fmt.Fscanf(bufin, "%d\n", &x)
			del(x, maxbit, root)
		} else {
			fmt.Fscanf(bufin, "%s\n", &s)
			for len(s) < maxbit {
				s = "0" + s
			}
			res := query(s, maxbit-1, root)
			fmt.Fprintf(bufout, "%d\n", res)
		}
	}
}

package main

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

import "strings"

type node struct {
	count int64
	even  *node
	odd   *node
}

func addvalue(value int64, n *node) {
	r := value % 2
	d := value / 10
	if r == 0 {
		if n.even == nil {
			n.even = &node{0, nil, nil}
		}
		n = n.even
	} else {
		if n.odd == nil {
			n.odd = &node{0, nil, nil}
		}
		n = n.odd
	}
	if d == 0 {
		n.count++
		return
	}
	addvalue(d, n)
}
func delvalue(value int64, n *node) {
	r := value % 2
	d := value / 10
	if r == 0 {
		n = n.even
	} else {
		n = n.odd
	}
	if d == 0 {
		n.count--
		return
	}
	delvalue(d, n)
}

func p(n *node, s []int) {
	if n == nil {
		return
	}
	if n.count > 0 {
		fmt.Print(s)
	}
	p(n.even, append(s, 0))
	p(n.odd, append(s, 1))
}

func check(p int64, n *node, c int64) int64 {
	if n == nil {
		return c
	}
	if p == 0 {
		return check(0, n.even, c+n.count)
	}
	r := p % 2
	d := p / 10
	c += n.count
	if r == 0 {
		n = n.even
	} else {
		c = 0
		n = n.odd
	}
	return check(d, n, c)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")

	base := node{0, nil, nil}
	c, _ := strconv.Atoi(s[0])
	//x, _ := strconv.ParseInt(s[1], 10, 64)
	for i := 0; i < c; i++ {
		text, _ := reader.ReadString('\n')
		text = strings.TrimRight(text, "\r\n")
		s := strings.Split(text, " ")
		x, _ := strconv.ParseInt(s[1], 10, 64)
		if s[0] == "?" {
			fmt.Println(check(x, &base, 0))
		} else if s[0] == "+" {
			addvalue(x, &base)
		} else if s[0] == "-" {
			delvalue(x, &base)
		}
	}
}

package main

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

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

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

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

type Tree struct {
	tree     [524289]int
}

func (tree *Tree) change(value [18]int, delta int) {
	end_idx := 1
	for _, i := range value {
		end_idx *= 2
		if i == 1 {
			end_idx += 1
		}
	}
	tree.tree[end_idx] += delta
}

func (tree *Tree) query(value [18]int) int{
	end_idx := 1
	for _, i := range value {
		end_idx *= 2
		if i == 1 {
			end_idx += 1
		}
	}
	return tree.tree[end_idx]
}

func to01(int_string string) [18]int {
	var result [18]int
	digitCount := len(int_string)
	for idx, i := range int_string {
		if int(i) % 2 == 1 {
			result[digitCount - 1 - idx] = 1
		}
	}
	return result
}

func to01Template(int_string string) [18]int {
	var result [18]int
	digitCount := len(int_string)
	for idx, i := range int_string {
		if i == '1' {
			result[digitCount - 1 - idx] = 1
		}
	}
	return result
}

func main()  {

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

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

	n := getI()

	tree := *new(Tree)

	for opNo := 0; opNo < n; opNo++ {
		command, value := getS(), getS()
		if command == "+" {
			tree.change(to01(value), 1)
		} else if command == "-" {
			tree.change(to01(value), -1)
		} else {
			writer.WriteString(strconv.Itoa(tree.query(to01Template(value))))
			writer.WriteByte('\n')
		}
	}

}

package main

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

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

type Node struct {
	val   int
	child [2]*Node
}

func create(v int) *Node {
	r := &Node{
		val:   0,
		child: [2]*Node{nil, nil},
	}
	return r
}

func add(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	if node.child[bit] == nil {
		node.child[bit] = create(0)
	}
	node.child[bit].val++
	add(x/10, i-1, node.child[bit])
}

func del(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	node.child[bit].val--
	del(x/10, i-1, node.child[bit])
}

func query(bits []byte, i int, node *Node) int {
	if i < 0 {
		return node.val
	}
	bit := bits[i] - '0'
	if node.child[bit] != nil {
		return query(bits, i-1, node.child[bit])
	}
	return 0
}

const maxbit = 20

var root *Node

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

	var n int
	var x int64
	var op, s string

	root = create(0)
	fmt.Fscanf(bufin, "%d\n", &n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%s\n", &op)
		if op == "+" {
			fmt.Fscanf(bufin, "%d\n", &x)
			add(x, maxbit, root)
		} else if op == "-" {
			fmt.Fscanf(bufin, "%d\n", &x)
			del(x, maxbit, root)
		} else {
			fmt.Fscanf(bufin, "%s\n", &s)
			bits := []byte(s)
			res := query(bits, len(bits)-1, root)
			fmt.Fprintf(bufout, "%d\n", res)
		}
	}
}

package main

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

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

type Node struct {
	val   int
	child [2]*Node
}

func create(v int) *Node {
	r := &Node{
		val:   v,
		child: [2]*Node{nil, nil},
	}
	return r
}

func add(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	if node.child[bit] == nil {
		node.child[bit] = create(0)
	}
	node.child[bit].val++
	add(x/10, i-1, node.child[bit])
}

func del(x int64, i int, node *Node) {
	if i < 0 {
		return
	}
	bit := x & 1
	node.child[bit].val--
	del(x/10, i-1, node.child[bit])
}

func query(bits string, i int, node *Node) int {
	if i < 0 {
		return node.val
	}
	bit := bits[i] - '0'
	if node.child[bit] != nil {
		return query(bits, i-1, node.child[bit])
	}
	return 0
}

const maxbit = 30

var root *Node

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

	var n int
	var x int64
	var op, s string

	root = create(0)
	fmt.Fscanf(bufin, "%d\n", &n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%s\n", &op)
		if op == "+" {
			fmt.Fscanf(bufin, "%d\n", &x)
			add(x, maxbit, root)
		} else if op == "-" {
			fmt.Fscanf(bufin, "%d\n", &x)
			del(x, maxbit, root)
		} else {
			fmt.Fscanf(bufin, "%s\n", &s)
			res := query(s, len(s)-1, root)
			fmt.Fprintf(bufout, "%d\n", res)
		}
	}
}


New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.Vasya's verse contains $$$n$$$ parts. It takes $$$a_i$$$ seconds to recite the $$$i$$$-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes $$$a_1$$$ seconds, secondly — the part which takes $$$a_2$$$ seconds, and so on. After reciting the verse, Vasya will get the number of presents equal to the number of parts he fully recited.Vasya can skip at most one part of the verse while reciting it (if he skips more than one part, then Santa will definitely notice it).Santa will listen to Vasya's verse for no more than $$$s$$$ seconds. For example, if $$$s = 10$$$, $$$a = [100, 9, 1, 1]$$$, and Vasya skips the first part of verse, then he gets two presents.Note that it is possible to recite the whole verse (if there is enough time). Determine which part Vasya needs to skip to obtain the maximum possible number of gifts. If Vasya shouldn't skip anything, print 0. If there are multiple answers, print any of them.You have to process $$$t$$$ test cases.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^5, 1 \le s \le 10^9$$$) — the number of parts in the verse and the maximum number of seconds Santa will listen to Vasya, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the time it takes to recite each part of the verse. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print one integer — the number of the part that Vasya needs to skip to obtain the maximum number of gifts. If Vasya shouldn't skip any parts, print 0.

NoteIn the first test case if Vasya skips the second part then he gets three gifts.In the second test case no matter what part of the verse Vasya skips.In the third test case Vasya can recite the whole verse.

package main

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

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

func main() {

    defer writer.Flush()

    var t int
    var a int

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

    for br:=0;br<t;br++ {
        var n, s int
        scanf("%d %d\n",&n,&s)
        var sum int64
        sum=0;
        var mx int
        mx=0
        var ans int
        ans=0
        var taj int
        taj=0
        var ind int
        ind=0
        for i:=1;i<=n;i++ {
            scanf("%d",&a);
            sum+=int64(a);
            if mx<a {
                mx=a
                ind=i
            }
            if sum<=int64(s) {
                ans=i
                taj=0
            }
            if sum-int64(mx)<=int64(s) {
                if ans<i-1 {
                    ans=i-1
                    taj=ind
                }
            }
        }
        scanf("\n")
        printf("%d\n",taj);
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscanf(in, "%d\n", &t)
	for tt := 0; tt < t; tt++ {
		n, s := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &s)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}
		fmt.Fscanf(in, "\n")
		curMax := 0
		ans := 0
		skip := false
		for i := 0; i < n; i++ {
			if !skip && a[i] > curMax {
				curMax = a[i]
				ans = i + 1
			}
			if s < a[i] && !skip {
				s += curMax
				skip = true
			}
			if s < a[i] {
				break
			}
			s -= a[i]
		}
		if skip {
			fmt.Fprintf(out, "%d\n", ans)
		} else {
			fmt.Fprintf(out, "%d\n", 0)
		}
	}
	return
}

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

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"sort"
	"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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

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

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		s := readll()
		_, a := readIntsll(n)
		println(solve(n, s, a) + 1)
	}
}

func solve(n int, s int64, a []int64) int {
	S := make([]int64, n+1)
	for i := range a {
		S[i+1] = S[i] + a[i]
	}

	calc := func(i, j int) (int, int64) {
		s := S[j]
		if i < j {
			s -= a[i]
			return j - 1, s
		}
		return j, s
	}

	var ans, maxv int
	for i, t := range S {
		if s < t {
			break
		}
		maxv = max(maxv, i)
	}
	ans = -1

	for i := 0; i <= n; i++ {
		k := sort.Search(n, func(j int) bool {
			_, t := calc(i, j+1)
			if s < t {
				return true
			}
			return false
		})
		v, _ := calc(i, k)
		//v, t := calc(i, k)
		if maxv < v {
			//eprintln("update", v, t)
			maxv = v
			if k <= i {
				ans = -1
			} else {
				ans = i
			}
		}
	}
	return ans
}

package main

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

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

func main() {

    defer writer.Flush()

    var t int
    var a int

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

    for br:=0;br<t;br++ {
        var n, s int
        scanf("%d %d\n",&n,&s)
        var sum int64
        sum=0;
        var mx int
        mx=0
        var ans int
        ans=0
        var taj int
        taj=0
        var ind int
        ind=0
        for i:=1;i<=n;i++ {
            scanf("%d",&a);
            sum+=int64(a);
            if mx<a {
                mx=a
                ind=i
            }
            if sum<=int64(s) {
                ans=i
                taj=0
            }
            if sum-int64(mx)<=int64(s) {
                if ans<i-1 {
                    ans=i-1
                    taj=ind
                }
            }
        }
        printf("%d\n",taj);
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, p, k := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &p, &k)
		a := make([]int, n)
		f := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}
		sort.Ints(a)
		fmt.Fscanf(in, "\n")
		f[0] = a[0]
		ans := 0
		if f[0] <= p {
			ans = 1
		}
		for i := 1; i < n; i++ {
			if (i + 1) < k {
				f[i] = f[i-1] + a[i]
			} else if (i + 1) == k {
				f[i] = a[i]
			} else {
				f[i] = f[i-k] + a[i]
			}
			if f[i] <= p {
				ans = i + 1
			}
		}
		// l := 0
		// r := n
		// for l < r {
		// 	mid := (l + r + 1) / 2
		// 	cost := 0
		// 	need := mid / k
		// 	if mid%k != 0 {
		// 		need++
		// 	}
		// 	cur := mid%k - 1
		// 	if cur < 0 {
		// 		cur += k
		// 	}
		// 	for i := 0; i < need; i++ {
		// 		cost += a[cur]
		// 		cur += k
		// 	}
		// 	if cost > p {
		// 		r = mid - 1
		// 	} else {
		// 		l = mid
		// 	}
		// }
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"sort"
	"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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

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

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		s := readi()
		_, a := readInts(n)
		println(solve(n, s, a))
	}
}

func solve(n, s int, a []int) int {
	sort.Ints(a)
	var sum int
	var i int
	for ; i < n && sum < s; i++ {
		sum += a[i]
	}
	if s < sum {
		i--
	}
	return n - i
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"sort"
	"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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

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

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		s := readi()
		_, a := readInts(n)
		println(solve(n, s, a) + 1)
	}
}

func solve(n, s int, a []int) int {
	S := make([]int, n+1)
	for i := range a {
		S[i+1] = S[i] + a[i]
	}

	calc := func(i, j int) (int, int) {
		s := S[j]
		if i < j {
			s -= a[i]
			return j - 1, s
		}
		return j, s
	}

	var ans, maxv int
	for i, t := range S {
		if s < t {
			break
		}
		maxv = max(maxv, i)
	}
	ans = -1

	for i := 0; i <= n; i++ {
		k := sort.Search(n, func(j int) bool {
			_, t := calc(i, j+1)
			if s < t {
				return true
			}
			return false
		})
		v, _ := calc(i, k)
		if maxv < v {
			//eprintln("update", v, t)
			maxv = v
			if k <= i {
				ans = -1
			} else {
				ans = i
			}
		}
	}
	return ans
}


It is the easy version of the problem. The only difference is that in this version $$$k = 3$$$.You are given a positive integer $$$n$$$. Find $$$k$$$ positive integers $$$a_1, a_2, \ldots, a_k$$$, such that:  $$$a_1 + a_2 + \ldots + a_k = n$$$  $$$LCM(a_1, a_2, \ldots, a_k) \le \frac{n}{2}$$$ Here $$$LCM$$$ is the least common multiple of numbers $$$a_1, a_2, \ldots, a_k$$$.We can show that for given constraints the answer always exists.

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$  — the number of test cases. The only line of each test case contains two integers $$$n$$$, $$$k$$$ ($$$3 \le n \le 10^9$$$, $$$k = 3$$$).

For each test case print $$$k$$$ positive integers $$$a_1, a_2, \ldots, a_k$$$, for which all conditions are satisfied.

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, k int
		fmt.Fscan(in, &n, &k)

		var a, b, c int
		if n%2 == 0 {
			if n/2%2 == 0 {
				a, b, c = n/2, n/4, n/4
			} else {
				a, b, c = 2, (n-2)/2, (n-2)/2
			}
		} else {
			a, b, c = 1, n/2, n/2
		}
		fmt.Fprintln(out, a, b, c)
	}
}

package main

import "fmt"

func main() {
	var T, n, k int
	fmt.Scanf("%d\n", &T)
	for i := 1; i <= T; i++ {
		fmt.Scanf("%d%d\n", &n, &k)
		if n%2 == 1 {
			fmt.Printf("%d %d %d\n", 1, n/2, n/2)
		} else {
			if (n/2)%2 == 0 {
				fmt.Printf("%d %d %d\n", n/4, n/4, n/2)
			} else {
				fmt.Printf("%d %d %d\n", 2, n/2-1, n/2-1)
			}
		}
	}
}

package main

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

/*
11
3 3
4 3
5 3
6 3
7 3
8 3
9 3
10 3
11 3
12 3
13 3
---
1 1 1	lcm=1
2 1 1	lcm=2
2 2 1	lcm=2
2 2 2	lcm=2
3 3 1	lcm=4
4 2 2	lcm=4
3 3 3	lcm=3
4 4 2	lcm=4
5 5 1	lcm=5
4 4 4	lcm=4
6 6 1	lcm=6
*/

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

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

	for ; t > 0; t-- {
		var n, k int
		scanf("%d %d\n", &n, &k)

		switch {
		case n%2 != 0:
			fmt.Fprintln(writer, n/2, n/2, 1)
		case n%4 == 0:
			fmt.Fprintln(writer, n/4, n/4, n/2)
		case n%4 != 0:
			fmt.Fprintln(writer, n/2-1, n/2-1, 2)
		}
	}
}

const maxUint = ^uint(0)

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int64) int64 {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int
		Fscan(in, &n, &k)

		if n & 0x1 == 1 {
			Fprintln(out, 1, n / 2, n / 2)
		} else {
			if n & 3 == 0 {
				Fprintln(out, n / 2, n / 4, n / 4)
			} else {
				Fprintln(out, n / 2 - 1, n / 2 - 1, 2)
			}
		}
	}
}

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

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

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

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

package main

import "fmt"

func main() {
	var t, n, k int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &k)
		if n%2 == 1 {
			fmt.Println(1, n/2, n/2)
		} else {
			if n%4 == 0 {
				fmt.Println(n/4, n/4, n/2)
			} else {
				fmt.Println(2, (n-2)/2, (n-2)/2)
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)
	for i := 1; i <= t; i++ {
		var n, k int
		fmt.Scan(&n, &k)
		if n%2 == 1 {
			fmt.Println(1, (n-1)/2, (n-1)/2)
		} else {
			if n%4 == 0 {
				fmt.Println(n/2, n/4, n/4)
			} else {
				fmt.Println(2, (n-2)/2, (n-2)/2)
			}
		}
	}
}

package main

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

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

func solver(n int64) (a, b, c int64) {
	temp := n
	mul := int64(1)
	for temp&1 == 0 {
		temp >>= 1
		mul <<= 1
	}
	if temp == 1 {
		// if n is a power of 2
		return n >> 1, n >> 2, n >> 2
	}
	half := temp >> 1
	return mul, mul * half, mul * half
}

func main() {
	defer writer.Flush()
	var testcases int
	fmt.Fscan(reader, &testcases)

	var n, k, a, b, c int64
	for testcase := 0; testcase < testcases; testcase++ {
		fmt.Fscan(reader, &n, &k)
		a, b, c = solver(n)
		fmt.Fprintln(writer, a, b, c)
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

func MKO(x, y int) int {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int64
		var k int
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &k)

		// STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)

		if n%3 == 0 {
			j := int(n / 3)
			fmt.Println(j)
			fmt.Println(j)
			fmt.Println(j)

		} else {
			if n%2 == 1 {
				m := int(n / 2)
				fmt.Println(m)
				fmt.Println(m)
				fmt.Println(1)

			} else {
				m := int(n / 2)
				if m%2 == 1 {
					fmt.Println(m - 1)
					fmt.Println(m - 1)
					fmt.Println(2)
				} else {
					j := int(m / 2)
					fmt.Println(m)
					fmt.Println(j)
					fmt.Println(j)

				}
			}
		}

	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n, k int
		Fscan(in, &n, &k)
		if n&1 > 0 {
			Fprintln(out, 1, n/2, n/2)
		} else if n%4 == 0 {
			Fprintln(out, n/2, n/4, n/4)
		} else {
			n -= 2
			Fprintln(out, 2, n/2, n/2)
		}
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

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, k int
		fmt.Fscan(in, &n, &k)

		var a, b, c int
		if n%2 == 0 {
			a, b, c = 2, (n-2)/2, (n-2)/2
		} else {
			a, b, c = 1, n/2, n/2
		}
		fmt.Fprintln(out, a, b, c)
	}
}

package main

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

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

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

		var a, b, c int
		if n%2 == 0 {
			a, b = n/2, n/4
			c = n - a - b
		} else {
			a, b, c = 1, n/2, n/2
		}
		fmt.Fprintln(out, a, b, c)
	}
}

package main

import "fmt"

func main() {
	var T, n, k int
	fmt.Scanf("%d", &T)
	for i := 1; i <= T; i++ {
		fmt.Scanf("%d%d", &n, &k)
		if n%2 == 1 {
			fmt.Printf("%d %d %d", 1, n/2, n/2)
		} else {
			if (n/2)%2 == 0 {
				fmt.Printf("%d %d %d", n/4, n/4, n/2)
			} else {
				fmt.Printf("%d %d %d", 2, n/2-1, n/2-1)
			}
		}
		fmt.Println()
	}
}