Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the tournament.It is known that in a match between two players, the one whose skill is greater will win. The skill of the $$$i$$$-th player is equal to $$$s_i$$$ and all skill levels are pairwise different (i. e. there are no two identical values in the array $$$s$$$).The tournament is called fair if the two players with the highest skills meet in the finals.Determine whether the given tournament is fair.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. A single line of test case contains four integers $$$s_1, s_2, s_3, s_4$$$ ($$$1 \le s_i \le 100$$$) — skill of the players. It is guaranteed that all the numbers in the array are different.

For each testcase, output YES if the tournament is fair, or NO otherwise.

NoteConsider the example:  in the first test case, players $$$2$$$ and $$$3$$$ with skills $$$7$$$ and $$$9$$$ advance to the finals;  in the second test case, players $$$2$$$ and $$$4$$$ with skills $$$5$$$ and $$$9$$$ advance to the finals. The player with skill $$$6$$$ does not advance, but the player with skill $$$5$$$ advances to the finals, so the tournament is not fair;  in the third test case, players $$$1$$$ and $$$3$$$ with skills $$$5$$$ and $$$8$$$ advance to the finals;  in the fourth test case, players $$$1$$$ and $$$3$$$ with skills $$$6$$$ and $$$3$$$ advance to the finals. The player with skill $$$5$$$ does not advance, but the player with skill $$$3$$$ advances to the finals, so the tournament is not fair.

package main

import (
    "fmt"
)

func main() {
    var s [4]int
    var tc int

    mapping := [4]int{1, 0, 3, 2}

    fmt.Scanf("%d\n", &tc)

    for ; tc != 0; tc-- {
	for i := 0; i < 4; i++ {
	    fmt.Scanf("%d", &s[i])
	}
	fmt.Scanf("\n")
	//fmt.Println(s)

	var imax1, imax2 int

	if s[0] > s[1] {
	    imax1 = 0
	} else {
	    imax1 = 1
	}

	if s[2] > s[3] {
	    imax2 = 2
	} else {
	    imax2 = 3
	}

	var fair bool

	if s[imax1] > s[imax2] {
	    fair = s[mapping[imax1]] < s[imax2]
	    //fmt.Println("first:", mapping[imax1], s[mapping[imax1]], s[imax2])
	} else {
	    fair = s[mapping[imax2]] < s[imax1]
	    //fmt.Println("second:", mapping[imax2], s[mapping[imax2]], s[imax1])
	}

	if fair {
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
    }
}

package main

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

func minimum(a int32, b int32) int32 {
	if a < b {
		return a
	} else {
		return b
	}
}

func maximum(a int32, b int32) int32 {
	if a > b {
		return a
	} else {
		return b
	}
}

func solve(x int32, y int32, a int32, b int32) string {
	minLeft := minimum(x, y)
	maxLeft := maximum(x, y)
	minRight := minimum(a, b)
	maxRight := maximum(a, b)
	if maxLeft > minRight && maxRight > minLeft {
		return "YES"
	} else {
		return "NO"
	}
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		m := int32(0)
		a := int32(0)
		b := int32(0)
		fmt.Fscanf(in, "%d %d %d %d\n", &n, &m, &a, &b)
		fmt.Fprintf(out, "%s\n", solve(n, m, a, b))
		tt--
	}
	out.Flush()
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (isPrefix bool = true
		err error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln),err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)

	for i:=0; i<k; i++ {
		pln,_ := Readln(reader)
		sln := strings.Split(pln," ")
		ln :=  make([] int, 4)
		for j := range sln {
			ln[j], _ = strconv.Atoi(sln[j])
		}
		win1 := 0
		if ln[0] > ln[1] {
			win1 = ln[0]
		} else {
			win1 = ln[1]
		}
		win2 := 0
		if ln[2] > ln[3] {
			win2 = ln[2]
		} else {
			win2 = ln[3]
		}
		sort.Ints(ln)
		if ln[3]+ln[2] != win1+win2 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")

		}

	}

}

package main

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

)

func run(r io.Reader ,w io.Writer){

	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	solve := func(){

		/*var n int

		fmt.Fscan(in , &n)*/

		scorepoints := make([]int , 4)
		var Fisrtmax int
		var FirstMin int
		var Nextmin int
		var Nextmax int

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

		fmt.Fscan(in , &scorepoints[i])

			if i == 1 {

			Fisrtmax = max(scorepoints[i-1], scorepoints[i])
			FirstMin = min(scorepoints[i-1], scorepoints[i])

		}

			if  i == len(scorepoints)-1 {
				Nextmax = max(scorepoints[i-1] , scorepoints[i])
				Nextmin = min(scorepoints[i-1] , scorepoints[i])

		//fmt.Println("maxNum",Nextmax, "Nextmin",Nextmin,"Fisrtmax",Fisrtmax,"FirstMin",FirstMin)
				if Nextmin > Fisrtmax ||  FirstMin > Nextmax {
					fmt.Fprintln(out,"NO")
					return
				}else{
					fmt.Fprintln(out,"YES")
					return
				}
			}

		}

	}

	T := 1

	fmt.Fscan(in ,&T)

	for o := 0 ; o < T ; o++{
		solve()
	}

}

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 main(){
	run(os.Stdin , os.Stdout)
}

package main

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

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

func maxes(arr [4]int) (int, int) {
	var max1, max2 int
	if arr[0] > arr[1] {
		max1, max2 = arr[0], arr[1]
	} else {
		max2, max1 = arr[0], arr[1]
	}
	for _, v := range arr[1:] {
		if v < max1 && v > max2 {
			max2 = v
		}
		if v > max1 {
			max2 = max1
			max1 = v

		}
	}

	return max1, max2
}

func main() {
	defer writer.Flush()
	var n, max, max2, win1, win2 int
	var arr [4]int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d %d %d %d\n", &arr[0], &arr[1], &arr[2], &arr[3])
		max, max2 = maxes(arr)
// 		fmt.Fprintln(writer, max, max2)
		win1, win2 = arr[1], arr[2]
		if arr[0] > arr[1] {
			win1 = arr[0]
		}
		if arr[3] > arr[2] {
			win2 = arr[3]
		}
		if win1 > win2 {
			if max != win1 {
				fmt.Fprintln(writer, "NO")
				continue
			}
			if max2 != win2 {
				fmt.Fprintln(writer, "NO")
				continue
			}

		}
		if win1 < win2 {
			if max != win2 {
				fmt.Fprintln(writer, "NO")
				continue
			}
			if max2 != win1 {
				fmt.Fprintln(writer, "NO")
				continue
			}

		}
		fmt.Fprintln(writer, "YES")
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var x, m, sm, im, ism int
		for i := 1; i <= 4; i++ {
			fmt.Scan(&x)
			if x > m {
				sm = m
				ism = im
				m = x
				im = i
			} else if x > sm {
				sm = x
				ism = i
			}
		}
		//fmt.Println(m, im, sm, ism)
		if (im == 3 || im == 4) && (ism == 1 || ism == 2) {
			fmt.Println("YES")
		} else if (im == 1 || im == 2) && (ism == 3 || ism == 4) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	for i:=0;i<n;i++{
		var a,b,c,d int
		fmt.Scan(&a,&b,&c,&d)
		if a > b {
			if b > c && b > d {
				fmt.Println("NO")
				continue
			}
			if a < c && a < d {
				fmt.Println("NO")
				continue
			}
		} else {
			if a > c && a > d {
				fmt.Println("NO")
				continue
			}
			if b < c && b < d {
				fmt.Println("NO")
				continue
			}
		}
		fmt.Println("YES")
	}
}

