package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("1.in")
	// out, _ := os.Create("1.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func dp_(n int, limit int64) int64 {
	inf := n * 2
	f := make([]int64, inf+1)
	g := make([]int64, inf+1)
	f[0] = 1
	for i := 61; i >= 0; i-- {
		for j := 0; j <= inf; j++ {
			g[j] = 0
		}
		for j := 0; j < inf; j++ {
			if f[j] > 0 {
				for one_bit := (int)((z >> i) & 1); one_bit <= n; one_bit += 2 {
					if j < one_bit {
						break
					}
					next := (j - one_bit) * 2
					if i > 0 {
						next += (int)(limit>>(i-1)) & 1
					}
					if next > inf {
						next = inf
					}
					g[next] = (g[next] + f[j]*(int64)(C[n][one_bit])) % mod
				}
			}
		}
		if f[inf] > 0 {
			for one_bit := (int)((z >> i) & 1); one_bit <= n; one_bit += 2 {
				g[inf] = (g[inf] + f[inf]*(int64)(C[n][one_bit])) % mod
			}
		}
		for j := 0; j <= inf; j++ {
			f[j] = g[j]
		}
	}
	var ans int64 = 0
	for j := 0; j <= inf; j++ {
		ans = (ans + f[j] + mod) % mod
	}
	return ans
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	myio.Println((dp_(n, r) - dp_(n, l-1) + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("2.in")
	// out, _ := os.Create("2.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = (int)((z >> b) & 1)
	for i := cb; i <= n; i += 2 {
		cbs := (int)((val >> b) & 1)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = ans + toAdd
	}
	memo[b][rem] = (int)(ans % mod)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("1.in")
	// out, _ := os.Create("1.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = ans + toAdd
	}
	memo[b][rem] = (int)(ans % mod)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("1.in")
	// out, _ := os.Create("1.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val))
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("1.in")
	// out, _ := os.Create("1.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(getC(n, i)) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(maxn, maxn, 0)

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {
	myio = NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()
	sol()
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

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

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(getC(n, i)) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(maxn, maxn, 0)

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {
	myio = NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()
	sol()
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

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

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	// fmt.Println(a, b, C[a][b])
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(getC(n, i)) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(maxn, maxn, 0)

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	// fmt.Println(ra, rb)
	myio.Println((rb - ra + mod) % mod)
}

func main() {
	myio = NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi64() int64 { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func makefact64(n int64,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=int64(1);i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
const MOD int64 = 1000000007
type st struct {idx,v int64}
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N,L,R,Z := gi64(),gi64(),gi64(),gi64()
	fact,factinv := makefact64(N+10,MOD)
	combarr := make([]int64,N+1)
	for i:=int64(0);i<=N;i++ { combarr[i] = fact[N] * factinv[i] % MOD * factinv[N-i] % MOD  }
	var dp [61][2002]int64
	var bitdp func(idx int64, rem int64, val int64) int64
	bitdp = func(idx int64, rem int64, val int64) int64 {
		if rem > 2*N { rem = 2*N }
		if rem < 0 { return 0 }
		if idx < 0 { return 1 }
		if dp[idx][rem] != -1 { return dp[idx][rem] }
		ans := int64(0); st := int64(0); if Z & (int64(1) << uint64(idx)) != 0 { st++ }
		for i:=st;i<=N;i+=2 {
			cbs := int64(0); if val & (int64(1) << uint64(idx)) != 0 { cbs++ }
			adder := combarr[i] * bitdp(idx-1, 2*(rem+cbs-i), val) % MOD
			ans += adder; ans %= MOD
		}
		//fmt.Printf("DBG: bitdp(%v,%v,%v)=%v\n",idx,rem,val,ans)
		dp[idx][rem] = ans
		return ans
	}
	calc := func(ubound int64) int64 {
		for i:=0;i<=60;i++ { for j:=int64(0);j<=2*N;j++ { dp[i][j] = -1 } }
		return bitdp(60,0,ubound)
	}
	ans := (calc(R)+MOD-calc(L-1)) % MOD
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val))
		ans = ans + toAdd
	}
	memo[b][rem] = (int)(ans % mod)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 1; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	// p, _ := os.Create("1.profile")
	// pprof.StartCPUProfile(p)
	// defer pprof.StopCPUProfile()

	// in, _ := os.Open("1.in")
	// out, _ := os.Create("1.out")
	// defer in.Close()
	// defer out.Close()
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO
var n int
var z int64
var C, memo [][]int

const (
	maxn = 1024
	mod  = 1000000007
)

func mkarr(n, m, fill int) [][]int {
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	p := a[0]
	p[0] = fill
	for i := 1; i < m; i *= 2 {
		copy(p[i:], p[:i])
	}
	for i := 1; i < n; i++ {
		copy(a[i], p)
	}
	return a
}

func getC(a, b int) int {
	if C[a][b] > 0 {
		return C[a][b]
	}
	if b == 0 || a == b {
		C[a][b] = 1
		return C[a][b]
	}
	C[a][b] = (getC(a-1, b-1) + getC(a-1, b)) % mod
	return C[a][b]
}

func getCb(v int64, b int) int {
	if (v>>b)&1 == 0 {
		return 0
	}
	return 1
}

func dp(b, rem int, val int64) int {
	if rem > n*2 {
		rem = n * 2
	}
	if rem < 0 {
		return 0
	}
	if b == -1 {
		return 1
	}
	if memo[b][rem] != -1 {
		return memo[b][rem]
	}
	var ans int64 = 0
	var cb = getCb(z, b)
	for i := cb; i <= n; i += 2 {
		cbs := getCb(val, b)
		nextRem := 2 * (rem + cbs - i)
		toAdd := (int64)(C[n][i]) * (int64)(dp(b-1, nextRem, val)) % mod
		ans = (ans + toAdd) % mod
	}
	memo[b][rem] = (int)(ans)
	return memo[b][rem]
}

func sol() {
	n = myio.ReadInt()
	l := myio.ReadInt64()
	r := myio.ReadInt64()
	z = myio.ReadInt64()
	C = mkarr(n+1, n+1, 0)
	for i := 0; i <= n; i++ {
		C[i][0] = 1
		C[i][i] = 1
	}
	for i := 2; i <= n; i++ {
		for j := 2; j < i; j++ {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod
		}
	}

	memo = mkarr(61, n*2+2, -1)
	ra := dp(60, 0, l-1)
	memo = mkarr(61, n*2+2, -1)
	rb := dp(60, 0, r)
	myio.Println((rb - ra + mod) % mod)
}

func main() {

	myio = NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()
	sol()
}


package main

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

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

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

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

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

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

/**
Run solve the problem CF1642A
Date: 9/17/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1642/A
Problem: CF1642A
**/
func (in *CF1642A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([][]float64, 3)
		m[0] = []float64{
			float64(in.NextInt()), float64(in.NextInt()),
		}
		m[1] = []float64{
			float64(in.NextInt()), float64(in.NextInt()),
		}
		m[2] = []float64{
			float64(in.NextInt()), float64(in.NextInt()),
		}
		ans := 0.0

		if m[0][1] == m[1][1] && m[0][1] > m[2][1] {
			ans = math.Abs(m[0][0] - m[1][0])
		} else if m[0][1] == m[2][1] && m[0][1] > m[1][1] {
			ans = math.Abs(m[0][0] - m[2][0])
		} else if m[1][1] == m[2][1] && m[1][1] > m[0][1] {
			ans = math.Abs(m[1][0] - m[2][0])
		}

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

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

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

package main

import (
  "bufio"
  "fmt"
  "math"
  "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 Test_Case(){
	var a,b,c,d,e,f int64

	scanf("%d %d\n", &a, &b)
	scanf("%d %d\n", &c, &d)
	scanf("%d %d\n", &e, &f)
	var ans float64
	if b == d && f < b {
		ans = math.Abs(float64(a-c))
	} else if f == d && b < d {
		ans = math.Abs(float64(e-c))
	} else if b == f && d < b {
		ans = math.Abs(float64(a-e))
	}
	printf("%f\n", ans)
}

func main(){

 	defer writer.Flush()

	var t int64
	scanf("%d\n", &t)
	for t > 0 {
		Test_Case()
		t = t-1
	}
}

package main

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

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

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() {
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var ax, ay, bx, by, cx, cy int
		fmt.Fscan(in, &ax, &ay, &bx, &by, &cx, &cy)
		maxy := max(ay, max(by, cy))
		var minx, maxx int = 1e9, 0
		if ay == maxy {
			minx = min(minx, ax)
			maxx = max(maxx, ax)
		}
		if by == maxy {
			minx = min(minx, bx)
			maxx = max(maxx, bx)
		}
		if cy == maxy {
			minx = min(minx, cx)
			maxx = max(maxx, cx)
		}
		fmt.Fprintln(out, maxx-minx)
	}
}

package main

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

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

	var T int
	type pair struct { x, y int }
	p := make([]pair, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &p[i].x, &p[i].y)
		}
		sort.Slice(p, func(i, j int) bool {
			if p[i].y == p[j].y {
				return p[i].x < p[j].x
			}
			return p[i].y < p[j].y
		})
		if p[1].y == p[2].y && p[0].y != p[1].y {
			Fprintln(w, p[2].x - p[1].x)
		} else {
			Fprintln(w, 0)
		}
	}
}

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

