package main

import(
	"fmt"
)

func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b int32
		fmt.Scan(&a,&b)
		if a==b{
			fmt.Println(0)
		}else if a>b{
			var res int32=a-b
			if res%2==0{
				fmt.Println(1)
			}else{
				fmt.Println(2)
			}
		}else{
			var res int32=b-a
			if res%2!=0{
				fmt.Println(1)
			}else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
		a, b := ScanInt(), ScanInt()
		count := 0
		//for a != b {
		//	count++
		if a == b {
			count = 0
		} else if a < b {
			count = nextOdd(b - a)
			//fmt.Println("evenNum:", num)
			//a = a + num
		} else {
			count = prevEven(a - b)
			//fmt.Println("prevEven:", num)
			//a = a - num
		}
		//}

		//P(count)
		P(count)
	}

	close(O)
	oWg.Wait()
}

func prevEven(x int) int {
	if x%2 == 0 {
		return 1
	}
	return 2
}
func nextOdd(x int) int {
	if x%2 == 1 {
		return 1
	}
	return 2
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

import "fmt"

type arr struct {
	x int64
	y int64
}

func main() {
	n:=int64(0)
	fmt.Scanln(&n)
	ad:=make([]arr,n)
	for i:=int64(0);i<n ; i++ {
		fmt.Scanln(&ad[i].x,&ad[i].y)
	}
	for i:=int64(0);i<n ; i++  {
		if ad[i].x<ad[i].y {
			if (ad[i].y-ad[i].x)%2!=0 {
				fmt.Println(1)
			}else {
				fmt.Println(2)
			}
		}else if ad[i].x>ad[i].y {
			if (ad[i].y-ad[i].x)%2!=0 {
				fmt.Println(2)
			}else {
				fmt.Println(1)
			}
		}else {
			fmt.Println(0)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d \n", &t)
	for i := 0; i < t; i++ {
	    var a,b int
		fmt.Scanf("%d %d \n", &a, &b)

		var ans = -1
		if a == b {
			ans = 0
		} else if a < b {
			if (b-a)%2 == 0 {
				ans = 2
			} else {
				ans = 1
			}
		} else {
			if (a-b)%2 == 0 {
				ans = 1
			} else {
				ans = 2
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		var diff = b - a
		if diff == 0 {
			fmt.Println(0)
		} else if diff > 0 {
			if diff%2 == 0 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		} else {
			if diff%2 == 0{
				fmt.Println(1)
			} else{
				fmt.Println(2)
			}
		}
	}
}

package main

import "fmt"

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

package main

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

func init() {
	log.SetFlags(0)
}

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

	if reader.Scan() {
		if err := reader.Err(); err != nil {
			log.Fatalln(err)
		}
	}

	n, err := strconv.Atoi(reader.Text())
	if err != nil {
		log.Fatalln(err)
	}

	var results []string
	for i := 0; i < n; i++ {
		if reader.Scan() {
			if reader.Err() != nil {
				log.Fatalln(err)
			}
			results = append(results, calc(strings.TrimSpace(reader.Text())))
		}
	}

	for i, v := range results {
		if i > 0 {
			fmt.Print("\n")
		}
		fmt.Print(v)
	}
}

func calc(s string) string {
	ss := strings.Fields(s)
	if n := len(ss); n != 2 {
		log.Fatalf("expected 2, got %d", n)
	}

	a, err := strconv.Atoi(ss[0])
	if err != nil {
		log.Fatalln(err)
	}
	b, err := strconv.Atoi(ss[1])
	if err != nil {
		log.Fatalln(err)
	}

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

	if a == b {
		return fmt.Sprint(0)
	}

	if ((b - a) > 0) && ((b-a)%2 == 1) {
		return fmt.Sprint(1)
	}

	if ((a - b) > 0) && ((b-a)%2 == 0) {
		return fmt.Sprint(1)
	}

	return fmt.Sprint(2)
}

package main

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

func main () {
	in := bufio.NewReader(os.Stdin);
	out := bufio.NewWriter(os.Stdout);
	var t int;
	fmt.Fscan(in, &t);
	for i := 0; i < t; i++ {
		a, b := 0, 0;
		fmt.Fscan(in, &a, &b);
		if (a == b) {
			fmt.Fprintln(out, 0);
		} else if ((b - a) > 0 && (b - a) % 2 == 1) {
			fmt.Fprintln(out, 1);
		} else if ((b - a) < 0 && (b - a) % 2 == 0) {
			fmt.Fprintln(out, 1);
		} else {
			fmt.Fprintln(out, 2);
		}
	}
	out.Flush();
}

// https://codeforces.com/problemset/problem/1311/A
package main

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

func findMoves(x, y string) {
	a, _ := strconv.ParseInt(x, 10, 32)
	b, _ := strconv.ParseInt(y, 10, 32)
	var ans string
	if a == b {
		ans = "0"
	} else if (a % 2) == (b % 2) {
		if a > b {
			ans = "1"
		} else {
			ans = "2"
		}
	} else {
		if a < b {
			ans = "1"
		} else {
			ans = "2"
		}
	}
	fmt.Println(ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	inputs, _ := strconv.ParseInt(scanner.Text(), 10, 32)
	var i int64
	for i = 0; i < inputs; i++ {
		var ab []string
		scanner.Scan()
		ab = strings.Split(scanner.Text(), " ")
		findMoves(ab[0], ab[1])
	}
}

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

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte,1<<12), 1<<20)
	s.Split(bufio.ScanWords)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	n := scanInt(s)

	for i := 0; i < n; i++ {
		a, b := scanInt(s), scanInt(s)
		c := 0
		if a < b {
			if (b - a)%2 == 0 {
				c = 2
			} else {
				c = 1
			}
		} else if a > b {
			if (a - b)%2 == 0 {
				c = 1
			} else {
				c = 2
			}
		} else {
			c = 0
		}
		fmt.Fprintln(w, c)
	}
}

package main

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

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

func main() {
	defer writer.Flush()

	var t int
	scanf("%d", &t)

	for i := 0; i < t; i++ {
		var a, b int
		scanf("%d %d", &a, &b)

		if a == b {
			printf("0")
			continue
		}

		bit := ((b-a) % 2 == 1) || ((b-a) % 2 == -1)
		sign := (b-a) > 0

		if bit == sign {
			printf("1")
		} else {
			printf("2")
		}
	}
}

 package main

 import (
         "fmt"
 )

 func main() {

         t := 0
         fmt.Scanf("%d\n", &t)
         for i := 0; i < t; i++ {
             var a,b int
             fmt.Scanf("%d %d\n", &a,&b)
             if a == b{
                 fmt.Println(0)

             }else if a < b{
                 if (b-a)%2 == 0{
                     fmt.Println(2)
                 }else{
                     fmt.Println(1)
                 }
             }else{
                 if (a-b)%2 == 0{
                     fmt.Println(1)
                 }else{
                     fmt.Println(2)
                 }
             }

        }
 }

package main

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

func main() {
	var t, a, b int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &a, &b)
		if a < b {
			if b%2 == a%2 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		} else if a > b {
			if b%2 == a%2 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else {
			fmt.Println(0)
		}
	}
}

// A. Add Odd or Subtract Even
/*
You are given two positive integers 𝑎 and 𝑏.

In one move, you can change 𝑎 in the following way:

    Choose any positive odd integer 𝑥 (𝑥>0) and replace 𝑎 with 𝑎+𝑥;
    choose any positive even integer 𝑦 (𝑦>0) and replace 𝑎 with 𝑎−𝑦.

You can perform as many such operations as you want. You can choose the same numbers 𝑥 and 𝑦 in different moves.

Your task is to find the minimum number of moves required to obtain 𝑏 from 𝑎. It is guaranteed that you can always obtain 𝑏 from 𝑎.

You have to answer 𝑡 independent test cases.

Input
The first line of the input contains one integer 𝑡 (1≤𝑡≤104) — the number of test cases.

Then 𝑡 test cases follow. Each test case is given as two space-separated integers 𝑎 and 𝑏 (1≤𝑎,𝑏≤109).

Output
For each test case, print the answer — the minimum number of moves required to obtain 𝑏 from 𝑎 if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain 𝑏 from 𝑎.

Example
Input
5
2 3
10 10
2 4
7 4
9 3

Output
1
0
2
2
1

Note
In the first test case, you can just add 1.

In the second test case, you don't need to do anything.

In the third test case, you can add 1 two times.

In the fourth test case, you can subtract 4 and add 1.

In the fifth test case, you can just subtract 6.
*/
package main

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

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

	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")
		a, _ := strconv.Atoi(arr[0])
		b, _ := strconv.Atoi(arr[1])

		if a == b {
			fmt.Println(0)
		} else if a > b {
			if (a-b)%2 == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else if a < b {
			if (b-a)%2 == 1 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	scanner.Scan()
	t := toInt(scanner.Bytes())

	for t > 0 {
		scanner.Scan()
		a := toInt(scanner.Bytes())
		scanner.Scan()
		b := toInt(scanner.Bytes())
		if a == b {
			fmt.Println(0)
			t--
			continue
		}
		if b > a {
			d := b - a
			if d % 2 != 0 || d == 1 {
				fmt.Println(1)
			}else {
				fmt.Println(2)
			}
		}else {
			d := b - a
			if d % 2 == 0 {
				fmt.Println(1)
			}else {
				fmt.Println(2)
			}
		}

		t--
	}

}

package main

import (
	"bufio"
	"os"
)

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	scanner.Scan()
	t := toInt(scanner.Bytes())

	for t > 0 {
		scanner.Scan()
		a := toInt(scanner.Bytes())
		scanner.Scan()
		b := toInt(scanner.Bytes())
		if a == b {
			out.WriteString("0\n")
			t--
			continue
		}
		if b > a {
			d := b - a
			if d % 2 != 0 {
				out.WriteString("1\n")
			}else {
				out.WriteString("2\n")
			}
		}else {
			d := b - a
			if d % 2 == 0 {
				out.WriteString("1\n")
			}else {
				out.WriteString("2\n")
			}
		}

		t--
	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Scan(&a, &b)
		if a == b {
			fmt.Println(0)
		} else if (b > a && (b-a)%2 == 1) || (b < a && (a-b)%2 == 0) {
			fmt.Println(1)
		} else {
			fmt.Println(2)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Scan(&a, &b)
		if a == b {
			fmt.Println(0)
		} else if a > b {
			if a%2 != b%2 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		} else {
			if a%2 != b%2 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

import (
	"fmt"
)

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

	as := make([]int, tests)
	bs := make([]int, tests)

	for i := 0; i < tests; i++ {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		as[i] = a
		bs[i] = b
	}

	for i := range as {
		fmt.Println(steps(as[i], bs[i]))
	}
}

func steps(a, b int) int {
	if a < b {
		// increase a by odd number.
		delta := b - a
		if isEven(delta) {
			delta--
		}
		// calculate again.
		return steps(a+delta, b) + 1
	}

	if a > b {
		// decrease a by even number.
		delta := a - b
		if isOdd(delta) {
			delta++
		}
		// calculate again.
		return steps(a-delta, b) + 1
	}

	return 0
}

func isOdd(num int) bool {
	return num%2 != 0
}

func isEven(num int) bool {
	return num%2 == 0
}

package main

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

type Scan struct {
	f *os.File
	in *bufio.Reader
	out *bufio.Writer
}

func setup() *Scan {
	r := &Scan{ f: nil }

	inputFile := os.Getenv("INPUT_FILE")
	if inputFile != "" {
		var err error
		if r.f, err = os.Open(inputFile); err == nil {
			os.Stdin = r.f
		}
	}
	r.in = bufio.NewReader(os.Stdin)
	r.out = bufio.NewWriter(os.Stdout)

	return r
}

func (r *Scan) close() {
	if r.f != nil {
		r.f.Close()
	}
}

func (r *Scan) readString() string {
	var x string
	fmt.Fscan(r.in, &x)
	return x
}

func (r *Scan) readInt() int {
	x, err := strconv.Atoi(r.readString())
	if err != nil {
		panic(err)
	}
	return x
}

func (r *Scan) strings(refs ... *string) {
	for _, ref := range refs {
		*ref = r.readString()
	}
}

func (r *Scan) ints(refs ... *int) {
	for _, ref := range refs {
		*ref = r.readInt()
	}
}

func (r *Scan) print(s string) {
	fmt.Printf("%s", s)
}

func main() {
	scan := setup()

	var t, a, b int

	scan.ints(&t)
	for tc := 0; tc < t; tc++ {
		scan.ints(&a, &b)
		diff := b-a
		mves := 0
		if diff > 0 {
			if (diff%2) == 1 {
				mves = 1
			} else {
				mves = 2
			}
		} else if diff < 0 {
			if (-diff)%2 == 1 {
				mves = 2
			} else {
				mves = 1
			}
		}
		fmt.Printf("%d\n", mves)
	}

	scan.close()
}

package main

import (
	"fmt"
	"os"
)

var f *os.File = nil

func setup() {
	inputFile := os.Getenv("INPUT_FILE")
	if inputFile != "" {
		var err error
		if f, err = os.Open(inputFile); err == nil {
			os.Stdin = f
		}
	}
}

func cleanUp() {
	if f != nil {
		f.Close()
	}
}

func main() {
	setup()

	var t, a, b int

	fmt.Scanf("%d\n", &t)
	for tc := 0; tc < t; tc++ {
		fmt.Scanf("%d %d\n", &a, &b)
		diff := b-a
		mves := 0
		if diff > 0 {
			if (diff%2) == 1 {
				mves = 1
			} else {
				mves = 2
			}
		} else if diff < 0 {
			if (-diff)%2 == 1 {
				mves = 2
			} else {
				mves = 1
			}
		}
		fmt.Printf("%d\n", mves)
	}

	cleanUp()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 3*1024*1024)
	scanner.Buffer(buffer, 10*1024*1024)
	scanner.Split(bufio.ScanWords)

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

	for t := input(); t > 0; t-- {
		a, b := input(), input()

		if a == b {
			fmt.Println(0)
		} else if b < a {
			if (a-b)%2 == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else if b > a {
			if (b-a)%2 == 1 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		var a, b int
		fmt.Scan(&a, &b)

		if a == b {
			fmt.Println(0)
		} else if a > b {
			if (a - b) % 2 == 0 {
				// subtract even, one move
				fmt.Println(1)
			} else {
				// odd difference, subtract even and add one
				fmt.Println(2)
			}
		} else if b > a {
			if (a - b) % 2 == 0 {
				// add odd twice
				fmt.Println(2)
			} else {
				// add odd once
				fmt.Println(1)
			}
		}
	}
}

package main

import (
	"fmt"
)

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

/**
 * Copyright shopee
 * @Author : Yuxiang.Lei
 * @MailBox: Yuxiang.Lei@shopee.com
 * @Date : 2020-02-24
 * @Version: v2.4
 **/

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b int
		fmt.Scanf("%d %d\n", &a, &b)
		if a==b {
			fmt.Println(0)
		} else if a > b {
			if (a-b) % 2 == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else {
			if (b-a) % 2 == 0 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		}
	}
}

/**
 * Copyright shopee
 * @Author : Yuxiang.Lei
 * @MailBox: Yuxiang.Lei@shopee.com
 * @Date : 2020-02-24
 * @Version: v2.4
 **/

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a,b int64
		fmt.Scanf("%d %d\n", &a, &b)
		if a==b {
			fmt.Println(0)
		} else if a > b {
			if (a-b) % 2 == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else {
			if (b-a) % 2 == 0 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		}
	}
}

package main

import "fmt"

func solve(a int64, b int64) int64 {
	if a == b {
		return 0
	}
	if a < b {
		if (b-a)%2 == 0 {
			return 2
		}
		return 1
	} else {
		if (a-b)%2 == 0 {
			return 1
		}
		return 2
	}
}

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

	for cas := 1; cas <= T; cas++ {
		var a, b int64
		fmt.Scanf("%v %v\n", &a, &b)
		fmt.Println(solve(a, b))
	}
}

package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		fmt.Scan(&a, &b)
		if a < b {
			if (b - a) % 2 == 0 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		} else if b < a {
			if (a - b) % 2 == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else {
			fmt.Println(0)
		}
	}
}

package main
import."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, a, b int
	for Scan(&T); T > 0; T-- {
		Scan(&a, &b)
		c := 0
		if a != b {
			c = 1
			if a < b != ((b-a)&1 > 0) {
				c = 2
			}
		}
		Println(c)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var a,b uint32
	fmt.Fscanf(in, "%d\n", &n)
	for k := 0; uint16(k) < n; k++{
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a > b{
			// hasna
			d := a - b
			if d % 2 == 0{
				fmt.Println(1)
			}else{
				fmt.Println(2)
			}

		}else if b > a {
			// nemne
			d := b - a
			if d % 2 != 0{
				fmt.Println(1)
			}else{
				fmt.Println(2)
			}
		}else if a == b{
			fmt.Println(0)
		}
	}

}

 package main

 import (
         "fmt"
 )

 func main() {

         t := 0
         fmt.Scanf("%d\n", &t)
         for i := 0; i < t; i++ {
             var a,b int
             fmt.Scanf("%d %d\n", &a,&b)
             if a == b{
                 fmt.Println(0)

             }else if a < b{
                 if (b-a)%2 == 0{
                     fmt.Println(2)
                 }else{
                     fmt.Println(1)
                 }
             }else{
                 if (a-b)%2 == 0{
                     fmt.Println(2)
                 }else{
                     fmt.Println(1)
                 }
             }

        }
 }

package main

import (
	"fmt"
)

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

	for i := 0; i < tests; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		fmt.Println(steps(a, b))
	}
}

