We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name $$$s$$$ can transform to another superhero with name $$$t$$$ if $$$s$$$ can be made equal to $$$t$$$ by changing any vowel in $$$s$$$ to any other vowel and any consonant in $$$s$$$ to any other consonant. Multiple changes can be made.In this problem, we consider the letters 'a', 'e', 'i', 'o' and 'u' to be vowels and all the other letters to be consonants.Given the names of two superheroes, determine if the superhero with name $$$s$$$ can be transformed to the Superhero with name $$$t$$$.

The first line contains the string $$$s$$$ having length between $$$1$$$ and $$$1000$$$, inclusive. The second line contains the string $$$t$$$ having length between $$$1$$$ and $$$1000$$$, inclusive. Both strings $$$s$$$ and $$$t$$$ are guaranteed to be different and consist of lowercase English letters only.

Output "Yes" (without quotes) if the superhero with name $$$s$$$ can be transformed to the superhero with name $$$t$$$ and "No" (without quotes) otherwise. You can print each letter in any case (upper or lower).

NoteIn the first sample, since both 'a' and 'u' are vowels, it is possible to convert string $$$s$$$ to $$$t$$$.In the third sample, 'k' is a consonant, whereas 'a' is a vowel, so it is not possible to convert string $$$s$$$ to $$$t$$$.

package main

import (
	"fmt"

	"regexp"
)

func main() {
	s := readString()
	t := readString()

	if fuck(s) == fuck(t) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func fuck(s string) string {
	return vowels.ReplaceAllLiteralString(consonants.ReplaceAllLiteralString(s, "0"), "1")
}

var (
	vowels = regexp.MustCompile("[aeiou]")
	consonants = regexp.MustCompile("[^aeiou]")
)

func readString() (r string) {
	fmt.Scan(&r)
	return
}

package main

import "fmt"

func main() {
	var s, t, res string
	fmt.Scanln(&s)
	fmt.Scanln(&t)
	if len(s) == len(t) {
	asdf:
		for x, y := range s {
			switch string(y) {
			case "a", "e", "i", "o", "u":
				z := string(t[x])
				switch z {
				case "a", "e", "i", "o", "u":
					res = "Yes"
				default:
					res = "No"
					break asdf
				}

			default:
				z := string(t[x])
				switch z {
				case "a", "e", "i", "o", "u":
					res = "No"
					break asdf
				default:
					res = "Yes"
				}
			}
		}
	} else {
		res = "No"
	}
	fmt.Println(res)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var a, b string
	fmt.Fscan(reader, &a, &b)
	if len(a) != len(b) {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(a); i++ {
		if isVowel(a[i]) != isVowel(b[i]) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func isVowel(l byte) bool {
	switch l {
	case 'a':
		return true
	case 'e':
		return true
	case 'i':
		return true
	case 'o':
		return true
	case 'u':
		return true
	}
	return false
}

package main

import (
	"fmt"
)

func main() {
	vowels := map[uint8]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true}
	var s, t string
	fmt.Scan(&s, &t)
	if len(s) != len(t) {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(s); i++ {
		if vowels[s[i]] != vowels[t[i]] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

import "fmt"

func isVowl(r byte) bool {
	for _, v := range "aeiou" {
		if rune(r) == v {
			return true
		}
	}
	return false
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	flgNG := false
	if len(s) != len(t) {
		flgNG = true
	} else {
		for i := range s {
			if isVowl(s[i]) != isVowl(t[i]) {
				flgNG = true
			}
		}
	}
	b2i := map[bool]int8{false: 0, true: 1}
	fmt.Println([...]string{"Yes", "No"}[b2i[flgNG]])
}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s\n%s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
			return
		}
	}
	fmt.Printf("YES")
}

package main

import "fmt"

func solve(name1, name2 string) bool {
	vowels := map[byte]bool{
		'a': true,
		'e': true,
		'i': true,
		'o': true,
		'u': true,
	}

	if len(name1) != len(name2) {
		return false
	}

	for i := range name1 {
		if vowels[name1[i]] != vowels[name2[i]] {
			return false
		}
	}

	return true
}

func main() {
	name1 := ""
	name2 := ""
	fmt.Scan(&name1, &name2)

	res := solve(name1, name2)

	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

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

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	// fmt.Println(s)
	// fmt.Println(t)
	for i := range s {
		if isVowel(vowel, s[i]) != isVowel(vowel, t[i]) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

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 isV(b byte) bool {
	if b == byte('a') {
		return true
	}
	if b == byte('e') {
		return true
	}
	if b == byte('i') {
		return true
	}
	if b == byte('o') {
		return true
	}
	if b == byte('u') {
		return true
	}
	return false
}

func main() {
	defer writer.Flush()
	var s, t string
	scanf("%s\n%s\n", &s, &t)

	if len(s) != len(t) {
		printf("No")
		return
	}

	for i := 0; i < len(s); i++ {
		if isV(s[i]) != isV(t[i]) {
			printf("No")
			return
		}
	}

	printf("Yes")
	return

}

package main

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

func isVowel(b byte) bool {
	vowel := []byte("aiueo")
	for _, v := range vowel {
		if v == b {
			return true
		}
	}
	return false
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	text1, _ := reader.ReadString('\n')
	text2, _ := reader.ReadString('\n')

	if len(text1) != len(text2) {
		fmt.Println("No")
		return
	}
	for k, _ := range text1 {
		if isVowel(text1[k]) != isVowel(text2[k]) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

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

func scanBytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

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

func scanInt() int {
	scanner.Scan()
	v, _ := strconv.Atoi(scanner.Text())
	return v
}

func scanInts(n int) []int {
	l := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.Atoi(scanner.Text())
	}

	return l
}

func scanInts64(n int64) []int64 {
	l := make([]int64, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}

	return l
}

func scanBool() bool {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v == 1
}

func scanBools(n int64) []bool {
	l := make([]bool, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		l[i] = v == 1
	}

	return l
}

func scanUint64() uint64 {
	scanner.Scan()
	v, _ := strconv.ParseUint(scanner.Text(), 10, 64)
	return v
}

type ByAge []uint64

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

var glasn = map[byte]bool{
	'a': true,
	'e': true,
	'i': true,
	'o': true,
	'u': true,
}

func main() {
	s, t := scanBytes(), scanBytes()

	if len(s) != len(t) {
		fmt.Println("No")
		return
	}

	for i, bs := range s {
		bt := t[i]

		if glasn[bt] != glasn[bs] {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func skipZero(a []uint64) []uint64 {
	for len(a) > 0 && a[0] == 0 {
		a = a[1:]
	}

	return a
}

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

	return -a
}

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

	return b
}

// run on go 1.11.4

package main

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

func next(scn *bufio.Scanner) string {
	scn.Scan()
	return scn.Text()
}

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)

	s := next(scn)
	t := next(scn)

	ans := solve(s, t)
	fmt.Println(ans)
}

func solve(s string, t string) string {
	// https://ashitani.jp/golangtips/tips_regexp.html

	c := regexp.MustCompile("[^aeiou]")
	v := regexp.MustCompile("[aeiou]")
  normalizedS := v.ReplaceAllString(c.ReplaceAllString(s, "C"), "V")
  normalizedT := v.ReplaceAllString(c.ReplaceAllString(t, "C"), "V")
  if (normalizedS == normalizedT) {
    return "Yes"
  } else {
    return "No"
  }
}

package main

import (
	"fmt"

	"regexp"
)

func main() {
	s := readString()
	t := readString()

	if fuck(s) == fuck(t) {
		println("Yes")
	} else {
		println("No")
	}
}

func fuck(s string) string {
	return vowels.ReplaceAllLiteralString(consonants.ReplaceAllLiteralString(s, "0"), "1")
}

var (
	vowels = regexp.MustCompile("[aeiou]")
	consonants = regexp.MustCompile("[^aeiou]")
)

func readString() (r string) {
	fmt.Scan(&r)
	return
}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s %s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
		}
	}
	fmt.Printf("YES")
}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s\n%s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
		}
	}
	fmt.Printf("YES")
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || isVowel(vowel, s[i]) && isVowel(vowel, t[i]) {
			count++
		}
	}

	if count < 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || !isVowel(vowel, s[i]) && !isVowel(vowel, t[i]) {
			count++
		}
	}

	if count == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || !isVowel(vowel, s[i]) && !isVowel(vowel, t[i]) {
			count++
		}
	}
	if count == 1 || count == len(s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	fmt.Println(s)
	fmt.Println(t)
	for i := range s {
		if isVowel(vowel, s[i]) != isVowel(vowel, t[i]) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}


This is an interactive problem. Refer to the Interaction section below for better understanding.Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).Chtholly wins if, at any time, all the sheets are filled with a number and the n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m rounds she still doesn't win, she loses the game.Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.