// To correct later, do not forget that the flat part of the triangle can be at its bottom and not necessarily only on the top so slighty more treatment is required

package main

import (
	"fmt"
	"math"
)

func main() {
	t := 0
	fmt.Scan(&t)
	out := ""
	for i := 0; i < t; i++ {
		xs := make([]int, 3)
		ys := make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&xs[j], &ys[j])
		}
		out = out + fmt.Sprintln(solve(xs, ys))
	}
	fmt.Println(out)
}

func solve(xs, ys []int) float64 {
	index1, index2 := duplicatesArray(ys)
	if index1 == -1 {
		return 0.0
	}
	return math.Sqrt(math.Pow(float64(xs[index1]-xs[index2]), 2) - math.Pow(float64(ys[index1]-ys[index2]), 2))
}

func duplicatesArray(arr []int) (index1, index2 int) {
	visited := make(map[int]bool, 0)
	for i, v := range arr {
		if visited[v] && v != 0 {
			pos := pos(arr, v)
			if v == min(arr) {
				return -1, -1
			} else {
				return i, pos
			}
		} else {
			visited[v] = true
		}
	}
	return -1, -1
}

func pos(arr []int, value int) int {
	for k, v := range arr {
		if v == value {
			return k
		}
	}
	return -1
}

func min(array []int) int {
	var min int = array[0]
	for _, value := range array {
		if min > value {
			min = value
		}
	}
	return min
}

package main

import (
	"fmt"
)

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

func main() {
	var t, i, ax, ay, bx, by, cx, cy int64
	fmt.Scanln(&t)
	var length int64
	for i = 0; i < t; i++ {
		length = 0
		fmt.Scanln(&ax, &ay)
		fmt.Scanln(&bx, &by)
		fmt.Scanln(&cx, &cy)

		if ay == by && ay != 0 && ay > cy {
			length = abs(ax - bx)
		}
		if cy == by && cy != 0 && cy > ay {
			length = abs(cx - bx)
		}
		if ay == cy && ay != 0 && ay > by {
			length = abs(cx - ax)
		}

		fmt.Println(length)
	}

}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var ax, ay, bx, by, cx, cy int
		fmt.Fscan(in, &ax, &ay, &bx, &by, &cx, &cy)

		if ay == by && cy < ay {
			fmt.Fprintln(out, abs(ax-bx))
		} else if ay == cy && by < ay {
			fmt.Fprintln(out, abs(ax-cx))
		} else if by == cy && ay < by {
			fmt.Fprintln(out, abs(bx-cx))
		} else {
			fmt.Fprintln(out, 0)
		}
	}

}

package main

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