func steps(a, b int) int {
	if a < b {
		// increase a by odd number.
		delta := b - a
		if isEven(delta) {
			delta--
		}
		// calculate again.
		return steps(a+delta, b) + 1
	}

	if a > b {
		// decrease a by even number.
		delta := a - b
		if isOdd(delta) {
			delta++
		}
		// calculate again.
		return steps(a-delta, b) + 1
	}

	return 0
}

func isOdd(num int) bool {
	return num%2 != 0
}

func isEven(num int) bool {
	return num%2 == 0
}

package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		fmt.Scan(&a, &b)
		if a < b {
			if (b - a) % 2 == 0 {
				println(2)
			} else {
				println(1)
			}
		} else if b < a {
			if (a - b) % 2 == 0 {
				println(1)
			} else {
				println(2)
			}
		} else {
			println(0)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		fmt.Scan(&a, &b)
		if a < b {
			if (b - a) % 2 == 0 {
				println(2)
			} else {
				println(1)
			}
		} else if b < a {
			if (a - b) % 2 == 0 {
				println(1)
			} else {
				println(2)
			}
		} else {
			print(0)
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		var diff = b - a
		if diff == 0 {
			fmt.Println(0)
		} else if diff > 0 {
			if diff%2 == 0 {
				fmt.Println(2)
			} else {
				fmt.Println(1)
			}
		} else {
			if diff%2 == 0{
				fmt.Println(1)
			} else{
				fmt.Println(2)
			}
		}
	}
}