// 1535A. Fair Playoff
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		a := make([]int, 4)
		m := make(map[int]int)
		for i := 0; i < 4; i++ {
			fmt.Fscan(reader, &a[i])
			m[a[i]] = i
		}
		sort.Ints(a)
		i, j := m[a[2]], m[a[3]]
		if i < 2 && j >= 2 || j < 2 && i >= 2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

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

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

	test := parseInt(getString(reader))
	for ; test > 0; test-- {
		S := getIntln(reader)
		a, b, c, d := max(S[0], S[1]), min(S[0], S[1]), max(S[2], S[3]), min(S[2], S[3])
		if a >= d && c >= b {
			writer.WriteString("YES\n")
		} else {
			writer.WriteString("NO\n")
		}
	}
	writer.Flush()
}

func max(a ...int) int {
	var res = a[0]
	for _, v := range a {
		if v > res {
			res = v
		}
	}
	return res
}

func min(a ...int) int {
	var res = a[0]
	for _, v := range a {
		if v < res {
			res = v
		}
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int {
	b := strings.Split(getString(in), " ")
	res := make([]int, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

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 s1, s2, s3, s4 int
		fmt.Fscan(in, &s1, &s2, &s3, &s4)

		var f bool
		if s1 > s2 && (s1 > s3 || s1 > s4) && (s2 < s3 || s2 < s4) {
			f = true
		} else if s2 > s1 && (s2 > s3 || s2 > s4) && (s1 < s3 || s1 < s4) {
			f = true
		}

		if !f {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

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

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

func solve(s []int) string {
	max1, min1 := maxmin(s[0], s[1])
	max2, min2 := maxmin(s[2], s[3])
	if min1 > max2 || min2 > max1 {
		return "NO"
	}
	return "YES"
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		s := make([]int, 4)
		fmt.Fscan(reader, &s[0], &s[1], &s[2], &s[3])
		fmt.Println(solve(s))
	}
}

package main

import "fmt"

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

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

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

	for t := 0; t < T; t++ {
		var arr [4]int

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

		f1 := max(arr[0], arr[1])
		l1 := min(arr[0], arr[1])

		f2 := max(arr[2], arr[3])
		l2 := min(arr[2], arr[3])

		if f1 > l2 && f2 > l1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

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

	for i := 0; i < t;i ++ {
		var a, b, c, d float64
		fmt.Scanln(&a, &b, &c, &d)

		abMax := math.Max(a, b)
		abMin := math.Min(a, b)

		cdMax := math.Max(c, d)
		cdMin := math.Min(c, d)

		if abMax > cdMin && cdMax > abMin {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

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

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

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

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

/**
 Run solve the problem CF1535A
 Date: 11/06/21
 User: pepradere
 URL: https://codeforces.com/problemset/problem/1535/A
 Problem: CF1535A
**/
func (in *CF1535A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		s1, s2, s3, s4 := in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt()

		arr := []int{s1, s2, s3, s4}
		sort.Ints(arr)

		ans := "YES"
		if (arr[3] == s1 && arr[2] == s2) || (arr[3] == s2 && arr[2] == s1) {
			ans = "NO"
		} else if (arr[3] == s3 && arr[2] == s4) || (arr[3] == s4 && arr[2] == s3) {
			ans = "NO"
		}

		fmt.Println(ans)
	}
}

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

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

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])
// }

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

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

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

func MAX(x, y int64) int64 {
	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 GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

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

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func LITTLE(x int) int64 {
	var answer int64
	answer = answer + int64((x*x*x*x-x*x)/4) + int64(x*x*(x-1)*(x-1)/8) - int64(x*(x-1)*(x+x+1)*(x+x-1)/12)
	return answer
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		ARRAY := make([]int, 5)

		for i := 1; i < 5; i++ {
			fmt.Fscan(input, &ARRAY[i])

		}

		var biggest, bigind int
		var Second, Snd int

		for i := 1; i < 5; i++ {
			if ARRAY[i] > biggest {
				biggest = ARRAY[i]
				bigind = i
			}
		}
		for i := 1; i < 5; i++ {
			if ARRAY[i] > Second && ARRAY[i] < biggest {
				Second = ARRAY[i]
				Snd = i
			}
		}
		if Snd+bigind == 3 || Snd+bigind == 7 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")

		}

	}

}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"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) {
		type pair struct{ v, i int }
		a := make([]pair, 4)
		for i := range a {
			Fscan(in, &a[i].v)
			a[i].i = i
		}
		sort.Slice(a, func(i, j int) bool { return a[i].v < a[j].v })
		x := 1<<a[0].i | 1<<a[1].i
		if x == 0b11 || x == 0b1100 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}

	T := 1
	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 (
    "fmt"
)

func main() {
    var s [4]int
    var tc int

    mapping := [4]int{1, 0, 3, 2}

    fmt.Scanf("%d", &tc)

    for ; tc != 0; tc-- {
	for i := 0; i < 4; i++ {
	    fmt.Scanf("%d", &s[i])
	}

	var imax1, imax2 int

	if s[0] > s[1] {
	    imax1 = 0
	} else {
	    imax1 = 1
	}

	if s[2] > s[3] {
	    imax2 = 2
	} else {
	    imax2 = 3
	}

	var fair bool

	if s[imax1] > s[imax2] {
	    fair = s[mapping[imax1]] < s[imax2]
	} else {
	    fair = s[mapping[imax2]] < s[imax1]
	}

	if fair {
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
    }
}

package main

import (
    "fmt"
)

func main() {
    var s [4]int
    var tc int

    mapping := [4]int{1, 0, 3, 2}

    //fmt.Scanf("%d\n", &tc)

    for ; tc != 0; tc-- {
	for i := 0; i < 4; i++ {
	    fmt.Scanf("%d", &s[i])
	}
	fmt.Scanf("\n")
	//fmt.Println(s)

	var imax1, imax2 int

	if s[0] > s[1] {
	    imax1 = 0
	} else {
	    imax1 = 1
	}

	if s[2] > s[3] {
	    imax2 = 2
	} else {
	    imax2 = 3
	}

	var fair bool

	if s[imax1] > s[imax2] {
	    fair = s[mapping[imax1]] < s[imax2]
	    //fmt.Println("first:", mapping[imax1], s[mapping[imax1]], s[imax2])
	} else {
	    fair = s[mapping[imax2]] < s[imax1]
	    //fmt.Println("second:", mapping[imax2], s[mapping[imax2]], s[imax1])
	}

	if fair {
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
    }
}

package main

import (
    "fmt"
)

func main() {
    var s [4]int
    var tc int

    mapping := [4]int{1, 0, 3, 2}

    fmt.Scanf("%d", &tc)

    for ; tc != 0; tc-- {
	for i := 0; i < 4; i++ {
	    fmt.Scanf("%d", &s[i])
	}

	fmt.Println(s)

	var imax1, imax2 int

	if s[0] > s[1] {
	    imax1 = 0
	} else {
	    imax1 = 1
	}

	if s[2] > s[3] {
	    imax2 = 2
	} else {
	    imax2 = 3
	}

	var fair bool

	if s[imax1] > s[imax2] {
	    fair = s[mapping[imax1]] < s[imax2]
	} else {
	    fair = s[mapping[imax2]] < s[imax1]
	}

	if fair {
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
    }
}

package main

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

func isNotFair(x int32, a int32, b int32) bool {
	return (x < a && x < b) || (x > a && x > b)
}

func solve(x int32, y int32, a int32, b int32) string {
	if x > y && isNotFair(x, a, b) {
		return "NO"
	}
	if y > x && isNotFair(y, a, b) {
		return "NO"
	}
	return "YES"
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		m := int32(0)
		a := int32(0)
		b := int32(0)
		fmt.Fscanf(in, "%d %d %d %d\n", &n, &m, &a, &b)
		fmt.Fprintf(out, "%s\n", solve(n, m, a, b))
		tt--
	}
	out.Flush()
}

package main

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

func isNotFair(x int32, a int32, b int32) bool {
	return (x < a && x < b) || (x > a && x > b)
}

func solve(x int32, y int32, a int32, b int32) string {
	if x > y && isNotFair(x, a, b) {
		return "NO"
	}
	if y > x && isNotFair(y, a, b) {
		return "NO"
	}
	return "YES"
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		m := int32(0)
		a := int32(0)
		b := int32(0)
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		fmt.Fprintf(out, "%s\n", solve(n, m, a, b))
		tt--
	}
	out.Flush()
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (isPrefix bool = true
		err error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln),err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)

	for i:=0; i<k; i++ {
		pln,_ := Readln(reader)
		sln := strings.Split(pln," ")
		ln :=  make([] int, k)
		for j := range sln {
			ln[j], _ = strconv.Atoi(sln[j])
		}
		win1 := 0
		if ln[0] > ln[1] {
			win1 = ln[0]
		} else {
			win1 = ln[1]
		}
		win2 := 0
		if ln[2] > ln[3] {
			win2 = ln[2]
		} else {
			win2 = ln[3]
		}
		sort.Ints(ln)
		if ln[3]+ln[2] != win1+win2 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")

		}

	}

}

package main

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

)