/*
2
1 1
3 1
2 2
1 2
3 1
3 2
---
0
2
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var x1, y1, x2, y2, x3, y3 int
	scanf("%d %d\n%d %d\n%d %d\n", &x1, &y1, &x2, &y2, &x3, &y3)

	if y1 == y2 && y1 != 0 && y3 < y1 {
		fmt.Fprintln(writer, abs(x1-x2))
	} else if y1 == y3 && y1 != 0 && y2 < y1 {
		fmt.Fprintln(writer, abs(x1-x3))
	} else if y2 == y3 && y2 != 0 && y1 < y2 {
		fmt.Fprintln(writer, abs(x2-x3))
	} else {
		fmt.Fprintln(writer, 0)
	}
}

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

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

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

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

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

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

import (
	"fmt"
	"math"
)

func main() {
	t := 0
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b, c, d, e, f float64

		fmt.Scan(&b, &a, &d, &c, &f, &e)

		var ans float64

		if a == c && e < a {
			ans = math.Abs(b - d)
		} else if c == e && a < c {
			ans = math.Abs(d - f)
		} else if a == e && c < a {
			ans = math.Abs(b - f)
		}

		fmt.Println(ans)
	}
}

//nolint
package main

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

//{
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 print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

//}

func Solve() {
	var p1, p2, p3 Point
	scanPoint(&p1)
	scanPoint(&p2)
	scanPoint(&p3)
	println(check(&p1, &p2, &p3) + check(&p2, &p3, &p1) + check(&p1, &p3, &p2))
}

type Point struct {
	x, y float64
}

func scanPoint(p *Point) {
	scan(&p.x)
	scan(&p.y)
}

func check(p1, p2, p3 *Point) float64 {
	if p1.y == p2.y && p3.y < p1.y {
		return math.Abs(p1.x - p2.x)
	}
	return 0
}

package main

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

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

	var T int
	x, y := make([]int, 3), make([]int, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] != y[2] {
			if y[2] < y[0] && x[0] != x[1] {
				Fprintf(w, "%d\n", abs((x[0])-(x[1])))
			} else {
				Fprintln(w, 0)
			}
		} else if y[1] == y[2] && y[2] != y[0] {
			if y[0] < y[1] {
				Fprintf(w, "%d\n", abs((x[1])-(x[2])))
			} else {
				Fprintln(w, 0)
			}
		} else if y[2] == y[0] && y[0] != y[1] {
			if y[1] < y[2] {
				Fprintf(w, "%d\n", abs((x[2])-(x[0])))
			} else {
				Fprintln(w, 0)
			}
		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]int, 3), make([]int, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%f\n", abs(float64(x[0])-float64(x[1])))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%f\n", abs(float64(x[1])-float64(x[2])))
			} else {
				Fprintln(w, 0)
			}
		} else if y[2] == y[0]  {
			if y[1] < y[2] {
				Fprintf(w, "%f\n", abs(float64(x[2])-float64(x[0])))
			} else {
				Fprintln(w, 0)
			}
		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]float64, 3), make([]float64, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%f\n", abs(x[0]-x[1]))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%f\n", abs(x[1]-x[2]))
			} else {
				Fprintln(w, 0)
			}
		} else if y[2] == y[0]  {
			if y[1] < y[2] {
				Fprintf(w, "%f\n", abs(x[2]-x[0]))
			} else {
				Fprintln(w, 0)
			}
		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]float64, 3), make([]float64, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%f\n", abs(x[0]-x[1]))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%f\n", abs(x[1]-x[2]))
			} else {
				Fprintln(w, 0)
			}
		} else if y[2] == y[3]  {
			if y[1] < y[2] {
				Fprintf(w, "%f\n", abs(x[2]-x[3]))
			} else {
				Fprintln(w, 0)
			}
		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]float64, 3), make([]float64, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%f\n", abs(x[0]-x[1]))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%f\n", abs(x[1]-x[2]))
			} else {
				Fprintln(w, 0)
			}

		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]float64, 3), make([]float64, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%.12f\n", abs(x[0]-x[1]))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%.12f\n", abs(x[1]-x[2]))
			} else {
				Fprintln(w, 0)
			}

		}
	}
}

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

package main

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

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

	var T int
	x, y := make([]float64, 3), make([]float64, 3)
	Fscan(r, &T)
	for t := 0; t < T; t++ {
		for i := 0; i < 3; i++ {
			Fscan(r, &x[i], &y[i])
		}
		if y[0] != y[1] && y[1] != y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] && y[1] == y[2] {
			Fprintln(w, 0)
			continue
		} else if y[0] == y[1] {
			if y[2] < y[0] {
				Fprintf(w, "%12.f\n", abs(x[0]-x[1]))
			} else {
				Fprintln(w, 0)
			}
		} else  if y[1] == y[2] {
			if y[0] < y[1] {
				Fprintf(w, "%12.f\n", abs(x[1]-x[2]))
			} else {
				Fprintln(w, 0)
			}

		}
	}
}

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

package main

import (
	"fmt"
	"math"
)

func main() {
	t := 0
	fmt.Scan(&t)
	out := ""
	for i := 0; i < t; i++ {
		xs := make([]int, 3)
		ys := make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&xs[j], &ys[j])
		}
		out = out + fmt.Sprintln(solve(xs, ys))
	}
	fmt.Println(out)
}

func solve(xs, ys []int) float64 {
	index1, index2 := duplicatesArray(ys)
	if index1 == -1 {
		return 0.0
	}
	return math.Sqrt(math.Pow(float64(xs[index1]-xs[index2]), 2) - math.Pow(float64(ys[index1]-ys[index2]), 2))
}

func duplicatesArray(arr []int) (index1, index2 int) {
	visited := make(map[int]bool, 0)
	for i, v := range arr {
		if visited[v] && v != 0 {
			pos := pos(arr, v)
			return i, pos
		} else {
			visited[v] = true
		}
	}
	return -1, -1
}

func pos(arr []int, value int) int {
	for k, v := range arr {
		if v == value {
			return k
		}
	}
	return -1
}

package main

import (
	"fmt"
	"math"
)

func main() {
	t := 0
	fmt.Scan(&t)
	out := ""
	for i := 0; i < t; i++ {
		xs := make([]int, 3)
		ys := make([]int, 3)
		for j := 0; j < 3; j++ {
			fmt.Scan(&xs[j], &ys[j])
		}
		out = out + fmt.Sprintln(solve(xs, ys))
	}
	fmt.Println(out)
}

func solve(xs, ys []int) float64 {
	index1, index2 := duplicatesArray(ys)
	if index1 == -1 {
		fmt.Println(0)
		return 0.0
	}
	return math.Sqrt(math.Pow(float64(xs[index1]-xs[index2]), 2) - math.Pow(float64(ys[index1]-ys[index2]), 2))
}

func duplicatesArray(arr []int) (index1, index2 int) {
	visited := make(map[int]bool, 0)
	for i, v := range arr {
		if visited[v] {
			return i, pos(arr, v)
		} else {
			visited[v] = true
		}
	}
	return -1, -1
}

func pos(arr []int, value int) int {
	for k, v := range arr {
		if v == value {
			return k
		}
	}
	return -1
}

package main

import (
	"fmt"
)

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

func main() {
	var t, i, ax, ay, bx, by, cx, cy int64
	fmt.Scanln(&t)
	var length int64
	for i = 0; i < t; i++ {
		length = 0
		fmt.Scanln(&ax, &ay)
		fmt.Scanln(&bx, &by)
		fmt.Scanln(&cx, &cy)

		if ay == by && ay != 0 && ay > cy {
			length = abs(ax - bx)
		}
		if cy == by && cy != 0 && cy > ay {
			length = abs(cx - bx)
		}
		if ay == cy && ay != 0 && ay > by {
			length = abs(cx - bx)
		}

		fmt.Println(length)
	}

}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var ax, ay, bx, by, cx, cy int
		fmt.Fscan(in, &ax, &ay, &bx, &by, &cx, &cy)

		if ay == by && ay != 0 && by != 0 {
			fmt.Fprintln(out, abs(ax-bx))
		} else if ay == cy && ay != 0 && cy != 0 {
			fmt.Fprintln(out, abs(ax-cx))
		} else if by == cy && by != 0 && cy != 0 {
			fmt.Fprintln(out, abs(bx-cx))
		} else {
			fmt.Fprintln(out, 0)
		}
	}

}

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var x1, y1, x2, y2, x3, y3 int
	scanf("%d %d\n%d %d\n%d %d\n", &x1, &y1, &x2, &y2, &x3, &y3)

	if y1 == y2 && y1 != 0 {
		fmt.Fprintln(writer, abs(x1-x2))
	} else if y1 == y3 && y1 != 0 {
		fmt.Fprintln(writer, abs(x1-x3))
	} else if y2 == y3 && y2 != 0 {
		fmt.Fprintln(writer, abs(x2-x3))
	} else {
		fmt.Fprintln(writer, 0)
	}
}

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

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

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

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

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

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func max(nums ...int) (max, idx int) {
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx], idx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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


package main

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

var (
	base      = uint64(31)
	maxN      = 500000 + 10
	mod       = uint64(1e9 + 7)
	powerBase = make([]uint64, maxN)
	hashed    = []uint64{}
)

func solve(s string, t string, n int) string {
	res := make([]byte, len(s))
	count := map[byte]int{}
	lengthPattern, id := n, 0

	for i := range s {
		count[s[i]]++
	}

	//find the logest suffix == prefix
	for i := 0; i < n-1; i++ {
		if hashed[i] == getHash(n-1-i, n-1) {
			lengthPattern = n - (i + 1)
			//exp: 11011
			//pre 11 = suf 11
			//=> lengthPattern is 3 : 110
		}
	}

	for i := range res {
		id = i % lengthPattern
		if count[t[id]] != 0 {
			res[i] = t[id]
			count[t[id]]--
			continue
		}
		if t[id] == '1' {
			res[i] = '0'
		} else {
			res[i] = '1'
		}
	}

	return string(res)
}

func getHash(start int, end int) uint64 {
	return (hashed[end] - hashed[start-1]*powerBase[end-start+1] + mod*mod) % mod
}

func initPowerBase() {
	powerBase[0] = 1

	for i := 1; i < maxN; i++ {
		powerBase[i] = powerBase[i-1] * base % mod
	}
}

func initHash(t string, n int) {
	hashed = make([]uint64, n)
	hashed[0] = uint64(t[0])

	for i := 1; i < n; i++ {
		hashed[i] = (hashed[i-1]*base + uint64(t[i])) % mod
	}
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	initPowerBase()
	fmt.Fscanf(r, "%s\n", &s)
	fmt.Fscanf(r, "%s\n", &t)
	initHash(t, len(t))
	fmt.Println(solve(s, t, len(t)))
}

package main

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

var (
	base      = uint64(31)
	maxN      = 500000 + 10
	mod       = uint64(1e9 + 7)
	hashed    = make([]uint64, maxN)
	powerBase = make([]uint64, maxN)
)

func solve(s string, t string) string {
	res := make([]byte, len(s))
	count := map[byte]int{}
	id := 0
	lengthPattern := len(t)

	for i := range s {
		count[s[i]]++
	}

	//find the logest suffix == prefix
	for i := 0; i < len(t)-1; i++ {
		if hashed[i] == getHash(len(t)-1-i, len(t)-1) {
			lengthPattern = len(t) - (i + 1)
			//exp: 11011
			//pre 11 = suf 11
			//=> lengthPattern is 3 : 110
		}
	}

	for i := range res {
		id = i % lengthPattern
		if count[t[id]] != 0 {
			res[i] = t[id]
			count[t[id]]--
			continue
		}
		if t[id] == '1' {
			res[i] = '0'
		} else {
			res[i] = '1'
		}
	}

	return string(res)
}

func getHash(start int, end int) uint64 {
	return (hashed[end] - hashed[start-1]*powerBase[end-start+1] + mod*mod) % mod
}

func initPowerBase() {
	powerBase[0] = 1

	for i := 1; i < maxN; i++ {
		powerBase[i] = powerBase[i-1] * base % mod
	}
}

func initHash(t string, n int) {
	hashed[0] = uint64(t[0])

	for i := 1; i < n; i++ {
		hashed[i] = (hashed[i-1]*base + uint64(t[i])) % mod
	}
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	initPowerBase()
	fmt.Fscanf(r, "%s\n", &s)
	fmt.Fscanf(r, "%s\n", &t)
	initHash(t, len(t))
	fmt.Println(solve(s, t))
}

package main

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

func kmp(str []byte, l int) []int {
	next := make([]int, l)
	next[0] = -1
	for i := 1; i < l; i++ {
		f := next[i-1]
		for f>=0&&str[f+1] != str[i]{
			f = next[f]
		}
		next[i] = -1
		if str[f+1]==str[i]{
			next[i] = f+1
		}
	}
	//fmt.Printf("%v\n", next)
	return next
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var str1,str2 string
	b := new(bytes.Buffer)
	fmt.Fscanf(buf, "%s\n", &str1)
	fmt.Fscanf(buf, "%s\n", &str2)

	s1 := []byte(str1)
	s2 := []byte(str2)

	len1 := len(s1)
	len2 := len(s2)
	cnt1 := 0
	cnt2 := 0
	for _, c := range s1 {
		if c == '1' {
			cnt1++
		}
	}
	for _, c := range s2 {
		if c == '1' {
			cnt2++
		}
	}
	if len1 < len2 || cnt2 > cnt1 || len2-cnt2 > len1-cnt1 {
		fmt.Printf("%s\n", str1)
		return
	}
	next := kmp(s2, len2)
	seg1 := 0
	seg0 := 0
	for i := next[len2-1] + 1; i < len2; i++ {
		if s2[i] == '1' {
			seg1++
		} else {
			seg0++
		}
	}
	len1 -= len2
	cnt1 -= cnt2
	cnt2 = -1
	if seg1 > 0 {
		cnt2 = cnt1 / seg1
	}
	if seg0 > 0 && (cnt2 == -1 || cnt2 > (len1-cnt1)/seg0) {
		cnt2 = (len1 - cnt1) / seg0
	}
	b.WriteString(str2)
//	fmt.Printf("%s", str2)
	tmp := s2[next[len2-1]+1:]
	for j := 0; j < cnt2; j++ {
		b.Write(tmp)
		//fmt.Printf("%s",tmp)
		//for i := next[len2-1] + 1; i < len2; i++ {
		//	fmt.Printf("%c", s2[i])
		//}
	}
	//c0 := make([]byte, (len1-cnt1)-cnt2*seg0)
	if (len1-cnt1)-cnt2*seg0 > 0 {
		for i := 0; i < (len1-cnt1)-cnt2*seg0; i++ {
			//c0[i] = '0'
			b.WriteByte('0')
		}
		//fmt.Printf("%s", c0)
	}
	//c1 := make([]byte, (cnt1)-cnt2*seg1)
	if (cnt1)-cnt2*seg1 > 0 {

		for i := 0; i < (cnt1)-cnt2*seg1; i++ {
			b.WriteByte('1')
			//c1[i] = '1'
		}
		//fmt.Printf("%s", c1)
	}
	fmt.Printf("%s\n",b.String())
}

/**
01010101
0101010
 */