package main

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

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

	var buf bytes.Buffer

	n := readNum(reader)
	edges := make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		edges[i] = readNNums(reader, 2)
	}
	q := readNum(reader)
	queries := make([][]int, q)

	for i := 0; i < q; i++ {
		k := readNum(reader)
		queries[i] = readNNums(reader, k)
	}
	res := solve(n, edges, queries)
	for _, ans := range res {
		if ans {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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

func normalize(s string) string {

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

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

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

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

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

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

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

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

	return i
}

const H = 20

func solve(n int, edges [][]int, queries [][]int) []bool {

	g := NewGraph(n, 2*(n-1))

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

	D := make([]int, n)

	in := make([]int, n)
	out := make([]int, n)

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

	var dfs func(p, u int)
	var time int
	dfs = func(p, u int) {
		P[u][0] = p
		for i := 1; i < H; i++ {
			P[u][i] = P[P[u][i-1]][i-1]
		}
		in[u] = time
		time++
		for i := g.node[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				dfs(u, v)
			}
		}
		out[u] = time
		time++
	}

	dfs(0, 0)

	isAncestor := func(u, v int) bool {
		return in[u] <= in[v] && out[v] <= out[u]
	}

	lca := func(u, v int) int {
		if D[u] < D[v] {
			u, v = v, u
		}
		for i := H - 1; i >= 0; i-- {
			if D[u]-(1<<i) >= D[v] {
				u = P[u][i]
			}
		}
		if u == v {
			return u
		}
		for i := H - 1; i >= 0; i-- {
			if P[u][i] != P[v][i] {
				u = P[u][i]
				v = P[v][i]
			}
		}
		return P[u][0]
	}

	arr := make([]int, n)

	check := func(query []int) bool {
		if len(query) <= 2 {
			return true
		}
		m := len(query)

		for i := 0; i < m; i++ {
			query[i]--
		}
		sort.Slice(query, func(i, j int) bool {
			a := query[i]
			b := query[j]
			return D[a] < D[b]
		})

		var it int

		x := query[m-1]

		for i := m - 2; i >= 0; i-- {
			y := query[i]
			if isAncestor(y, x) {
				x = y
			} else {
				arr[it] = y
				it++
			}
		}
		if it == 0 {
			return true
		}
		// last one is x
		u := arr[0]

		for i := 1; i < it; i++ {
			v := arr[i]
			if !isAncestor(v, u) {
				return false
			}
			u = v
		}

		p1 := lca(arr[0], query[m-1])
		p2 := lca(u, x)

		return p1 == p2
	}

	ans := make([]bool, len(queries))

	for i, cur := range queries {
		ans[i] = check(cur)
	}
	return ans
}

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

func NewGraph(n int, e int) *Graph {
	g := new(Graph)
	g.node = make([]int, n)
	g.next = make([]int, e+1)
	g.to = make([]int, e+1)
	g.cur = 0
	return g
}

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

package main

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

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

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	edges := make([][]int, n)
	for i:=1;i<n;i++ {
		var u, v int
		fmt.Fscan(rr, &u, &v)
		u, v = u - 1, v - 1
		edges[u] = append(edges[u], v)
		edges[v] = append(edges[v], u)
	}
	var q int
	fmt.Fscan(rr, &q)
	for qq:=0;qq<q;qq++ {
		set := map[int]bool{}
		var m int
		fmt.Fscan(rr, &m)
		for i:=0;i<m;i++ {
			var a int
			fmt.Fscan(rr, &a)
			set[a-1] = true
		}
		ans := "YES"
		var dfs func(i int, last int, has bool) int
		dfs = func(i, last int, has bool) int {
			cnt := 0
			sum := 0
			newhas := has
			if set[i] {
				newhas = true
			}
			maxcur := 1
			for _, v := range edges[i] {
				if v == last {
					continue
				}
				cur := dfs(v, i, newhas)
				maxcur = max(maxcur, cur)
				if cur >= 2 && set[i] {
					ans = "NO"
				}
				if cur > 0 {
					cnt++
				}
				sum += cur
			}
			if sum >= 3 {
				ans = "NO"
			}
			if cnt == 1 {
				return maxcur
			} else if cnt == 2 {
				return 2
			} else if cnt >= 3 {
				ans = "NO"
				return 2
			} else if set[i] {
				return 1
			} else {
				return 0
			}
		}
		dfs(0, -1, false)
		fmt.Fprintln(ww, ans)
	}
}

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

package main

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

func solve0(n int, a [][]int, s []bool) {
	k := get()
	for i := range s {
		s[i] = false
	}
	var start int
	for t := k; t > 0; t-- {
		start = get() - 1
		s[start] = true
	}

	var dfs func(v, p, max int) int
	dfs = func(v, p, max int) int {
		count := 0
		for _, u := range a[v] {
			if u != p {
				switch dfs(u, v, 1) {
				case 1:
					if count == max {
						return 2
					}
					count++
				case 2:
					return 2
				}
			}
		}
		if count > 0 || s[v] {
			return 1
		}
		return 0
	}
	yn(dfs(start, -1, 2) != 2)
}

func solve() {
	n := get()
	a := make([][]int, n)
	for t := n - 1; t > 0; t-- {
		v := get() - 1
		u := get() - 1
		a[v] = append(a[v], u)
		a[u] = append(a[u], v)
	}

	q := get()
	s := make([]bool, n)
	for t := q; t > 0; t-- {
		solve0(n, a, s)
	}
}

const (
	once       = true
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
)

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

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

	if once {
		solve()
		return
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

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

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	edges := make([][]int, n)
	for i:=1;i<n;i++ {
		var u, v int
		fmt.Fscan(rr, &u, &v)
		u, v = u - 1, v - 1
		edges[u] = append(edges[u], v)
		edges[v] = append(edges[v], u)
	}
	var q int
	fmt.Fscan(rr, &q)
	for qq:=0;qq<q;qq++ {
		set := map[int]bool{}
		var m int
		fmt.Fscan(rr, &m)
		for i:=0;i<m;i++ {
			var a int
			fmt.Fscan(rr, &a)
			set[a-1] = true
		}
		ans := "YES"
		var dfs func(i int, last int, has bool) int
		dfs = func(i, last int, has bool) int {
			cnt := 0
			sum := 0
			newhas := has
			if set[i] {
				newhas = true
			}
			for _, v := range edges[i] {
				if v == last {
					continue
				}
				cur := dfs(v, i, newhas)
				if cur == 2 && set[i] {
					ans = "NO"
				}
				if cur > 0 {
					cnt++
				}
				sum += cur
			}
			if sum >= 3 {
				ans = "NO"
			}
			if cnt == 1 {
				return 1
			} else if cnt == 2 {
				return 2
			} else if cnt >= 3 {
				ans = "NO"
				return 2
			} else if set[i] {
				return 1
			} else {
				return 0
			}
		}
		dfs(0, -1, false)
		fmt.Fprintln(ww, ans)
	}
}

package main

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

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

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	edges := make([][]int, n)
	for i:=1;i<n;i++ {
		var u, v int
		fmt.Fscan(rr, &u, &v)
		u, v = u - 1, v - 1
		edges[u] = append(edges[u], v)
		edges[v] = append(edges[v], u)
	}
	var q int
	fmt.Fscan(rr, &q)
	for qq:=0;qq<q;qq++ {
		set := map[int]bool{}
		var m int
		fmt.Fscan(rr, &m)
		for i:=0;i<m;i++ {
			var a int
			fmt.Fscan(rr, &a)
			set[a-1] = true
		}
		ans := "YES"
		var dfs func(i int, last int, has bool) int
		dfs = func(i, last int, has bool) int {
			cnt := 0
			sum := 0
			newhas := has
			if set[i] {
				newhas = true
			}
			for _, v := range edges[i] {
				if v == last {
					continue
				}
				cur := dfs(v, i, newhas)
				if cur > 0 {
					cnt++
				}
				sum += cur
			}
			if set[i] {
				sum++
			}
			if (cnt >= 2 && has) || (cnt >= 3) {
				ans = "NO"
			}
			return sum
		}
		dfs(0, -1, false)
		fmt.Fprintln(ww, ans)
	}
}