func run(r io.Reader ,w io.Writer){

	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	solve := func(){

		/*var n int

		fmt.Fscan(in , &n)*/

		scorepoints := make([]int , 4)
		Fisrtmax := -1
		var FirstMin int
		var Nextmin int
		var Nextmax int

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

		fmt.Fscan(in , &scorepoints[i])

			if i < 2 {

			Fisrtmax = max(Fisrtmax, scorepoints[i])

		}
			FirstMin = min(Fisrtmax , scorepoints[1])

			if  i == len(scorepoints)-1 {
				Nextmax = max(scorepoints[i-1] , scorepoints[i])
				Nextmin = min(scorepoints[i-1] , scorepoints[i])

		//fmt.Println("maxNum",Nextmax, "Nextmin",Nextmin,"Fisrtmax",Fisrtmax,"FirstMin",FirstMin)
				if Nextmin > Fisrtmax ||  FirstMin > Nextmax {
					fmt.Fprintln(out,"NO")
					return
				}else{
					fmt.Fprintln(out,"YES")
					return
				}
			}

		}

	}

	T := 1

	fmt.Fscan(in ,&T)

	for o := 0 ; o < T ; o++{
		solve()
	}

}

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 main(){
	run(os.Stdin , os.Stdout)
}

package main

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

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

func maxes(arr [4]int) (int, int) {
	var max1, max2 int
	if arr[0] > arr[1] {
		max1, max2 = arr[0], arr[1]
	} else {
		max2, max1 = arr[0], arr[1]
	}
	for _, v := range arr[1:] {
		if v < max1 && v > max2 {
			max2 = v
		}
		if v > max1 {
			max2 = max1
			max1 = v

		}
	}

	return max1, max2
}

func main() {
	defer writer.Flush()
	var n, max, max2, win1, win2 int
	var arr [4]int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d %d %d %d\n", &arr[0], &arr[1], &arr[2], &arr[3])
		max, max2 = maxes(arr)
		fmt.Fprintln(writer, max, max2)
		win1, win2 = arr[1], arr[2]
		if arr[0] > arr[1] {
			win1 = arr[0]
		}
		if arr[3] > arr[2] {
			win2 = arr[3]
		}
		if win1 > win2 {
			if max != win1 {
				fmt.Fprintln(writer, "NO")
				continue
			}
			if max2 != win2 {
				fmt.Fprintln(writer, "NO")
				continue
			}

		}
		if win1 < win2 {
			if max != win2 {
				fmt.Fprintln(writer, "NO")
				continue
			}
			if max2 != win1 {
				fmt.Fprintln(writer, "NO")
				continue
			}

		}
		fmt.Fprintln(writer, "YES")
	}
}


Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $$$i$$$-th page contains some mystery that will be explained on page $$$a_i$$$ ($$$a_i \ge i$$$).Ivan wants to read the whole book. Each day, he reads the first page he didn't read earlier, and continues to read the following pages one by one, until all the mysteries he read about are explained and clear to him (Ivan stops if there does not exist any page $$$i$$$ such that Ivan already has read it, but hasn't read page $$$a_i$$$). After that, he closes the book and continues to read it on the following day from the next page.How many days will it take to read the whole book?

The first line contains single integer $$$n$$$ ($$$1 \le n \le 10^4$$$) — the number of pages in the book. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$i \le a_i \le n$$$), where $$$a_i$$$ is the number of page which contains the explanation of the mystery on page $$$i$$$.

Print one integer — the number of days it will take to read the whole book.

NoteExplanation of the example test:During the first day Ivan will read only the first page. During the second day Ivan will read pages number $$$2$$$ and $$$3$$$. During the third day — pages $$$4$$$-$$$8$$$. During the fourth (and the last) day Ivan will read remaining page number $$$9$$$.

package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    ans := 0
    cur := 1

    for i := 1; i <= n; i ++ {
        var a int
        fmt.Scan(&a)
        cur = max(a, cur)
        if cur <= i {
            ans++
            cur = i + 1
        }
    }

    fmt.Print(ans)
}

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

    return y
}