The first line contains 3 integers n, m and c (,  means  rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.

NoteIn the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game. Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.The input format for hacking:   The first line contains 3 integers n, m and c;  The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.

package main

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

var reader = bufio.NewReader(os.Stdin)
var scanner = bufio.NewScanner(reader)

func rint() int {
	scanner.Scan()
	t := scanner.Text()
	v, _ := strconv.ParseInt(t, 10, 32)
	return int(v)
}

func findFirstLarger(a []int, x int, l int, r int) int {
	// fmt.Println(a, x, l, r)
	if l > r {
		return l
	}

	for l < r {
		m := (l + r) / 2
		if a[m] > x {
			r = m
		} else if a[m] <= x {
			l = m + 1
		}
	}

	if a[l] <= x {
		l++
	}
	return l
}

func findLastSmaller(a []int, x int, l int, r int) int {
	// fmt.Println(a, x, l, r)
	if l > r {
		return r
	}

	for l < r {
		m := (l + r) / 2
		if a[m] >= x {
			r = m - 1
		} else if a[m] < x {
			l = m + 1
		}
	}

	if a[l] >= x {
		l--
	}
	return l
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := bufio.NewWriter(os.Stdout)
	n, _, c := rint(), rint(), rint()

	sheet := make([]int, n+10)
	l, r := -1, n

	for l < r-1 {
		x := rint()
		var p int
		if x <= c/2 {
			p = findFirstLarger(sheet, x, 0, l)
			if p > l {
				l = p
			}
		} else {
			p = findLastSmaller(sheet, x, r, n-1)
			if p < r {
				r = p
			}
		}
		// fmt.Println("p: ", p)
		sheet[p] = x
		//fmt.Println(p + 1)
		w.WriteString(strconv.Itoa(p+1) + "\n")
		w.Flush()
	}
}


There are n cities and m two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible that there is no way to get from one city to some other city using only these roads.The road minister decided to make a reform in Berland and to orient all roads in the country, i.e. to make each road one-way. The minister wants to maximize the number of cities, for which the number of roads that begins in the city equals to the number of roads that ends in it.

The first line contains a positive integer t (1 ≤ t ≤ 200) — the number of testsets in the input. Each of the testsets is given in the following way. The first line contains two integers n and m (1 ≤ n ≤ 200, 0 ≤ m ≤ n·(n - 1) / 2) — the number of cities and the number of roads in Berland.  The next m lines contain the description of roads in Berland. Each line contains two integers u and v (1 ≤ u, v ≤ n) — the cities the corresponding road connects. It's guaranteed that there are no self-loops and multiple roads. It is possible that there is no way along roads between a pair of cities. It is guaranteed that the total number of cities in all testset of input data doesn't exceed 200. Pay attention that for hacks, you can only use tests consisting of one testset, so t should be equal to one.

For each testset print the maximum number of such cities that the number of roads that begins in the city, is equal to the number of roads that ends in it. In the next m lines print oriented roads. First print the number of the city where the road begins and then the number of the city where the road ends. If there are several answers, print any of them. It is allowed to print roads in each test in arbitrary order. Each road should be printed exactly once.

package main

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

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

func dfs(a [][]bool, n int, u int, ru *[]int, rv *[]int) {
	for v := 0; v <= n; v++ {
		if a[u][v] {
			a[u][v] = false
			a[v][u] = false
			*ru = append(*ru, u)
			*rv = append(*rv, v)
			dfs(a, n, v, ru, rv)
		}
	}
}

func solution() {
	var n, m, u, v int
	fmt.Fscanf(bufin, "%d %d\n", &n, &m)

	a := make([][]bool, n+1)
	d := make([]int, n+1)

	for u = 0; u <= n; u++ {
		a[u] = make([]bool, n+1)
		for v = 0; v <= n; v++ {
			a[u][v] = false
		}
		d[u] = 0
	}

	for i := 0; i < m; i++ {
		fmt.Fscanf(bufin, "%d %d\n", &u, &v)
		a[u][v] = true
		a[v][u] = true
		d[u]++
		d[v]++
	}

	for v = 1; v <= n; v++ {
		if d[v]%2 == 1 {
			a[0][v] = true
			a[v][0] = true
			d[0]++
			d[v]++
		}
	}

	var ru, rv []int
	for u := 0; u <= n; u++ {
		dfs(a, n, u, &ru, &rv)
	}

	fmt.Fprintf(bufout, "%d\n", n-d[0])
	k := len(ru)
	for i := 0; i < k; i++ {
		if (ru[i] != 0) && (rv[i] != 0) {
			fmt.Fprintf(bufout, "%d %d\n", ru[i], rv[i])
		}
	}
}

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

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

	for test := 0; test < ntest; test++ {
		solution()
	}
}


Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another one — xor of all pairwise sums of elements in the array, she realized that she couldn't compute it for a very large array, thus she asked for your help. Can you do it? Formally, you need to compute$$$$$$ (a_1 + a_2) \oplus (a_1 + a_3) \oplus \ldots \oplus (a_1 + a_n) \\ \oplus (a_2 + a_3) \oplus \ldots \oplus (a_2 + a_n) \\ \ldots \\ \oplus (a_{n-1} + a_n) \\ $$$$$$Here $$$x \oplus y$$$ is a bitwise XOR operation (i.e. $$$x$$$ ^ $$$y$$$ in many modern programming languages). You can read about it in Wikipedia: https://en.wikipedia.org/wiki/Exclusive_or#Bitwise_operation.