package main
import (
  "bufio"
  "fmt"
  //"sort"
  "os"
)
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(){
  I,O:=bufio.NewReader(os.Stdin),bufio.NewWriter(os.Stdout);defer O.Flush()

  var t,n,a,b,u,v,w int
  fmt.Fscan(I,&t)
  for i:=0;i<t;i++{
    fmt.Fscan(I,&n,&a,&b);g:=make([][][]int,n+1)
    for j:=0;j<n-1;j++{
      fmt.Fscan(I,&u,&v,&w)
      g[u]=append(g[u],[]int{v,w});g[v]=append(g[v],[]int{u,w}) //带权图
    }
    var f func(int)map[int]bool
    f=func(start int)(map[int]bool){
      z:=map[int]bool{}
      var dfs func(int,int,int)
      dfs=func(u,fa,x int){
        if u!=b{z[x]=true}
        for _,V:=range g[u]{v,w:=V[0],V[1];if v!=fa && v!=b{dfs(v,u,x^w)}}
      }
      dfs(start,0,0)
      return z
    }
    // a->c路径值为x，b->d路径（长度最短为2）值为y，c和d可以相同（此时不使用瞬移）
    // 即求是否存在x==y
    z:="NO";v1,v2:=f(a),f(b)
    if len(v1)>len(v2){v1,v2=v2,v1}
    for k:=range v1{
      if ok:=v2[k];ok{z="YES";break}
    }
    fmt.Fprintln(O,z)
  }
}

package main

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

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

// source: https://codeforces.com/contest/1760/problem/G
func solve() {
	n, a, b := _readInt(), _readInt(), _readInt()
	graph := make([]map[int]int, n+1)
	for i := 0; i < n-1; i++ {
		u, v, w := _readInt(), _readInt(), _readInt()
		if graph[u] == nil {
			graph[u] = make(map[int]int)
		}
		if graph[v] == nil {
			graph[v] = make(map[int]int)
		}
		graph[u][v] = w
		graph[v][u] = w
	}

	vals := make(map[int]bool)
	var dfs1 func(v, prev, x int)
	dfs1 = func(v, prev, x int) {
		if v == b {
			return
		}
		vals[x] = true
		for u, w := range graph[v] {
			if u == prev {
				continue
			}
			dfs1(u, v, w^x)
		}
	}
	dfs1(a, -1, 0)

	var dfs2 func(v, prev, x int) bool
	dfs2 = func(v, prev, x int) bool {
		if v != b && vals[x] {
			return true
		}
		for u, w := range graph[v] {
			if u == prev {
				continue
			}
			if dfs2(u, v, w^x) {
				return true
			}
		}
		return false
	}

	if dfs2(b, -1, 0) {
		_print("YES")
	} else {
		_print("NO")
	}
}

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

// ====
func _readInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}
func _readStr() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}
func _readArr(x ...int) (int, []int) {
	var n int
	if len(x) == 0 {
		fmt.Fscan(in, &n)
	} else {
		n = x[0]
	}
	var v = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &v[i])
	}
	return n, v
}
func _print(x ...any) {
	fmt.Fprintln(out, x...)
}
func _max(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] > x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _min(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] < x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _sum(x ...int) int {
	res := 0
	for _, i := range x {
		res += i
	}
	return res
}
func _abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func _sortStr(x string) string {
	r := []rune(x)
	sort.Slice(r, func(i, j int) bool {
		return r[i] < r[j]
	})
	return string(r)
}
func _reverseInts(x []int) {
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
}
func _reverseStr(s string) string {
	x := []rune(s)
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
	return string(x)
}
func _makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

const cf = true

type edge struct {
	to int
	w  int
}