package main

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

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

	var n int

	fmt.Fscanf(buf, "%d\n", &n)
	mat := make([]int,n+1)

	var ans int64 = 0
	for i:=0;i < n;i++{
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	var p int=0
	for i:=0;i < n;i++{
		if mat[i] > p{
			p = mat[i]
		}
		if p <=i+1{
			ans++
			p = i+1
		//	fmt.Printf("%d\n",i+1)
		}

	}
	fmt.Printf("%d\n", ans)

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,x int
	fmt.Fscan(in,&n)
	a := make([]int,n + 2)
	for i := 1 ;i  <= n;i++{
		fmt.Fscan(in,&x)
		a[i] = x
	}
	ans := 0
	for i := 1 ; i <= n;i++{
		mx := a[i]
		ans ++
		for mx > i{
			i ++
			mx = max(mx,a[i])
		}
	}
	fmt.Fprint(out,ans)

}

func max(i int, i2 int) int {
	if(i < i2){
		return i2
	}else{
		return i
	}
}
func min(i int , i2 int)  int {
	if(i < i2){
		return i
	}else{
		return i2
	}

}

package main

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

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

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

// task A
func main() {
	defer writer.Flush()

	var n string
	scanf("%s\n", &n)

	size, _ := strconv.Atoi(n)

	var val string
	var page, days, max int
	max = 1;
	days = 0;
	page = 0;

	for (page < size) {
		scanf("%s ", &val)
		page++;
		num, _ := strconv.Atoi(val)
		if (num > max) {
			max = num;
		} else if (page == max) {
			max++;
			days++;
		}
	}
	printf("%d\n", days)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	ans := 0
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
		a[i]--
	}
	i := 0
	//	fmt.Println(n)
	for i < n {
		ans++
		max := a[i]
		for i < max && i < n {
			//fmt.Println(i, max)
			i++
			if a[i] > max {
				max = a[i]
			}
		}
		i++
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

package main

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

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

	fmt.Fscan(reader, &n)
	var mx, count int
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(reader, &x)
		mx = max(mx, x)

		if mx == i+1 {
			count++
		}
	}

	fmt.Println(count)
}

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

package main

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

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

	fmt.Fscan(reader, &n)

	sherlock := make(map[int]bool)

	var count int
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(reader, &x)
		sherlock[x] = true
		delete(sherlock, i+1)
		if len(sherlock) == 0 {
			count++
		}
	}

	fmt.Println(count)
}

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

package main

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

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

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

// task A
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n string
	scanf("%s\n", &n)

	size, _ := strconv.Atoi(n)
	a := make([]int, size)

	var val string

	for i := 0;  i < size; i++ {
		scanf("%s ", &val)
		a[i], _ = strconv.Atoi(val)
	}
	///////////
   var numOfDays, index int
   size2 := size
   numOfDays = 1

   for {
		if (a[index] > index + 1) {
			size2 = size - a[index]
		} else {
			numOfDays += 1
		}
	   index += 1
		if (size2 == 0 || index >= size) {
			break
		}
	}
	print(numOfDays - 2)
}

package main

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

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

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

// task A
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n string
	scanf("%s\n", &n)

	size, _ := strconv.Atoi(n)
	a := make([]int, size)

	var val string

	for i := 0;  i < size; i++ {
		scanf("%s ", &val)
		a[i], _ = strconv.Atoi(val)
	}
	///////////
   var numOfDays, curMax, index int
	curMax = a[0]
   size2 := size
   numOfDays = 1

   for {
		if (a[index] <= index + 1) {
			if (curMax > index) {
				index = curMax
			} else {
				numOfDays += 1
				index += 1
			}
		} else {
			if (curMax < a[index] ) {
				curMax = a[index]
			}
			index += 1
		}
		if (size2 == 0 || index >= size) {
			break
		}
	}
	print(numOfDays+2)
}

package main

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

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

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

// task A
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n string
	scanf("%s\n", &n)

	size, _ := strconv.Atoi(n)
	a := make([]int, size)

	var val string

	for i := 0;  i < size; i++ {
		scanf("%s ", &val)
		a[i], _ = strconv.Atoi(val)
	}
	///////////
   var numOfDays, curMax, index int
	curMax = a[0]
   size2 := size
   numOfDays = 1

   for {
		if (a[index] <= index + 1) {
			if (curMax > index) {
				index = curMax
			} else {
				numOfDays += 1
				index += 1
			}
		} else {
			if (curMax < a[index] ) {
				curMax = a[index]
			}
			index += 1
		}
		if (size2 == 0 || index >= size) {
			break
		}
	}
	printf("%d\n",numOfDays+1)
}

package main

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

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

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

// task A
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n string
	scanf("%s\n", &n)

	size, _ := strconv.Atoi(n)
	a := make([]int, size)

	var val string

	for i := 0;  i < size; i++ {
		scanf("%s ", &val)
		a[i], _ = strconv.Atoi(val)
	}
	///////////
   var numOfDays, curMax, index int
	curMax = a[0]
   size2 := size
   numOfDays = 1

   for {
		if (a[index] <= index + 1) {
			if (curMax > index) {
				index = curMax
			} else {
				numOfDays += 1
				index += 1
			}
		} else {
			if (curMax < a[index] ) {
				curMax = a[index]
			}
			index += 1
		}
		if (size2 == 0 || index >= size) {
			break
		}
	}
	print(numOfDays+1)
}


Alice and Bob play ping-pong with simplified rules.During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't make a return.The one who doesn't make a return loses this play. The winner of the play commences the next play. Alice starts the first play.Alice has $$$x$$$ stamina and Bob has $$$y$$$. To hit the ball (while serving or returning) each player spends $$$1$$$ stamina, so if they don't have any stamina, they can't return the ball (and lose the play) or can't serve the ball (in this case, the other player serves the ball instead). If both players run out of stamina, the game is over.Sometimes, it's strategically optimal not to return the ball, lose the current play, but save the stamina. On the contrary, when the server commences a play, they have to hit the ball, if they have some stamina left.Both Alice and Bob play optimally and want to, firstly, maximize their number of wins and, secondly, minimize the number of wins of their opponent.Calculate the resulting number of Alice's and Bob's wins.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first and only line of each test case contains two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, y \le 10^6$$$) — Alice's and Bob's initial stamina.

For each test case, print two integers — the resulting number of Alice's and Bob's wins, if both of them play optimally.

NoteIn the first test case, Alice serves the ball and spends $$$1$$$ stamina. Then Bob returns the ball and also spends $$$1$$$ stamina. Alice can't return the ball since she has no stamina left and loses the play. Both of them ran out of stamina, so the game is over with $$$0$$$ Alice's wins and $$$1$$$ Bob's wins.In the second test case, Alice serves the ball and spends $$$1$$$ stamina. Bob decides not to return the ball — he loses the play but saves stamina. Alice, as the winner of the last play, serves the ball in the next play and spends $$$1$$$ more stamina. This time, Bob returns the ball and spends $$$1$$$ stamina. Alice doesn't have any stamina left, so she can't return the ball and loses the play. Both of them ran out of stamina, so the game is over with $$$1$$$ Alice's and $$$1$$$ Bob's win.In the third test case, Alice serves the ball and spends $$$1$$$ stamina. Bob returns the ball and spends $$$1$$$ stamina. Alice ran out of stamina, so she can't return the ball and loses the play. Bob, as a winner, serves the ball in the next $$$6$$$ plays. Each time Alice can't return the ball and loses each play. The game is over with $$$0$$$ Alice's and $$$7$$$ Bob's wins.