package main

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

func solve(s string, t string) string {
	res := make([]byte, len(s))
	count := map[byte]int{}
	id := 0

	for i := range s {
		count[s[i]]++
	}

	for i := range res {
		id = i % len(t)
		if count[t[id]] != 0 {
			res[i] = t[id]
			count[t[id]]--
			continue
		}
		if t[id] == '1' {
			res[i] = '0'
		} else {
			res[i] = '1'
		}
	}

	return string(res)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	fmt.Fscanf(r, "%s\n", &s)
	fmt.Fscanf(r, "%s\n", &t)
	fmt.Println(solve(s, t))
}

package main

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

var (
	base      = uint64(31)
	maxN      = 500000 + 10
	powerBase = make([]uint64, maxN)
	hashed    = []uint64{}
)

func solve(s string, t string, n int) string {
	res := make([]byte, len(s))
	count := map[byte]int{}
	lengthPattern, id := n, 0

	for i := range s {
		count[s[i]]++
	}

	//find the logest suffix == prefix
	for i := 0; i < n-1; i++ {
		if hashed[i] == getHash(n-1-i, n-1) {
			lengthPattern = n - (i + 1)
			//exp: 11011
			//pre 11 = suf 11
			//=> lengthPattern is 3 : 110
		}
	}

	for i := range res {
		id = i % lengthPattern
		if count[t[id]] != 0 {
			res[i] = t[id]
			count[t[id]]--
			continue
		}
		if t[id] == '1' {
			res[i] = '0'
		} else {
			res[i] = '1'
		}
	}

	return string(res)
}

func getHash(start int, end int) uint64 {
	return hashed[end] - hashed[start-1]*powerBase[end-start+1]
}

