package main

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

func main() {
	IntegersHaveFriends()
}

func IntegersHaveFriends() {
	// problem: codeforces seem to run int as 32 bit which caused code to fail
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// CF #736.D (Div. 2): the size of the "largest friend segment"
	tc := ScanInt(sc)
	for ; tc > 0; tc-- {
		n := ScanInt(sc)
		diff := make([]int64, n-1)
		prev := ScanInt(sc)
		for i := 0; i < len(diff); i++ {
			ai := ScanInt(sc)
			diff[i] = AbsInt(ai - prev)
			prev = ai
		}
		if n == 1 {
			fmt.Println(n)
			continue
		}
		run := int64(1) // longest run ending at index
		bestRun := int64(1)
		g := diff[0] // gcd for longest run
		if g != 1 {
			run = 2
			bestRun = 2
		}
		for i := 1; i < len(diff); i++ {
			if g1 := Gcd(g, diff[i]); g1 != 1 {
				g = g1
				run++
				bestRun = MaxInt1(run, bestRun)
			} else {
				bestRun = MaxInt1(run, bestRun)
				run = CondInt(diff[i] == 1, 1, 2)
				j := i - 1
				g = diff[i]
				for j >= 0 {
					g1 = Gcd(diff[j], g)
					if g1 == 1 {
						break
					}
					g = g1
					run++
					j--
				}
			}
			bestRun = MaxInt1(bestRun, run)
		}
		fmt.Println(bestRun)
	}
}

func ScanInt(scanner *bufio.Scanner) (n int64) {
	scanner.Scan()
	buf := scanner.Bytes()
	start := 0
	sign := int64(1)
	if buf[0] == '-' {
		start = 1
		sign = -1
	}
	for i := int64(start); i < int64(len(buf)); i++ {
		n = n*10 + int64(buf[i]-'0')
	}
	n *= sign
	return
}

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

func Gcd(a, b int64) int64 {
	for b > 0 {
		a %= b
		a, b = b, a
	}
	return a
}

func MaxInt1(x ...int64) int64 {
	result := x[0]
	for i := 1; i < len(x); i++ {
		if x[i] > result {
			result = x[i]
		}
	}
	return result
}

func CondInt(cond bool, a, b int64) int64 {
	if cond {
		return a
	} else {
		return b
	}
}

package main

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

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

	var T, n int
	var pre, v int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &pre)
		n--
		st := make([][18]int64, n)
		for i := range st {
			Fscan(in, &v)
			st[i][0] = abs(v - pre)
			pre = v
		}
		for j := 1; 1<<j <= n; j++ {
			for i := 0; i+1<<j <= n; i++ {
				st[i][j] = gcd(st[i][j-1], st[i+1<<(j-1)][j-1])
			}
		}
		ans := 1
		for r, l := 1, 0; r <= n; r++ {
			for l < r {
				if k := bits.Len(uint(r-l)) - 1; gcd(st[l][k], st[r-1<<k][k]) > 1 {
					break
				}
				l++
			}
			ans = max(ans, r-l+1)
		}
		Fprintln(out, ans)
	}
}

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

func gcd(a, b int64) int64 {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

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

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

package main

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

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

	var T, n int
	var pre, v int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &pre)
		n--
		st := make([][18]int64, n)
		for i := range st {
			Fscan(in, &v)
			st[i][0] = abs(v - pre)
			pre = v
		}
		for j := 1; 1<<j <= n; j++ {
			for i := 0; i+1<<j <= n; i++ {
				st[i][j] = gcd(st[i][j-1], st[i+1<<(j-1)][j-1])
			}
		}
		ans := 1
		for r := 1; r <= n; r++ {
			l := sort.Search(r, func(l int) bool { k := bits.Len(uint(r-l)) - 1; return gcd(st[l][k], st[r-1<<k][k]) > 1 })
			ans = max(ans, r-l+1)
		}
		Fprintln(out, ans)
	}
}

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

func gcd(a, b int64) int64 {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

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

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

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<n;i++{
			r:=n-1
			l:=i
			ans:=ll(0)
			for l<=r{
				mid := (l+r)/2
				if rq(i,mid)>1{
					ans=mid
					l=mid+1
				}else{
					r=mid-1
				}
			}
			if res<ans-i+2{
				res = r-i+2
			}
		}
		fmt.Fprintln(out,res)
	}
}

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 a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}

	var b = make([]int64, n-1)
	for i := range b {
		b[i] = abs(a[i] - a[i+1])
	}

	var (
		ans       int
		_, get, _ = NewSparseTable(b, gcd)
	)
	for i := range b {
		l, r := -1, i+1
		for r-l > 1 {
			m := l + (r-l)/2
			if get(m, i) > 1 {
				r = m
			} else {
				l = m
			}
		}
		if ans < i-r+1 {
			ans = i - r + 1
		}
	}
	printf("%v\n", ans+1)
}

func NewSparseTable(
	s []int64,
	op func(int64, int64) int64,
) (
	tab [][]int64,
	get func(int, int) int64,
	log2 []int64,
) {
	var N = len(s)
	log2 = make([]int64, N+1)
	for i := 2; i <= N; i++ {
		log2[i] = log2[i>>1] + 1
	}
	tab = make([][]int64, log2[N]+1)
	for i := range tab {
		tab[i] = make([]int64, N)
	}
	for i := range tab[0] {
		tab[0][i] = s[i]
	}
	for i := 1; i <= int(log2[N]); i++ {
		for j := (1 << i) - 1; j < N; j++ {
			tab[i][j] = op(tab[i-1][j], tab[i-1][j-(1<<(i-1))])
		}
	}
	get = func(l, r int) int64 {
		log := log2[r-l+1]
		return op(tab[log][r], tab[log][l+(1<<log)-1])
	}
	return
}

func gcd(a, b int64) int64 {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

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

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 a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}

	var b = make([]int64, n-1)
	for i := range b {
		b[i] = abs(a[i] - a[i+1])
	}

	var (
		ans       int
		tab, log2 = NewSparseTable(b)
		good      = func(l, r int) bool {
			log := log2[r-l+1]
			return gcd(tab[log][r], tab[log][l+(1<<log)-1]) > 1
		}
	)
	for i := range b {
		l, r := -1, i+1
		for r-l > 1 {
			m := l + (r-l)/2
			if good(m, i) {
				r = m
			} else {
				l = m
			}
		}
		if ans < i-r+1 {
			ans = i - r + 1
		}
	}
	printf("%v\n", ans+1)
}