The first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 400\,000$$$) — the number of integers in the array. The second line contains integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^7$$$).

Print a single integer — xor of all pairwise sums of integers in the given array.

NoteIn the first sample case there is only one sum $$$1 + 2 = 3$$$.In the second sample case there are three sums: $$$1 + 2 = 3$$$, $$$1 + 3 = 4$$$, $$$2 + 3 = 5$$$. In binary they are represented as $$$011_2 \oplus 100_2 \oplus 101_2 = 010_2$$$, thus the answer is 2.$$$\oplus$$$ is the bitwise xor operation. To define $$$x \oplus y$$$, consider binary representations of integers $$$x$$$ and $$$y$$$. We put the $$$i$$$-th bit of the result to be 1 when exactly one of the $$$i$$$-th bits of $$$x$$$ and $$$y$$$ is 1. Otherwise, the $$$i$$$-th bit of the result is put to be 0. For example, $$$0101_2 \, \oplus \, 0011_2 = 0110_2$$$.

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func bsearch(a []int, limitMask int, value int) int {
	l := 0
	r := len(a) - 1
	res := len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid]&limitMask >= value {
			res = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return res
}

func rangeSum(l, r, i int) int64 {
	if r > i {
		r = i
	}
	if l < r {
		return int64(r - l)
	} else {
		return 0
	}
}

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

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

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

	var limitMask int

	less := func(i, j int) bool {
		return a[i]&limitMask < a[j]&limitMask
	}

	var result int

	// var res int
	// for i := 0; i < n; i++ {
	// 	for j := i + 1; j < n; j++ {
	// 		res ^= a[i] + a[j]
	// 	}
	// }
	// fmt.Fprintln(out, res)

	for k := 0; k <= 25; k++ {
		nextPow := (1 << uint(k+1))
		limitMask = nextPow - 1
		sort.Slice(a, less)
		currPow := (1 << uint(k))
		var counts [2]int64
		// stderr("K=", k)

		// for i := 0; i < n; i++ {
		// 	stderr("sorted", i, "a[i]", a[i], fmt.Sprintf("%b", a[i]&limitMask))
		// }

		for i := 0; i < n; i++ {
			mask := a[i] & limitMask
			// more := currPow - (mask & (^currPow))
			// carryPos := bsearch(a, limitMask, more)
			firstOneMask := currPow - mask
			firstOnePos := bsearch(a, limitMask, firstOneMask)
			nextZeroMask := nextPow - mask
			nextZeroPos := bsearch(a, limitMask, nextZeroMask)
			secondOnePos := bsearch(a, limitMask, currPow+nextPow-mask)
			counts[0] += rangeSum(0, firstOnePos, i)
			counts[1] += rangeSum(firstOnePos, nextZeroPos, i)
			counts[0] += rangeSum(nextZeroPos, secondOnePos, i)
			counts[1] += rangeSum(secondOnePos, n, i)
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", firstOneMask), "firstOnePos", firstOnePos, "nextZeroMask", fmt.Sprintf("%b", nextZeroMask), "nextZeroPos", nextZeroPos)
			// carryZeroPos :=
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", more), "carryPos", carryPos, "firstOnePos", firstOnePos)
			// if (mask & currPow) == 0 {
			// 	counts[0] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[1] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[1] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[0] += rangeSum(max(firstOnePos, carryPos), n, i)
			// } else {
			// 	counts[1] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[0] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[0] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[1] += rangeSum(max(firstOnePos, carryPos), n, i)
			// }
			// stderr("ones", counts[1])
		}
		// stderr("ones", counts[1])
		if counts[1]%2 == 1 {
			result ^= currPow
		}
	}
	fmt.Fprintln(out, result)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1323D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n, ans := read(), 0
	a := make([]int, n)
	for i := range a {
		a[i] = read()
	}
	b := make([]int, n)
	search := func(l, x int) int {
		r := n
		for l < r {
			m := (l + r) >> 1
			if b[m] >= x {
				r = m
			} else {
				l = m + 1
			}
		}
		return l
	}
	for i := uint(0); i < 25; i++ {
		for j, v := range a {
			b[j] = v &^ (-1 << (i + 1))
		}
		sort.Ints(b)
		cnt := 0
		for j, v := range b {
			cnt ^= n - search(j+1, 3<<i-v) + search(j+1, 2<<i-v) - search(j+1, 1<<i-v)
		}
		ans |= cnt & 1 << i
	}
	Fprint(_w, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1323D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n, ans := read(), 0
	a := make([]int, n)
	for i := range a {
		a[i] = read()
	}
	b := make([]int, n)
	search := func(l, x int) int {
		r := n
		for l < r {
			m := (l + r) >> 1
			if b[m] >= x {
				r = m
			} else {
				l = m + 1
			}
		}
		return l
	}
	for i := uint(0); i < 25; i++ {
		for j, v := range a {
			b[j] = v &^ (-1 << (i + 1))
		}
		sort.Ints(b)
		cnt := 0
		for j, v := range b {
			cnt ^= search(j+1, 2<<i-v) - search(j+1, 1<<i-v)
			cnt ^= n - search(j+1, 3<<i-v)
		}
		ans |= cnt & 1 << i
	}
	Fprint(_w, ans)
}

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

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func bsearch(a []int, limitMask int, value int) int {
	l := 0
	r := len(a) - 1
	res := len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid]&limitMask >= value {
			res = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return res
}