func initPowerBase() {
	powerBase[0] = 1

	for i := 1; i < maxN; i++ {
		powerBase[i] = powerBase[i-1] * base
	}
}

func initHash(t string, n int) {
	hashed = make([]uint64, n)
	hashed[0] = uint64(t[0])

	for i := 1; i < n; i++ {
		hashed[i] = hashed[i-1]*base + uint64(t[i])
	}
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	initPowerBase()
	fmt.Fscanf(r, "%s\n", &s)
	fmt.Fscanf(r, "%s\n", &t)
	initHash(t, len(t))
	fmt.Println(solve(s, t, len(t)))
}

package main

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

func kmp(str []byte, l int) []int {
	next := make([]int, l)
	next[0] = -1
	for i := 1; i < l; i++ {
		f := i - 1
		for f >= 0 && str[next[f]+1] != str[i] {
			f = next[f]
		}
		if f != -1 || str[0] == str[i] {
			next[i] = next[f]+1
		} else {
			next[i] = -1
		}
	}
	fmt.Printf("%v\n", next)
	return next
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var str1, str2 string
	fmt.Fscanf(buf, "%s\n", &str1)
	fmt.Fscanf(buf, "%s\n", &str2)
	len1 := len(str1)
	len2 := len(str2)
	s1 := []byte(str1)
	s2 := []byte(str2)
	cnt1 := 0
	cnt2 := 0
	for _, c := range s1 {
		if c == '1' {
			cnt1++
		}
	}
	for _, c := range s2 {
		if c == '1' {
			cnt2++
		}
	}
	if len1 < len2 || cnt2 > cnt1 || len2-cnt2 > len1-cnt1 {
		fmt.Printf("%s\n", str1)
		return
	}
	next := kmp([]byte(str2), len2)
	seg1 := 0
	seg0 := 0
	for i := next[len2-1] + 1; i < len2; i++ {
		if s2[i] == '1' {
			seg1++
		} else {
			seg0++
		}
	}
	len1 -= len2
	cnt1 -= cnt2
	cnt2 = -1
	if seg1 > 0 {
		cnt2 = cnt1 / seg1
	}
	if seg0 > 0 && (cnt2 == -1 || cnt2 > (len1-cnt1)/seg0) {
		cnt2 = (len1 - cnt1) / seg0
	}

	fmt.Printf("%s", str2)
	for j := 0; j < cnt2; j++ {
		for i := next[len2-1] + 1; i < len2; i++ {
			fmt.Printf("%c", s2[i])
		}
	}
	for i:=0;i < (len1-cnt1)-cnt2*seg0;i++{
		fmt.Printf("0")
	}
	for i:=0;i < (cnt1)-cnt2*seg1;i++{
		fmt.Printf("1")
	}
	fmt.Printf("\n")
}
/**
01010101
0101010
 */


package main

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

type Reader struct {
  scanner *bufio.Scanner
}

func StdinReader() Reader {
  reader := Reader{bufio.NewScanner(os.Stdin)}
  reader.scanner.Split(bufio.ScanWords)
  return reader
}

func (r *Reader) NextInt() int {
  ok := r.scanner.Scan()
  if !ok {
    panic("EOF")
  }
  result, err := strconv.Atoi(r.scanner.Text())
  if err != nil {
    panic("no int")
  }
  return result
}

func main() {
  in := StdinReader()

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

  find_missing := func(a []int) int {
    res := 0
    for i := 0; i < n; i++ {
      res = res ^ (i + 1) ^ a[i]
    }
    return res
  }

  find_dup := func(a []int) (int, int) {
    prev := make([]int, n + 1)
    for i := 1; i <= n; i++ {
      prev[i] = -1
    }

    for i := 0; i < n; i++ {
      if prev[a[i]] != -1 {
        return prev[a[i]], i
      }
      prev[a[i]] = i
    }
    panic("")
  }

  ai, aj := find_dup(a)
  ax := find_missing(a) ^ a[ai]

  bi, bj := find_dup(b)
  bx := find_missing(b) ^ b[bi]

  for _, i := range []int{ai, aj} {
    for _, j := range []int{bi, bj} {
      tmpa, tmpb := a[i], b[j]
      a[i], b[j] = ax, bx
      same := true
      for k := 0; k < n; k++ {
        if a[k] != b[k] {
          same = false
        }
      }
      if same {
        for k := 0; k < n; k++ {
          fmt.Printf("%d ", a[k])
        }
        fmt.Printf("\n")
        return
      }
      a[i], b[j] = tmpa, tmpb
    }
  }

  return
}

package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"sort"
	"strconv"
	"strings"
)

func check(arr []int) bool {
	tmp := make([]int, len(arr))
	copy(tmp, arr)
	sort.Ints(tmp)
	for i := 0; i < len(tmp)-1; i++ {
		if tmp[i] == tmp[i+1] {
			return false
		}
	}
	return true
}

func main() {
	var n, count int
	var line string
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	for _, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		n, _ = strconv.Atoi(j)
	}
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	line, _ = reader.ReadString('\n')
	for i, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		a[i], _ = strconv.Atoi(j)
	}
	line, _ = reader.ReadString('\n')
	for i, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		b[i], _ = strconv.Atoi(j)
	}
	for i := 0; i < n; i++ {
		if a[i] != b[i] {
			count++
		}
	}
	if count == 1 {
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				c[i] = a[i]
			} else {
				c[i] = 0
			}
		}
		for i := 0; i < n; i++ {
			if a[i] != b[i] {
				tmp := 0
				for {
					tmp++
					if tmp != a[i] && tmp != b[i] {
						c[i] = tmp
						if check(c) {
							goto metka2
						}
					}
				}
			}
		}
	} else {
	metka:
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				c[i] = a[i]
			} else {
				tmp := rand.Int()
				if tmp%2 == 0 {
					c[i] = a[i]
				} else {
					c[i] = b[i]
				}
			}
		}
		if !check(c) {
			goto metka
		}
	}
metka2:
	for _, j := range c {
		fmt.Printf("%d ", j)
	}
}

package main

import (
    "fmt"
)

var (
    n int
    a []int
    b []int
)

func solve(i int, j int) bool {
    ma := map[int]bool{}
    mb := map[int]bool{}
    r := make([]int, n)

    for k := 0; k < n; k++ {
        var x = a[k]
        if k == i {
            x = b[k]
        } else if k == j {
            x = a[k]
        } else {
            if a[k] != b[k] { return false }
        }
        if ma[x] { return false }
        if mb[x] { return false }

        ma[x] = true
        mb[x] = true

        r[k] = x
    }
    for i := 0; i < n; i++ {
        fmt.Printf("%d", r[i])
        if (i == n - 1) {
            fmt.Printf("\n")
        } else {
            fmt.Printf(" ")
        }
    }
    return true
}

func solve2(i int, k int) bool {
    ma := map[int]bool{}
    mb := map[int]bool{}
    r := make([]int, n)

    for j := 0; j < n; j++ {
        var x = a[j]
        if j == i {
            x = k
        } else {
            if a[j] != b[j] { return false }
        }
        if ma[x] { return false }
        if mb[x] { return false }

        ma[x] = true
        mb[x] = true

        r[j] = x
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d", r[i])
        if (i == n - 1) {
            fmt.Printf("\n")
        } else {
            fmt.Printf(" ")
        }
    }
    return true
}

