"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    if (xor == 0) {
        io.writeLine('YES');
        return;
    }
    let xor2 = 0;
    let count = 0;
    for (let i = 0; i < n; i++) {
        xor2 ^= arr[i];
        if (xor == xor2) {
            xor2 = 0;
            count++;
        }
    }
    io.writeLine(count > 2 ? 'YES' : 'NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var res = a[0]
    var met = false
    for (let j = 1; j < n ; j++) {
      res = res ^ a[j]
    }

    if (res === 0) return console.log('YES')
    var count = 0

    var aa = 0
    for (let j = 0; j < n; j++) {
      aa = a[j] ^aa
      if(aa === res) {
        count++
        aa = 0
      }
    }
    if (count>=3) return console.log('YES')
    console.log('NO')
  })
}

'use strict';

function solve(n, a) {
  const sum = a.reduce((a, b) => a ^ b, 0);
  if (sum === 0) return 'YES';
  let count = 0,
      cur = 0;
  for (let i = 0; i < n; i++) {
    cur ^= a[i];
    if (cur === sum) {
      cur = 0;
      count++;
    }
  }
  if (count >= 2) return 'YES';
  return 'NO';
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();

		let ans, req = 0;
		for (let i = 0; i < n-1; i++) {
			req ^= a[i];
			let cur = 0, found;
			for (j = i + 1; j < n; j++) {
				cur ^= a[j];
				if (cur == req) {
					found = true;
					cur = 0;
				}
			}
			ans = ans || found && cur == 0;
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    var b = 1;
    for (var a = 0; a < t; a++) {
        var n = Number(input[b]);
        b++;
        var arr = input[b].split(" ").map((i) => {
            return Number(i);
        })
        b++;
        var total = 0;
        for (var i = 0; i < arr.length; i++) {
            total = total ^ arr[i];
        }
        if (total === 0) {
            console.log("YES")
            continue;
        }
        var sum = 0;
        var count = 0;
        for (var i = 0; i < arr.length; i++) {
            sum = sum ^ arr[i];
            if (sum === total) {
                count++;
                sum = 0;
            }
        }
        if (sum === 0 && count >= 3) {
            console.log("YES");
        } else {
            console.log("NO");
        }
    }
});

var T = parseInt(readline());