func rangeSum(l, r, i int) int {
	if r > i {
		r = i
	}
	if l < r {
		return r - l
	} else {
		return 0
	}
}

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

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

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

	var limitMask int

	less := func(i, j int) bool {
		return a[i]&limitMask < a[j]&limitMask
	}

	var result int

	// var res int
	// for i := 0; i < n; i++ {
	// 	for j := i + 1; j < n; j++ {
	// 		res ^= a[i] + a[j]
	// 	}
	// }
	// fmt.Fprintln(out, res)

	for k := 0; k <= 25; k++ {
		nextPow := (1 << uint(k+1))
		limitMask = nextPow - 1
		sort.Slice(a, less)
		currPow := (1 << uint(k))
		var counts [2]int
		// stderr("K=", k)

		// for i := 0; i < n; i++ {
		// 	stderr("sorted", i, "a[i]", a[i], fmt.Sprintf("%b", a[i]&limitMask))
		// }

		for i := 0; i < n; i++ {
			mask := a[i] & limitMask
			// more := currPow - (mask & (^currPow))
			// carryPos := bsearch(a, limitMask, more)
			firstOneMask := currPow - mask
			firstOnePos := bsearch(a, limitMask, firstOneMask)
			nextZeroMask := nextPow - mask
			nextZeroPos := bsearch(a, limitMask, nextZeroMask)
			secondOnePos := bsearch(a, limitMask, currPow+nextPow-mask)
			counts[0] += rangeSum(0, firstOnePos, i)
			counts[1] += rangeSum(firstOnePos, nextZeroPos, i)
			counts[0] += rangeSum(nextZeroPos, secondOnePos, i)
			counts[1] += rangeSum(secondOnePos, n, i)
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", firstOneMask), "firstOnePos", firstOnePos, "nextZeroMask", fmt.Sprintf("%b", nextZeroMask), "nextZeroPos", nextZeroPos)
			// carryZeroPos :=
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", more), "carryPos", carryPos, "firstOnePos", firstOnePos)
			// if (mask & currPow) == 0 {
			// 	counts[0] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[1] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[1] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[0] += rangeSum(max(firstOnePos, carryPos), n, i)
			// } else {
			// 	counts[1] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[0] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[0] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[1] += rangeSum(max(firstOnePos, carryPos), n, i)
			// }
			// stderr("ones", counts[1])
		}
		// stderr("ones", counts[1])
		if counts[1]%2 == 1 {
			result ^= currPow
		}
	}
	fmt.Fprintln(out, result)
}