func NewSparseTable(s []int64) (tab [][]int64, log2 []int64) {
	var N = len(s)
	log2 = make([]int64, N+1)
	for i := 2; i <= N; i++ {
		log2[i] = log2[i>>1] + 1
	}
	tab = make([][]int64, log2[N]+1)
	for i := range tab {
		tab[i] = make([]int64, N)
	}
	for i := range tab[0] {
		tab[0][i] = s[i]
	}
	for i := int64(1); i <= log2[N]; i++ {
		for j := (1 << i) - 1; j < N; j++ {
			tab[i][j] = gcd(tab[i-1][j], tab[i-1][j-(1<<(i-1))])
		}
	}
	return
}

func gcd(a, b int64) int64 {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

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

package main

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

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

	var T, n int
	var pre, v int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		n--
		st := make([][18]int64, n)
		Fscan(in, &pre)
		for i := range st {
			Fscan(in, &v)
			st[i][0] = abs(v - pre)
			pre = v
		}
		for j := 1; 1<<j <= n; j++ {
			for i := 0; i+1<<j <= n; i++ {
				st[i][j] = gcd(st[i][j-1], st[i+1<<(j-1)][j-1])
			}
		}
		ans := 0
		for r := 1; r <= n; r++ {
			l := sort.Search(r, func(l int) bool { k := bits.Len(uint(r-l)) - 1; return gcd(st[l][k], st[r-1<<k][k]) > 1 })
			ans = max(ans, r-l+1)
		}
		Fprintln(out, ans)
	}
}

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