for (t = 0; t < T; t++) {
	var n = parseInt(readline());
	var a = readline().split(" ").map(x => parseInt(x));

	var ok = false;
	for (i = 0; i < n - 1; i++) {
		var re = 0;
		for (j = 0; j <= i; j++) {
			re ^= a[j];
		}
		var cur = 0;
		var once = false;
		for (j = i + 1; j < n; j++) {
			if (cur == re) { cur = 0; once = true; }
			cur ^= a[j];
		}
		if (cur == re || (once && cur == 0)) {
			ok = true;
			break;
		}
	}
	if (ok) {
		print("YES");
	} else {
		print("NO");
	}
}
/*var a = readline().split(" ").map(x => parseInt(x));

var mii = 0, mai = 0;
for (var i = 0; i < n; i++) {
	if (a[i] <= a[mii]) mii = i;
	if (a[i] > a[mai]) mai = i;
}

var ans = mai + n - mii - 1;
if (mai > mii) ans -= 1;
print(ans);*/

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    arr = arr.filter((x) => x);
    while (arr.length < 2) {
        arr.push(0);
    }
    n = arr.length;
    // console.log(arr);
    if (n === 2) {
        io.writeLine(arr[0] === arr[1] ? 'YES' : 'NO');
        return;
    }
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    // console.log({ xor, arr });
    if (xor == 0) {
        io.writeLine('YES');
        return;
    }
    let xor2 = 0;
    for (let i = 0; i < n - 1; i++) {
        xor ^= arr[i];
        if (xor == xor2) {
            io.writeLine('YES');
            return;
        }
    }
    io.writeLine('NO');
    return;
    // console.log({ arr, xor });
    // if (arr.length % 2 === 0) {
    //   io.writeLine(xor == 0 ? 'YES' : 'NO');
    //   return;
    // }
    // xor = 0;
    // for (let i = 1; i < n; i++) {
    //   xor ^= arr[i];
    // }
    // io.writeLine(xor == arr[0] ? 'YES' : 'NO');
    // return;
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== xor) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    //console.log(arr);
    io.writeLine(arr.length > 1 && arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    if (n === 2) {
        io.writeLine(arr[0] === arr[1] ? 'YES' : 'NO');
        return;
    }
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    // console.log({ xor, arr });
    if (xor == 0) {
        io.writeLine('YES');
        return;
    }
    let xor2 = 0;
    for (let i = 0; i < n - 1; i++) {
        xor ^= arr[i];
        if (xor == xor2) {
            io.writeLine('YES');
            return;
        }
    }
    io.writeLine('NO');
    return;
    // console.log({ arr, xor });
    // if (arr.length % 2 === 0) {
    //   io.writeLine(xor == 0 ? 'YES' : 'NO');
    //   return;
    // }
    // xor = 0;
    // for (let i = 1; i < n; i++) {
    //   xor ^= arr[i];
    // }
    // io.writeLine(xor == arr[0] ? 'YES' : 'NO');
    // return;
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== xor) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    //console.log(arr);
    io.writeLine(arr.length > 1 && arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    if (xor == 0) {
        io.writeLine('YES');
        return;
    }
    let xor2 = 0;
    for (let i = 0; i < n - 1; i++) {
        xor ^= arr[i];
        if (xor == xor2) {
            io.writeLine('YES');
            return;
        }
    }
    io.writeLine('NO');
    return;
    // console.log({ arr, xor });
    // if (arr.length % 2 === 0) {
    //   io.writeLine(xor == 0 ? 'YES' : 'NO');
    //   return;
    // }
    // xor = 0;
    // for (let i = 1; i < n; i++) {
    //   xor ^= arr[i];
    // }
    // io.writeLine(xor == arr[0] ? 'YES' : 'NO');
    // return;
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== xor) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    //console.log(arr);
    io.writeLine(arr.length > 1 && arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== xor) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    //console.log(arr);
    io.writeLine(arr.length > 1 && arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let xor = 0;
    for (let i = 0; i < n; i++) {
        xor ^= arr[i];
    }
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== xor) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    console.log(arr);
    io.writeLine(arr.length > 1 && arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let b = [];
    // if (arr.every((a) => a === arr[0])) {
    //   io.writeLine('YES');
    //   return;
    // }
    // let ret = 0;
    for (let i = 0; i < arr.length - 1;) {
        if (arr[i] !== arr[i + 1]) {
            arr[i] = arr[i] ^ arr[i + 1];
            arr.splice(i + 1, 1);
        }
        else {
            i++;
        }
        // ret ^= arr[i];
    }
    io.writeLine(arr.every((a) => a === arr[0]) ? 'YES' : 'NO');
    // io.writeLine(ret === arr[n - 1] ? 'YES' : 'NO');
    // for (let a of arr) {
    //   ret ^= a;
    // }
    // console.log({ ret });
    // if (ret === 0) {
    //   io.writeLine('YES');
    //   return;
    // }
    // if (arr.some((a) => a === ret)) {
    //   io.writeLine('YES');
    //   return;
    // }
    // io.writeLine('NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    if (arr.every((a) => a === arr[0])) {
        io.writeLine('YES');
        return;
    }
    let ret = 0;
    for (let a of arr) {
        ret ^= a;
    }
    io.writeLine(ret == 0 ? 'YES' : 'NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n, arr) {
    let ret = 0;
    for (let a of arr) {
        ret ^= a;
    }
    io.writeLine(ret == 0 ? 'YES' : 'NO');
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            let arr = io.nextNumArray(n);
            solve(n, arr);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var res = a[0]
    var met = false
    for (let j = 1; j < n ; j++) {
      res = res ^ a[j]
    }

    if (res === 0) return console.log('YES')
    var count = 0

    var aa = 0
    for (let j = 0; j < n; j++) {
      aa = a[j] ^aa
      if(aa === res) count++
    }
    if (count>=3) return console.log('YES')
    console.log('NO')
  })
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var res = a[0]
    var met = false
    for (let j = 1; j < n - 1; j++) {
      res = res ^ a[j]
      if (res === a[n - 1]) met = true
    }
    if (res === a[n - 1] || res === 0 && met) return console.log('YES')
    console.log('NO')
  })
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var res = a[0]
    for (let j = 1; j < n; j++) {
      res = res ^ a[j]
    }
    var count = 0
    if (res === 0) return console.log('YES')
    for (let j = 0; j < n; j++) {
      if (a[j] === res) count++
    }
    if (count >= 1 && n %2===1) return console.log('YES')
    return console.log('NO')

  })
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var res = a[0]
    for (let j = 1; j < n; j++) {
      res = res ^ a[j]
    }
    if (res === 0) return console.log('YES')
    return console.log('NO')

  })
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    for (let j = 0; j < n; j++) {
      var res
      res = j === 0 ? a[1] : a[0]
      for (let i = 0; i < n; i++) {
        if (i !== j) res = res ^ a[i]
      }
      if(res === a[j]) return console.log('YES')
    }
    return console.log('NO')

    console.log(a.join(' '))

  })
}

'use strict';