You are given a tree consisting of $$$n$$$ vertices. Some of the vertices (at least two) are black, all the other vertices are white.You place a chip on one of the vertices of the tree, and then perform the following operations:  let the current vertex where the chip is located is $$$x$$$. You choose a black vertex $$$y$$$, and then move the chip along the first edge on the simple path from $$$x$$$ to $$$y$$$. You are not allowed to choose the same black vertex $$$y$$$ in two operations in a row (i. e., for every two consecutive operations, the chosen black vertex should be different).You end your operations when the chip moves to the black vertex (if it is initially placed in a black vertex, you don't perform the operations at all), or when the number of performed operations exceeds $$$100^{500}$$$.For every vertex $$$i$$$, you have to determine if there exists a (possibly empty) sequence of operations that moves the chip to some black vertex, if the chip is initially placed on the vertex $$$i$$$.

The first line contains one integer $$$n$$$ ($$$3 \le n \le 3 \cdot 10^5$$$) — the number of vertices in the tree. The second line contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$0 \le c_i \le 1$$$), where $$$c_i = 0$$$ means that the $$$i$$$-th vertex is white, and $$$c_i = 1$$$ means that the $$$i$$$-th vertex is black. At least two values of $$$c_i$$$ are equal to $$$1$$$. Then $$$n-1$$$ lines follow, each of them contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$; $$$u_i \ne v_i$$$) — the endpoints of some edge. These edges form a tree.

Print $$$n$$$ integers. The $$$i$$$-th integer should be equal to $$$1$$$ if there exists a (possibly empty) sequence of operations that moves the chip to some black vertex if it is placed on the vertex $$$i$$$, and $$$0$$$ if no such sequence of operations exists.

package main

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

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

type Edge struct {
	fr        int
	to        int
	flagCount int
	rev       *Edge
	active    bool
}

func NewEdge(fr, to int) *Edge {
	return &Edge{fr: fr, to: to, flagCount: -1, rev: nil, active: false}
}

var graph [][]*Edge
var flag []bool
var parent []int
var subtreeCount []int
var queue []int

func countFlagsRec(node, parentNode int) int {
	if flag[node] {
		subtreeCount[node] = 1
	}

	parent[node] = parentNode
	for _, edge := range graph[node] {
		if edge.to != parentNode {
			subtreeCount[node] += countFlagsRec(edge.to, node)
		}
	}
	return subtreeCount[node]
}

// func (e *Edge) countFlagsRec() int {
// 	if e.flagCount != -1 {
// 		return e.flagCount
// 	}

// 	e.flagCount = 0
// 	if flag[e.to] {
// 		e.flagCount++
// 	}
// 	for _, edge := range graph[e.to] {
// 		if edge.to != e.fr {
// 			e.flagCount += edge.countFlagsRec()
// 		}
// 	}
// 	return e.flagCount
// }

func main() {
	var n int
	fmt.Fscan(in, &n)

	flag = make([]bool, n)
	graph = make([][]*Edge, n)

	for i := 0; i < n; i++ {
		var isMarked int
		fmt.Fscan(in, &isMarked)
		flag[i] = isMarked == 1
	}

	for edge := 0; edge < n-1; edge++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		a--
		b--
		ab := NewEdge(a, b)
		ba := NewEdge(b, a)
		ab.rev = ba
		ba.rev = ab
		graph[a] = append(graph[a], ab)
		graph[b] = append(graph[b], ba)
	}

	parent = make([]int, n)
	subtreeCount = make([]int, n)
	countFlagsRec(0, 0)
	for fr := 0; fr < n; fr++ {
		for _, edge := range graph[fr] {
			if parent[edge.to] == fr {
				edge.flagCount = subtreeCount[edge.to]
			} else {
				edge.flagCount = subtreeCount[0] - subtreeCount[edge.fr]
			}
			if edge.flagCount > 1 {
				edge.rev.active = true
				// fmt.Fprintf(out, "1. active edge: %d -> %d. count = %d\n", edge.rev.fr+1, edge.rev.to+1, edge.flagCount)
			}
		}
	}

	for i := 0; i < n; i++ {
		if flag[i] {
			queue = append(queue, i)
			for _, edge := range graph[i] {
				edge.active = true
				// fmt.Fprintf(out, "2. active edge: %d -> %d\n", edge.fr+1, edge.to+1)
			}
		}
	}

	for len(queue) > 0 {
		var node = queue[0]
		queue = queue[1:]

		for _, edge := range graph[node] {
			if flag[edge.to] {
				continue
			}
			if edge.active {
				flag[edge.to] = true
				queue = append(queue, edge.to)
			}
		}
	}

	var ansBytes = make([]byte, 2*n)
	for i := 0; i < n; i++ {
		if flag[i] {
			ansBytes[i<<1] = '1'
		} else {
			ansBytes[i<<1] = '0'
		}
		ansBytes[(i<<1)|1] = ' '
	}
	fmt.Fprintf(out, "%s\n", string(ansBytes))
	out.Flush()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"runtime/debug"
)

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

	var n, v, w int
	Fscan(in, &n)
	a := make([]bool, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	ans := make([]int8, n)
	cnt := make([]int, n)
	var f func(int, int)
	f = func(v, fa int) {
		if a[v] {
			ans[v] = 1
			cnt[v] = 1
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
				cnt[v] += cnt[w]
				if a[w] || ans[w] > 0 && cnt[w] > 1 {
					ans[v] = 1
				}
			}
		}
	}
	f(0, -1)
	f = func(v, fa int) {
		for _, w := range g[v] {
			if w != fa {
				if a[v] || ans[v] > 0 && cnt[0]-cnt[w] > 1 {
					ans[w] = 1
				}
				f(w, v)
			}
		}
	}
	f(0, -1)
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

func main() { CF1626E(os.Stdin, os.Stdout) }
func init() { debug.SetGCPercent(-1) }