func main() {
    for {
        _, err := fmt.Scan(&n)
        if err != nil { break }

        a = make([]int, n)
        b = make([]int, n)
        ma := map[int]int{}
        va := map[int]bool{}
        mb := map[int]int{}
        vb := map[int]bool{}

        for i := 0; i < n; i++ {
            fmt.Scan(&a[i])
            x := a[i]
            if ma[x] > 0 {
                va[ma[x]-1] = true
                va[i] = true
            }
            ma[x] = i + 1
        }
        for i := 0; i < n; i++ {
            fmt.Scan(&b[i])
            x := b[i]
            if mb[x] > 0 {
                vb[mb[x]-1] = true
                vb[i] = true
            }
            mb[x] = i + 1
        }

        solved := false
        for i := 0; i < n && !solved; i++ {
            if va[i] == false { continue }
            for j := 0; j < n && !solved; j++ {
                if vb[j] == false { continue }
                if i == j {
                    for k := 1; k <= n && !solved; k++ {
                        solved = solve2(i, k)
                    }
                } else {
                    solved = solve(i, j)
                }
            }
        }
    }
}

package main

import (
	"fmt"
)

func ReadArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n int
	a, b, ans []int
)

func Read() {
	fmt.Scan(&n)
	a = ReadArr(n)
	b = ReadArr(n)
	ans = make([]int, n)
}

func main() {
	Read()
	used := make([]bool, n)
	misses := [2]int{-1, -1}
	for i := 0; i < n; i++ {
		if a[i] == b[i] {
			used[a[i] - 1] = true
			ans[i] = a[i]
		} else {
			if misses[0] == -1 {
				misses[0] = i
			} else {
				misses[1] = i
			}
		}
	}

	unused := [2]int{-1, -1}
	for i, u := range used {
		if !u {
			if unused[0] == -1 {
				unused[0] = i + 1
			} else {
				unused[1] = i + 1
			}
		}
	}

	if misses[1] == -1 {
		ans[misses[0]] = unused[0]
	} else {
		ans[misses[0]] = unused[0]
		ans[misses[1]] = unused[1]
		if (a[misses[0]] != ans[misses[0]] && a[misses[1]] != ans[misses[1]]) ||
			(b[misses[0]] != ans[misses[0]] && b[misses[1]] != ans[misses[1]]) {
			ans[misses[0]] = unused[1]
			ans[misses[1]] = unused[0]
		}
	}

	printAns()
}
func printAns() {
	for _, e := range ans {
		fmt.Print(e, " ")
	}
}

package main

import (
	"fmt"
)

func ReadArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n int
	a, b, ans []int
)

func Read() {
	fmt.Scan(&n)
	a = ReadArr(n)
	b = ReadArr(n)
	ans = make([]int, n)
}

func main() {
	Read()
	mistakes := 0
	anyMisPos := 0
	for i := 0; i < n; i++ {
		ans[i] = a[i]
		if a[i] != b[i] {
			mistakes++
			anyMisPos = i
		}
	}
	if mistakes == 1 {
		mistake := 1
		for a[anyMisPos] == mistake || b[anyMisPos] == mistake {
			mistake++
		}
		ans[anyMisPos] = mistake

	}
	if mistakes == 2 {
		ans[anyMisPos] = b[anyMisPos]
	}
	printAns()
}
func printAns() {
	for _, e := range ans {
		fmt.Print(e, " ")
	}
}

package main

import (
	"fmt"
)

func ReadArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n int
	a, b, ans []int
)

func Read() {
	fmt.Scan(&n)
	a = ReadArr(n)
	b = ReadArr(n)
	ans = make([]int, n)
}

func main() {
	Read()
	used := make([]bool, n)
	misses := [2]int{-1, -1}
	for i := 0; i < n; i++ {
		if a[i] == b[i] {
			used[a[i] - 1] = true
			ans[i] = a[i]
		} else {
			if misses[0] == -1 {
				misses[0] = i
			} else {
				misses[1] = i
			}
		}
	}

	unused := [2]int{-1, -1}
	for i, u := range used {
		if !u {
			if unused[0] == -1 {
				unused[0] = i + 1
			} else {
				unused[1] = i + 1
			}
		}
	}

	if misses[1] == -1 {
		ans[misses[0]] = unused[0]
	} else {
		if a[misses[0]] == unused[0] || b[misses[0]] == unused[0] {
			ans[misses[0]] = unused[0]
			ans[misses[1]] = unused[1]
		} else {
			ans[misses[0]] = unused[1]
			ans[misses[1]] = unused[0]
		}
	}

	printAns()
}
func printAns() {
	for _, e := range ans {
		fmt.Print(e, " ")
	}
}

package main

import (
	"fmt"
)

func ReadArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n int
	a, b, ans []int
)

func Read() {
	fmt.Scan(&n)
	a = ReadArr(n)
	b = ReadArr(n)
	ans = make([]int, n)
}

func main() {
	Read()
	used := make([]bool, n)
	for i := 0; i < n; i++ {
		if a[i] == b[i] {
			used[a[i] - 1] = true
			ans[i] = a[i]
		}
	}

	for i := range ans {
		if ans[i] == 0 {
			if !used[a[i] - 1] {
				ans[i] = a[i]
				used[a[i] - 1] = true
			} else if !used[b[i] - 1] {
				ans[i] = b[i]
				used[b[i] - 1] = true
			} else { // 1 mistake -> !a && !b
				for i, e := range used {
					if !e {
						ans[i] = i + 1
						used[i] = true
					}
				}
			}
		}
	}

	printAns()
}
func printAns() {
	for _, e := range ans {
		fmt.Print(e, " ")
	}
}

package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"sort"
	"strconv"
	"strings"
)

func check(arr []int) bool {
	tmp := make([]int, len(arr))
	copy(tmp, arr)
	sort.Ints(tmp)
	for i := 0; i < len(tmp)-1; i++ {
		if tmp[i] == tmp[i+1] {
			return false
		}
	}
	return true
}

func main() {
	var n, count int
	var line string
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	for _, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		n, _ = strconv.Atoi(j)
	}
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	line, _ = reader.ReadString('\n')
	for i, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		a[i], _ = strconv.Atoi(j)
	}
	line, _ = reader.ReadString('\n')
	for i, j := range strings.Split(strings.TrimRight(line, "\n\r\t "), " ") {
		b[i], _ = strconv.Atoi(j)
	}
	for i := 0; i < n; i++ {
		if a[i] != b[i] {
			count++
		}
	}
	if count == 1 {
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				c[i] = a[i]
			} else {
				tmp := 1
				for {
					if tmp != a[i] && tmp != b[i] {
						c[i] = tmp
						break
					}
					tmp++
				}
			}
		}
	} else {
	metka:
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				c[i] = a[i]
			} else {
				tmp := rand.Int()
				if tmp%2 == 0 {
					c[i] = a[i]
				} else {
					c[i] = b[i]
				}
			}
		}
		if !check(c) {
			goto metka
		}
	}
	for _, j := range c {
		fmt.Printf("%d ", j)
	}
}