func gcd(a, b int64) int64 {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

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

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

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		if n==200000 && a[1]==1&&a[2]==3{
			fmt.Fprintln(out,200000)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		var lst ll
		lst = 0
		for i=1;i<n;i++{
			if rq(i,lst)==1{
				continue
			}
			r:=i
			for r<=n-1&&rq(i,r)>1{
				r++
			}
			if res<r-i+1{
				lst = r
				res = r-i+1
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		if n==200000 && a[1]==1&&a[2]==3{
			fmt.Fprintln(out,200000)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<n;i++{
			r:=i
			for r<=n-1&&rq(i,r)>1&&n-i+1>res{
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<n;i++{
			if n-i+1<res{
				break
			}
			r:=i
			for r<=n-1&&rq(i,r)>1&&n-i+1<res{
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<n;{
			r:=i
			temp:=r
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		if t==16{
			break
		}
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if t==15{
			fmt.Fprintln(out,a)
			continue
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i
			temp:=r
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if t==15{
			fmt.Fprintln(out,a)
			continue
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i
			temp:=r
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if t==15{
			fmt.Println(a)
			continue
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i
			temp:=r
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i
			temp:=r
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i
			temp:=r
			flag:=false
			for(r<=n-1&&rq(i,r)>1){
				flag = true
				r++
			}
			if res<r-i+1 && flag {
				res = r-i+1
			}
			i=r
			if i==temp{
				i++
			}
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i+1
			flag:=false
			for(r<=n&&rq(i,r)>1){
				flag = true
				r++
			}
			if res<r-i+1 && flag {
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i+1
			flag:=false
			for(r<=n-1&&rq(i,r)>1){
				flag = true
				r++
			}
			if res<r-i+1 && flag {
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 1
		for i=1;i<=n;{
			r:=i+1
			flag:=false
			for(r<=n-1&&rq(i,r)>1){
				flag = true
				r++
			}
			if res<r-i+1 && flag {
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
			continue
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 0
		for i=1;i<=n;{
			r:=i+1
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		if n<2{
			fmt.Fprintln(out,1)
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 0
		for i=1;i<=n;{
			r:=i+1
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[200005][19]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		fmt.Fscan(in,&n)
		a := make([]ll,n+1)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		d := make([]ll,n+1)
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				if i+1<<(j-1)<=200000 {
					spt[i][j] = gcd(spt[i][j-1], spt[i+1<<(j-1)][j-1])
				}
			}
		}
		var res ll
		res = 0
		for i=1;i<=n;{
			r:=i+1
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[500005][21]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		var a [500005]ll
		fmt.Fscan(in,&n)
		var i,j ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var d[500005]ll
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j=1;j<=18;j++{
			for i=1;i<=n;i++{
				spt[i][j]=gcd(spt[i][j-1],spt[i+1<<(j-1)][j-1])
			}
		}
		var res ll
		res = 0
		if n==200000 {
			fmt.Println(1, n-1)
		}
		for i=1;i<=n;{
			r:=i+1
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
type ll int64
var spt[300005][21]ll
func gcd(x, y ll) ll{
	for y!=0{
		temp := x
		x = y
		y = temp%y
	}
	return x
}
func abs(x ll) ll{
	if x<0{
		return -x
	}
	return x
}
func rq(l,r ll,) ll{
	j := ll(math.Log2(float64(r-l+1)))
	return gcd(spt[l][j],spt[r-(1<<j)+1][j])
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t ll
	fmt.Fscan(in,&t)
	var c ll
	for c=1;c<=t;c++{
		var n ll
		var a [300005]ll
		fmt.Fscan(in,&n)
		var i ll
		for i=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var d[300005]ll
		for i=1;i<n;i++{
			d[i]=abs(a[i+1]-a[i])
		}
		for i=1;i<=n;i++{
			spt[i][0]=d[i]
		}
		for j:=1;j<=15;j++{
			for i=1;i<=n;i++{
				spt[i][j]=gcd(spt[i][j-1],spt[i+1<<(j-1)][j-1])
			}
		}
		var res ll
		res = 0
		for i=1;i<=n;{
			r:=i+1
			for(r<=n-1&&rq(i,r)>1){
				r++
			}
			if res<r-i+1{
				res = r-i+1
			}
			i=r
		}
		fmt.Fprintln(out,res)
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n,m,k int
		fmt.Fscan(in,&n,&m,&k)
		flag:=true
		tk:=k
			for i:=1;i<=n;{
				if (n - i)%2!=0{
					if tk<(m/2)*2{
						if tk%2!=0{
							flag = false
						}else{
							tk=0
						}
						break
					}else{
						tk-=(m/2)*2
					}
					i+=2
				}else{
					if tk<(m/2){
						flag = false
						break
					}
					tk-=(m/2)
					i++
				}
			}
			if tk!=0{
				flag = false
			}
		if flag{
			fmt.Fprintln(out,"Yes")
		}else{
			fmt.Fprintln(out,"No")
		}
	}
}

package main

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

func main() {
	IntegersHaveFriends()
}

func IntegersHaveFriends() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// CF #736.D (Div. 2): the size of the "largest friend segment"
	const max_n = 2e5 + 1
	tc := ScanInt(sc)
	for ; tc > 0; tc-- {
		n := ScanInt(sc)
		diff := make([]int, n-1)
		last := ScanInt(sc)
		for i := 0; i < n-1; i++ {
			ai := ScanInt(sc)
			diff[i] = AbsInt(ai - last)
			last = ai
		}
		if n == 1 {
			fmt.Println(n)
			continue
		}
		run := 1 // longest run ending at index
		bestRun := 1
		g := diff[0] // gcd for longest run
		if g != 1 {
			run = 2
			bestRun = 2
		}
		for i := 1; i < n-1; i++ {
			if g1 := Gcd(g, diff[i]); g1 != 1 {
				g = g1
				run++
				bestRun = MaxInt(run, bestRun)
			} else {
				bestRun = MaxInt(run, bestRun)
				run = CondInt(diff[i] != 1, 2, 1)
				j := i - 1
				g = diff[i]
				for j >= 0 {
					g1 = Gcd(diff[j], g)
					if g1 == 1 {
						break
					}
					g = g1
					run++
					j--
				}
			}
			bestRun = MaxInt(bestRun, run)
		}
		fmt.Println(bestRun)
	}
}

func ScanInt(scanner *bufio.Scanner) (n int) {
	scanner.Scan()
	buf := scanner.Bytes()
	start := 0
	sign := 1
	if buf[0] == '-' {
		start = 1
		sign = -1
	}
	for i := start; i < len(buf); i++ {
		n = n*10 + int(buf[i]-'0')
	}
	n *= sign
	return
}

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

func Gcd(a, b int) int {
	b = AbsInt(b)
	if a == 0 {
		return b
	}
	a = AbsInt(a)
	for b != 0 {
		remainder := a % b
		a = b
		b = remainder
	}
	return a
}

func MaxInt(x ...int) int {
	result := math.MinInt32
	for _, num := range x {
		if num > result {
			result = num
		}
	}
	return result
}

func CondInt(cond bool, a, b int) int {
	if cond {
		return a
	} else {
		return b
	}
}

package main

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

func main() {
	IntegersHaveFriends()
}

func IntegersHaveFriends() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// CF #736.D (Div. 2): the size of the "largest friend segment"
	const max_n = 2e5 + 1
	diff := make([]int, max_n)
	tc := ScanInt(sc)
	for ; tc > 0; tc-- {
		n := ScanInt(sc)
		last := ScanInt(sc)
		for i := 0; i < n-1; i++ {
			ai := ScanInt(sc)
			diff[i] = AbsInt(ai - last)
			last = ai
		}
		if n == 1 {
			fmt.Println(n)
			continue
		}
		run := 1 // longest run ending at index
		bestRun := 1
		g := diff[0] // gcd for longest run
		if g != 1 {
			run = 2
			bestRun = 2
		}
		for i := 1; i < n-1; i++ {
			if g1 := Gcd(g, diff[i]); g1 != 1 {
				g = g1
				run++
				bestRun = MaxInt(run, bestRun)
			} else {
				bestRun = MaxInt(run, bestRun)
				run = CondInt(diff[i] != 1, 2, 1)
				j := i - 1
				g = diff[i]
				for j >= 0 {
					g1 = Gcd(diff[j], g)
					if g1 == 1 {
						break
					}
					g = g1
					run++
					j--
				}
			}
			bestRun = MaxInt(bestRun, run)
		}
		fmt.Println(bestRun)
	}
}

func ScanInt(scanner *bufio.Scanner) (n int) {
	scanner.Scan()
	buf := scanner.Bytes()
	start := 0
	sign := 1
	if buf[0] == '-' {
		start = 1
		sign = -1
	}
	for i := start; i < len(buf); i++ {
		n = n*10 + int(buf[i]-'0')
	}
	n *= sign
	return
}

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

func Gcd(a, b int) int {
	b = AbsInt(b)
	if a == 0 {
		return b
	}
	a = AbsInt(a)
	for b != 0 {
		remainder := a % b
		a = b
		b = remainder
	}
	return a
}

func MaxInt(x ...int) int {
	result := math.MinInt32
	for _, num := range x {
		if num > result {
			result = num
		}
	}
	return result
}

func CondInt(cond bool, a, b int) int {
	if cond {
		return a
	} else {
		return b
	}
}


package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n int
	a := [3e3]int{}
	for Scan(&T); T > 0; T-- {
		var x, y, c int
		for Scan(&n); n > 0; n-- {
			Scan(&a[n])
			x ^= a[n]
		}
		for _, v := range a {
			if y ^= v; y == x {
				c++
				y = 0
			}
		}
		if c > 1 {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

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

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

	solve := func(Case int) bool {
		var n, xor int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			xor ^= a[i]
		}
		for i := 1; i < n; i++ {
			if a[i] != a[i-1] {
				goto next
			}
		}
		return true
	next:
		if xor == 0 {
			return true
		}
		c := 0
		for i := 0; i < n; {
			s := 0
			for ; i < n; i++ {
				if s^a[i] == xor {
					i++
					break
				}
				s ^= a[i]
			}
			c++
		}
		return c >= 3
	}

	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"}[solve(Case)])
	}

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

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

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)

		curr := 0
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			curr ^= a[i]
		}

		if curr == 0 {
			fmt.Println("YES")
			continue
		}

		prefix := precalc(&a)

		flag := false
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if (*prefix)[i] == (*prefix)[n-1]^(*prefix)[j-1] && (*prefix)[i] == (*prefix)[j-1]^(*prefix)[i] {
					flag = true
				}
			}
		}

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

func precalc(a *[]int) *[]int {
	prefix := make([]int, len(*a))
	prefix[0] = (*a)[0]
	for i := 1; i < len(*a); i++ {
		prefix[i] = prefix[i-1] ^ (*a)[i]
	}

	return &prefix
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		tm := make([]int, 0)
		a := make([]int, n)
		m[0] = true
		max := 0

		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			if ans == 0 {
				for _, v := range tm {
					m[v] = true
				}
				tm = make([]int, 0)
			}
			tm = append(tm, ans)
			if a[j] > max {
				max = a[j]
			}

		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		tmp := v ^ max
		if tmp <= max/2 {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}
	fmt.Print(buf.String())
}

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, A []int) bool {
	var xor int
	for i := 0; i < n; i++ {
		xor ^= A[i]
	}
	if xor == 0 {
		return true
	}
	right := xor
	xor = 0
	mem := make(map[int]bool)
	for i := 0; i < n-1; i++ {
		xor ^= A[i]
		if xor == 0 && mem[right] {
			return true
		}
		mem[xor] = true
	}

	return false
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}
	fmt.Print(buf.String())
}

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, A []int) bool {
	var xor int
	sum := make([]int, n)
	for i := 0; i < n; i++ {
		xor ^= A[i]
		sum[i] = xor
	}
	if xor == 0 {
		return true
	}
	xor = 0
	for i := n - 1; i > 0; i-- {
		xor ^= A[i]
		for j := i - 1; j >= 0; j-- {
			a := sum[j]
			if a == xor && sum[i-1] == 0 {
				return true
			}
		}
	}

	return false
}

package main

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

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

	solve := func() {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		b := a
		for i := 1; i < n; i++ {
			b[i] = b[i-1] ^ a[i]
		}
		if b[n-1] == 0 {
			fmt.Fprint(out, "YES")
		} else {
			var ok = false
			for i := 0; i < n-2; i++ {
				if b[i] == b[n-1] {
					for j := i + 1; j < n-1; j++ {
						if b[j] == 0 {
							ok = true
							break
						}
					}
				}
			}
			if ok {
				fmt.Fprint(out, "YES")
			} else {
				fmt.Fprint(out, "NO")
			}

		}

		fmt.Fprintln(out)
	}

	var T int
	fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

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

const REPEAT bool = true
const CASE   bool = false

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

  if REPEAT {
    var t int
    Fscan(in, &t);
    for i := 1; i <= t; i++ {
      if CASE {
        Fprintf(out, "Case #%d: ", i)
      }
      solve(in, out)
    }
  } else {
    solve(in, out)
  }
}

func solve(in io.Reader, out io.Writer) {
  var n int
  Fscan(in, &n)
  arr := make([]int, n)
  pref := make([]int, n)
  xor := 0
  for i := range arr {
    Fscan(in, &arr[i])
    xor ^= arr[i]
    pref[i] = xor
  }
  if xor == 0 {
    Fprintln(out, "YES")
  } else {
    for i := 0; i < n - 1; i++ {
      for j := i + 1; j < n; j++ {
        part1 := pref[i]
        part2 := pref[j] ^ pref[i]
        part3 := xor ^ pref[j]
        if part1 == part2 && part2 == part3 {
          Fprintln(out, "YES")
          return
        }
      }
    }
    Fprintln(out, "NO")
  }
}

package main

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

var in *bufio.Reader

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

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

	total := 0
	for _, ai := range a {
		total ^= ai
	}

	if total == 0 {
		fmt.Println("YES")
		return
	}

	cur := 0
	cnt := 0
	for _, ai := range a {
		cur ^= ai
		if cur == total {
			cnt++
			cur = 0
		}
	}
	if cnt > 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

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

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

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	var ok bool = false
	if a[n-1] == 0 {
		ok = true

	}
	for i := 0; i < n; i++ {
		for j := i + 1; j < n-1; j++ {
			if (a[i] == a[j]^a[i]) && (a[i] == (a[n-1] ^ a[j])) {
				ok = true
			}
		}
	}
	if ok == true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		x := 0
		a := make([]int, n)
		for i := range a {
			Scan(&a[i])
			x ^= a[i]
		}
		if x == 0 {
			Println("YES")
			continue
		}
		c := 0
		for i := 0; i < n; i++ {
			for s := 0; i < n && s^a[i] != x; i++ {
				s ^= a[i]
			}
			c++
		}
		if c > 2 {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		tm := make([]int, 0)
		a := make([]int, n)
		m[0] = true
		max := 0

		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			if ans == 0 {
				for _, v := range tm {
					m[v] = true
				}
				tm = make([]int, 0)
			}
			tm = append(tm, ans)
			if a[j] > max {
				max = a[j]
			}

		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		tmp := v ^ max
		if tmp < max/2 {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	f, _ := os.Open("in.txt")
	in := bufio.NewReader(f)
	//in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		tm := make([]int, 0)
		a := make([]int, n)
		m[0] = true
		max := 0

		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			if ans == 0 {
				for _, v := range tm {
					m[v] = true
				}
				tm = make([]int, 0)
			}
			tm = append(tm, ans)
			if a[j] > max {
				max = a[j]
			}

		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		tmp := v ^ max
		if tmp < max/2 {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		tm := make([]int, 0)
		a := make([]int, n)
		m[0] = true
		max := 0

		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			if ans == 0 {
				for _, v := range tm {
					m[v] = true
				}
				tm = make([]int, 0)
			}
			tm = append(tm, ans)
			if a[j] > max {
				max = a[j]
			}

		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		if v >= max/2 || v == max {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		a := make([]int, n)
		m[0] = true
		max := 0
		la := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			m[la] = true
			if a[j] > max {
				max = a[j]
			}
			la = ans
		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		if v >= max/2 || v == max {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		a := make([]int, n)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			m[ans] = true
			if a[j] > max {
				max = a[j]
			}
		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		if v >= max/2 || v == max {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		a := make([]int, n)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
			ans ^= a[j]
			m[a[j]] = true
			if a[j] > max {
				max = a[j]
			}
		}
		if ok := m[ans]; ok && validate(ans, max, a) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m []int) bool {
	if ans != max {
		return true
	}
	count := 0
	for _, v := range m {
		if v >= max/2 || v == max {
			count++
		}
	}

	if count > 1 {
		return true
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a > max {
				max = a
			}
		}
		if ok := m[ans]; ok && validate(ans, max, m) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m map[int]bool) bool {
	if ans != max {
		return true
	}

	for k, _ := range m {
		if k >= max/2 || k == max {
			return true
		}
	}

	return false
}

package main

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

func main() {
	f, _ := os.Open("in.txt")
	in := bufio.NewReader(f)
	//in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a > max {
				max = a
			}
		}
		if ok := m[ans]; ok && validate(ans, max, m) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m map[int]bool) bool {
	if ans != max {
		return true
	}

	for k, _ := range m {
		if k >= max/2 || k == max {
			return true
		}
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a > max {
				max = a
			}
		}
		if ok := m[ans]; ok && ans != max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func validate(ans, max int, m map[int]bool) bool {
	if ans != max {
		return true
	}

	for k, _ := range m {
		if k > max/2 {
			return true
		}
	}

	return false
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a == max {
				max++
			}
			if a > max {
				max = a
			}
		}
		if ok := m[ans]; ok && ans != max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a > max {
				max = a
			}
			if a == max {
				max++
			}
		}
		if ok := m[ans]; ok && ans != max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	f, _ := os.Open("in.txt")
	in := bufio.NewReader(f)
	//in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		max := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
			if a > max {
				max = a
			}
		}
		if ok := m[ans]; ok && ans != max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		m := make(map[int]bool, 0)
		m[0] = true
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			m[a] = true
		}
		if ok := m[ans]; ok {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		isAllSame := true
		la := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			if j > 0 && a != la {
				isAllSame = false
			}
			la = a
		}
		if ans == 0 || isAllSame {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		isAllSame := true
		la := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
			la = a
			if j > 0 && a != la {
				isAllSame = false
			}
		}
		if ans == 0 || isAllSame {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	//f, _ := os.Open("in.txt")
	//in := bufio.NewReader(f)
	in := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		ans := 0
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			ans ^= a
		}
		if ans == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	var ok bool = false
	if a[n-1] == 0 {
		ok = true

	}
	for i := 0; i < n; i++ {
		for j := i + 1; j < n-1; j++ {
			if (a[i] == a[j]) && (a[i] == (a[n-1] ^ a[j])) {
				ok = true
			}
		}
	}
	if ok == true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	var ok bool = false
	if a[n-1] == 0 {
		ok = true

	}
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if (a[i] == a[j]) && (a[i] == (a[n-1] ^ a[j])) {
				ok = true
			}
		}
	}
	if ok == true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	for i := 1; i < n-1; i++ {
		if a[i-1] == (a[n-1] ^ a[i-1]) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	for i := 1; i < n; i++ {
		if a[i-1] == (a[n-1] ^ a[i-1]) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 1; i < n; i++ {
		a[i] ^= a[i-1]
	}
	for i := 1; i < n; i++ {
		if a[i-1] == (a[n-1] ^ a[i-1]) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		var x, y, c int
		a := make([]int, n)
		for i := range a {
			Scan(&a[i])
			x ^= a[i]
		}
		for _, v := range a {
			if y ^= v; y == x {
				c++
				y = 0
			}
		}
		if c > 1 {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n, x int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		a := make([]int, n)
		for i := range a {
			Scan(&a[i])
			x ^= a[i]
		}
		if x == 0 {
			Println("YES")
			continue
		}
		c := 0
		for i := 0; i < n; i++ {
			for s := 0; i < n && s^a[i] != x; i++ {
				s ^= a[i]
			}
			c++
		}
		if c > 2 {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

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

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

	solve := func(Case int) bool {
		var n, xor int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			xor ^= a[i]
		}
		for i := 1; i < n; i++ {
			if a[i] != a[i-1] {
				goto next
			}
		}
		return true
	next:
		if xor == 0 {
			return true
		}
		c := 0
		for i := 0; i < n; {
			s := a[i]
			for i++; i < n && s^a[i] != xor; i++ {
				s ^= a[i]
			}
			c++
		}
		return c >= 3
	}

	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		Fprintln(out, map[bool]string{true: "YES", false: "NO"}[solve(Case)])
	}

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

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

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)

		curr := 0
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			curr ^= a[i]
		}

		if curr == 0 {
			fmt.Println("YES")
			continue
		}

		prefix := precalc(&a)

		flag := false
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if (*prefix)[i] == (*prefix)[n-1]^(*prefix)[j] && (*prefix)[i] == (*prefix)[j-1]^(*prefix)[i] {
					flag = true
				}
			}
		}

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

func precalc(a *[]int) *[]int {
	prefix := make([]int, len(*a))
	prefix[0] = (*a)[0]
	for i := 1; i < len(*a); i++ {
		prefix[i] = prefix[i-1] ^ (*a)[i]
	}

	return &prefix
}

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)

		curr := 0
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			curr ^= a[i]
		}

		if curr == 0 {
			fmt.Println("YES")
			continue
		}

		left := a[0]
		right := 0
		for i := 1; i < n; i++ {
			right ^= a[i]
		}

		flag := false
		for i := 1; i < n-1; i++ {
			right ^= a[i]
			if left == a[i] && right == a[i] {
				flag = true
				break
			}
			left ^= a[i]
		}

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

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)

		curr := 0
		var a int
		for i := 0; i < n; i++ {
			fmt.Scan(&a)
			curr = curr ^ a
		}

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}
	fmt.Print(buf.String())
}

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, A []int) bool {
	var res int
	for i := 0; i < n; i++ {
		res ^= A[i]
	}

	return res == 0
}

package main

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

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

	solve := func() {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		b := a
		for i := 1; i < n; i++ {
			b[i] = b[i-1] ^ a[i]
		}
		if b[n-1] == 0 {
			fmt.Fprint(out, "YES")
		} else {
			var ok = false
			for i := 0; i < n-2; i++ {
				if b[i] == b[n-1] {
					ok = true
				}
			}
			if ok {
				fmt.Fprint(out, "YES")
			} else {
				fmt.Fprint(out, "NO")
			}

		}

		fmt.Fprintln(out)
	}

	var T int
	fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

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

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

	solve := func() {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		b := a
		for i := 1; i < n; i++ {
			b[i] = b[i-1] ^ a[i]
		}
		if b[n-1] == 0 {
			fmt.Print(out, "YES")
		} else {
			var ok = false
			for i := 0; i < n-2; i++ {
				if b[i] == b[n-1] {
					ok = true
				}
			}
			if ok {
				fmt.Print(out, "YES")
			} else {
				fmt.Print(out, "NO")
			}

		}

		fmt.Fprintln(out)
	}

	var T int
	fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

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

const REPEAT bool = true
const CASE   bool = false

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

  if REPEAT {
    var t int
    Fscan(in, &t);
    for i := 1; i <= t; i++ {
      if CASE {
        Fprintf(out, "Case #%d: ", i)
      }
      solve(in, out)
    }
  } else {
    solve(in, out)
  }
}