/*
URL:
https://codeforces.com/contest/1455/problem/C
*/

package main

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

var (
	t int

	x, y int
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		x, y = readi2()

		solve()
	}
}

func solve() {
	printf("%d %d\n", x-1, y)
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

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

	return a * pow(a, e-1)
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

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

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

	var t, x, y int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &x, &y)

		fmt.Printf("%d %d\n", x-1, y)
	}
}


You are given a string $$$t$$$ consisting of $$$n$$$ lowercase Latin letters and an integer number $$$k$$$.Let's define a substring of some string $$$s$$$ with indices from $$$l$$$ to $$$r$$$ as $$$s[l \dots r]$$$.Your task is to construct such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ positions $$$i$$$ such that $$$s[i \dots i + n - 1] = t$$$. In other words, your task is to construct such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ substrings of $$$s$$$ equal to $$$t$$$.It is guaranteed that the answer is always unique.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 50$$$) — the length of the string $$$t$$$ and the number of substrings. The second line of the input contains the string $$$t$$$ consisting of exactly $$$n$$$ lowercase Latin letters.

Print such string $$$s$$$ of minimum possible length that there are exactly $$$k$$$ substrings of $$$s$$$ equal to $$$t$$$. It is guaranteed that the answer is always unique.

// You can edit this code!
// Click here and start typing.
package main

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

var nxt [55]int

func getNext(s string, n int) {
	nxt[0] = -1
	j := -1
	for i := 0; i < n; {
		if j == -1 || s[i] == s[j] {
			i++
			j++
			nxt[i] = j
		} else {
			j = nxt[j]
		}
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var n, k int
	var s string
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n, &k)
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &s)

	getNext(s, n)
	p := n - nxt[n]

	fmt.Println(s + strings.Repeat(s[n-p:n], k-1))
}

package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k)
	fmt.Scan(&s)
	id := 0
	for i := 1; i < n; i++ {
		ns := s[i:n] + s[n-i:n]
		if s == ns {
			id = n - i
			break
		}
	}
	for i := 1; i < k; i++ {
		s += s[id:n]
	}
	fmt.Println(s)
}

package main

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

func main()  {

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

	var n, k int
	fmt.Fscan(in, &n, &k)

	var t string
	fmt.Fscan(in, &t)

	s := t
	for i := 0; i < k - 1; i++ {
		p := false
		for j := 1; j < len(t); j++ {
			if s[len(s) - len(t[:len(t) - j]):] == t[:len(t) - j] {
				s += t[len(t) - j:]
				p = true
				break
			}
		}
		if !p {
			s += t
		}
	}

	fmt.Fprintln(out, s)

}

package main

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

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

	S := sc.NextLine()
	if A == 1 {
		fmt.Println(S)
		return
	}

	last := N
	for i := 1; i < N; i++ {
		flag := true
		for j := 0; i+j < N; j++ {
			if S[i+j] != S[j] {
				flag = false
				break
			}
		}
		if flag {
			last = i
			break
		}
	}

	out := S
	for i := 1; i < A; i++ {
		out += S[N-last:]
	}
	fmt.Println(out)

}

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 (
	"fmt"
)

func main() {
	var n,k int
	var s string
	fmt.Scan(&n,&k,&s)
	var j int
	l := len(s)
	for i:=0;i<n-1;i++{

		if s[:i+1] == s[l-i-1:] {
			j = i + 1
		}
	}
	var r string
	r += s

	for i := 0;i< k-1;i++{
		r += s[j:]
	}

	fmt.Println(r)
}

package main

import "fmt"

func main() {
	var str string
	var count, k int
	fmt.Scan(&count, &k, &str)
	addstr := str
	for i := 0; i < len(str)-1; i++{

		if str == str[1+i:] + str[len(str)-1-i:] {
			addstr = str[len(str)-1-i:]
			break
		}
	}
	for i:=0; i < k-1; i++{
		str += addstr
	}
	fmt.Println(str)

}

package main

import "fmt"

func main() {
	var str string
	var count, k int
	fmt.Scan(&count, &k, &str)
	addstr := str
	for i := 0; i < count-1; i++{

		if str == str[1+i:] + str[count-1-i:] {
			addstr = str[count-1-i:]
			break
		}
	}
	for i:=0; i < k-1; i++{
		str += addstr
	}
	fmt.Println(str)

}

package main

import (
	"fmt"
)

func main() {
	var n,k int
	var s string
	fmt.Scan(&n,&k,&s)
	var j int
	l := len(s)
	for i:=0;i<n/2;i++{

		if s[i] == s[l-i-1] {
			j = i + 1
		} else {
			break
		}
	}
	var r string
	for i := 0;i< k-1;i++{
		r += s[:l-j]
	}
	r += s
	fmt.Println(r)
}

package main

import "fmt"

func main() {
	var str string
	var count, k int
	fmt.Scan(&count, &k, &str)
	addstr := str
	for i := 0; i < len(str)-1; i++{
		fmt.Println(str[1+i:], str[len(str)-1-i:])

		if str == str[1+i:] + str[len(str)-1-i:] {
			addstr = str[len(str)-1-i:]
		}
	}
	for i:=0; i < k-1; i++{
		str += addstr
	}
	fmt.Println(str)

}

package main

import "fmt"

func main() {
	var str string
	var count, k int
	fmt.Scan(&count, &k, &str)
	addstr := str
	for i := 0; i < k-1; i++{

		if str == str[1+i:] + str[k-1-i:] {
			addstr = str[k-1-i:]
			break
		}
	}
	for i:=0; i < k-1; i++{
		str += addstr
	}
	fmt.Println(str)

}

package main

import "fmt"

func main() {
	var str string
	var count, k int
	fmt.Scan(&count, &k, &str)
	addstr := str
	for i := 0; i < len(str)-1; i++{

		if str == str[1+i:] + str[len(str)-1-i:] {
			addstr = str[len(str)-1-i:]
		}
	}
	for i:=0; i < k-1; i++{
		str += addstr
	}
	fmt.Println(str)

}


You had $$$n$$$ positive integers $$$a_1, a_2, \dots, a_n$$$ arranged in a circle. For each pair of neighboring numbers ($$$a_1$$$ and $$$a_2$$$, $$$a_2$$$ and $$$a_3$$$, ..., $$$a_{n - 1}$$$ and $$$a_n$$$, and $$$a_n$$$ and $$$a_1$$$), you wrote down: are the numbers in the pair equal or not.Unfortunately, you've lost a piece of paper with the array $$$a$$$. Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array $$$a$$$ which is consistent with information you have about equality or non-equality of corresponding pairs?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ cases follow. The first and only line of each test case contains a non-empty string $$$s$$$ consisting of characters E and/or N. The length of $$$s$$$ is equal to the size of array $$$n$$$ and $$$2 \le n \le 50$$$. For each $$$i$$$ from $$$1$$$ to $$$n$$$:    if $$$s_i =$$$ E then $$$a_i$$$ is equal to $$$a_{i + 1}$$$ ($$$a_n = a_1$$$ for $$$i = n$$$);  if $$$s_i =$$$ N then $$$a_i$$$ is not equal to $$$a_{i + 1}$$$ ($$$a_n \neq a_1$$$ for $$$i = n$$$).