func solve() {
	var n, a, b int
	fmt.Fscan(in, &n, &a, &b)
	graph := map[int][]edge{}
	for i := 1; i < n; i++ {
		var u, v, w int
		fmt.Fscan(in, &u, &v, &w)
		graph[u] = append(graph[u], edge{to: v, w: w})
		graph[v] = append(graph[v], edge{to: u, w: w})
	}

	vals := map[int]struct{}{}

	visitedB := map[int]struct{}{}

	dfsB := func(cur int, x int) { panic(1) }
	dfsB = func(cur int, x int) {
		visitedB[cur] = struct{}{}
		if cur != b {
			vals[x] = struct{}{}
		}
		for _, neighbour := range graph[cur] {
			if _, ok := visitedB[neighbour.to]; !ok {
				dfsB(neighbour.to, x^neighbour.w)
			}
		}
	}
	dfsB(b, 0)

	visitedA := map[int]struct{}{}

	dfsA := func(cur, x int) bool { panic(1) }
	dfsA = func(cur, x int) bool {
		if cur == b {
			return false
		}
		visitedA[cur] = struct{}{}
		if _, ok := vals[x]; ok {
			return true
		}
		for _, neighbour := range graph[cur] {
			if _, ok := visitedA[neighbour.to]; !ok {
				if dfsA(neighbour.to, x^neighbour.w) {
					return true
				}
			}
		}
		return false
	}
	if dfsA(a, 0) {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}
}

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

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func GCD(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

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

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

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n,a,b int
		Fscan(in, &n,&a,&b)
		a--
		b--
		type nb struct{ to, wt int }
		g := make([][]nb, n)
		for i := 0; i < n-1; i++ {
			v, w, wt := 0, 0, 0
			Fscan(in, &v, &w, &wt)
			v--
			w--
			g[v] = append(g[v], nb{w, wt})
			g[w] = append(g[w], nb{v, wt})
		}

		m := map[int]bool{}
		ok := false
		var d0 func(v, fa ,xor int)
		d0 = func(v, fa ,xor int) {
			m[xor] = true
			for _, e := range g[v] {
				w := e.to
				if w != fa  {
					if w == b {
						if xor ^e.wt == 0 {
							ok = true
						}
						continue
					}
					d0(w, v,xor ^ e.wt)
				}
			}
		}
		d0(a, -1, 0)
		if ok {
			Fprintln(out, "YES")
			return
		}

		var d1 func(v, fa ,xor int)
		d1 = func(v, fa ,xor int) {
			if fa != -1 && m[xor] {
				ok = true
			}
			for _, e := range g[v] {
				w := e.to
				if w != fa  {
					d1(w, v,xor ^ e.wt)
				}
			}
		}
		d1(b, -1, 0)

		if ok{
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

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

}

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

package main

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

func dfs(adj [][][]int, vis []bool, xor []int, i, x int, b int) {
	vis[i] = true
	xor[i] = x
	if i == b {
		return
	}

	for _, v := range adj[i] {
		if ! vis[v[0]] {
			dfs(adj, vis, xor, v[0], x ^ v[1], b)
		}
	}
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, a, b int
		fmt.Fscan(r, &n, &a, &b)
		a--
		b--

		adj := make([][][]int, n)
		for i := 0; i < n-1; i++ {
			var u, v, w int
			fmt.Fscan(r, &u, &v, &w)
			u--
			v--
			adj[u] = append(adj[u], []int{v, w})
			adj[v] = append(adj[v], []int{u, w})
		}

		// fmt.Fprintln(w, "%%% n a b", n, a, b)
		// fmt.Fprintln(w, "%%% vis1", vis1)
		// fmt.Fprintln(w, "%%% adj", adj)
		xor1 := make([]int, n)
		for i := range xor1 {
			xor1[i] = -1
		}
		vis1 := make([]bool, n)
		dfs(adj, vis1, xor1, a, 0, b)

		xor2 := make([]int, n)
		vis2 := make([]bool, n)
		dfs(adj, vis2, xor2, b, 0, -1)

		m := make(map[int]bool)
		for i, v := range xor2 {
			if i != b {
				m[v] = true
			}
		}

		res := "NO"
		for i, v := range xor1 {
			if (i != b && m[v]) || (i == b && v == 0) {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main
import (
  "bufio"
  "fmt"
  //"sort"
  "os"
)
/*
题意：一棵树中，x起始值为0，每走过一条值为w的边，值变为x^w。最多允许在两点之间瞬移一次（且不允许瞬移到b），
进入点b的条件是x为0。问：从某个节点a出发，能否到达点b？

用u->v:val表示：从u出发到达某点v时路径上的异或和为val。设a->c(不经过点b):val1, b->d:val2，
也就是说存在这样的点c和d，使得val1==val2，若c与d相同，表示不使用瞬移，
那么解法就是分别求a,b出发的异或和，检查是否存在相同值。
若不采用“分别求异或和再检查交集”的做法，可以在求b出发的异或和时边在f(a)的结果中检测，及时返回。
*/
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(){
  I,O:=bufio.NewReader(os.Stdin),bufio.NewWriter(os.Stdout);defer O.Flush()

  var t,n,a,b,u,v,w int
  fmt.Fscan(I,&t)
  for i:=0;i<t;i++{
    fmt.Fscan(I,&n,&a,&b);g:=make([][][]int,n+1)
    for j:=0;j<n-1;j++{
      fmt.Fscan(I,&u,&v,&w)
      g[u]=append(g[u],[]int{v,w});g[v]=append(g[v],[]int{u,w}) //带权图
    }

    m:=map[int]bool{};ok:=false
    var f1 func(int,int,int)
    f1=func(u,fa,x int){
      if u==b{if x==0{ok=true};return}
      m[x]=true
      for _,V:=range g[u]{v,w:=V[0],V[1];if v!=fa{f1(v,u,x^w)}}
    }
    f1(a,0,0)
    if ok{fmt.Fprintln(O,"YES");continue}

    var f2 func(int,int,int)
    f2=func(u,fa,x int){
      if u!=b && m[x]{ok=true;return}
      for _,V:=range g[u]{v,w:=V[0],V[1];if v!=fa{f2(v,u,x^w)}}
    }
    f2(b,0,0);z:="NO"
    if ok{z="YES"}
    fmt.Fprintln(O,z)
  }
}

package main

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

func dfs(adj [][][]int, vis []bool, xor []int, i, x int) {
	vis[i] = true
	xor[i] = x

	for _, v := range adj[i] {
		if ! vis[v[0]] {
			dfs(adj, vis, xor, v[0], x ^ v[1])
		}
	}
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, a, b int
		fmt.Fscan(r, &n, &a, &b)
		a--
		b--

		adj := make([][][]int, n)
		xor1 := make([]int, n)
		xor2 := make([]int, n)
		vis1 := make([]bool, n)
		vis2 := make([]bool, n)

		for i := 0; i < n-1; i++ {
			var u, v, w int
			fmt.Fscan(r, &u, &v, &w)
			u--
			v--
			adj[u] = append(adj[u], []int{v, w})
			adj[v] = append(adj[v], []int{u, w})
		}

		// fmt.Fprintln(w, "%%% n a b", n, a, b)
		// fmt.Fprintln(w, "%%% vis1", vis1)
		// fmt.Fprintln(w, "%%% adj", adj)
		dfs(adj, vis1, xor1, a, 0)
		dfs(adj, vis2, xor2, b, 0)

		m := make(map[int]bool)
		for i, v := range xor2 {
			if i != b {
				m[v] = true
			}
		}

		res := "NO"
		for i, v := range xor1 {
			if (i != b && m[v]) || (i == b && v == 0) {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

type deque[T any] struct {
	q []T
}

func (q *deque[T]) emplace(n T) {
	q.q = append(q.q, n)
}

func (q deque[T]) empty() bool {
	return len(q.q) == 0
}

func (q deque[T]) back() T {
	if q.empty() {
		panic("back() performed on empty deque")
	}
	return q.q[len(q.q)-1]
}

func (q *deque[T]) popback() T {
	if q.empty() {
		panic("popback() performed on empty deque")
	}
	res := q.back()
	q.q = q.q[:len(q.q)-1]
	return res
}

func (q deque[T]) front() T {
	if q.empty() {
		panic("front() performed on empty deque")
	}
	return q.q[0]
}

func (q *deque[T]) popfront() T {
	if q.empty() {
		panic("popfront() performed on empty deque")
	}
	res := q.front()
	q.q = q.q[1:]
	return res
}

func getdeque[T any](capacity int) deque[T] {
	return deque[T]{ make([]T, 0, capacity) }
}

func bfs(adj [][][]int, vis []bool, xor []int, i, x int) {
	q := getdeque[int](1e6)
	vis[i] = true
	q.emplace(i)

	for ! q.empty() {
		j := q.popfront()
		for _, v := range adj[j] {
			if ! vis[v[0]] {
				vis[v[0]] = true
				xor[v[0]] = x ^ v[1]
				q.emplace(v[0])
			}
		}
	}
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, a, b int
		fmt.Fscan(r, &n, &a, &b)
		a--
		b--

		adj := make([][][]int, n)
		xor1 := make([]int, n)
		xor2 := make([]int, n)
		vis1 := make([]bool, n)
		vis2 := make([]bool, n)

		for i := 0; i < n-1; i++ {
			var u, v, w int
			fmt.Fscan(r, &u, &v, &w)
			u--
			v--
			adj[u] = append(adj[u], []int{v, w})
			adj[v] = append(adj[v], []int{u, w})
		}

		// fmt.Fprintln(w, "%%% n a b", n, a, b)
		// fmt.Fprintln(w, "%%% vis1", vis1)
		// fmt.Fprintln(w, "%%% adj", adj)
		bfs(adj, vis1, xor1, a, 0)
		bfs(adj, vis2, xor2, b, 0)

		m := make(map[int]bool)
		for i, v := range xor2 {
			if i != b {
				m[v] = true
			}
		}

		res := "NO"
		for i, v := range xor1 {
			if (i != b && m[v]) || (i == b && v == 0) {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main
import (
  "bufio"
  "fmt"
  //"sort"
  "os"
)
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(){
  I,O:=bufio.NewReader(os.Stdin),bufio.NewWriter(os.Stdout);defer O.Flush()

  var t,n,a,b int
  fmt.Fscan(I,&t)
  for i:=0;i<t;i++{
    fmt.Fscan(I,&n,&a,&b);g:=make([][][]int,n+1)
    for j:=0;j<n-1;j++{
      var u,v,w int
      fmt.Fscan(I,&u,&v,&w)
      g[u]=append(g[u],[]int{v,w});g[v]=append(g[v],[]int{u,w}) //带权图
    }
    var f func(int)map[int]bool
    f=func(start int)(map[int]bool){
      z:=map[int]bool{}
      var dfs func(int,int,int)
      dfs=func(u,fa,x int){
        if u!=b{z[x]=true}
        for _,V:=range g[u]{v,w:=V[0],V[1];if v!=fa{dfs(v,u,x^w)}}
      }
      dfs(start,0,0)
      return z
    }
    // a->c路径值为x，b->d路径（长度最短为2）值为y，c和d可以相同（此时不使用瞬移）
    // 即求是否存在x==y
    z:="NO";v1,v2:=f(a),f(b)
    if len(v1)>len(v2){v1,v2=v2,v1}
    for k:=range v1{
      if ok:=v2[k];ok{z="YES";break}
    }
    fmt.Fprintln(O,z)
  }
}


package main

import (
	"bufio"
	"container/heap"
	"os"
	"runtime"
	"sort"
	"strconv"
)

/* solution */

type sect struct {
	l int
	r int
}

type event struct {
	t     int
	time  int
	index int
}

type eventArr []event

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

type heapItem struct {
	index int
	r     int
}

type heapStorage struct {
	storage []heapItem
	pos     []int
}

func (h heapStorage) Len() int           { return len(h.storage) }
func (h heapStorage) Less(i, j int) bool { return h.storage[i].r > h.storage[j].r }
func (h heapStorage) Swap(i, j int) {
	h.storage[i], h.storage[j] = h.storage[j], h.storage[i]
	h.pos[h.storage[i].index] = i
	h.pos[h.storage[j].index] = j
}

func (h *heapStorage) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	item := x.(heapItem)
	h.storage = append(h.storage, item)
	h.pos[item.index] = len(h.storage) - 1
}

func (h *heapStorage) Pop() interface{} {
	old := *h
	n := len(old.storage)
	x := old.storage[n-1]
	h.pos[x.index] = -1
	h.storage = old.storage[0 : n-1]
	return x
}

func solve() {

	n, k := readInt(), readInt()
	a := make([]sect, n)
	e := make(eventArr, 2*n)
	for i := 0; i < n; i++ {
		l, r := readInt(), readInt()
		a[i] = sect{l: l, r: r}
		e[2*i] = event{t: 1, time: l, index: i}
		e[2*i+1] = event{t: -1, time: r + 1, index: i}
	}

	sort.Sort(e)

	h := &heapStorage{storage: make([]heapItem, 0), pos: make([]int, n)}
	ans := make([]int, 0)

	for i := 0; i < 2*n; i++ {
		if e[i].t == 1 {
			heap.Push(h, heapItem{index: e[i].index, r: a[e[i].index].r})
		} else {
			idx := h.pos[e[i].index]
			if idx > -1 {
				h.storage[idx].r = 1000000
				heap.Fix(h, idx)
				heap.Pop(h)
			}
		}
		if i < 2*n-1 && e[i+1].time == e[i].time {
			continue
		}
		for len(h.storage) > k {
			x := heap.Pop(h).(heapItem)
			ans = append(ans, x.index+1)
		}
	}

	printInt(len(ans))
	ln()
	for i := 0; i < len(ans); i++ {
		printInt(ans[i])
	}

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString(" ")
}

func ln() {
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

type Pair struct {
	value int
	idx int
}

type PairSorter [] Pair

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

func (a PairSorter) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a PairSorter) Len() int {
	return len(a)
}

const N = 222
var n, k int
var seg[N] PairSorter

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	for i := 1; i <= n; i++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		if seg[u] == nil {
			seg[u] = make([]Pair, 0)
		}
		seg[u] = append(seg[u], Pair{v, i})
	}

	var cur = make(PairSorter, 0)
	var clr = make([]int, 0)

	for i := 1; i < N; i++ {
		for _, value := range seg[i] {
			cur = append(cur, value)
		}
		sort.Sort(cur)

		var wt = 0
		var newSt = make(PairSorter, 0)

		for _, value := range cur {
			if value.value >= i {
				wt++
				if wt <= k {
					newSt = append(newSt, value)
				} else {
					clr = append(clr, value.idx)
				}
			}
		}

		cur = newSt
	}

	fmt.Fprintf(writer, "%d\n", len(clr))
	for _, value := range clr {
		fmt.Fprintf(writer, "%d ", value)
	}
}


package main

import "fmt"

func main() {
    var n,m int
    var a [105][105]int
    fmt.Scan(&n,&m)
    for i := 0; i < n; i++ {
        for j := 0; j < m; j++ {
            fmt.Scan(&a[i][j])
        }
    }
    ans := n
    for (ans > 1) && (ans%2 == 0) {
        ok := true
        for i := 0; (i < ans/2) && ok; i++ {
            for j := 0; j < m; j++ {
                if a[i][j] != a[ans-i-1][j] {
                    ok = false
                    break
                }
            }
        }
        if !ok { break } else { ans /= 2 }
    }
    fmt.Println(ans)
}

// 426B
package main

import (
	"fmt"
)

func main() {
	var n, m int
	var xy [100][100]int
	flag := true
	fmt.Scan(&n, &m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scan(&xy[i][j])
		}
	}
	for n%2 == 0 && flag == true {
		flag = true
		for i := 0; i < n/2; i++ {
			for j := 0; j < m; j++ {
				if xy[i][j] == xy[n-1-i][j] {
					continue
				}
				flag = false
				break
			}
			if flag == false {
				break
			}
		}
		if flag == true {
			n = n / 2
		}
	}
	fmt.Println(n)
}

// 426B-mic
package main

import (
	"fmt"
)

func main() {
	var a [107][107]int
	f := true
	var n, m int
	fmt.Scan(&n, &m)
	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	for n%2 == 0 {
		b := n / 2
		for i := 1; i <= b; i++ {
			for j := 1; j <= m; j++ {
				if a[n+1-i][j] != a[i][j] {
					f = false
					break
				}
			}
		}
		if !f {
			break
		} else {
			n /= 2
		}
	}
	fmt.Println(n)
}

package main

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

func main(){
	var n, m int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	var a [101][101]int
	for i:=0; i<n; i++ {
		for j:=0; j<m; j++ {
			r.Scan()
			a[i][j], _ = strconv.Atoi(r.Text())
		}
	}
	ans := n
	nn := n
	ii := 0
	for nn % 2 == 0 {
		ii = nn - 1
		nn = nn / 2
		for i:=0; i<nn; i++ {
			for j:=0; j<m; j++ {
				if a[i][j] != a[ii][j] {
					w.WriteString(strconv.Itoa(ans)+"\n")
					w.Flush()
					return
				}
			}
			ii -= 1
		}
		ans = nn
	}
	w.WriteString(strconv.Itoa(ans)+"\n")
	w.Flush()
}

package main

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

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

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

	n, m := nextInt(), nextInt()

	a := make([][]int, n)

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

	// if n==1 {
	// 	println(0)
	// 	return
	// }

	// if n % 2 == 0 && !isMirroring(a, n) {
	// 	println(0)
	// 	return
	// }

	for i:=n; i>0; i /= 2 {
		if i % 2 == 1 {
			println(i)
			return
		}

		if !isMirroring(a, i) {
			println(i)
			return
		}
	}
}

func isMirroring(a [][]int, n int) bool {
	for i, j := 0, n-1; i<j; i, j = i+1, j-1 {
		for col:=0; col<len(a[i]); col++ {
			if a[i][col] != a[j][col] {
				return false
			}
		}
	}
	return true
}

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

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

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

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

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

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

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

func main() {
	var n,m,i,j,t,r int
	var a [110][110]int
	input := bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	fmt.Scan(&n,&m)
	for i=0;i<n;i++ {
		for j=0;j<m;j++ {
			input.Scan()
			aa,_:=strconv.Atoi(input.Text())
			a[i][j]=aa
		}
	}
	r=n
	for ;(r/2)!=0 && r%2==0; {
		t=0
		for i=0;i<r/2;i++ {
			for j=0;j<m;j++ {
				if a[i][j]!=a[r-1-i][j] {
					t=1
				}
			}
		}
		if t==1 {
			break
		}
		r/=2
	}
	out := bufio.NewWriter(os.Stdout)
	out.WriteString(strconv.Itoa(r))
	out.Flush()
}

package main

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

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

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

	n, m := nextInt(), nextInt()

	a := make([][]int, n)

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

	if n==1 {
		println(0)
		return
	}

	// if n % 2 == 0 && !isMirroring(a, n) {
	// 	println(0)
	// 	return
	// }

	for i:=n; i>0; i /= 2 {
		if i % 2 == 1 {
			println(i)
			return
		}

		if !isMirroring(a, i) {
			println(i)
			return
		}
	}
}

func isMirroring(a [][]int, n int) bool {
	for i, j := 0, n-1; i<j; i, j = i+1, j-1 {
		for col:=0; col<len(a[i]); col++ {
			if a[i][col] != a[j][col] {
				return false
			}
		}
	}
	return true
}

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

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

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

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

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

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

package main

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

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

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

	n, m := nextInt(), nextInt()

	a := make([][]int, n)

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

	if n==1 {
		println(0)
		return
	}

	if n % 2 == 0 && !isMirroring(a, n) {
		println(0)
		return
	}

	for i:=n; i>0; i /= 2 {
		if i % 2 == 1 {
			println(i)
			return
		}

		if !isMirroring(a, i) {
			println(i)
			return
		}
	}
}

func isMirroring(a [][]int, n int) bool {
	for i, j := 0, n-1; i<j; i, j = i+1, j-1 {
		for col:=0; col<len(a[i]); col++ {
			if a[i][col] != a[j][col] {
				return false
			}
		}
	}
	return true
}

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

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

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

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

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

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

package main

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

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

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

	n, m := nextInt(), nextInt()

	a := make([][]int, n)

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

	if n==1 || !isMirroring(a, n) {
		println(0)
		return
	}

	for i:=n; i>0; i /= 2 {
		if i % 2 == 1 {
			println(i)
			return
		}

		if !isMirroring(a, i) {
			println(i)
			return
		}
	}
}

func isMirroring(a [][]int, n int) bool {
	for i, j := 0, n-1; i<j; i, j = i+1, j-1 {
		for col:=0; col<len(a[i]); col++ {
			if a[i][col] != a[j][col] {
				return false
			}
		}
	}
	return true
}

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

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

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

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

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

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


package main

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

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

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

var (
  visited []int
  covers [][]int
  children [][]int
  infeasible bool
)

func descend(u, whichSet int) {
  if visited[u] != -1 {
    if visited[u] != whichSet {
      infeasible = true
    }
    return
  }
  visited[u] = whichSet
  covers[whichSet] = append(covers[whichSet], u)
  for _, v := range children[u] {
    descend(v, whichSet ^ 1)
  }
}

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

  n, m := getI(), getI()
  children = make([][]int, n + 1)
  for i := 0; i < m; i++ {
    u, v := getI(), getI()
    children[u] = append(children[u], v)
    children[v] = append(children[v], u)
  }
  visited = make([]int, n + 1)
  for u := 1; u <= n; u++ {
    visited[u] = -1
  }
  covers = make([][]int, 2)
  for u := 1; u <= n; u++ {
    if visited[u] == -1 {
      descend(u, 0)
    }
  }

  if infeasible {
    writer.WriteString("-1\n")
    return
  }
  for _, cover := range covers {
    writer.WriteString(fmt.Sprintf("%d\n%d", len(cover), cover[0]))
    for i := 1; i < len(cover); i++ {
      writer.WriteString(fmt.Sprintf(" %d", cover[i]))
    }
    writer.WriteString("\n")
  }
}

package main

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

const (
	RED   = 1
	GREEN = 2
)

type Graph struct {
	Visited     map[int]bool
	Color       map[int]int
	Edges       map[int][]int
	IsBipartite bool
	Sets        map[int][]int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	if _, ok := g.Color[u]; !ok {
		g.Color[u] = RED
	}
	g.Sets[g.Color[u]] = append(g.Sets[g.Color[u]], u)
	if edges, ok := g.Edges[u]; ok {
		for _, v := range edges {
			if _, ok := g.Visited[v]; !ok {
				if g.Color[u] == RED {
					g.Color[v] = GREEN
				} else {
					g.Color[v] = RED
				}
				explore(g, v)
			} else {
				if g.Color[v] == g.Color[u] {
					g.IsBipartite = false
				}
			}
		}
	}
}

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

	g := Graph{Visited: make(map[int]bool), Color: make(map[int]int), Edges: make(map[int][]int), Sets: make(map[int][]int), IsBipartite: true}
	g.Sets[RED] = make([]int, 0)
	g.Sets[GREEN] = make([]int, 0)

	var n, m, u, v int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		g.Edges[v] = append(g.Edges[v], u)
	}
	for p, _ := range g.Edges {
		if _, ok := g.Visited[p]; !ok {
			explore(&g, p)
		}
	}
	if g.IsBipartite == true {
		for _, vertices := range g.Sets {
			size := len(vertices)
			fmt.Fprintf(writer, "%d\n", size)
			for idx, vertex := range vertices {
				if idx == size-1 {
					fmt.Fprintf(writer, "%d\n", vertex)
				} else {
					fmt.Fprintf(writer, "%d ", vertex)
				}
			}
		}
	} else {
		fmt.Fprintf(writer, "%d\n", -1)
	}
}