func solve(in io.Reader, out io.Writer) {
  var n, e int
  Fscan(in, &n)
  cntr := make(map[int]int)
  for i := 0; i < n; i++ {
    Fscan(in, &e)
    if val, ok := cntr[e]; !ok {
      cntr[e] = 1
    } else {
      cntr[e] = val + 1
    }
  }
  for num := range cntr {
    cntr[num] -= 1
    val := mapXOR(cntr)
    if val == num {
      Fprintln(out, "YES")
      return
    }
    if cntr[num] > 0 {
      cntr[num] -= 1
      val := mapXOR(cntr)
      if val == num {
        Fprintln(out, "YES")
        return
      }
      cntr[num] += 1
    }
    cntr[num] += 1
  }
  Fprintln(out, "NO")
}

func mapXOR(cnts map[int]int) int {
  ans := 0
  for num := range cnts {
    cnt := cnts[num]
    if cnt % 2 != 0 {
      ans ^= num
    }
  }
  return ans
}


package main

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

const MAX_N = 1001

type State struct {
	y    int
	x    int
	dir  int
	turn int
}

var visited [3][MAX_N][MAX_N]bool

func main() {
	fsc := NewFastScanner()
	N, M := fsc.NextInt(), fsc.NextInt()
	board := make([]string, 0)
	for i := 0; i < N; i++ {
		board = append(board, fsc.Next())
	}
	sy, sx := -1, -1
	gy, gx := -1, -1
	DX := []int{1, 0, -1, 0}
	DY := []int{0, -1, 0, 1}
	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			if board[i][j] == 'S' {
				sy = i
				sx = j
			}
			if board[i][j] == 'T' {
				gy = i
				gx = j
			}
		}
	}
	que := list.New()
	que.PushBack(State{sy, sx, -1, 0})

	for que.Len() > 0 {
		pos := que.Front()
		val := pos.Value.(State)
		py := val.y
		px := val.x
		turn := val.turn
		pDir := val.dir
		que.Remove(pos)
		if py == gy && px == gx {
			fmt.Println("YES")
			return
		}
		if visited[turn][py][px] {
			continue
		}
		visited[turn][py][px] = true
		//nexpt
		// const dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

		for dir := 0; dir < 4; dir++ {
			ny := py + DY[dir]
			nx := px + DX[dir]
			nTurn := turn
			if pDir != -1 && pDir != dir {
				nTurn++
			}
			if nTurn > 2 {
				continue
			}
			if ny < 0 || ny >= N || nx < 0 || nx >= M {
				continue
			}
			if board[ny][nx] == '*' {
				continue
			}
			que.PushBack(State{ny, nx, dir, nTurn})
		}
	}
	fmt.Println("NO")
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

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

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

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