For each test case, print YES if it's possible to choose array $$$a$$$ that are consistent with information from $$$s$$$ you know. Otherwise, print NO. It can be proved, that if there exists some array $$$a$$$, then there exists an array $$$a$$$ of positive integers with values less or equal to $$$10^9$$$.

NoteIn the first test case, you can choose, for example, $$$a_1 = a_2 = a_3 = 5$$$.In the second test case, there is no array $$$a$$$, since, according to $$$s_1$$$, $$$a_1$$$ is equal to $$$a_2$$$, but, according to $$$s_2$$$, $$$a_2$$$ is not equal to $$$a_1$$$.In the third test case, you can, for example, choose array $$$a = [20, 20, 4, 50, 50, 50, 20]$$$.In the fourth test case, you can, for example, choose $$$a = [1, 3, 3, 7]$$$.

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		s := readString(reader)
		countN := 0
		for i := 0; i < len(s); i++ {
			if s[i] == 'N' {
				countN++
			}
		}

		if countN == 1 {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, s := 0, ""
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &s)
		c := 0
		for j := 0; j < len(s); j++ {
			if string(s[j]) == "N" {
				c++
			}
		}
		if c == 1 {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

/*
7
EEE
NNN
NNE
ENE
EEN
EE
NN
---
YES
YES
YES
NO
NO
YES
YES
====
1
NEE
---
NO
*/

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var s string
		scanf("%s\n", &s)

		if len(s) == 2 {
			if s[0] == 'E' && s[1] == 'E' || s[0] == 'N' && s[1] == 'N' {
				fmt.Fprintln(&bld, "YES")
			} else {
				fmt.Fprintln(&bld, "NO")
			}
		} else {
			nCnt := 0
			for _, r := range s {
				if r == 'N' {
					nCnt++
				}
			}

			if nCnt == 1 {
				fmt.Fprintln(&bld, "NO")
			} else {
				fmt.Fprintln(&bld, "YES")
			}
		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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 {
	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
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var word string
		fmt.Fscan(in,&word)
		var count int
		for j:=0;j<len(word);j++{
			if string(word[j]) == "N" {
				count++
			}
		}
		if count == 1 {
			fmt.Fprintln(out,"NO")
		} else {
			fmt.Fprintln(out,"YES")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1620A
Date: 17/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1620/A
Problem: CF1620A
**/
func (in *CF1620A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		n := len(str)
		ans := true
		arr := make([]int, n)
		index := -1
		for i := 0; i < n; i++ {
			if str[0] != str[i] {
				index = i
				break
			}
		}

		if index != -1 {
			cont := 1
			for i, j := 0, index; i < n; i++ {
				if str[j] == 'E' {
				    arr[j] = cont
				    if arr[(j+1)%n] == 0{
					    arr[(j+1)%n] = cont
					}
				} else {
				   if arr[(j+1)%n] == 0{
						cont++
						arr[(j+1)%n] = cont
					}
				}
				j = (j + 1) % n
			}

			//fmt.Println("---> ", arr)

			for i := 0; i < n; i++ {
				if str[i] == 'E' && arr[i] != arr[(i+1)%n] {
					ans = false
					break
				} else if str[i] == 'N' && arr[i] == arr[(i+1)%n] {
					ans = false
					break
				}
			}
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		var s string
		count := 0
		fmt.Scan(&s)
		for _, item := range s {
			if string(item) == "N" {
				count++
			}
		}
		if count == 1 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
		t--
	}
}

package main

import (
	"fmt"
)

func main() {

	t := 0
	str := ""

	fmt.Scan(&t)

	for t > 0 {

		fmt.Scan(&str)
		fmt.Println(solve(str))

		t--
	}

}

func solve(str string) string {

	//size := len(str)
	count := 0

	for i := range str {
		if str[i] == 'N' {
			count++
		}
	}

	if count == 1 {
		return "NO"
	} else {
		return "YES"
	}

}

package main

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

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

func main() {

	var t int64
	fmt.Fscan(rr, &t)

	for i := int64(0); i < t; i++ {

		var str string
		fmt.Fscan(rr, &str)

		cntN := int64(0)

		for j := 0; j < len(str); j++ {
			if str[j] == 'N' {
				cntN++
			}
		}

		if cntN == 1 {
			fmt.Fprintln(ww, "NO")

		} else {
			fmt.Fprintln(ww, "YES")
		}

		ww.Flush()

	}
	ww.Flush()
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

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

)
func main(){
	r := bufio.NewReader(os.Stdin)
    w := bufio.NewWriter(os.Stdout)
    defer w.Flush()
    var t int
    fmt.Fscan(r, &t)
    for j := 0; j < t; j++ {
		var s string
		fmt.Fscan(r, &s)
		i := 0
		for _, x := range s {
			if (x == 'N') {
				i++
			}
		}
		if i != 1 {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}

}

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 s string
		fmt.Fscan(in, &s)

		var c int
		for _, ch := range s {
			if ch == 'N' {
				c++
			}
		}

		if c == 1 {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

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

var s string

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &s)

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

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

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() string {

	var E, N int

	for i := 0; i < len(s); i++ {
		if s[i] == 'E' {
			E++
		} else {
			N++
		}
	}

	if N == 1 {
		return "NO"
	}

	return "YES"
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

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

package main

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

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

	var T int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		if strings.Count(s, "N") == 1 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}
}

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

package main

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

func solve(r *bufio.Reader, w *bufio.Writer) {
	var s string
	fmt.Fscan(r, &s)
	if strings.Count(s, "N") == 1 {
		fmt.Fprintf(w, "NO\n")
	} else {
		fmt.Fprintf(w, "YES\n")
	}
}

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

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

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t      int
	s      string
)

func solve(s string) string {
	countN := 0
	for _, x := range s {
		if x == 'N' {
			countN++
		}
	}
	if countN == 1 {
		return "NO"
	}
	return "YES"
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &s)
		fmt.Println(solve(s))
	}
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		s := readString(reader)
		if len(s) == 2 && s[0] != s[1] {
			fmt.Fprintln(writer, "NO")
		} else if s == "ENE" {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		s := readString(reader)
		if s[0] == s[len(s)-1] {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

// Brute forcing it. Cant seem to find a pattern
func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, s := 0, ""
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &s)
		k, e := 1, []int{}
		for j := 0; j < len(s); j++ {
			if j+1 == len(s) {
				if string(s[j]) == "E" && e[j] == e[0] {
					fmt.Fprintln(w, "YES")
				} else if string(s[j]) == "E" && e[j] != e[0] {
					fmt.Fprintln(w, "NO")
				} else if string(s[j]) == "N" && e[j] == e[0] {
					fmt.Fprintln(w, "NO")
				} else {
					fmt.Fprintln(w, "YES")
				}
				break
			}
			if string(s[j]) == "E" {
				e = append(e, k)
				if j == 0 {
					e = append(e, k)
				}
			} else {
				e = append(e, k)
				if j == 0 {
					e = append(e, k+1)
					k++
				}
			}
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, s := 0, ""
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &s)
		if s != "EN" && s != "NE" {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()

}

func main() {
	solve()
}

package main

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

/*
5
EEE
NNN
NNE
ENE
EEN
---
YES
YES
YES
NO
NO
====
1
ENE
*/

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var s string
		scanf("%s\n", &s)

		if len(s) == 2 {
			if s[0] == 'E' && s[1] == 'E' {
				fmt.Fprintln(&bld, "YES")
			} else {
				fmt.Fprintln(&bld, "NO")
			}
		} else {
			nCnt := 0
			for _, r := range s {
				if r == 'N' {
					nCnt++
				}
			}

			if nCnt == 1 {
				fmt.Fprintln(&bld, "NO")
			} else {
				fmt.Fprintln(&bld, "YES")
			}

			//allExceptLastIsE := true
			//for i := 0; i < len(s)-1; i++ {
			//	if s[i] != 'E' {
			//		allExceptLastIsE = false
			//		break
			//	}
			//}
			//
			//if allExceptLastIsE && s[len(s)-1] == 'N' {
			//	fmt.Fprintln(&bld, "NO")
			//} else {
			//	fmt.Fprintln(&bld, "YES")
			//}
		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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 {
	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"
	"math"
	"os"
	"strings"
)

/*
5
EEE
NNN
NNE
ENE
EEN
---
YES
YES
YES
YES
NO
*/

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var s string
		scanf("%s\n", &s)

		if len(s) == 2 {
			if s[0] == 'E' && s[1] == 'E' {
				fmt.Fprintln(&bld, "YES")
			} else {
				fmt.Fprintln(&bld, "NO")
			}
		} else {
			allExceptLastIsE := true
			for i := 0; i < len(s)-1; i++ {
				if s[i] != 'E' {
					allExceptLastIsE = false
					break
				}
			}

			if allExceptLastIsE && s[len(s)-1] == 'N' {
				fmt.Fprintln(&bld, "NO")
			} else {
				fmt.Fprintln(&bld, "YES")
			}

		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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 {
	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
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var word string
		fmt.Fscan(in,&word)
		if string(word[0]) == string(word[len(word)-1]) {
			fmt.Fprintln(out,"YES")
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1620A
Date: 17/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1620/A
Problem: CF1620A
**/
func (in *CF1620A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		n := len(str)
		ans := true
		en := 0
		ne := 0
		for i := 0; i < n; i++ {
			if str[i] == 'E' && str[(i+1)%n] == 'N' {
				en++
			}
			if str[i] == 'N' && str[(i+1)%n] == 'E' {
				ne++
			}
		}
		if en == n || ne == n || (ne+en == n && en == 1) || (ne+en == n && ne == 1) {
			ans = false
		}

		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		var s string
		fmt.Scan(&s)
		if len(s) == 2 {
			if s[0] != s[1] {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		} else {
			fmt.Println("YES")
		}
		t--
	}
}

package main

import "fmt"

func main() {

	t := 0
	str := ""

	fmt.Scan(&t)

	for t > 0 {

		fmt.Scan(&str)

		if str[0] == str[len(str)-1] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		t--
	}

}

package main

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

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

func main() {

	var t int64
	fmt.Fscan(rr, &t)

	for i := int64(0); i < t; i++ {

		var str string
		fmt.Fscan(rr, &str)

		if len(str) > 2 {
			fmt.Fprintln(ww, "YES")
			ww.Flush()

			continue
		}

		if str[0] == str[1] {
			fmt.Fprintln(ww, "YES")
			ww.Flush()

			continue
		}

		fmt.Fprintln(ww, "NO")

		ww.Flush()

	}
	ww.Flush()
}

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

)
func main(){
	r := bufio.NewReader(os.Stdin)
    w := bufio.NewWriter(os.Stdout)
    defer w.Flush()
    var t int
    fmt.Fscan(r, &t)
    for j := 0; j < t; j++ {
		var s string
		fmt.Fscan(r, &s)
		l := len(s)
		la := s[l-2: l];
		flag := ("NE" == la && l > 2) || "EE" == la || "NN" == la

		if flag {
			fmt.Fprintln(w, "YES");
		} else {
			fmt.Fprintln(w, "NO");
		}
	}

}


You are given a sequence $$$a$$$, initially consisting of $$$n$$$ integers.You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element).To achieve this, you choose some integer $$$x$$$ that occurs at least once in $$$a$$$, and then perform the following operation any number of times (possibly zero): choose some segment $$$[l, r]$$$ of the sequence and remove it. But there is one exception: you are not allowed to choose a segment that contains $$$x$$$. More formally, you choose some contiguous subsequence $$$[a_l, a_{l + 1}, \dots, a_r]$$$ such that $$$a_i \ne x$$$ if $$$l \le i \le r$$$, and remove it. After removal, the numbering of elements to the right of the removed segment changes: the element that was the $$$(r+1)$$$-th is now $$$l$$$-th, the element that was $$$(r+2)$$$-th is now $$$(l+1)$$$-th, and so on (i. e. the remaining sequence just collapses).Note that you can not change $$$x$$$ after you chose it.For example, suppose $$$n = 6$$$, $$$a = [1, 3, 2, 4, 1, 2]$$$. Then one of the ways to transform it in two operations is to choose $$$x = 1$$$, then:  choose $$$l = 2$$$, $$$r = 4$$$, so the resulting sequence is $$$a = [1, 1, 2]$$$;  choose $$$l = 3$$$, $$$r = 3$$$, so the resulting sequence is $$$a = [1, 1]$$$. Note that choosing $$$x$$$ is not an operation. Also, note that you can not remove any occurrence of $$$x$$$.Your task is to find the minimum number of operations required to transform the sequence in a way described above.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each test case, print the answer — the minimum number of operations required to transform the given sequence in a way described in the problem statement. It can be proven that it is always possible to perform a finite sequence of operations so the sequence is transformed in the required way.

package main

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

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

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

type pp struct {
	val int
	ind int
}

func solve() {
	var n int
	scanf("%d\n", &n)
	v := make([]pp, n)
	for i := 0; i < n; i++ {
		if i + 1 == n {
			scanf("%d\n", &v[i].val)
		} else {
			scanf("%d ", &v[i].val)
		}
		v[i].ind = i
	}
	sort.Slice(v, func(i, j int) bool {
		return v[i].val < v[j].val || (v[i].val == v[j].val && v[i].ind < v[j].ind)
	})
	//fmt.Println(v)
	ans := n
	for i := 0; i < n; i++ {
		curr := 0
		if v[i].ind > 0 {
			curr++
		}
		j := i + 1
		for ; j < n && v[i].val == v[j].val; j++ {
			if v[j].ind - v[j - 1].ind != 1 {
				curr++
			}
		}
		j--
		if v[j].ind + 1 < n {
			curr++
		}
		if ans > curr {
			ans = curr
		}
		i = j
	}
	printf("%d\n", ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		pos := map[int][]int{}
		for i, v := range a {
			pos[v] = append(pos[v], i)
		}
		ans := int(1e9)

		for _, ps := range pos {
			if ps == nil {
				continue
			}
			c:=0
			if ps[0] > 0 {
				c++
			}
			if ps[len(ps)-1] < n-1 {
				c++
			}
			for i := 1; i < len(ps); i++ {
				if ps[i]-ps[i-1] > 1 {
					c++
				}
			}
			ans = min(ans, c)
		}
		Fprintln(out, ans)
	}

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

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

package main

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

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

	var t, n, cur int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		a := make(map[int]int)
		prev := -1
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &cur)
			a[cur]++
			if prev == cur {
				a[cur]--
			}
			if i == 0 || i == n-1 {
				a[cur]--
			}
			prev = cur
		}
		if len(a) == 1 {
			fmt.Println(0)
			continue
		}
		min := n
		for _, v := range a {
			if v < min {
				min = v
			}
		}
		fmt.Println(min + 1)
	}
}

package main

import(

	"fmt"
	."fmt"
	"bufio"
	"os"
)

const hell int = 1000000007

func solve(a *[]int){
	arr := *a
	n := len(arr)

	m := make(map[int][]int)

	for i := range arr{
		m[arr[i]] = append(m[arr[i]],i)
	}

	ans := hell

	min := func (x,y int)int{
				if x>y{
					return y
				}
				return x
			}

	for _,varr := range m{
		cur,jumps := 0,0
		for _,val := range varr{
			if cur == val || (cur==val-1 && arr[cur]==arr[val]){
				cur = val
			}else{
				jumps+=1
				cur = val
			}
		}
		if cur+1 != n{
			jumps+=1
		}
		ans = min(ans,jumps)
	}

	fmt.Println(ans)

}
func main(){
	var TESTS int
	in := bufio.NewReader(os.Stdin)

	Fscan(in,&TESTS)

	for ;TESTS>0;TESTS--{
		var n int
		Fscan(in,&n)
		a := make([]int,n)

		for i := range a{
			Fscan(in,&a[i])
		}

		solve(&a)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		pos := map[int][]int{}
		for i, v := range a {
			pos[v] = append(pos[v], i)
		}
		ans := int(1e9)

		for _, ps := range pos {
			if ps == nil {
				continue
			}
			c:=0
			if ps[0] > 0 {
				c++
			}
			if ps[len(ps)-1] < n {
				c++
			}
			for i := 1; i < len(ps); i++ {
				if ps[i]-ps[i-1] > 1 {
					c++
				}
			}
			ans = min(ans, c)
		}
		Fprintln(out, ans)
	}

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

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

package main

import(

	"fmt"
	."fmt"
	"bufio"
	"os"
)

const hell int = 1000000007

func solve(a *[]int){
	arr := *a
	n := len(arr)

	m := make(map[int][]int)

	for i := range arr{
		m[arr[i]] = append(m[arr[i]],i)
	}

	ans := hell

	min := func (x,y int)int{
				if x>y{
					return y
				}
				return x
			}

	for _,varr := range m{
		cur,jumps := 0,0
		for _,val := range varr{
			if cur == val || cur==val-1{
				cur = val
			}else{
				jumps+=1
				cur = val
			}
		}
		if cur+1 != n{
			jumps+=1
		}
		ans = min(ans,jumps)
	}

	fmt.Println(ans)

}
func main(){
	var TESTS int
	in := bufio.NewReader(os.Stdin)

	Fscan(in,&TESTS)

	for ;TESTS>0;TESTS--{
		var n int
		Fscan(in,&n)
		a := make([]int,n)

		for i := range a{
			Fscan(in,&a[i])
		}

		solve(&a)
	}
}

package main

import(

	"fmt"
	."fmt"
	"bufio"
	"os"
)

const hell int = 1000000007

func solve(a *[]int){
	arr := *a
	n := len(arr)

	m := make(map[int][]int)

	for i := range arr{
		m[arr[i]] = append(m[arr[i]],i)
	}

	ans := hell

	min := func (x,y int)int{
				if x>y{
					return y
				}
				return x
			}

	for _,varr := range m{
		cur,jumps := 0,0
		for _,val := range varr{
			if cur == val || (cur==val-1 && cur!=0){
				cur = val
			}else{
				jumps+=1
				cur = val
			}
		}
		if cur+1 != n{
			jumps+=1
		}
		ans = min(ans,jumps)
	}

	fmt.Println(ans)

}
func main(){
	var TESTS int
	in := bufio.NewReader(os.Stdin)

	Fscan(in,&TESTS)

	for ;TESTS>0;TESTS--{
		var n int
		Fscan(in,&n)
		a := make([]int,n)

		for i := range a{
			Fscan(in,&a[i])
		}

		solve(&a)
	}
}


Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being black and 0 being white. Now Magnus wants to change color of some squares in such a way that he recolors minimum number of squares and obtained pieces form a valid chessboard. Every square has its color different to each of the neightbouring by side squares in a valid board. Its size should be 2n by 2n. You are allowed to move pieces but not allowed to rotate or flip them.

The first line contains odd integer n (1 ≤ n ≤ 100) — the size of all pieces of the board.  Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty line.

Print one number — minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.

package main

import (
	"fmt"
	"math"
)

func perm(n int) [][]int {
	if n == 1 {
		return [][]int{{0}}
	}
	var p [][]int
	for i := 0; i < n; i++ {
		for _, q := range perm(n - 1) {
			q := q
			q = append(q[:i], append([]int{n-1}, q[i:]...)...)
			p = append(p, q)
		}
	}
	return p
}

type board []string

func newBoard(n int, tl, tr, bl, br []string) board {
	var ss []string
	ss = make([]string, n+n)
	for i := range tl {
		ss[i] = tl[i] + tr[i]
		ss[i+n] = bl[i] + br[i]
	}
	return board(ss)
}

func (b board) recolor() int {
	var cnt int
	for i, row := range b {
		for j, sq := range row {
			sq := sq
			sq -= '0'
			if ((i + j) & 1) != int(sq) {
				cnt++
			}
		}
	}
	return cnt
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	a := make([][]string, 4)
	for k := range a {
		a[k] = make([]string, n)
		for i := range a[k] {
			fmt.Scanf("%s\n", &a[k][i])
		}
		fmt.Scanln()
	}
	var ans int
	ans = math.MaxInt32
	for _, p := range perm(4) {
		if v := newBoard(n, a[p[0]], a[p[1]], a[p[2]], a[p[3]]).recolor(); v < ans {
			ans = v
		}
	}
	fmt.Println(ans)
}