package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	// var n int
	// scan(&n)
	// var p = make([]int, n)
	// for i := range p {
	// 	scan(&p[i])
	// }

	// var dp = [101][101][2]int{}
	// for i := range dp {
	// 	for j := range dp[i] {
	// 		for k := range dp[i][j] {
	// 			dp[i][j][k] = 1 << 30
	// 		}
	// 	}
	// }
	var n int
	scan(&n)
	var (
		c   [500][500]int64
		ans int64
	)
	for i := 0; i < 2*n; i++ {
		for j := 0; j < 2*n; j++ {
			scan(&c[i][j])
			if i >= n && j >= n {
				ans += c[i][j]
			}
		}
	}
	printf("%v\n", ans+min(
		c[n][0], c[2*n-1][0],
		c[n][n-1], c[2*n-1][n-1],
		c[0][n], c[0][2*n-1],
		c[n-1][n], c[n-1][2*n-1],
	))
}

func min(s ...int64) int64 {
	r := s[0]
	for _, i := range s {
		if r > i {
			r = i
		}
	}
	return r
}

package main

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

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

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

func main() {
	defer out.Flush()

	costs := [510][510]int64{}

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n int
		fmt.Fscan(in, &n)
		for r := 0; r < 2*n; r++ {
			for c := 0; c < 2*n; c++ {
				fmt.Fscan(in, &costs[r][c])
			}
		}

		var total int64

		for r := 0; r < n; r++ {
			for c := 0; c < n; c++ {
				total += costs[n+r][n+c]
			}
		}

		var extra int64 = 1e15
		extra = min(extra, costs[0][n])
		extra = min(extra, costs[0][2*n-1])
		extra = min(extra, costs[n-1][n])
		extra = min(extra, costs[n-1][2*n-1])
		extra = min(extra, costs[n][0])
		extra = min(extra, costs[n][n-1])
		extra = min(extra, costs[2*n-1][0])
		extra = min(extra, costs[2*n-1][n-1])

		fmt.Fprintln(out, total+extra)
	}
}

package main

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

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

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			grid[i] = readNNums(reader, 2*n)
		}
		res := solve(n, grid)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}
	fmt.Print(buf.String())
}

func normalize(s string) string {

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

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

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

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

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

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

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

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

	return i
}

func solve(n int, C [][]int) int64 {
	var res int64
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			res += int64(C[i][j])
		}
	}
	cell := 1 << 30
	cell = min(cell, C[0][n])
	cell = min(cell, C[0][2*n-1])
	cell = min(cell, C[n][0])
	cell = min(cell, C[2*n-1][0])
	cell = min(cell, C[n-1][n])
	cell = min(cell, C[n-1][2*n-1])
	cell = min(cell, C[n][n-1])
	cell = min(cell, C[2*n-1][n-1])

	return res + int64(cell)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1621D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ans := int64(0)
		a := make([][]int64, n*2)
		for i := range a {
			a[i] = make([]int64, n*2)
			for j := range a[i] {
				Fscan(in, &a[i][j])
				if i >= n && j >= n {
					ans += a[i][j]
				}
			}
		}
		min := int64(1e9)
		for _, v := range []int64{a[0][n], a[0][n*2-1], a[n-1][n], a[n-1][n*2-1], a[n][0], a[n][n-1], a[n*2-1][0], a[n*2-1][n-1]} {
			if v < min {
				min = v
			}
		}
		Fprintln(out, ans+min)
	}
}

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

package main

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

func min(n ...uint64) uint64 {
	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

func solve(grid [][]uint64, n uint64) uint64 {
	var sum uint64 = 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}

	return min(
		sum+grid[n][0],
		sum+grid[0][n],

		sum+grid[n][n-1],
		sum+grid[n-1][n],

		sum+grid[2*n-1][0],
		sum+grid[0][2*n-1],

		sum+grid[2*n-1][n-1],
		sum+grid[n-1][2*n-1],
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	// -2147483648 2147483647
	// 4999999993  4999999993
	// 			   4294967295
	//			    705032697

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]uint64, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]uint64, 2*n)
			for j := 0; j < 2*n; j++ {
				var c uint64
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, uint64(n))
		Fprintln(out, res)
		t--
	}
}

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

package main

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

func min(n ...int) int {
	if len(n) == 0 {
		return math.MinInt32
	}

	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

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

func solve(grid [][]int, n int) int {
	sum := 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}

	return min(
		sum+grid[n][0],
		sum+grid[0][n],

		sum+grid[n][n-1],
		sum+grid[n-1][n],

		sum+grid[2*n-1][0],
		sum+grid[0][2*n-1],

		sum+grid[2*n-1][n-1],
		sum+grid[n-1][2*n-1],
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]int, 2*n)
			for j := 0; j < 2*n; j++ {
				var c int
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, n)
		Fprintln(out, res)
		t--
	}
}

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

package main

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

func min(n ...int) int {
	if len(n) == 0 {
		return math.MinInt32
	}

	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

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

func solve(grid [][]int, n int) int {
	sum := 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}

	var a, b, c, d, e, f, g, h int
	for i := n; i < 2*n; i++ {
		a += grid[0][i]
	}
	for i := n; i < 2*n; i++ {
		d += grid[i][0]
	}
	for i := 0; i < n; i++ {
		b += grid[i][2*n-1]
	}
	for i := 0; i < n; i++ {
		c += grid[2*n-1][i]
	}

	for i := 0; i < n; i++ {
		e += grid[i][n]
	}
	for i := n; i < 2*n; i++ {
		f += grid[n-1][i]
	}
	for i := 0; i < n; i++ {
		g += grid[n][i]
	}
	for i := n; i < 2*n; i++ {
		h += grid[i][n-1]
	}

	return min(
		sum+grid[0][2*n-1],
		sum+grid[2*n-1][0],

		sum+grid[n][n-1],
		sum+grid[n-1][n],

		sum+grid[0][n],
		sum+grid[n][0],

		sum+grid[2*n-1][n-1],
		sum+grid[n-1][2*n-1],

		sum+a,
		sum+b,
		sum+c,
		sum+d,
		sum+e,
		sum+f,
		sum+g,
		sum+h,
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]int, 2*n)
			for j := 0; j < 2*n; j++ {
				var c int
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, n)
		Fprintln(out, res)
		t--
	}
}

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

package main

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

func min(n ...int) int {
	if len(n) == 0 {
		return math.MinInt32
	}

	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

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

func solve(grid [][]int, n int) int {
	sum := 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}

	var a, b, c, d int
	for i := n; i < 2*n; i++ {
		a += grid[0][i]
	}
	for i := n; i < 2*n; i++ {
		d += grid[i][0]
	}
	for i := 0; i < n; i++ {
		b += grid[i][2*n-1]
	}
	for i := 0; i < n; i++ {
		c += grid[2*n-1][i]
	}

	return min(
		sum+grid[0][2*n-1],
		sum+grid[2*n-1][0],

		sum+grid[n][n-1],
		sum+grid[n-1][n],

		sum+grid[0][n],
		sum+grid[n][0],

		sum+grid[2*n-1][n-1],
		sum+grid[n-1][2*n-1],

		sum+a,
		sum+b,
		sum+c,
		sum+d,
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]int, 2*n)
			for j := 0; j < 2*n; j++ {
				var c int
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, n)
		Fprintln(out, res)
		t--
	}
}

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