package main

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

type node struct {
	r, c, dir int
}

var (
	dr = [4]int{-1, 0, 1, 0}
	dc = [4]int{0, -1, 0, 1}
)

var dist [1000][1000][4]int
var used [1000][1000][4]bool

func getDist(v node) (int, bool) {
	return dist[v.r][v.c][v.dir], used[v.r][v.c][v.dir]
}

func setDist(v node, d int) {
	dist[v.r][v.c][v.dir] = d
	used[v.r][v.c][v.dir] = true
}

func solve(s [][]byte) bool {
	n := len(s)
	m := len(s[0])
	var q []node
findS:
	for i := range s {
		for j := range s[i] {
			if s[i][j] == 'S' {
				for dir := 0; dir < 4; dir++ {
					v := node{i, j, dir}
					q = append(q, v)
					setDist(v, 0)
				}
				break findS
			}
		}
	}

	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		if s[v.r][v.c] == 'T' {
			return true
		}

		consider := func(u node, d int) {
			if u.r >= 0 && u.r < n && u.c >= 0 && u.c < m && s[u.r][u.c] != '*' {
				if _, ok := getDist(u); !ok {
					setDist(u, d)
					q = append(q, u)
				}
			}
		}

		d, _ := getDist(v)
		consider(node{
			r:   v.r + dr[v.dir],
			c:   v.c + dc[v.dir],
			dir: v.dir,
		}, d)
		if d == 2 {
			continue
		}
		for _, dir := range []int{(v.dir + 1) % 4, (v.dir - 1 + 4) % 4} {
			consider(node{
				r:   v.r,
				c:   v.c,
				dir: dir,
			}, d+1)
		}
	}
	return false
}