package main

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

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

	var n, v, w int
	Fscan(in, &n)
	a := make([]bool, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	ans := make([]int8, n)
	cnt := make([]int, n)
	var f func(int, int)
	f = func(v, fa int) {
		if a[v] {
			ans[v] = 1
			cnt[v] = 1
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
				cnt[v] += cnt[w]
				if a[w] || ans[w] > 0 && cnt[w] > 1 {
					ans[v] = 1
				}
			}
		}
	}
	f(0, -1)
	f = func(v, fa int) {
		for _, w := range g[v] {
			if w != fa {
				if a[v] || ans[v] > 0 && cnt[0]-cnt[w] > 1 {
					ans[w] = 1
				}
				f(w, v)
			}
		}
	}
	f(0, -1)
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

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


You are given two strings $$$s$$$ and $$$t$$$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $$$1$$$. You can't choose a string if it is empty.For example:  by applying a move to the string "where", the result is the string "here",  by applying a move to the string "a", the result is an empty string "". You are required to make two given strings equal using the fewest number of moves. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the initial strings.Write a program that finds the minimum number of moves to make two given strings $$$s$$$ and $$$t$$$ equal.

The first line of the input contains $$$s$$$. In the second line of the input contains $$$t$$$. Both strings consist only of lowercase Latin letters. The number of letters in each string is between 1 and $$$2\cdot10^5$$$, inclusive.

Output the fewest number of moves required. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the given strings.

NoteIn the first example, you should apply the move once to the first string and apply the move once to the second string. As a result, both strings will be equal to "est".In the second example, the move should be applied to the string "codeforces" $$$8$$$ times. As a result, the string becomes "codeforces" $$$\to$$$ "es". The move should be applied to the string "yes" once. The result is the same string "yes" $$$\to$$$ "es".In the third example, you can make the strings equal only by completely deleting them. That is, in the end, both strings will be empty.In the fourth example, the first character of the second string should be deleted.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var s, t string
	fmt.Fscan(in, &s)
	fmt.Fscan(in, &t)
	result := len(s) + len(t)
	for i := 0; i < len(s) && i < len(t) && s[len(s)-1-i] == t[len(t)-1-i]; i++ {
		result -= 2
	}
	fmt.Println(result)
}

package main

import (
	"fmt"
)

func main() {
	var (
		s, t string
		ans int
	)

	fmt.Scan(&s)
	fmt.Scan(&t)
	ans = len(s) + len(t)

	/*for s != t {
		if len(s) > len(t) {
			s = s[1:]
		} else {
			t = t[1:]
		}
		ans++
	}*/

	for i := 0; i < len(s) && i < len(t) && t[len(t) - 1 - i] == s[len(s) - 1 - i]; i++ {
		ans -= 2;
	}

	fmt.Println(ans)
}

package main

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

func main(){
	in:=bufio.NewReader(os.Stdin)
	s:=""
	fmt.Fscan(in,&s)
	t:=""
	fmt.Fscan(in,&t)

	sLen:=len(s)
	tLen:=len(t)
	n:=sLen
	if tLen<n{
		n=tLen
	}
	ans:=sLen-tLen
	if ans<0{
		ans=-ans
	}
	for i:=0;i<n;i++{
		if s[sLen-i-1]!=t[tLen-i-1]{
			ans+=(n-i)*2
			break
		}
	}
	fmt.Print(ans)
}

package main

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

//Item eh um elemento da fila de prioridades
type Item struct {
	value    int
	priority int
	index    int
}

//PriorityQueue implmenta a heap interface
type PriorityQueue []*Item

//Len retorna o tamanho da  pq
func (pq PriorityQueue) Len() int { return len(pq) }

//Less verifica se um tem maior priotidade que o outro
func (pq PriorityQueue) Less(i, j int) bool { return pq[i].priority < pq[j].priority }

//Swap troca os elementos de lugar
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

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

//Pop remove um elemento da pq
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 //for safety
	*pq = old[0 : n-1]
	return item
}

//update modifica o valor e a prioridade de um item na fila
func (pq *PriorityQueue) update(item *Item, value int, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

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

type pair struct {
	first  interface{}
	second interface{}
}

type intPair struct {
	first  int64
	second int64
}

type vertex struct {
	list []intPair
}

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

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

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

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

/*************************************************************************/
func main() {
	var (
		str1 string
		str2 string
		cnt  int
	)

	fmt.Scan(&str1)
	fmt.Scan(&str2)

	i := len(str1) - 1
	j := len(str2) - 1
	for j >= 0 && i >= 0 && str1[i] == str2[j] {
		i--
		j--
		cnt++
	}
	fmt.Println(len(str1) - cnt + len(str2) - cnt)
}

package main

import (
	"fmt"
)

func main() {
	var str1, str2 string
	fmt.Scan(&str1)
	fmt.Scan(&str2)

	len1, len2 := len(str1), len(str2)

	total, dec := len1+len2, 0

	if len1 > len2 {
		for i := len2 - 1; i >= 0; i-- {
			if str2[i] != str1[len1-(len2-i)] {
				break
			}
			dec += 2
		}
	} else {
		for i := len1 - 1; i >= 0; i-- {
			if str1[i] != str2[len2-(len1-i)] {
				break
			}
			dec += 2
		}
	}
	fmt.Println(total - dec)
}


Gabriella has been instructed to organize a renowned wine tasting event which will be attended by $$$m$$$ critics. On display, there will be $$$n$$$ different varieties of wine, each of which can either be a red wine or a white wine.The wines will come in $$$n$$$ bottles arranged in a line on the table, and, for convenience, each critic will sip from a contiguous interval of bottles: that is, he/she will taste exactly the bottles at position $$$a, \, a + 1, \, \dots, \, b$$$ for some $$$1 \le a \le b \le n$$$. The interval depends on the critic, who will select it on the spot according to their preferences. In fact, the $$$i$$$-th critic ($$$1 \le i \le m$$$) has requested that he/she wants to taste exactly $$$r_i$$$ red wines and $$$w_i$$$ white wines.Gabriella has yet to choose how many bottles of red wine and white wine there will be, and in what order they will appear. Help her find an arrangement (that is, a sequence of $$$n$$$ bottles of either red or white wine) that satisfies the requests of all the critics, or state that no such arrangement exists.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1\le t\le 100$$$) — the number of test cases. The descriptions of the $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$1 \le m \le 100$$$) — the number of bottles of wine and the number of critics. Each of the next $$$m$$$ lines contains two integers $$$r_i$$$ and $$$w_i$$$ ($$$0 \le r_i, \, w_i \le 100$$$, $$$r_i + w_i \ge 1$$$) — the number of red and white wines that the $$$i$$$-th critic wants to taste.