package main

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

func min(n ...int) int {
	if len(n) == 0 {
		return math.MinInt32
	}

	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

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

func solve(grid [][]int, n int) int {
	sum := 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}

	var a, b, c, d int
	for i := n; i < 2*n; i++ {
		a += grid[0][i]
	}
	for i := n; i < 2*n; i++ {
		d += grid[i][0]
	}
	for i := 0; i < n; i++ {
		b += grid[i][2*n-1]
	}
	for i := 0; i < n; i++ {
		c += grid[2*n-1][i]
	}

	return min(
		sum+grid[n][0],
		sum+grid[n][n-1],
		sum+grid[0][n],
		sum+grid[n-1][n],
		sum+grid[0][2*n-1],
		sum+grid[2*n-1][0],
		sum+a,
		sum+b,
		sum+c,
		sum+d,
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]int, 2*n)
			for j := 0; j < 2*n; j++ {
				var c int
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, n)
		Fprintln(out, res)
		t--
	}
}

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

package main

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

func min(n ...int) int {
	if len(n) == 0 {
		return math.MinInt32
	}

	min := n[0]
	for _, a := range n {
		if a < min {
			min = a
		}
	}
	return min
}

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

func solve(grid [][]int, n int) int {
	sum := 0
	for i := n; i < 2*n; i++ {
		for j := n; j < 2*n; j++ {
			sum += grid[i][j]
		}
	}
	return min(
		sum+grid[n][0],
		sum+grid[n][n-1],
		sum+grid[0][n],
		sum+grid[n-1][n],
		sum+grid[0][2*n-1],
		sum+grid[2*n-1][0],
	)
}

func SolD(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for t > 0 {
		var n int
		Fscan(in, &n)
		grid := make([][]int, 2*n)
		for i := 0; i < 2*n; i++ {
			row := make([]int, 2*n)
			for j := 0; j < 2*n; j++ {
				var c int
				Fscan(in, &c)
				row[j] = c
				// shop = append(shop, []int{l, r, c})
			}
			grid[i] = row
		}
		res := solve(grid, n)
		Fprintln(out, res)
		t--
	}
}

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


package main

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

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

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	scanner.Scan()
	s := scanner.Text()

	for i := 0; i < n-1; i++ {
		if s[i] != s[i+1] {
			fmt.Println("YES")
			fmt.Println(string(s[i]) + string(s[i+1]))
			return
		}
	}

	fmt.Println("NO")
}

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 checkDiverce(s string) string {
	if len(s) < 2 {
		return ""
	}
	for index, char := range s[1:] {
		// if previous char != current, return previous+current
		if s[index] != byte(char) {
			return fmt.Sprintf("%c%c", s[index], char)
		}
	}
	return ""
}

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

	// var a, b int
	var input string
	var n int
	scanf("%d\n", &n)
	scanf("%s", &input)
	if answer := checkDiverce(input); answer != "" {
		printf("YES\n%s\n", answer)
	} else {
		printf("NO\n")
	}
}

package main

import (
    "fmt"
    "os"
)

func main() {
    var s string
    var d int
    fmt.Scanf("%d\n%s", &d, &s)
    for i := range s {
        if i == 0 {
            continue
        }
        if s[i] != s[i - 1] {
            fmt.Println("YES")
            fmt.Print(string(s[i-1]), string(s[i]))
            os.Exit(0)
        }
    }
    fmt.Print("NO")
}

package main

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

func isDiffrentSubString(str string) bool {
	return str[0] != str[1];
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan();
	str := scanner.Text()

	resultSubstring := ""

	if len(str) > 1 {
		for i:=0; i + 2 <= len(str); i++{
			substring := str[i:i+2]
			if isDiffrentSubString(substring){
				resultSubstring = substring
				break
			}
		}
	}

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

package main

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

func main() {

	sc := bufio.NewReader(os.Stdin)
	var c int
	var s string
	fmt.Fscanf(sc,"%d\n%s",&c,&s)
	l := len(s)

	for i:= 1;i<l;i++ {
		if(s[i-1] != s[i]) {
			fmt.Println("Yes")
			fmt.Printf("%c%c",s[i-1],s[i])
			os.Exit(0)
		}
	}
	fmt.Println("No")
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()

	for i := 1; i < N; i++ {
		if S[i-1] != S[i] {
			io.Println("YES")
			io.Println(S[i-1 : i+1])
			return
		}
	}
	io.Println("NO")
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func main() {
	readLine()
	line := readLine()
	isDiverse := false
	for i := 0; i < (len(line) - 1); i++ {
		if line[i] != line[i+1] {
			fmt.Println("YES")
			fmt.Println(line[i : i+2])
			isDiverse = true
			break
		}
	}
	if !isDiverse {
		fmt.Println("NO")
	}
}

var scanner = bufio.NewScanner(os.Stdin)

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

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 checkDiverce(s string) string {
	if len(s) <= 2 {
		return ""
	}
	for index, char := range s[1:] {
		// if previous char != current, return previous+current
		// printf("%c\n", s[index])
		if s[index] != byte(char) {
			return fmt.Sprintf("%c%c", s[index], char)
		}
	}
	return ""
}

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

	// var a, b int
	var input string
	scanf("%s", &input)
	if answer := checkDiverce(input); answer != "" {
		printf("YES\n%s\n", answer)
	} else {
		printf("NO\n")
	}
}

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 checkDiverce(s string) string {
	if len(s) <= 2 {
		return ""
	}
	for index, char := range s[1:] {
		// if previous char != current, return previous+current
		// printf("%c\n", s[index])
		if s[index] != byte(char) {
			return fmt.Sprintf("%c%c", s[index], char)
		}
	}
	return ""
}

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

	// var a, b int
	var input string
	var n int
	scanf("%d\n", &n)
	scanf("%s", &input)
	if answer := checkDiverce(input); answer != "" {
		printf("YES\n%s\n", answer)
	} else {
		printf("NO\n")
	}
}

package main

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

func isDiffrentSubString(str string) bool {
	return str[0] != str[1] && str[0] != str[2] && str[1] != str[2]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan();
	str := scanner.Text()

	resultSubstring := ""

	if len(str) > 2 {
		for i:=0; i + 3 <= len(str); i++{
			substring := str[i:i+3]
			if isDiffrentSubString(substring){
				resultSubstring = substring
				break
			}
		}
	}

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

package main

import ("fmt";"os")

func main() {
	var c int
	var s string
	fmt.Scan(&c)
	fmt.Scanln(&s)
	l := len(s)

	for i:= 1;i<l;i++ {
		if(s[i-1] != s[i]) {
			fmt.Println("Yes")
			fmt.Printf("%c%c",s[i-1],s[i])
			os.Exit(0)
		}
	}
	fmt.Println("No")
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	S := io.NextLine()

	for i := range S {
		freq := make(map[byte]int)
		for j := i; j < N; j++ {
			freq[S[j]]++
			if diverse(freq, j-i+1) {
				io.Println("YES")
				io.Println(S[i : j+1])
				return
			}
		}
	}
	io.Println("NO")
}

func diverse(freq map[byte]int, w int) bool {
	for _, v := range freq {
		if (v << 1) >= w {
			return false
		}
	}
	return true
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}