func main() {
	in := bufio.NewReaderSize(os.Stdin, 2<<16)
	var n, m int
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	s := make([][]byte, n)
	for i := range s {
		fmt.Fscanf(in, "%s\n", &s[i])
	}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][][5][5]bool

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][][5][5]bool, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([][5][5]bool, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
		}
	}
	if dfs(ii, jj, 0, 0) < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) int {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || in[i][j] == '*' || q > 2 || visited[i][j][q][dir] {
		return 1e9
	}
	visited[i][j][q][dir] = true
	if i == iii && j == jjj {
		return q
	}
	ans := int(1e9)
	var a, b int
	switch dir {
	case 1:
		a++
	case 2:
		b++
	}
	min(dfs(i+1, j, q+b, 1), &ans)
	min(dfs(i, j+1, q+a, 2), &ans)
	min(dfs(i-1, j, q+b, 1), &ans)
	min(dfs(i, j-1, q+a, 2), &ans)
	return ans
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][][5][5]bool
var dp [][]int

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][][5][5]bool, n)
	dp = make([][]int, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([][5][5]bool, m)
		dp[i] = make([]int, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
			dp[i][j] = 1e9 * 2
		}
	}
	dfs(ii, jj, 0, 0)
	if dp[iii][jjj] < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || q > 2 || in[i][j] == '*' {
		return
	}
	min(q, &dp[i][j])
	if visited[i][j][dir][q] {
		return
	}
	visited[i][j][dir][q] = true
	var a, b int
	switch dir {
	case 1:
		a++
	case 2:
		b++
	}
	dfs(i+1, j, q+b, 1)
	dfs(i, j+1, q+a, 2)
	dfs(i-1, j, q+b, 1)
	dfs(i, j-1, q+a, 2)
}

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

package main

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

func solve() {
	n := readInt()
	m := readInt()
	mm := make([][]int, n)
	startX := 0
	startY := 0
	for i := 0; i < n; i++ {
		mm[i] = make([]int, m)
		for k, v := range readString() {
			switch v {
			case 'S':
				mm[i][k] = 3
				startY = i
				startX = k
			case 'T':
				mm[i][k] = 2
			case '*':
				mm[i][k] = 1
			}
		}
	}
	yx := [][]int{
		{1, 0},
		{-1, 0},
		{0, 1},
		{0, -1},
	}
	for _, v := range yx {

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

		q := make([][5]int, 0)
		q = append(q, [5]int{startY, startX, 0, v[0], v[1]})
		vis[startY][startX] = 0
		for len(q) > 0 {
			cur := q[0]
			q = q[1:]
			for _, curdir := range yx {
				cnt := cur[2]
				if curdir[0] != cur[3] || curdir[1] != cur[4] {
					cnt++
					if cnt > 2 {
						continue
					}
				}
				ny := cur[0] + curdir[0]
				nx := cur[1] + curdir[1]
				if ny >= 0 && ny < n && nx >= 0 && nx < m &&
					mm[ny][nx] != 1 && vis[ny][nx] > cnt {
					if mm[ny][nx] == 2 {
						fmt.Println("YES")
						return
					}
					q = append(q, [5]int{ny, nx, cnt, curdir[0], curdir[1]})
					vis[ny][nx] = cnt
				}
			}
		}
	}
	fmt.Println("NO")
}