For each test case, if at least one solution exists, print a string of length $$$n$$$ made up of the characters R and W, where the $$$j$$$-th character ($$$1 \le j \le n$$$) denotes the type of the wine in the $$$j$$$-th bottle of the arrangement (R for red and W for white). If there are multiple solutions, print any. If no solution exists, print the string IMPOSSIBLE.

NoteIn the first test case, there are $$$n = 5$$$ bottles of wine to be arranged and $$$m = 3$$$ critics. The arrangement RWRRW satisfies the requests of all three critics. Indeed:   the first critic can choose the interval $$$[3, \, 3]$$$, which contains exactly one bottle of red wine (note that $$$[1, \, 1]$$$ and $$$[4, \, 4]$$$ are other valid choices);  the second critic can choose the interval $$$[1, \, 5]$$$, which contains $$$3$$$ bottles of red wine and $$$2$$$ bottles of white wine;  the third critic can choose the interval $$$[2, \, 5]$$$, which contains $$$2$$$ bottles of red wine and $$$2$$$ bottles of white wine.

package main

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

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

func solve() {
	var n, m int
	fmt.Fscan(in, &n, &m)
	mx1 := 0
	mx2 := 0
	for i := 0; i < m; i++ {
		var r, w int
		fmt.Fscan(in, &r, &w)
		if r > mx1 {
			mx1 = r
		}
		if w > mx2 {
			mx2 = w
		}
	}
	if mx1+mx2 > n {
		fmt.Fprintf(out, "IMPOSSIBLE\n")
	} else {
		ans := ""
		for i := 0; i < mx1; i++ {
			ans += "R"
		}
		for i := 0; i < n-mx1; i++ {
			ans += "W"
		}
		fmt.Fprintf(out, "%s\n", ans)
	}
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		solve()
	}
}

package main

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

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

func solve() {
	var n, m int
	fmt.Fscan(in, &n, &m)
	mx1 := 0
	mx2 := 0
	for i := 0; i < m; i++ {
		var r, w int
		fmt.Fscan(in, &r, &w)
		if r > mx1 {
			mx1 = r
		}
		if w > mx2 {
			mx2 = w
		}
	}
	if mx1+mx2 > n {
		fmt.Fprintf(out, "IMPOSSIBLE\n")
	} else {
		ans := ""
		for i := 0; i < mx1; i++ {
			ans += "R"
		}
		for i := 0; i < mx2; i++ {
			ans += "W"
		}
		fmt.Fprintf(out, "%s\n", ans)
	}
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		solve()
	}
}


Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold and silver..."How am I to tell which is the One?!" the mage howled."Throw them one by one into the Cracks of Doom and watch when Mordor falls!" Somewhere in a parallel Middle-earth, when Saruman caught Frodo, he only found $$$n$$$ rings. And the $$$i$$$-th ring was either gold or silver. For convenience Saruman wrote down a binary string $$$s$$$ of $$$n$$$ characters, where the $$$i$$$-th character was 0 if the $$$i$$$-th ring was gold, and 1 if it was silver.Saruman has a magic function $$$f$$$, which takes a binary string and returns a number obtained by converting the string into a binary number and then converting the binary number into a decimal number. For example, $$$f(001010) = 10, f(111) = 7, f(11011101) = 221$$$.Saruman, however, thinks that the order of the rings plays some important role. He wants to find $$$2$$$ pairs of integers $$$(l_1, r_1), (l_2, r_2)$$$, such that: $$$1 \le l_1 \le n$$$, $$$1 \le r_1 \le n$$$, $$$r_1-l_1+1\ge \lfloor \frac{n}{2} \rfloor$$$  $$$1 \le l_2 \le n$$$, $$$1 \le r_2 \le n$$$, $$$r_2-l_2+1\ge \lfloor \frac{n}{2} \rfloor$$$  Pairs $$$(l_1, r_1)$$$ and $$$(l_2, r_2)$$$ are distinct. That is, at least one of $$$l_1 \neq l_2$$$ and $$$r_1 \neq r_2$$$ must hold. Let $$$t$$$ be the substring $$$s[l_1:r_1]$$$ of $$$s$$$, and $$$w$$$ be the substring $$$s[l_2:r_2]$$$ of $$$s$$$. Then there exists non-negative integer $$$k$$$, such that $$$f(t) = f(w) \cdot k$$$.Here substring $$$s[l:r]$$$ denotes $$$s_ls_{l+1}\ldots s_{r-1}s_r$$$, and $$$\lfloor x \rfloor$$$ denotes rounding the number down to the nearest integer.Help Saruman solve this problem! It is guaranteed that under the constraints of the problem at least one solution exists.

Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^4$$$) — length of the string. The second line of each test case contains a non-empty binary string of length $$$n$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For every test case print four integers $$$l_1$$$, $$$r_1$$$, $$$l_2$$$, $$$r_2$$$, which denote the beginning of the first substring, the end of the first substring, the beginning of the second substring, and the end of the second substring, respectively. If there are multiple solutions, print any.