package main

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

const (
	RED   = 1
	GREEN = 2
)

type Graph struct {
	Visited     map[int]bool
	Color       map[int]int
	Edges       map[int][]int
	IsBipartite bool
	Sets        map[int][]int
}

func explore(g *Graph, u int) {
	g.Visited[u] = true
	if _, ok := g.Color[u]; !ok {
		g.Color[u] = RED
	}
	g.Sets[g.Color[u]] = append(g.Sets[g.Color[u]], u)
	if edges, ok := g.Edges[u]; ok {
		for _, v := range edges {
			if _, ok := g.Visited[v]; !ok {
				if g.Color[u] == RED {
					g.Color[v] = GREEN
				} else {
					g.Color[v] = RED
				}
				explore(g, v)
			} else {
				if g.Color[v] == g.Color[u] {
					g.IsBipartite = false
				}
			}
		}
	}
}

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

	g := Graph{Visited: make(map[int]bool), Color: make(map[int]int), Edges: make(map[int][]int), Sets: make(map[int][]int), IsBipartite: true}
	g.Sets[RED] = make([]int, 0)
	g.Sets[GREEN] = make([]int, 0)

	var n, m, u, v int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		if _, ok := g.Edges[u]; !ok {
			g.Edges[u] = make([]int, 0)
		}
		if _, ok := g.Edges[v]; !ok {
			g.Edges[v] = make([]int, 0)
		}
		g.Edges[u] = append(g.Edges[u], v)
		g.Edges[v] = append(g.Edges[v], u)
	}
	for p, _ := range g.Edges {
		if _, ok := g.Visited[p]; !ok {
			explore(&g, p)
		}
	}
	if g.IsBipartite {
		for _, vertices := range g.Sets {
			size := len(vertices)
			fmt.Fprintf(writer, "%d\n", size)
			for idx, vertex := range vertices {
				if idx == size-1 {
					fmt.Fprintf(writer, "%d\n", vertex)
				} else {
					fmt.Fprintf(writer, "%d ", vertex)
				}
			}
		}
	} else {
		fmt.Fprintf(writer, "%d\n", -1)
	}
}