function solve(n, a) {
  const sum = a.reduce((a, b) => a ^ b, 0);
  if (sum === 0) return 'YES';
  const s = new Array(n);
  for (let i = 0; i < n; i++) {
    var _s;
    s[i] = ((_s = s[i - 1]) !== null && _s !== void 0 ? _s : 0) ^ a[i];
  }
  for (let i = 1; i < n - 1; i++) {
    for (let j = i; j < n - 1; j++) {
      var _s2;
      if (sum === (s[j] ^ ((_s2 = s[i - 1]) !== null && _s2 !== void 0 ? _s2 : 0))) return 'YES';
    }
  }
  return 'NO';
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

function solve(n, a) {
  const sum = a.reduce((a, b) => a ^ b, 0);
  if (sum === 0) return 'YES';
  const s = new Array(n);
  for (let i = 0; i < n; i++) {
    var _s;
    s[i] = ((_s = s[i - 1]) !== null && _s !== void 0 ? _s : 0) ^ a[i];
  }
  for (let i = 0; i < n; i++) {
    const N = i === 0 ? n - 1 : n;
    for (let j = i + 1; j < N; j++) {
      var _s2;
      if (sum === (s[j] ^ ((_s2 = s[i - 1]) !== null && _s2 !== void 0 ? _s2 : 0))) return 'YES';
    }
  }
  return 'NO';
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();

		let ans, req = 0;
		for (let i = 0; i < n-1; i++) {
			req ^= a[i];
			let cur = 0;
			for (j = i + 1; j < n; j++) {
				if (cur == req) cur = 0;
				cur ^= a[j];
			}
			ans = ans || req == cur;
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

var T = parseInt(readline());

for (t = 0; t < T; t++) {
	var n = parseInt(readline());
	var a = readline().split(" ").map(x => parseInt(x));

	var ok = false;
	for (i = 0; i < n - 1; i++) {
		var re = 0;
		for (j = 0; j <= i; j++) {
			re ^= a[j];
		}
		var cur = 0;
		for (j = i + 1; j < n; j++) {
			if (cur == re) cur = 0;
			cur ^= a[j];
		}
		if (cur == re) {
			ok = true;
			break;
		}
	}
	if (ok) {
		print("YES");
	} else {
		print("NO");
	}
}
/*var a = readline().split(" ").map(x => parseInt(x));

var mii = 0, mai = 0;
for (var i = 0; i < n; i++) {
	if (a[i] <= a[mii]) mii = i;
	if (a[i] > a[mai]) mai = i;
}

var ans = mai + n - mii - 1;
if (mai > mii) ans -= 1;
print(ans);*/

var T = parseInt(readline());

for (t = 0; t < T; t++) {
	var n = parseInt(readline());
	var a = readline().split(" ").map(x => parseInt(x));

	var ok = false;
	for (i = 0; i < n - 1; i++) {
		var re = 0;
		for (j = 0; j <= i; j++) {
			re ^= a[j];
		}
		var cur = 0;
		for (j = i + 1; j < n; j++) {
			cur ^= a[j];
			if (cur == re) cur = 0;
		}
		if (cur == 0) {
			ok = true;
			break;
		}
	}
	if (ok) {
		print("YES");
	} else {
		print("NO");
	}
}
/*var a = readline().split(" ").map(x => parseInt(x));

var mii = 0, mai = 0;
for (var i = 0; i < n; i++) {
	if (a[i] <= a[mii]) mii = i;
	if (a[i] > a[mai]) mai = i;
}

var ans = mai + n - mii - 1;
if (mai > mii) ans -= 1;
print(ans);*/


function sa(n, s){
        var dp = [];
        dp[0] = 0;
        var lastL = 0;
        var lastR = 0;
        var lastU = 0;
        var lastD = 0;
        for(var i=1;i<=n;i++){
            if(s[i-1] == "R"){
                lastR = i;
            } else if(s[i-1] == "L"){
                lastL = i;
            } else if(s[i-1] == "U"){
                lastU = i;
            } else if(s[i-1] == "D"){
                lastD = i;
            }
            var first = Math.min(lastL, lastR);
            var second = Math.min(lastU, lastD);
            dp[i] = dp[Math.max(first, second)] + 1;

        }
        return dp[n];
    }

    var n = Number(readline());
    var s = readline();
    print(sa(n, s));

var num = readline();
var data = readline().split("");

a(num,data);

function a(num, data){
     var cnt = 1;
     var r = false; var l = false; var d = false; var u = false;
     for(i = 0; i<num; i++){
          switch(data[i]){
               case "R":
                    if(l){ var r = true; var l = false; var d = false; var u = false; cnt++; }else{ r = true; }
               break;
               case "L":
                    if(r){ var r = false; var l = true; var d = false; var u = false; cnt++; }else{ l = true; }
               break;
               case "U":
                    if(d){ var r = false; var l = false; var d = false; var u = true; cnt++; }else{ u = true; }
               break;
               case "D":
                    if(u){ var r = false; var l = false; var d = true; var u = false; cnt++; }else{ d = true; }
               break;
          }
     }
     print(cnt);
}