package main

import (
	"fmt"
)

func findPairs(bin string, n int) [4]int {
	m := int(n / 2)

	for i := 0; i < n; i++ {
		if bin[i] == '0' {
			if i < m {
				return [4]int{i + 1, n, i + 2, n}
			} else {
				return [4]int{1, i + 1, 1, i}
			}
		}
	}

	return [4]int{1, n - 1, 2, n}
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanln(&n)
		fmt.Scanln(&s)

		// ns = append(ns, n)
		// bins = append(bins, s)

		// if t > 10 {
		// 	fmt.Println(n, s)
		// }
		r := findPairs(s, n)
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j + 1, i + 1, j
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

package main

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

func main() {
	// in := bufio.NewReader(os.Stdin)
	// out := os.Stdout
	var t int
	fmt.Scan(&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Scan(&n)
		var s string
		fmt.Scan(&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Println(i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Println(1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Println(1,len(s)-1,2,len(s))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var s string
		fmt.Fscan(in,&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Fprintln(out,i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Fprintln(out,1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Fprintln(out,1,len(s)-1,2,len(s))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var tests int
	fmt.Fscan(in, &tests)
	for test := 0; test < tests; test++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		beg := 0
		end := n/2 - 1
		found := false
		for end < n {
			prev := beg - 1
			next := end + 1
			if next < n && s[next] == '0' {
				fmt.Fprintln(out, beg+1, next+1, beg+1, end+1)
				found = true
				break
			} else if beg > 0 && s[prev] == '0' {
				fmt.Fprintln(out, prev+1, end+1, beg+1, end+1)
				found = true
				break
			}
			beg++
			end++
		}

		if found {
			continue
		}
		beg = 0
		end = n/2 - 1
	esc:
		for end < n {
			if equalsZero(s[beg : end+1]) {
				fmt.Fprintln(out, beg+1, end+1, 1, n)
				break
			}
			b := beg + 1
			f := end + 1
			for f < n {
				if equals(s[beg:end+1], s[b:f+1]) {
					fmt.Fprintln(out, beg+1, end+1, b+1, f+1)
					break esc
				}
				b++
				f++
			}
			beg++
			end++
		}
	}
}

func equals(s1, s2 string) bool {
	if len(s1) == len(s2) {
		for i := range s1 {
			if s1[i] != s2[i] {
				return false
			}
		}
		return true
	}
	return false
}

func equalsZero(s string) bool {
	for i := range s {
		if s[i] != '0' {
			return false
		}
	}
	return true
}

package main

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

var in *bufio.Reader

func solve() {
	var n int
	fmt.Fscan(in, &n)

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

	for i := (n + 1) / 2; i < n; i++ {
		if s[i] == '0' {
			fmt.Printf("%d %d %d %d\n", 1, i+1, 1, i)
			return
		}
	}
	for i := n/2 - 1; i >= 0; i-- {
		if s[i] == '0' {
			fmt.Printf("%d %d %d %d\n", i+1, n, i+2, n)
			return
		}
	}
	fmt.Printf("%d %d %d %d\n", 1, (n+1)/2, n/2+1, n)
}

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

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

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

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

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

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(s string) (l1, r1, l2, r2 int) {
	zeroPos := strings.IndexRune(s, '0')
	if zeroPos == -1 {
		return 0, len(s)-2, 1, len(s)-1
	}

	if zeroPos < len(s) / 2 {
		return zeroPos, len(s)-1, zeroPos+1, len(s)-1
	}
	return 0, zeroPos, 0, zeroPos-1
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i++ {
		_, s := stdin.Int(), stdin.Word()
		l1, r1, l2, r2 := solve(s)
		fmt.Println(l1+1, r1+1, l2+1, r2+1)
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	bins := []string{}
	ns := []int{}

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		ns = append(ns, n)
		bins = append(bins, s)
	}

    fmt.Println(bins, ns)

	for i := 0; i < t; i++ {
		r := findPairs(bins[i], ns[i])
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	bins := []string{}
	ns := []int{}

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		ns = append(ns, n)
		bins = append(bins, s)
	}

	for i := 0; i < t; i++ {
		r := findPairs(bins[i], ns[i])
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			fmt.Println("cache", v)
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	fmt.Println(visited)
	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		r := findPairs(s, n)
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2 + 1
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j + 1, i + 1, j
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2 + 1
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j, i + 1, j + 1
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

package main
import (
	"fmt"
	// "sort"
	// "reflect"
)
func puts(x string){
	fmt.Println(x)
}
func print(x int){
	fmt.Print(x);
	fmt.Print(" ");
}
func test_case(){
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var indx int
	for i,val:=range s{
		var ok rune
		ok=rune(val)
		temp:=string(ok)
		if temp=="0"{
			indx=i
		}

	}
	indx=indx+1
	half:=(len(s)+1)/2
	if(indx>=half+1){
		fmt.Print(1)
		fmt.Print(" ")
		fmt.Print(indx)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")
		fmt.Print(indx-1)
	}else if indx<=half{
		fmt.Print(indx)
		fmt.Print(" ")
		fmt.Print(len(s))
		fmt.Print(" ")
		fmt.Print(indx+1)
		fmt.Print(" ")
		fmt.Print(len(s))
	}
	puts("")

}
func main(){
	var t int
	fmt.Scan(&t)
	for t>0{
		test_case()
		t-=1
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var s string
		fmt.Fscan(in,&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Fprintln(out,i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Fprintln(out,1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Fprintln(out,1,len(s)-1,2,len(s))
		}
	}
}