package main

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

// 邻接表
const MAXN = 1e5 + 1
var G [MAXN][]int

var n,m int
var color [MAXN]int

func readGraph()  {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 1; i <= m; i++ {
		scanner.Scan()
		f, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		s, _ := strconv.Atoi(scanner.Text())
		G[f] = append(G[f], s)
		G[s] = append(G[s], f)
	}

}

// current node v has color c
func dfs(v int, c int)  bool{

	color[v] = c
	for i:=0; i < len(G[v]); i++ {
		if color[G[v][i]] == 0 {
			if !dfs(G[v][i],3-c) {return false} //dfs, whether or not feasible
		}else { //already has color
			if color[G[v][i]] != 3-c{return  false} //conflict
		}
	}
	return true
}

func main()  {
	fmt.Scan(&n,&m)
	readGraph()
	for i := 1; i <= n; i++ {
		if color[i] == 0 {
			if !dfs(i,1){
				fmt.Println(-1)
				return
			}
		}
	}
	var res [3][]int
	for i := 1; i <= n; i++ {
		res[color[i]] = append(res[color[i]],i)
	}

	for j := 1; j <= 2; j++ {
		fmt.Println(len(res[j]))
		for i := 0; i < len(res[j]); i++ {
			fmt.Printf("%d ",res[j][i])
		}
		fmt.Println()
	}
}

package main

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

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

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

var (
  visited []int
  covers [][]int
  children [][]int
  infeasible bool
)

func descend(u, v, whichSet int) {
  //fmt.Printf("%d %d %d\n", u, v, whichSet)
  if visited[v] != -1 {
    //fmt.Printf("  visited[%d]: %d, whichSet: %d\n", v, visited[v], whichSet)
    if visited[v] != whichSet {
      infeasible = true
      //fmt.Printf("  infeasible\n")
    }
    return
  }
  visited[v] = whichSet
  covers[whichSet] = append(covers[whichSet], v)
  for _, w := range children[v] {
    if w == u {
      continue
    }
    descend(v, w, whichSet ^ 1)
  }
}

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

  n, m := getI(), getI()
  children = make([][]int, n + 1)
  for i := 0; i < m; i++ {
    u, v := getI(), getI()
    children[u] = append(children[u], v)
    children[v] = append(children[v], u)
  }
  visited = make([]int, n + 1)
  for u := 1; u <= n; u++ {
    visited[u] = -1
  }
  covers = make([][]int, 2)
  for u := 1; u <= n; u++ {
    if visited[u] == -1 {
      descend(-1, u, 0)
    }
  }

  if infeasible {
    writer.WriteString("-1\n")
    return
  }
  for _, cover := range covers {
    writer.WriteString(fmt.Sprintf("%d\n%d", len(cover), cover[0]))
    for i := 1; i < len(cover); i++ {
      writer.WriteString(fmt.Sprintf(" %d", cover[i]))
    }
    writer.WriteString("\n")
  }
}

package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	adj     []*Vertex
	color   []bool
	visited []bool
)

type Vertex struct {
	to []int
}

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

func dfs(u, fa int) bool {
	visited[u] = true
	if adj[u] == nil {
		return true
	}
	for i := 0; i < len(adj[u].to); i++ {
		v := adj[u].to[i]
		if visited[v] {
			if color[v] == color[u] {
				return false
			}
			continue
		}
		color[v] = !color[u]
		if !dfs(v, u) {
			return false
		}
	}
	return true
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer writer.Flush()
	n, m := ReadInt(), ReadInt()
	adj = make([]*Vertex, n, n)
	color = make([]bool, n, n)
	visited = make([]bool, n, n)
	for i := 0; i < m; i++ {
		a, b := ReadInt(), ReadInt()
		a--
		b--
		if adj[a] == nil {
			adj[a] = &Vertex{
				to: make([]int, 0),
			}
		}
		if adj[b] == nil {
			adj[b] = &Vertex{
				to: make([]int, 0),
			}
		}
		adj[a].to = append(adj[a].to, b)
		adj[b].to = append(adj[b].to, a)
	}
	var is bool = true
	for i := 0; i < n; i++ {
		if !visited[i] {
			color[i] = true
			if !dfs(i, -1) {
				is = false
				break
			}
		}
	}
	if !is {
		writer.WriteString("-1\n")
		return
	}
	r, b := make([]int, 0, n), make([]int, 0, n)
	for i := 0; i < n; i++ {
		if color[i] {
			r = append(r, i)
		} else {
			b = append(b, i)
		}
	}
	l := fmt.Sprintf("%d", len(r))
	writer.WriteString(l + "\n")
	for i := 0; i < len(r); i++ {
		writer.WriteString(strconv.Itoa(r[i]+1) + " ")
	}
	writer.WriteString("\n")
	l = fmt.Sprintf("%d", len(b))
	writer.WriteString(l + "\n")
	for i := 0; i < len(b); i++ {
		writer.WriteString(strconv.Itoa(b[i]+1) + " ")
	}
	writer.WriteString("\n")
}

package main

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

func isIn(s []int64, e int64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

type node struct {
	id    int64
	links []int64
	owner int
}

func assignNode(nodes []node, n int64, o int) (retnodes []node, err error) {
	if (nodes[n].owner != 0) && (nodes[n].owner != o) {
		return nil, errors.New("")
	}
	if nodes[n].owner == o {
		return nodes, nil
	}

	nodes[n].owner = o
	for _, i := range nodes[n].links {
		newo := 2
		if o == 2 {
			newo = 1
		}
		var err error
		nodes, err = assignNode(nodes, i, newo)
		if err != nil {
			return nil, errors.New("")
		}
	}
	return nodes, nil
}

func main() {
	var i int64
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	n, _ := strconv.ParseInt(s[0], 10, 64)
	m, _ := strconv.ParseInt(s[1], 10, 64)

	nodes := []node{node{0, []int64{}, 0}}
	for i = 1; i <= n; i++ {
		newnode := node{i, []int64{}, 0}
		nodes = append(nodes, newnode)
	}
	for i = 0; i < m; i++ {
		scanner.Scan()
		s := strings.Split(scanner.Text(), " ")
		e1, _ := strconv.ParseInt(s[0], 10, 64)
		e2, _ := strconv.ParseInt(s[1], 10, 64)
		nodes[e1].links = append(nodes[e1].links, e2)
		nodes[e2].links = append(nodes[e2].links, e1)
	}
	for i = 0; i < n; i++ {
		if nodes[i].owner == 0 && len(nodes[i].links) > 0 {
			var err error
			nodes, err = assignNode(nodes, i, 1)
			if err != nil {
				fmt.Println("-1")
				return
			}
		}
	}
	p := []int64{}
	a := []int64{}
	for i = 1; i <= n; i++ {
		if nodes[i].owner == 1 {
			p = append(p, i)
		}
		if nodes[i].owner == 2 {
			a = append(a, i)
		}
	}
	fmt.Printf("%d\n", len(p))
	for _, i := range p {
		fmt.Printf("%d ", i)
	}
	fmt.Println()
	fmt.Printf("%d\n", len(a))
	for _, i := range a {
		fmt.Printf("%d ", i)
	}
	fmt.Println()

}

package main

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

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

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

var (
  visited []int
  covers [][]int
  children [][]int
  infeasible bool
)

func descend(u, v, whichSet, depth int) {
  //fmt.Printf("%d %d %d %d\n", u, v, whichSet, depth)
  if visited[v] != -1 {
    //fmt.Printf("  visited[%d]: %d, whichSet: %d\n", v, visited[v], whichSet)
    if visited[v] != whichSet && depth % 2 == 1 {
      infeasible = true
      //fmt.Printf("  infeasible\n")
    }
    return
  }
  visited[v] = whichSet
  covers[whichSet] = append(covers[whichSet], v)
  for _, w := range children[v] {
    if w == u {
      continue
    }
    descend(v, w, whichSet ^ 1, depth + 1)
  }
}

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

  n, m := getI(), getI()
  children = make([][]int, n + 1)
  for i := 0; i < m; i++ {
    u, v := getI(), getI()
    children[u] = append(children[u], v)
    children[v] = append(children[v], u)
  }
  visited = make([]int, n + 1)
  for u := 1; u <= n; u++ {
    visited[u] = -1
  }
  covers = make([][]int, 2)
  for u := 1; u <= n; u++ {
    descend(-1, u, 0, 0)
  }

  if infeasible {
    writer.WriteString("-1\n")
    return
  }
  for _, cover := range covers {
    writer.WriteString(fmt.Sprintf("%d\n%d", len(cover), cover[0]))
    for i := 1; i < len(cover); i++ {
      writer.WriteString(fmt.Sprintf(" %d", cover[i]))
    }
    writer.WriteString("\n")
  }
}