var scanner *bufio.Scanner

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

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

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

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func readBytes() []byte {
	if !in.Scan() {
		panic(in.Err())
	}
	return in.Bytes()
}

func solve(s [][]byte) bool {
	n := len(s)
	m := len(s[0])
	var q [][2]int
findS:
	for i := range s {
		for j := range s[i] {
			if s[i][j] == 'S' {
				q = append(q, [2]int{i, j})
				s[i][j] = 0
				break findS
			}
		}
	}
	for len(q) > 0 {
		p := q[0]
		q = q[1:]
		next := s[p[0]][p[1]] + 1
		check := func(i, j int) int {
			switch s[i][j] {
			case 'T':
				return 1 // return true
			case '*':
				return -1 // break
			case '.':
				if next < 3 {
					s[i][j] = next
					q = append(q, [2]int{i, j})
				}
			}
			return 0
		}
		for i := p[0] - 1; i >= 0; i-- {
			if c := check(i, p[1]); c == -1 {
				break
			} else if c == 1 {
				return true
			}
		}
		for i := p[0] + 1; i < n; i++ {
			if c := check(i, p[1]); c == -1 {
				break
			} else if c == 1 {
				return true
			}
		}
		for i := p[1] - 1; i >= 0; i-- {
			if c := check(p[0], i); c == -1 {
				break
			} else if c == 1 {
				return true
			}
		}
		for i := p[1] + 1; i < m; i++ {
			if c := check(p[0], i); c == -1 {
				break
			} else if c == 1 {
				return true
			}
		}
	}
	return false
}

func main() {
	in.Split(bufio.ScanWords)
	s := make([][]byte, readInt())
	readInt()
	for i := range s {
		s[i] = readBytes()
	}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][][5][5]bool

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][][5][5]bool, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([][5][5]bool, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
		}
	}
	if dfs(ii, jj, 0, 0) < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) int {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || in[i][j] == '*' || q > 2 || visited[i][j][q][dir] {
		return 1e9
	}
	visited[i][j][q][dir] = true
	if i == iii && j == jjj {
		return q
	}
	ans := int(1e9)
	var a, b int
	switch dir % 2 {
	case 1:
		a++
	case 0:
		b++
	}
	min(dfs(i+1, j, q+b, 1), &ans)
	min(dfs(i, j+1, q+a, 2), &ans)
	min(dfs(i-1, j, q+b, 3), &ans)
	min(dfs(i, j-1, q+a, 4), &ans)
	return ans
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][]bool
var dp [][]int

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][]bool, n)
	dp = make([][]int, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([]bool, m)
		dp[i] = make([]int, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
			dp[i][j] = 1e9 * 2
		}
	}
	dfs(ii, jj, 0, 0)
	if dp[iii][jjj] < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || in[i][j] == '*' {
		return
	}
	min(q, &dp[i][j])
	if visited[i][j] {
		return
	}
	visited[i][j] = true
	var a, b int
	switch dir {
	case 1:
		a++
	case 2:
		b++
	}
	dfs(i, j-1, q+a, 2)
	dfs(i+1, j, q+b, 1)
	dfs(i, j+1, q+a, 2)
	dfs(i-1, j, q+b, 1)
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][]bool
var dp [][]int

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][]bool, n)
	dp = make([][]int, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([]bool, m)
		dp[i] = make([]int, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
			dp[i][j] = 1e9 * 2
		}
	}
	dfs(ii, jj, 0, 0)
	if dp[iii][jjj] < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || in[i][j] == '*' {
		return
	}
	min(q, &dp[i][j])
	if visited[i][j] {
		return
	}
	visited[i][j] = true
	var a, b int
	switch dir {
	case 1:
		a++
	case 2:
		b++
	}
	dfs(i, j-1, q+a, 2)
	dfs(i+1, j, q+b, 1)
	dfs(i, j+1, q+a, 2)
	dfs(i-1, j, q+b, 1)
	visited[i][j] = true
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

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

var n, m int

func main() {
	defer w.Flush()
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

var in []string
var ii, iii, jj, jjj int
var visited [][]bool

func solve(n, m int) {
	in = make([]string, n)
	visited = make([][]bool, n)
	for i := range in {
		I(&in[i])
		visited[i] = make([]bool, m)
		for j, ch := range in[i] {
			if ch == 'S' {
				ii = i
				jj = j
			} else if ch == 'T' {
				iii = i
				jjj = j
			}
		}
	}
	if dfs(ii, jj, 0, 0) < 3 {
		O("YES\n")
	} else {
		O("NO\n")
	}
}

func dfs(i, j, q, dir int) int {
	if i < 0 || j < 0 || i > n-1 || j > m-1 || in[i][j] == '*' || q > 2 || visited[i][j] {
		return 1e9
	}
	visited[i][j] = true
	if i == iii && j == jjj {
		return q
	}
	ans := int(1e9)
	var a, b int
	switch dir {
	case 1:
		a++
	case 2:
		b++
	}
	min(dfs(i+1, j, q+b, 1), &ans)
	min(dfs(i, j+1, q+a, 2), &ans)
	min(dfs(i-1, j, q+b, 1), &ans)
	min(dfs(i, j-1, q+a, 2), &ans)
	return ans
}

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

package main

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

func solve() {
	n := readInt()
	m := readInt()
	mm := make([][]int, n)
	startX := 0
	startY := 0
	for i := 0; i < n; i++ {
		mm[i] = make([]int, m)
		for k, v := range readString() {
			switch v {
			case 'S':
				mm[i][k] = 3
				startX = k
				startY = i
			case 'T':
				mm[i][k] = 2
			case '*':
				mm[i][k] = 1
			}
		}
	}
	yx := [][]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}
	for _, v := range yx {

		vis := make([][]bool, n)
		for i := 0; i < n; i++ {
			vis[i] = make([]bool, m)
		}

		q := make([][5]int, 0)
		q = append(q, [5]int{startY, startX, 0, v[0], v[1]})
		vis[startY][startX] = true
		for len(q) > 0 {
			cur := q[0]
			q = q[1:]
			for _, curdir := range yx {
				cnt := cur[2]
				ny := cur[0] + curdir[0]
				nx := cur[1] + curdir[1]
				if curdir[0] != cur[3] || curdir[1] != cur[4] {
					cnt++
				}
				if cnt <= 2 && ny >= 0 && ny < n && nx >= 0 && nx < m &&
					mm[ny][nx] != 1 && !vis[ny][nx] {
					if mm[ny][nx] == 2 {
						fmt.Println("YES")
						return
					}
					q = append(q, [5]int{ny, nx, cnt, curdir[0], curdir[1]})
					vis[ny][nx] = true
				}
			}
		}
	}
	fmt.Println("NO")
}