package main

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

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)

    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    scanner.Scan()
    m, _ := strconv.Atoi(scanner.Text())
    if n > m {
        for (n > 0) && (m > 0) { writer.WriteString("BG"); n--; m--; }
        for (n > 0) { writer.WriteString("B"); n--; }
    } else {
        for (n > 0) && (m > 0) { writer.WriteString("GB"); n--; m--; }
        for (m > 0) { writer.WriteString("G"); m--; }
    }
    writer.WriteString("\n")
    writer.Flush()
}

package main

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

var file, _ = os.Open("input.txt")
var outfile, _ = os.Create("output.txt")
var in = bufio.NewScanner(file)
var out = bufio.NewWriter(outfile)

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

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

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

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    m := nextInt()
    if n > m {
        for i := 0; i < m; i++ {
            out.WriteString("BG");
        }
        for i := 0; i < n - m; i++ {
            out.WriteString("B");
        }
    } else {
        for i := 0; i < n; i++ {
            out.WriteString("GB");
        }
        for i := 0; i < m - n; i++ {
            out.WriteString("G");
        }

    }
}

// Author: sighduck
// URL: https://codeforces.com/contest/253/problem/A

package main

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

func Solve(b int, g int) string {
	if b < g {
		return strings.Repeat("GB", b) + strings.Repeat("G", g-b)
	}
	return strings.Repeat("BG", g) + strings.Repeat("B", b-g)
}

func main() {
	inputFile, _ := os.Open("input.txt")
	outputFile, _ := os.Create("output.txt")
	reader := bufio.NewReader(inputFile)
	writer := bufio.NewWriter(outputFile)
	defer writer.Flush()

	var b, g int
	fmt.Fscanf(reader, "%d %d\n", &b, &g)
	fmt.Fprintf(writer, "%s\n", Solve(b, g))
}

package main

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

var fi, _ = os.Open("input.txt")
var fo, _ = os.Create("output.txt")

var in = bufio.NewScanner(fi)
var out = bufio.NewWriter(fo)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	var n, m int = NextInt(), NextInt()
	if n >= m {
		for i := 0; i < m; i++ {
			fmt.Fprint(out, "BG")
		}
		for i := 0; i < n - m; i++ {
			fmt.Fprint(out, "B")
		}
	}else {
		for i := 0; i < n; i++ {
			fmt.Fprint(out, "GB")
		}
		for i := 0; i < m - n; i++ {
			fmt.Fprint(out, "G")
		}
	}
	fmt.Fprintln(out)
}

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

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

func Next() string{
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int{
	ret, _ := strconv.Atoi(Next())
	return ret
}

package main
import (
	//"fmt"
	"bufio"
	"os"
	"strconv"
)
func main() {
	var m,n int
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	input.Scan()
	out := bufio.NewWriter(os.Stdout)
	aa,_:= strconv.Atoi(input.Text())
	n=aa
	input.Scan()
	bb,_:= strconv.Atoi(input.Text())
	m=bb
	//fmt.Scan(&n,&m)
	if n>=m {
		for i:=0;i<m;i++ {
			out.WriteString("BG")
		}
		out.Flush()
		for i:=0;i<n-m;i++ {
			out.WriteRune('B')
		}
		out.Flush()
	} else {
		for i:=0;i<n;i++ {
			out.WriteString("GB")
		}
		out.Flush()
		for i:=0;i<m-n;i++ {
			out.WriteRune('G')
		}
		out.Flush()
	}
}

package main

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

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)
    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    scanner.Scan()
    m, _ := strconv.Atoi(scanner.Text())
    for (n > 0) && (m > 0) { writer.WriteString("BG"); n--; m--; }
    for (n > 0) { writer.WriteString("B"); n--; }
    for (m > 0) { writer.WriteString("G"); m--; }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

import "fmt"

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    for (n > 0) && (m > 0) { fmt.Print("BG"); n--; m--; }
    for (n > 0) { fmt.Print("B"); n--; }
    for (m > 0) { fmt.Print("G"); m--; }
    fmt.Println()
}

package main

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

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)

    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    scanner.Scan()
    m, _ := strconv.Atoi(scanner.Text())
    for (n > 0) && (m > 0) { writer.WriteString("BG"); n--; m--; }
    for (n > 0) { writer.WriteString("B"); n--; }
    for (m > 0) { writer.WriteString("G"); m--; }
    writer.WriteString("\n")
    writer.Flush()
}

package main

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

func main() {
    input, _ := os.Open("input.txt")
    defer input.Close()
    scanner := bufio.NewScanner(input)
    scanner.Split(bufio.ScanWords)
    output, _ := os.Create("output.txt")
    defer output.Close()
    writer := bufio.NewWriter(output)

    scanner.Scan()
    n, _ := strconv.Atoi(scanner.Text())
    scanner.Scan()
    m, _ := strconv.Atoi(scanner.Text())
    for (n > 0) && (m > 0) { writer.WriteString("GB"); n--; m--; }
    for (n > 0) { writer.WriteString("B"); n--; }
    for (m > 0) { writer.WriteString("G"); m--; }
    writer.WriteString("\n")
    writer.Flush()
}


package main

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

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

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

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	avg := make([]float64, 0, n)
	count := make([]int, 0, n)
	for i := len(a) - 1; i >= 0; i-- {
		sum := float64(a[i])
		cc := 1
		best := float64(a[i])
		for len(avg) > 0 {
			m := len(avg) - 1
			x := (sum + avg[m]*float64(count[m])) / float64(cc+count[m])
			if x >= best {
				break
			}
			sum += avg[m] * float64(count[m])
			cc += count[m]
			avg = avg[:m]
			count = count[:m]
			best = x
		}
		avg = append(avg, best)
		count = append(count, cc)
	}

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

	for i := len(avg) - 1; i >= 0; i-- {
		for j := 0; j < count[i]; j++ {
			fmt.Fprintf(writer, "%.10f\n", avg[i])
		}
	}
}

package main

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

type vec struct{ x, y int64 }

func (a vec) sub(b vec) vec   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }

// github.com/EndlessCheng/codeforces-go
func CF1299C(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n := read()
	s := make([]int64, n+1)
	ps := make([]vec, 1, n+1)
	for i := 1; i <= n; i++ {
		s[i] = s[i-1] + int64(read())
		p := vec{int64(i), s[i]}
		for {
			sz := len(ps)
			if sz <= 1 || ps[sz-1].sub(ps[sz-2]).det(p.sub(ps[sz-1])) > 0 {
				break
			}
			ps = ps[:sz-1]
		}
		ps = append(ps, p)
	}
	for i := 1; i < len(ps); i++ {
		a, b := ps[i-1], ps[i]
		l := b.x - a.x
		avg := float64(b.y-a.y) / float64(l)
		for ; l > 0; l-- {
			Fprintf(out, "%.9f\n", avg)
		}
	}
}

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

package main

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

type vec struct{ x, y int64 }

func (a vec) sub(b vec) vec   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }

// github.com/EndlessCheng/codeforces-go
func CF1299C(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n := read()
	s := make([]int64, n+1)
	ps := make([]vec, 1, n+1)
	for i := 1; i <= n; i++ {
		s[i] = s[i-1] + int64(read())
		p := vec{int64(i), s[i]}
		for {
			sz := len(ps)
			if sz <= 1 || ps[sz-1].sub(ps[sz-2]).det(p.sub(ps[sz-1])) > 0 {
				break
			}
			ps = ps[:sz-1]
		}
		ps = append(ps, p)
	}
	sz := len(ps)
	for i := 1; i < sz; i++ {
		a, b := ps[i-1], ps[i]
		l := b.x - a.x
		avg := float64(b.y-a.y) / float64(l)
		for ; l > 0; l-- {
			Fprintf(out, "%.9f\n", avg)
		}
	}
}

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

package main

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

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

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

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	avg := make([]float64, 0, n)
	count := make([]int, 0, n)
	for i := len(a) - 1; i >= 0; i-- {
		sum := float64(a[i])
		cc := 1
		best := float64(a[i])
		for len(avg) > 0 {
			m := len(avg) - 1
			x := (sum + avg[m]*float64(count[m])) / float64(cc+count[m])
			if x >= best {
				break
			}
			sum += avg[m] * float64(count[m])
			cc += count[m]
			avg = avg[:m]
			count = count[:m]
			best = x
		}
		avg = append(avg, best)
		count = append(count, cc)
	}

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

	for i := len(avg) - 1; i >= 0; i-- {
		for j := 0; j < count[i]; j++ {
			fmt.Fprintf(writer, "%f\n", avg[i])
		}
	}
}