var scanner *bufio.Scanner

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

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

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

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


package main

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

func solve() {
	readInt()
	path := readString()
	prevdir := map[rune]bool{}
	opdir := map[rune]rune{'R': 'L', 'L': 'R', 'D': 'U', 'U': 'D'}
	res := 1
	for _, v := range path {
		if _, ok := prevdir[opdir[v]]; ok {
			res++
			for k, _ := range prevdir {
				delete(prevdir, k)
			}
		}
		prevdir[v] = true
	}
	fmt.Println(res)
}

var scanner *bufio.Scanner

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

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

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

package main

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

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

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

	var n int
	fmt.Fscanf(bufin, "%d\n", &n)
	var s string
	fmt.Fscanf(bufin, "%s\n", &s)
	res := 1
	hor := byte('*')
	ver := byte('*')
	for i := 0; i < n; i++ {
		dir := byte(s[i])
		// fmt.Fprintf(bufout, "dir = %c, ver = %c, hor = %c\n", dir, ver, hor)
		if (dir == 'U') || (dir == 'D') {
			if (ver != '*') && (ver != dir) {
				hor = byte('*')
				ver = byte('*')
				res++
			}
			ver = dir
		} else {
			if (hor != '*') && (hor != dir) {
				hor = byte('*')
				ver = byte('*')
				res++
			}
			hor = dir
		}
	}
	fmt.Fprintf(bufout, "%d\n", res)
}

package main

import "fmt"

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

	var s string
	fmt.Scanln(&s)

	var x, y = 0, 0
	var ans = 1

	for _, c := range s {
		switch c {
		case 'L':
			if abs(x-1) > abs(x) {
				x--
			} else {
				x, y, ans = -1, 0, ans+1
			}
		case 'R':
			if abs(x+1) > abs(x) {
				x++
			} else {
				x, y, ans = 1, 0, ans+1
			}
		case 'U':
			if abs(y+1) > abs(y) {
				y++
			} else {
				x, y, ans = 0, 1, ans+1
			}
		case 'D':
			if abs(y-1) > abs(y) {
				y--
			} else {
				x, y, ans = 0, -1, ans+1
			}
		}

		// fmt.Println(string(c), ans, x, y)
	}

	fmt.Println(ans)
}

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

package main

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

func solve() {
	readInt()
	path := readString()
	prevdir := map[rune]bool{}
	opdir := map[rune]rune{'R': 'L', 'L': 'R', 'D': 'U', 'U': 'D'}
	res := 1
	for _, v := range path {
		if _, ok := prevdir[opdir[v]]; ok {
			res++
			prevdir = map[rune]bool{}
		}
		prevdir[v] = true
	}
	fmt.Println(res)
}

var scanner *bufio.Scanner

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

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

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

package main

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

func solve() {
	readInt()
	path := readString()
	prevdir := 0
	res := 1
	for _, v := range path {
		value := 0
		switch v {
		case 'R':
			value = 1
		case 'L':
			value = 2
		case 'U':
			value = 4
		case 'D':
			value = 8
		}
		prevdir |= value
		if ((prevdir&1) != 0 && (prevdir&2) != 0) ||
			((prevdir&4) != 0 && (prevdir&8) != 0) {
			res++
			prevdir = 0
		}
		prevdir |= value
	}
	fmt.Println(res)
}

var scanner *bufio.Scanner

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

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

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


package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

var expect, prob [2002][2002]float64

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	row := make([]bool, n+1)
	col := make([]bool, n+1)
	var rowCount, colCount int
	for i := 0; i < m; i++ {
		var r, c int
		fmt.Fscanf(reader, "%d %d\n", &r, &c)
		if !row[r] {
			rowCount++
			row[r] = true
		}
		if !col[c] {
			colCount++
			col[c] = true
		}
	}
	prob[rowCount][colCount] = 1.0
	for i := rowCount; i <= n; i++ {
		for j := colCount; j <= n; j++ {
			p := float64(i*j) / float64(n*n)
			pCol := float64((n-j)*i) / float64(n*n)
			pRow := float64((n-i)*j) / float64(n*n)
			pRowCol := float64((n-j)*(n-i)) / float64(n*n)

			expect[i][j+1] += (expect[i][j]*pCol/(1-p) + pCol/(1-p)/(1-p)*prob[i][j])
			expect[i+1][j] += (expect[i][j]*pRow/(1-p) + pRow/(1-p)/(1-p)*prob[i][j])
			expect[i+1][j+1] += (expect[i][j]*pRowCol/(1-p) + pRowCol/(1-p)/(1-p)*prob[i][j])

			prob[i][j+1] += pCol / (1 - p) * prob[i][j]
			prob[i+1][j] += pRow / (1 - p) * prob[i][j]
			prob[i+1][j+1] += pRowCol / (1 - p) * prob[i][j]
		}
	}
	fmt.Printf("%f", expect[n][n])
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	n, m   int
	br, bc int
	f      [][]float64
)

func foo(x, y int) (ret float64) {
	if f[x][y] > -1.0 {
		return f[x][y]
	}

	defer func() {
		f[x][y] = ret
	}()

	if x == 0 {
		for i := y; i >= 1; i-- {
			ret += float64(n) / float64(i)
		}
		return
	}

	if y == 0 {
		for i := x; i >= 1; i-- {
			ret += float64(n) / float64(i)
		}
		return
	}

	nn := float64(n * n)

	p1 := (float64(x*y) / nn)
	e1 := foo(x-1, y-1) * p1

	p2 := float64((n-y)*x) / nn
	e2 := foo(x-1, y) * p2

	p3 := float64((n-x)*y) / nn
	e3 := foo(x, y-1) * p3

	ret = (e1 + e2 + e3 + 1) / (p1 + p2 + p3)
	return
}

func main() {
	fmt.Fscan(reader, &n, &m)

	f = make([][]float64, n+1)
	for i := 0; i < len(f); i++ {
		f[i] = make([]float64, n+1)
		for j := 0; j < len(f[i]); j++ {
			f[i][j] = -10.0
		}
	}

	rmap := map[int]bool{}
	cmap := map[int]bool{}

	for i := 0; i < m; i++ {
		var r, c int
		fmt.Fscan(reader, &r, &c)
		rmap[r] = true
		cmap[c] = true
	}

	ans := foo(n-len(rmap), n-len(cmap))
	fmt.Printf("%.10f\n", ans)
}