'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++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------

function main() {
    let t = getInt(readline());
    while (t--) {
        let [_, m] = getArray(readline());
        let arr = getArray(readline());
        for(let i=0; i< arr.length; i++) {
            m = m-arr[i];
        }
        console.log(m===0?'YES': 'NO');
    }
}

const solve = (n, m, a) => {
    let sum = 0;
    for (const item of a) {
        sum += item;
    }
    return sum == m ? 'YES' : 'NO';
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = Number(input[0][0]);
        let i = 1;
        while (t > 0) {
            let data = input.slice(i, i + 2);
            let n = data[0][0];
            let m = data[0][1];
            let a = data[1]
            console.log(solve(n, m, a));
            t--;
            i += 2;
        }
    });
};

main()

const solve = (n, m, a) => {
    let sum = 0;
    for (let i = 0; i < n; i++) {
        for (const item of a) {
            sum += item;
        }
        return sum == m ? 'YES' : 'NO';
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = Number(input[0][0]);
        let i = 1;
        while (t > 0) {
            let data = input.slice(i, i + 2);
            let n = data[0][0];
            let m = data[0][1];
            let a = data[1]
            console.log(solve(n, m, a));
            t--;
            i += 2;
        }
    });
};

main()

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  let t = +readLine();
  while (t--) {
    const [len, target] = readLine().split(" ").map(Number);
    let sum = 0;
    const arr = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        sum += n;
        return n;
      });
    if (sum === target) console.log("YES");
    else console.log("NO");
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var one = nextIntArray();
		var N = one[0];
		var M = one[1];
		var list = nextIntArray();
		var sum = 0;
		for(var j = 0; j < N; j++){
			sum += list[j];
		}
		output[i] = (sum == M) ? "YES" : "NO";
	}
	myout(myconv(output, 9));
}

// Alternative
// https://www.npmjs.com/package/competitive-programming-js
"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 input() {
    return inputString[currentLine++];
}
const print = x => console.log(x);
// Main starts here

function main() {
    let t = parseInt(input());
    // print("t " + t);
    while (t--) {
        let [n, m] = input().split(' ').map(v => parseInt(v));
        let ar = input().split(' ').map(v => parseInt(v));
        const sum = ar.reduce((val, sum) => val + sum);
        if (sum === m) print("YES");
        else print("NO");
    }
}

// Alternative
// https://www.npmjs.com/package/competitive-programming-js
"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 input() {
    return inputString[currentLine++];
}
const println = x => console.log(x);
const print = x => process.stdout.write(x);
// >>>>>>>>>>>>> Main starts here <<<<<<<<<<<<<<

function main() {
    let t = parseInt(input());
    // print("t " + t);
    while (t--) {
        let [n, m] = input().split(' ').map(v => parseInt(v));
        let ar = input().split(' ').map(v => parseInt(v));
        const sum = ar.reduce((val, sum) => val + sum);
        if (sum === m) print("YES");
        else print("NO");
        print("\n");
    }
}

#!/usr/bin/env node
'use strict';

const { createInterface } = require('readline');
const rl = createInterface({
  input: process.stdin,
  crlfDelay: Infinity
});

const buf = [];
const prom = [];
let maxBuf = 0;
let maxProm = 0;
rl.on('line', (line) => {
  if (prom.length > 0) {
    maxProm = Math.max(maxProm, prom.length);
    const [resolve, reject] = prom.shift();
    resolve(line);
  } else {
    rl.pause();
    buf.push(line);
    maxBuf = Math.max(maxBuf, buf.length);
  }
});

rl.on('close', () => {
  // console.error({maxProm, maxBuf});
});

async function getLine() {
  return new Promise((resolve, reject) => {
    if (buf.length > 0) {
      const line = buf.shift();
      resolve(line);
    } else {
      prom.push([resolve, reject]);
      rl.resume();
    }
  });
}

/**
 *
 * @param {Number []} a
 * @param {Number} m
 * @returns {String}
 */
function solve(a, m) {
  const sum = a.reduce((a, b) => a + b, 0);
  return (sum === m) ? 'YES' : 'NO';
}

async function main() {
  const t = Number(await getLine());
  for (let i = 0; i < t; i++) {
    const [n, m] = (await getLine()).split(' ').map(Number);
    const a = (await getLine()).split(' ').map(Number);
    const res = solve(a, m);
    console.log(res);
  }
}

if (require.main === module) {
  main();
}

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();
    });

    A();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,m] = ti(readline().split(' '));
        let a = ti(readline().split(' '));
        let sum = 0;
        for(let i = 0; i < a.length; i++)
            sum += a[i];

        if(sum === m)
            console.log('YES');
        else
            console.log('NO');
    }
}

function readInt() {
    return readline().split(" ").map(e => parseInt(e));
}

var t = readInt()[0]

for(var i=0; i<t; i++) {
    var input = readInt();
    var n = input[0], m = input[1], arr = readInt();
    var sum = 0;
    arr.forEach(x => sum+=x);
    print(sum == m? "YES":"NO");
}

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function A678(arr, m) {
  return arr.reduce(function (a, b) {
    return a + b;
  }, 0) === m ? "YES" : "NO";
}

function execute(readline, print) {
  var iter = {
    next: function next() {
      var _readline;

      return (_readline = readline()) === null || _readline === void 0 ? void 0 : _readline.trim();
    }
  };

  var split = function split(string) {
    return string.split(' ').map(Number);
  };

  var t = Number(iter.next());

  while (t--) {
    var _split = split(iter.next()),
        _split2 = _slicedToArray(_split, 2),
        n = _split2[0],
        m = _split2[1];

    var arr = split(iter.next());
    print(A678(arr, m));
  }
}

execute(readline, print)

var t = Number( readline() );
for(var k=0; k<t; k++){
 var r = readline().split(' ').map(x=>Number(x));
 var a = readline().split(' ').map(x=>Number(x));
 var q = 0;
 for(var i=0; i<r[0]; i++){
  q+=a[i];
 }
 var res = (q==r[1])?"YES":"NO";
 print(res);
}

var tc = parseInt(readline());
for (; tc--;){
 var firstLineInput = readline().split(' ').map((x) => parseInt(x));
var n = firstLineInput[0], m = firstLineInput[1];

var secondLineInput = readline().split(' ').map(x => parseInt(x));

var sum = 0 ;
secondLineInput.forEach((item) => {
	sum += item ;
});

if(sum === m){
	print('YES')
}else{
	print('NO')
}

}

var tc = parseInt(readline());
for (; tc--;){
    var AR = readline().split(' ').map(x => parseInt(x));
    var n = AR[0], m = AR[1];
    var ar = readline().split(' ').map(x => parseInt(x));
    var res = ar.reduce((a, b) => a + b);
    print(res == m ? 'YES' : 'NO');
}

/* A. Reorder
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
For a given array a consisting of n integers and a given integer m find if it is possible to reorder elements of the array a in such a way that ∑ni=1∑nj=iajj equals m? It is forbidden to delete elements as well as insert new elements. Please note that no rounding occurs during division, for example, 52=2.5.

Input
The first line contains a single integer t — the number of test cases (1≤t≤100). The test cases follow, each in two lines.

The first line of a test case contains two integers n and m (1≤n≤100, 0≤m≤106). The second line contains integers a1,a2,…,an (0≤ai≤106) — the elements of the array.

Output
For each test case print "YES", if it is possible to reorder the elements of the array in such a way that the given formula gives the given value, and "NO" otherwise.Example
inputCopy
2
3 8
2 5 1
4 4
0 1 2 3
outputCopy
YES
NO */

var testCasesNumber = readline();
var listOfNAndM = [];
var listOfNValues = [];

//Saisie des données

for (var i = 0; i < testCasesNumber; i++) {
    listOfNAndM.push(readline().split(' '));
    listOfNValues.push(readline().split(' '));
    }
for (var i = 0; i < testCasesNumber; i++) {
    var sum = 0;
    listOfNValues[i].forEach(myFunction);
    print(sum==listOfNAndM[i][1]? "Yes" :"No")

}

    function myFunction(item) {
      sum += parseInt(item);
      ;
    }

var numberOfTests = readline();
var input1 = [];
var toReorder = [];
for (var i = 0; i < numberOfTests; i++) {
    input1.push(readline().split(' '));
    toReorder.push(readline().split(' '));
}

for (var j = 0; j < numberOfTests; j++) {
    var sum = 0;
    toReorder[j].forEach(add);
    print(sum == input1[j][1]? 'Yes' : 'No');
}
function add(item) {
    sum += parseInt(item);
}

var T = +readline();

for (var i = 0; i < T; i++) {
  var p = readline().split(' ').map(i => +i);
  var n = p[0];
  var m = p[1];

  var d = readline().split(' ').map(i => +i);

  var res = 0;

  for (var y = 0; y < d.length; y++) {
    res += d[y];
  }

  if (res == m) {
    print('YES');
  } else {
    print('NO');
  }
}

var tc = parseInt(readline());
while(tc--){
    var A1 = readline().split(' ').map(x => parseInt(x));

    var n = A1[0];
    var m = A1[1];

    var A2 = readline().split(' ').map(x => parseInt(x));

    var total = A2.reduce((t, a)=> t+a, 0);
    print((total===m)?"YES":"NO");
}

// Alternative
// https://www.npmjs.com/package/competitive-programming-js
"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 input() {
    return inputString[currentLine++];
}
const print = x => console.log(x);
// Main starts here

function main() {
    let t = parseInt(input());
    // print("t " + t);
    let [n, m] = input().split(' ').map(v => parseInt(v));
    let ar = input().split(' ').map(v => parseInt(v));
    const sum = ar.reduce((val, sum) => val + sum);
    if (sum === m) print("YES");
    else print("NO");
}

function readInt() {
    return readline().split(" ").map(e => parseInt(e));
}

var t = readInt()[0]

for(var i=0; i<t; i++) {
    var input = readInt();
    var n = input[0], m = input[1], arr = readInt();
    var sum = 0;
    arr.forEach(x => sum+=x);
    print(sum%m == 0? "YES":"NO");
}

var firstLineInput = readline().split(' ').map((x) => parseInt(x));
var n = firstLineInput[0], m = firstLineInput[1];

var secondLineInput = readline().split(' ').map(x => parseInt(x));

var sum = 0 ;
secondLineInput.forEach((item) => {
	sum += item ;
});

if(sum == m){
	print('YES')
}else{
	print('NO')
}

var T = +readline();

for (var i = 0; i < T; i++) {
  var p = readline().split(' ').map(i => +i);
  var n = p[0];
  var m = p[1];

  var d = readline().split(' ').map(i => +i);
  // d = d.sort();

  // var res = 0;

  // for (var y = 0; y < d.length; y++) {
  //   for (var x = 0; x < d.slice(y).length; x++) {
  //     res += d.slice(y)[x] / (x + y + 1);
  //   }
  // }

  if (Math.max(...d) === m-n) {
    print('YES');
  } else {
    print('NO');
  }

  // if (m == res) {
  //   print('YES');
  // } else {
  //   print('NO');
  // }
}

var T = +readline();

for (var i = 0; i < T; i++) {
  var p = readline().split(' ').map(i => +i);
  var n = p[0];
  var m = p[1];

  var d = readline().split(' ').map(i => +i);
  d = d.sort();

  var res = 0;

  for (var y = 0; y < d.length; y++) {
    for (var x = 0; x < d.slice(y).length; x++) {
      res += d.slice(y)[x] / (x + y+ 1);
    }
  }

  if (m == res) {
    print('YES');
  } else {
    print('NO');
  }
}


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    const [a, b] = arr[j].split(' ').map(a => parseInt(a))
    let d = max(a, b) - min(a, b)

    for(let i = 0, s = 0; ; i++) {
      s += i
      if(s >= d && d % 2 == s % 2) {
        wr(i)
        break
      }
    }
  }
})

function wr(...x) {
  console.log(...x)
}

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var t, diff, sum, numbers;

t = Number(readline());

for (i = 0; i < t; i++) {           //loop cases

    numbers = readline().replace(/\r$/, '').split(' ').map(Number);
    diff = Math.abs(numbers[0] - numbers[1]);
    n = 0;
    sum = n * (n + 1) / 2;

    while(sum < diff || (sum % 2 != diff % 2)) {

        n++;
        sum = n * (n + 1) / 2;
    }

    print(n);
}

var input = '';
var curIndex = 0;
function readline(){ return input[curIndex++]; }

process.stdin.on('data', inputStdin => input += inputStdin );

process.stdin.on('end', () => {
    input = input.trim().split('\n').map(str => str.trim() );
    main();
});

function main(){
    var t; t = +readline();
	while(t--){
		let a,b; [a,b] = readline().split(' ').map(n => +n);
		let k = Math.abs(a-b);

		let l,r;
		l = 0, r = 1e9;
		while(l<=r){
			let m = ~~((l+r)/2);
			let pa = (m*(m+1))/2;
			if(pa < k) l = m+1;
			else r = m-1;
		}

		while( ((l*(l+1))/2 + k) % 2 !== 0 ) l++;

		console.log(l);

	}
}

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var t, number, answer, action;

t = Number(readline());

for (i = 0; i < t; i++) {

    answer = 0;
    action = 1;
    number = readline().replace(/\r$/, '').split(' ').map(Number);

    while (number[0] != number[1]) {

        if (number[0] > number[1]) {

            if (number[0] - number[1] >= action) {
                number[1] += action;
            } else {
                number[0] += action;
            }
        } else {

            if ((number[1] - number[0]) >= action) {
                number[0] += action;
            } else {
                number[1] += action;
            }
        }

        action++;
        answer++;
    }

    print(answer);
}


(()=>{"use strict";var t={675:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let o=0;o<t;++o){let t=[];for(let n=0;n<e;++n)t.push(r);n.push(t)}return n},Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.max(t,this[e]);return t},Array.prototype.min=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.min(t,this[e]);return t},Array.prototype.sum=function(){let t=0;for(let e=0;e<this.length;++e)t+=this[e];return t},Array.prototype.modSum=function(t){let e=0;for(let r=0;r<this.length;++r)e+=this[r],e%=t;return e},Array.prototype.avg=function(){return this.sum()/this.length},Array.prototype.groupBy=function(t){let e=new Map;for(let r=0;r<this.length;++r){const n=t(this[r]);e.has(n)?e.get(n).push(this[r]):e.set(n,[this[r]])}return e},Array.prototype.deepCopy=function(){let t=[];if(0==this.length)return t;let e=!1;Array.isArray(this[0])&&(e=!0);for(let r=0;r<this.length;++r)e?t.push(this[r].deepCopy()):t.push(this[r]);return t},Array.prototype.transpose=function(){let t=[];if(0==this.length)return[[]];for(let e=0;e<this[0].length;++e){let r=[];for(let t=0;t<this.length;++t)r.push(this[t][e]);t.push(r)}return t},Array.prototype.toString=function(){if(0==this.length)return"";if(!Array.isArray(this[0]))return this.join(" ");let t="";for(let e=0;e<this.length;++e)t+=this[e].join(" "),e!=this.length-1&&(t+="\n");return t}},312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(747));let s="",i=[],u=0,l="";const p="local"===process.argv[2],f=t=>{if(p){if(i=o.default.readFileSync("input.txt").toString().trim().split("\n").map((t=>t.trim())),t(),o.default.writeFileSync("output.txt",l),console.log(l),o.default.readFileSync("expected.txt").toString().trim()==l.trim()){const{exec:t}=r(129);t("osascript -e 'display notification \"✅ AC!!\"'")}}else process.stdin.resume(),process.stdin.setEncoding("utf-8"),process.stdin.on("data",(t=>{s+=t})),process.stdin.on("end",(e=>{i=s.trim().split("\n").map((t=>t.trim())),t(),console.log(l)}))};function h(){return i[u++]}function a(){return h().split(" ").map((t=>parseFloat(t)))}function c(){return h().split("")}e.default={runMain:f,runEachTest:t=>{f((()=>{let[e]=a();for(;e>0;)t(),e--}))},readline:h,nextNumbers:a,nextBigNumbers:function(){return h().split(" ").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(a());return e},nextCharacters:c,nextCharacterMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(c());return e},nextIntervalArray:function(t){let e=[];for(let r=0;r<t;++r){const[t,r]=a();e.push({a:t,b:r})}return e},put:function(t){l+=t},puts:function(t){l+=t+"\n"},debug:function(t){p&&console.log(t)}}},965:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),r(675);const o=n(r(312));o.default.runEachTest((function(){let[t,e]=o.default.nextNumbers(),r=o.default.nextCharacterMatrix(t),n=[],s=(t,e,o,s,i,u)=>{n.push(`${t+1} ${e+1} ${o+1} ${s+1} ${i+1} ${u+1}`),"0"==r[t][e]?r[t][e]="1":r[t][e]="0","0"==r[o][s]?r[o][s]="1":r[o][s]="0","0"==r[i][u]?r[i][u]="1":r[i][u]="0"};if(t%2==1)for(let t=0;t<e-1;t++)"1"==r[0][t]&&"1"==r[0][t+1]?s(0,t,0,t+1,1,t):"1"==r[0][t]?s(0,t,1,t+1,1,t):"1"==r[0][t+1]&&s(0,t+1,1,t+1,1,t);if(e%2==1)for(let e=t%2==0?0:1;e<t-1;++e)"1"==r[e][0]&&"1"==r[e+1][0]?s(e,0,e+1,0,e,1):"1"==r[e][0]?s(e,0,e+1,1,e,1):"1"==r[e+1][0]&&s(e,1,e+1,0,e+1,1);let i=(t,e)=>{"0"!=r[t][e]?"0"!=r[t+1][e]?"0"!=r[t][e+1]?"0"==r[t+1][e+1]&&s(t+1,e,t,e+1,t,e):s(t,e,t+1,e,t+1,e+1):s(t,e,t,e+1,t+1,e+1):s(t+1,e,t,e+1,t+1,e+1)},u=(t,e)=>{let n=[],o=[];for(let s=0;s<2;++s)for(let i=0;i<2;++i)"0"==r[t+s][e+i]?n.push({x1:t+s,x2:e+i}):o.push({x1:t+s,x2:e+i});s(n[0].x1,n[0].x2,n[1].x1,n[1].x2,o[0].x1,o[0].x2)},l=(t,e)=>{let n=[],o=[];for(let s=0;s<2;++s)for(let i=0;i<2;++i)"0"==r[t+s][e+i]?n.push({x1:t+s,x2:e+i}):o.push({x1:t+s,x2:e+i});s(n[0].x1,n[0].x2,n[1].x1,n[1].x2,o[0].x1,o[0].x2)};for(let n=t%2==0?0:1;n<t;n+=2)for(let t=e%2==0?0:1;t<e;t+=2){let e=0,o=0;"1"==r[n][t]?o++:e++,"1"==r[n+1][t]?o++:e++,"1"==r[n][t+1]?o++:e++,"1"==r[n+1][t+1]?o++:e++,0!=o&&(3!=o?2!=o?1!=o?4!=o||(s(n,t,n+1,t,n+1,t+1),u(n,t),l(n,t),i(n,t)):(u(n,t),l(n,t),i(n,t)):(l(n,t),i(n,t)):i(n,t))}o.default.puts(n.length),o.default.puts(n.join(" "))}))},129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")}},e={};!function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}(965)})();

// Solution written in typescript and compiled via webpack. Original source code below
// Happy Hacking 😜

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n, m] = io.nextNumbers()
//   let a = io.nextCharacterMatrix(n)
//
//   let flips = []
//
//   let flip = (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => {
//     flips.push(`${x1 + 1} ${y1 + 1} ${x2 + 1} ${y2 + 1} ${x3 + 1} ${y3 + 1}`)
//
//     if (a[x1][y1] == "0") {
//       a[x1][y1] = "1"
//     } else {
//       a[x1][y1] = "0"
//     }
//
//     if (a[x2][y2] == "0") {
//       a[x2][y2] = "1"
//     } else {
//       a[x2][y2] = "0"
//     }
//
//     if (a[x3][y3] == "0") {
//       a[x3][y3] = "1"
//     } else {
//       a[x3][y3] = "0"
//     }
//   }
//
//   if (n % 2 == 1) {
//     for (let i = 0; i < m - 1; i++) {
//       if (a[0][i] == "1" && a[0][i + 1] == "1") {
//         flip(0, i, 0, i + 1, 1, i)
//       } else if (a[0][i] == "1") {
//         flip(0, i, 1, i + 1, 1, i)
//       } else if (a[0][i + 1] == "1") {
//         flip(0, i + 1, 1, i + 1, 1, i)
//       }
//     }
//   }
//
//   if (m % 2 == 1) {
//     for (let i = n % 2 == 0 ? 0 : 1; i < n - 1; ++i) {
//       if (a[i][0] == "1" && a[i + 1][0] == "1") {
//         flip(i, 0, i + 1, 0, i, 1)
//       } else if (a[i][0] == "1") {
//         flip(i, 0, i + 1, 1, i, 1)
//       } else if (a[i + 1][0] == "1") {
//         flip(i, 1, i + 1, 0, i + 1, 1)
//       }
//     }
//   }
//
//   let proc3 = (x1: number, x2: number) => {
//     if (a[x1][x2] == "0") {
//       flip(x1 + 1, x2, x1, x2 + 1, x1 + 1, x2 + 1)
//       return
//     }
//
//     if (a[x1 + 1][x2] == "0") {
//       flip(x1, x2, x1, x2 + 1, x1 + 1, x2 + 1)
//       return
//     }
//
//     if (a[x1][x2 + 1] == "0") {
//       flip(x1, x2, x1 + 1, x2, x1 + 1, x2 + 1)
//       return
//     }
//
//     if (a[x1 + 1][x2 + 1] == "0") {
//       flip(x1 + 1, x2, x1, x2 + 1, x1, x2)
//     }
//   }
//
//   let proc1 = (x1: number, x2: number) => {
//     let zeroCoord = []
//     let oneCoord = []
//
//     for (let i = 0; i < 2; ++i) {
//       for (let j = 0; j < 2; ++j) {
//         if (a[x1 + i][x2 + j] == "0") {
//           zeroCoord.push({ x1: x1 + i, x2: x2 + j })
//         } else {
//           oneCoord.push({ x1: x1 + i, x2: x2 + j })
//         }
//       }
//     }
//
//     flip(
//       zeroCoord[0].x1,
//       zeroCoord[0].x2,
//       zeroCoord[1].x1,
//       zeroCoord[1].x2,
//       oneCoord[0].x1,
//       oneCoord[0].x2
//     )
//   }
//
//   let proc2 = (x1: number, x2: number) => {
//     let zeroCoord = []
//     let oneCoord = []
//
//     for (let i = 0; i < 2; ++i) {
//       for (let j = 0; j < 2; ++j) {
//         if (a[x1 + i][x2 + j] == "0") {
//           zeroCoord.push({ x1: x1 + i, x2: x2 + j })
//         } else {
//           oneCoord.push({ x1: x1 + i, x2: x2 + j })
//         }
//       }
//     }
//
//     flip(
//       zeroCoord[0].x1,
//       zeroCoord[0].x2,
//       zeroCoord[1].x1,
//       zeroCoord[1].x2,
//       oneCoord[0].x1,
//       oneCoord[0].x2
//     )
//   }
//
//   for (let i = n % 2 == 0 ? 0 : 1; i < n; i += 2) {
//     for (let j = m % 2 == 0 ? 0 : 1; j < m; j += 2) {
//       let nr0 = 0
//       let nr1 = 0
//
//       if (a[i][j] == "1") {
//         nr1++
//       } else {
//         nr0++
//       }
//
//       if (a[i + 1][j] == "1") {
//         nr1++
//       } else {
//         nr0++
//       }
//
//       if (a[i][j + 1] == "1") {
//         nr1++
//       } else {
//         nr0++
//       }
//
//       if (a[i + 1][j + 1] == "1") {
//         nr1++
//       } else {
//         nr0++
//       }
//
//       if (nr1 == 0) {
//         continue
//       }
//
//       if (nr1 == 3) {
//         proc3(i, j)
//         continue
//       }
//
//       if (nr1 == 2) {
//         proc2(i, j)
//         proc3(i, j)
//         continue
//       }
//
//       if (nr1 == 1) {
//         proc1(i, j)
//         proc2(i, j)
//         proc3(i, j)
//         continue
//       }
//
//       if (nr1 == 4) {
//         flip(i, j, i + 1, j, i + 1, j + 1)
//         proc1(i, j)
//         proc2(i, j)
//         proc3(i, j)
//         continue
//       }
//     }
//   }
//
//   io.puts(flips.length)
//   io.puts(flips.join(" "))
// }
//
// io.runEachTest(main)
// // io.runMain(main)


var input = readline().split(' ')
  , n = +input[0]
  , m = +input[1]
  , teams = [];

for (var i = 0, info = null; i < n; i++) {
  info = readline().split(' ');
  if (teams[info[1]] === undefined) {
    teams[info[1]]= [];
  }
  if (teams[info[1]][info[2]] === undefined ) {
    teams[info[1]][info[2]] = [];
  }
  teams[info[1]][info[2]].push(info[0]);
}

for (var i = 1, keys = []; i < teams.length; i++) {
  keys = Object.keys(teams[i]).reverse();
  if (teams[i][keys[0]].length > 2) {
    print('?');
    continue;
  } else if (teams[i][keys[0]].length === 2) {
      print(teams[i][keys[0]].join(' '));
      continue;
  } else if (teams[i][keys[1]].length > 1) {
    print('?');
    continue;
  } else {
    print(teams[i][keys[0]] + ' ' + teams[i][keys[1]]);
    continue;
  }
}

var arr = readline().split(" ", 2).map(Number);
var n = arr[0], m = arr[1];

var array = new Array(m);
for (var i = 0; i < m; ++i) {
    array[i] = [];
}
for (var i = 0; i < n; ++i) {
    arr = readline().split(" ", 3);
    array[Number(arr[1]) - 1].push({
        name: arr[0],
        score: Number(arr[2])
    });
}

function getMaxIndex(array, l, r) {
    var value = array[l].score, index = l;
    for (var i = l + 1; i < r; ++i) {
        if (array[i].score > value) {
            value = array[i].score;
            index = i;
        }
    }
    return index;
}
function swap(array, x, y) {
    if (x !== y && x >= 0 && x < array.length &&
        y >= 0 && y < array.length) {
            var temp = array[x];
            array[x] = array[y];
            array[y] = temp;
        }
}
function firstThree(array) {
    for (var i = 0; i < 3; ++i) {
        swap(array, i, getMaxIndex(array, i, array.length));
    }
}
for (var i = 0; i < m; ++i) {
    if (array[i].length === 2) {
        print(array[i][0].name + " " + array[i][1].name);
    } else {
        firstThree(array[i]);
        if (array[i][1].score === array[i][2].score) {
            print("?");
        } else {
            print(array[i][0].name + " " + array[i][1].name);
        }
    }
}

var isCodeForces = true;
var line, lines, echo;
if(!isCodeForces){
	lines = '';
	process.stdin.resume();
	process.stdin.on('data', function(buffer){lines += buffer.toString();});
	process.stdin.on('end', function(){
		lines = lines.trim().split('\n');
		echo = console.log;
		wrapper();
	});
}else{
	lines = [];
	while(line = readline()){
		lines.push(line);
	}
	echo = print;
	wrapper();
}

function wrapper(){
	init();
	var res = main();
	if(res != undefined){
		echo(res);
	}
}

function main(){
	var line = lines[0].split(' ');
	var n = parseInt(line[0]), m = parseInt(line[1]), res = new Array(m + 1).join(' ').split('').map(function(){
		return [];
	});
	for(var i = 1; i <= n; i++){
		line = lines[i].split(' ');
		var name = line[0], region = parseInt(line[1]) - 1, score = parseInt(line[2]);
		res[region].push([score, name]);
	}
	for(i = 0; i < m; i++){
		var row = res[i].sort(function(a, b){
			return b[0] - a[0];
		});
		if(row.length >= 3 && row[1][0] == row[2][0])
			res[i] = '?';
		else {
			res[i] = `${row[0][1]} ${row[1][1]}`;
		}
	}
	return res.join('\n');
}

function init(){
}


process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => {
    input.split('\r\n')
        .filter((_, index) => index >= 2 && index % 2 === 0)
        .map(line => line.split(' ').map(v => parseInt(v, 10)))
        .forEach(permutation => {
            let index = 0;
            while (index < permutation.length - 1) {
                const value = Math.min(...permutation.slice(index));
                const valueIndex = permutation.indexOf(value);
                for (let i = valueIndex - 1; i >= index; i--) { permutation[i + 1] = permutation[i]; }
                permutation[index] = value;
                index = Math.max(valueIndex, index + 1);
            }
            console.log(permutation.join(' '));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 2 && i % 2 === 0).map(l => l.split(' ').map(v => parseInt(v, 10)))
        .forEach(q => {
            for (let index = 0; index < q.length; index++) {
                const v = Math.min(...q.slice(index));
                const vIndex = q.indexOf(v);
                for (let i = vIndex - 1; i >= index; i--) { q[i + 1] = q[i]; }
                q[index] = v;
                index = Math.max(vIndex - 1, index);
            }
            console.log(q.join(' '));
        });
});

//DONE:
process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const q = parseInt(arr.shift())

  for(let i = 0; i < q; i++) {
    const n = parseInt(arr[2 * i])
    const no = arr[2 * i + 1].split(' ').map(a => parseInt(a))
    var a = min(no)
    console.log(a.join(' '))
  }
})

function min(no) {
  const n = no.length
  const i = no.indexOf(Math.min.apply(null, no))
  // console.log(i, no)
  if(i == n - 1) {
    const s  = no.pop()
    no.unshift(s)
    return no
  }
  else if(i == 0) {
    return [no[0]].concat(min(no.slice(1, n)))
  }

  else {
    // console.log(no)
    var a = no.slice(0, i + 1)
    a.unshift(a.pop())
    no = a.concat(no.slice(i + 1, n))
    // console.log(a, no)
    b = min(no.slice(i, n))
    // console.log(b)
    return a.slice(0, a.length - 1).concat(b)
  }
}

'use strict'

const problem = (n, p) => {
    let a = 0;
    for (let i = 1; i <= n; i++) {
        const b = p.indexOf(i);

        for (let j = b; j > a; j--) {
            const c = p[j]; p[j] = p[j - 1]; p[j - 1] = c;
        }
        if (a === b) a = b + 1;
        if (a < b) a = b;
    }
    return p.join(' ');
}

let q = +readline();
while (q--) print(problem(+readline(), readline().split(' ').map(Number)));

  var count = +readline();
  while (count--) {
    var n = +readline();
    var elements = readline()
      .split(" ")
      .map(Number);

    var a = 0;

    for (var i = 1; i < n + 1; i++) {
      var index = elements.indexOf(i);

      for (var j = index; j > a; j--) {
        var buf = elements[j - 1];
        elements[j - 1] = elements[j];
        elements[j] = buf;
      }

      if (a === index) a = index + 1;
      if (a < index) a = index;
    }
    print(elements.join(" "));
  }

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

let lineNumber = 0;
process.stdin.on('data', input => {
    input.split('\r\n').forEach(line => {
        // console.log('on line', lineNumber, input);
        if (++lineNumber >= 3 && lineNumber % 2 === 1) { resolve(line) }
    });
});

function resolve(input) {
    let permutation = input.split(' ').map(v => parseInt(v, 10));
    let index = 0;
    while (index < permutation.length - 1) {
        const value = Math.min(...permutation.slice(index));
        const valueIndex = permutation.indexOf(value);
        if (valueIndex > index) {
            for (let i = valueIndex - 1; i >= index; i--) {
                permutation[i + 1] = permutation[i];
            }
            permutation[index] = value;
            index = valueIndex - 1;
        }
        index++;
    }
    console.log(permutation.join(' '));
}

//DONE:
process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const q = parseInt(arr.shift())

  for(let i = 0; i < q; i++) {
    const n = parseInt(arr[2 * i])
    const no = arr[2 * i + 1].split(' ').map(a => parseInt(a))
    // console.log(no)
    var a = min(no)
    console.log(a.join(' '))
  }
})

function min(no) {
  const n = no.length
  const i = no.indexOf(Math.min.apply(null, no))
  // console.log(i, Math.min.apply(null, no))
  if(i == n - 1) {
    const s  = no.pop()
    no.unshift(s)
    return no
  }
  else if(i == 0) {
    return [no[0]].concat(min(no.slice(1, n)))
  }

  else {
    var a = no.slice(0, i + 1)
    a.unshift(a.pop())
    var b = min(no.slice(i + 1, n))
    // console.log(a, no.slice(i + 1, n))
    no = a.concat(b)
    if(no[i] > no[i + 1]) {
      const temp = no[i]
      no[i] = no[i + 1]
      no[i + 1] = temp
    }
    return no
  }
}

//DONE:
process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const q = parseInt(arr.shift())

  for(let i = 0; i < q; i++) {
    const n = parseInt(arr[2 * i])
    const no = arr[2 * i + 1].split(' ').map(a => parseInt(a))
    // console.log(no)
    var a = min(no)
    console.log(a.join(' '))
  }
})

function min(no) {
  const n = no.length
  const i = no.indexOf(Math.min.apply(null, no))
  // console.log(i, Math.min.apply(null, no))
  if(i == n - 1) {
    const s  = no.pop()
    no.unshift(s)
    return no
  }
  else if(i == 0) {
    return [no[0]].concat(min(no.slice(1, n)))
  }

  else {
    // console.log(no)
    var a = no.slice(0, i + 1)
    a.unshift(a.pop())
    no = a.concat(no.slice(i + 1, n))
    if(no[i] > no[i + 1]) {
      const temp = no[i]
      no[i] = no[i + 1]
      no[i + 1] = temp
      a = no.slice(0, i + 1)
    }
    // console.log(a, no)
    b = min(no.slice(i + 1, n))
    // console.log(b)
    return a.concat(b)
  }
}

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

let lineNumber = 0;
console.log('started');
process.stdin.on('data', input => {
    input.split('\r\n').forEach(line => {
        // console.log('on line', lineNumber, input);
        if (++lineNumber >= 3 && lineNumber % 2 === 1) { resolve(line) }
    });
});

function resolve(input) {
    let permutation = input.split(' ').map(v => parseInt(v, 10));
    let index = 0;
    while (index < permutation.length - 1) {
        const value = Math.min(...permutation.slice(index));
        const valueIndex = permutation.indexOf(value);
        if (valueIndex > index) {
            for (let i = valueIndex - 1; i >= index; i--) {
                permutation[i + 1] = permutation[i];
            }
            permutation[index] = value;
            index = valueIndex - 1;
        }
        index++;
    }
    console.log(permutation.join(' '));
}

'use strict'

const problem = (n, p) => {
    let a = 0, b, i = 0;
    while(i < n && a <= (b = p.indexOf(++i))) {
        for (let j = b; j > a; j--) {
            const c = p[j];
            p[j] = p[j - 1];
            p[j - 1] = c;
        }
        a = +(a === b) + b;
    }
    return p.join(' ');
}

let q = +readline();
while (q--) print(problem(+readline(), readline().split(' ').map(Number)));

'use strict'

const problem = (n, p) => {
    let a = 0;
    for (let i = 1; i < n; i++) {
        const b = p.indexOf(i);
        for (let j = b; j > a; j--) {
            const c = p[j];
            p[j] = p[j - 1];
            p[j - 1] = c;
        }
        a = +(a === b) + b;
    }
    return p.join(' ');
}

let q = +readline();
while (q--) {
    print(problem(+readline(), readline().split(' ').map(Number)));
}

  var sets = parseInt(readline());

  for (var i = 0; i < sets; i++) {
    var elementCount = parseInt(readline());
    var elements = readline()
      .split(" ")
      .map(function(value) {
        return parseInt(value);
      });
    var actions = Array(elementCount + 1).map(function(value) {
      return true;
    });

    for (var j = 0; j < actions.length; j++) {
      actions[j] = true;
    }
    var changed = true;

    for (var elem = 1; elem < elementCount + 1 && changed; elem++) {
      changed = false;

      if (elem === elements[elem - 1]) {
        elem++;
        changed = true;
        continue;
      }

      for (var j = 0; j < elementCount; j++) {
        if (elements[j + 1] === elem && elements[j] > elem && actions[j]) {
          var tmp = elements[j];
          elements[j] = elements[j + 1];
          elements[j + 1] = tmp;
          actions[j] = false;
          elem++;
          changed = true;
        }
      }
      elem = 0;
    }

    print(elements.join(' '));
  }

  var sets = parseInt(readline());

  for (var i = 0; i < sets; i++) {
    var elementCount = parseInt(readline());
    var elements = readline()
      .split(" ")
      .map(function(value) {
        return parseInt(value);
      });
    var actions = Array(elementCount + 1);

    for (var j = 0; j < actions.length; j++) {
      actions[j] = true;
    }
    var changed = true;

    for (var elem = 1; elem < elementCount + 1 && changed; elem++) {
      changed = false;

      if (elem === elements[elem - 1]) {
        changed = true;
        continue;
      }

      for (var j = 0; j < elementCount; j++) {
        if (elements[j + 1] === elem && elements[j] > elem && actions[j]) {
          var tmp = elements[j];
          elements[j] = elements[j + 1];
          elements[j + 1] = tmp;
          actions[j] = false;
          elem++;
          changed = true;
        }
      }
      elem = 0;
    }

    print(elements.join(" "));
  }

  var sets = parseInt(readline());

  for (var i = 0; i < sets; i++) {
    var elementCount = parseInt(readline());
    var elements = readline()
      .split(" ")
      .map(function(value) {
        return parseInt(value);
      });
    var actions = Array(elementCount + 1);

    for (var j = 0; j < actions.length; j++) {
      actions[j] = true;
    }
    var changed = true;

    for (var elem = 1; elem < elementCount + 1 && changed; elem++) {
      changed = false;

      if (elem === elements[elem - 1]) {
        elem++;
        changed = true;
        continue;
      }

      for (var j = 0; j < elementCount; j++) {
        if (elements[j + 1] === elem && elements[j] > elem && actions[j]) {
          var tmp = elements[j];
          elements[j] = elements[j + 1];
          elements[j + 1] = tmp;
          actions[j] = false;
          elem++;
          changed = true;
        }
      }
      elem = 0;
    }

    print(elements.join(" "));
  }


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function findCost(initial, chars) {
	var cost = 0,
		expected = initial, opposite = (initial+1)%2, temp;

	for (var position = 0; position < chars.length; ++position) {
		if (chars[position] != expected) {
			++cost;
		}
		temp = expected;
		expected = opposite;
		opposite = temp;
	}

	return cost;
}

function main() {
	var length = parseInt(readline(), 10);
	var input = readline().replace(/\s+/g, "");

	print(Math.min(findCost(0, input.split("")),
				findCost(1, input.split(""))));
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function findCost(initial, chars) {
	var cost = 0,
		expected = initial, opposite = (initial+1)%2;

	for (var position = 0; position < chars.length; ++position) {
		if (chars[position] != expected) {
			++cost;
		}
		var temp = expected;
		expected = opposite;
		opposite = temp;
	}

	return cost;
}

function main() {
	var length = parseInt(readline(), 10);
	var input = readline().replace(/\s+/g, "");

	print(Math.min(findCost(0, input.split("")),
				findCost(1, input.split(""))));
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function findCost(initial, chars) {
	var cost = 0,
		expected = (initial+1)%2, nextExpected = initial,
		position = 0;

	while (position != chars.length-1) {
		var temp = expected;
		expected = nextExpected;
		nextExpected = temp;

		if (chars[position] == chars[position+1]) {
			++cost;

			if (chars[position] == expected) {
				chars[position+1] = nextExpected;
				++position;
			}
			else {
				chars[position] = expected;
				if (position == 0) {
					position = 1;
				}
				else {
					--position;
				}
			}//end else
		}//end if

		else {
			++position;
		}
	}//end while

	return cost;
}//end findCost

function main() {
	var length = parseInt(readline(), 10);
	var input = readline().replace(/\s+/g, "");

	for (var position = 1; position < length; ++position) {
		if (input.charAt(position) == input.charAt(position-1)) {
			break;
		}
	}

	if (position == length) {
		print(0);
		return;
	}

	print(Math.min(findCost(0, input.split("")),
				findCost(1, input.split(""))));
}

main();


var str = '';
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  str = cmd;
              }).on('close', main);

function recheck(s) {
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[x][y] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[x][y] = 0;
	}
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[y][x] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[y][x] = 0;
	}
}

function main() {
    //console.log('goodbye!');

/*    var mn = 1000000000;
    for (var code=0; code<(1<<9); code++) {
	var cnt_ones = 0;
	for (var j=0; j<9; j++) cnt_ones += (code>>j)&1;
        var x = N;

    }*/

    var s = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]];

    for (var j=0; j<str.length; j++) {
    	if (str[j] === '0') {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<3 && !fnd; x++)
    			for (var y=0; y<4; y++) if (y===0)
    				if (s[x][y] === 0 && s[x+1][y] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
	   		s[xx][yy] = s[xx+1][yy] = 1;
    	}
    	else {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<4 && !fnd; x++)
    			for (var y=0; y<3; y++) if (y===1)
    				if (s[x][y] === 0 && s[x][y+1] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
    		s[xx][yy] = s[xx][yy+1] = 1;
    	}
    	recheck(s);
    }

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

function main(str){

      var h = false;
      var v = false;
      for(var i = 0 ; i < str.length ; i++){
        if(str[i] === "0"){
          if(v){
            print("3 4");
          }
          else{
            print("1 4");
          }
          v = !v;
        }
        else{
          if(h){
            print("4 3");
          }
          else{
            print("4 1");
          }
          h = !h;
        }
      }
}

var str = readline();

main(str);

function main(str){

      var h = false;
      var v = false;
      for(var i = 0 ; i < str.length ; i++){
        if(str[i] === "0"){
          if(v){
            print("4 3");
          }
          else{
            print("4 1");
          }
          v = !v;
        }
        else{
          if(h){
            print("1 3");
          }
          else{
            print("1 1");
          }
          h = !h;
        }
      }
}

var str = readline();

main(str);

try {

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];

function clean() {
    for (var i = 0; i < 4; i++) {
        if (array[i][0] === 1 && array[i][1] === 1 && array[i][2] === 1 && array[i][3] === 1) {
            array[i][0] = array[i][1] = array[i][2] = array[i][3] = 0;
        } else if (array[0][i] === 1 && array[1][i] === 1 && array[2][i] === 1 && array[3][i] === 1) {
            array[0][i] = array[1][i] = array[2][i] = array[3][i] = 0;
        }
    }
}

function getFree() {
    var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (v && array[i][j] === 0 && array[i + 1][j] === 0) {
                return [i, j];
            } else if (!v && array[i][j] === 0 && array[i][j + 1] === 0) {
                return [i, j];
            }
        }
    }
}

var arr = String(readline());

arr = arr.split("").map(Number);
arr.forEach(function (i) {
    var _getFree = getFree(i === 0),
        _getFree2 = _slicedToArray(_getFree, 2),
        x = _getFree2[0],
        y = _getFree2[1];

    array[x][y] = 1;
    i === 1 ? array[x][y + 1] = 1 : array[x + 1][y] = 1;
    write(x + 1 + " " + (y + 1) + "\n");
    clean();
});
} catch(e){write(String(e.stack).replace(/ /g, "-"))}

try {

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];

function clean() {
    for (var i = 0; i < 4; i++) {
        if (array[i][0] === 1 && array[i][1] === 1 && array[i][2] === 1 && array[i][3] === 1) {
            array[i][0] = array[i][1] = array[i][2] = array[i][3] = 0;
        } else if (array[0][i] === 1 && array[1][i] === 1 && array[2][i] === 1 && array[3][i] === 1) {
            array[0][i] = array[1][i] = array[2][i] = array[3][i] = 0;
        }
    }
}

function getFree() {
    var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (v && array[i][j] === 0 && array[i + 1][j] === 0) {
                return [i, j];
            } else if (!v && array[i][j] === 0 && array[i][j + 1] === 0) {
                return [i, j];
            }
        }
    }
}

var xx = "";
var arr = String(xx = readline());

arr = arr.split("").map(Number);
arr.forEach(function (i) {
    var _getFree = getFree(i === 0),
        _getFree2 = _slicedToArray(_getFree, 2),
        x = _getFree2[0],
        y = _getFree2[1];

    array[x][y] = 1;
    i === 1 ? array[x][y + 1] = 1 : array[x + 1][y] = 1;
    write(x + 1 + " " + (y + 1) + "\n");
    clean();
});
} catch(e){write(xx)}

try {

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];

function clean() {
    for (var i = 0; i < 4; i++) {
        if (array[i][0] === 1 && array[i][1] === 1 && array[i][2] === 1 && array[i][3] === 1) {
            array[i][0] = array[i][1] = array[i][2] = array[i][3] = 0;
        } else if (array[0][i] === 1 && array[1][i] === 1 && array[2][i] === 1 && array[3][i] === 1) {
            array[0][i] = array[1][i] = array[2][i] = array[3][i] = 0;
        }
    }
}

function getFree() {
    var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (v && array[i][j] === 0 && array[i + 1][j] === 0) {
                return [i, j];
            } else if (!v && array[i][j] === 0 && array[i][j + 1] === 0) {
                return [i, j];
            }
        }
    }
}

var arr = String(readline());

arr = arr.split("").map(Number);
arr.forEach(function (i) {
    var _getFree = getFree(i === 0),
        _getFree2 = _slicedToArray(_getFree, 2),
        x = _getFree2[0],
        y = _getFree2[1];

    array[x][y] = 1;
    i === 1 ? array[x][y + 1] = 1 : array[x + 1][y] = 1;
    write(x + 1 + " " + (y + 1) + "\n");
    clean();
});
} catch(e){write(e.stack)}

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];

function clean() {
    for (var i = 0; i < 4; i++) {
        if (array[i][0] === 1 && array[i][1] === 1 && array[i][2] === 1 && array[i][3] === 1) {
            array[i][0] = array[i][1] = array[i][2] = array[i][3] = 0;
        } else if (array[0][i] === 1 && array[1][i] === 1 && array[2][i] === 1 && array[3][i] === 1) {
            array[0][i] = array[1][i] = array[2][i] = array[3][i] = 0;
        }
    }
}

function getFree() {
    var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (v && array[i][j] === 0 && array[i][j + 1] === 0) {
                return [i, j];
            } else if (!v && array[i][j] === 0 && array[i + 1][j] === 0) {
                return [i, j];
            }
        }
    }
}

var arr = String(readline());
arr = arr.split("").map(Number);
arr.forEach(function (i) {
    var _getFree = getFree(i === 0),
        _getFree2 = _slicedToArray(_getFree, 2),
        x = _getFree2[0],
        y = _getFree2[1];

    array[x][y] = 1;
    i === 0 ? array[x][y + 1] = 1 : array[x + 1][y] = 1;
    write(x + 1 + " " + (y + 1) + "\n");
    clean();
});

try {

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];

function clean() {
    for (var i = 0; i < 4; i++) {
        if (array[i][0] === 1 && array[i][1] === 1 && array[i][2] === 1 && array[i][3] === 1) {
            array[i][0] = array[i][1] = array[i][2] = array[i][3] = 0;
        } else if (array[0][i] === 1 && array[1][i] === 1 && array[2][i] === 1 && array[3][i] === 1) {
            array[0][i] = array[1][i] = array[2][i] = array[3][i] = 0;
        }
    }
}

function getFree() {
    var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

    for (var i = 0; i < 4; i++) {
        for (var j = 0; j < 4; j++) {
            if (v && array[i][j] === 0 && array[i + 1][j] === 0) {
                return [i, j];
            } else if (!v && array[i][j] === 0 && array[i][j + 1] === 0) {
                return [i, j];
            }
        }
    }
}

var arr = String(readline());

arr = arr.split("").map(Number);
arr.forEach(function (i) {
    var _getFree = getFree(i === 0),
        _getFree2 = _slicedToArray(_getFree, 2),
        x = _getFree2[0],
        y = _getFree2[1];

    array[x][y] = 1;
    i === 1 ? array[x][y + 1] = 1 : array[x + 1][y] = 1;
    write(x + 1 + " " + (y + 1) + "\n");
    clean();
});
} catch(e){}

var str = '';
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  str = cmd;
              }).on('close', main);

function recheck(s) {
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[x][y] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[x][y] = 0;
	}
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[y][x] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[y][x] = 0;
	}
}

function main() {
    //console.log('goodbye!');

/*    var mn = 1000000000;
    for (var code=0; code<(1<<9); code++) {
	var cnt_ones = 0;
	for (var j=0; j<9; j++) cnt_ones += (code>>j)&1;
        var x = N;

    }*/

    var s = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]];

    for (var j=0; j<str.length; j++) {
    	if (str[j] === '0') {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<3 && !fnd; x++)
    			for (var y=0; y<4; y++)
    				if (s[x][y] === 0 && s[x+1][y] === 0 && Math.random() < 0.5) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
	   		s[xx][yy] = s[xx+1][yy] = 1;
    	}
    	else {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<4 && !fnd; x++)
    			for (var y=0; y<3; y++)
    				if (s[x][y] === 0 && s[x][y+1] === 0 && Math.random() < 0.5) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
    		s[xx][yy] = s[xx][yy+1] = 1;
    	}
    	recheck(s);
    }

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

var str = '';
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  str = cmd;
              }).on('close', main);

function recheck(s) {
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[x][y] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[x][y] = 0;
	}
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[y][x] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[y][x] = 0;
	}
}

function main() {
    //console.log('goodbye!');

/*    var mn = 1000000000;
    for (var code=0; code<(1<<9); code++) {
	var cnt_ones = 0;
	for (var j=0; j<9; j++) cnt_ones += (code>>j)&1;
        var x = N;

    }*/

    var s = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]];

    for (var j=0; j<str.length; j++) {
    	if (str[j] === '0') {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<3 && !fnd; x++)
    			for (var y=0; y<4; y++)
    				if (s[x][y] === 0 && s[x+1][y] === 0 && Math.random() < 0.2) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
	   		s[xx][yy] = s[xx+1][yy] = 1;
    	}
    	else {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<4 && !fnd; x++)
    			for (var y=0; y<3; y++)
    				if (s[x][y] === 0 && s[x][y+1] === 0 && Math.random() < 0.2) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
    		s[xx][yy] = s[xx][yy+1] = 1;
    	}
    	recheck(s);
    }

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

var str = '';
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  str = cmd;
              }).on('close', main);

function recheck(s) {
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[x][y] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[x][y] = 0;
	}
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[y][x] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[y][x] = 0;
	}
}

function main() {
    //console.log('goodbye!');

/*    var mn = 1000000000;
    for (var code=0; code<(1<<9); code++) {
	var cnt_ones = 0;
	for (var j=0; j<9; j++) cnt_ones += (code>>j)&1;
        var x = N;

    }*/

    var s = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]];

    for (var j=0; j<str.length; j++) {
    	if (str[j] === '0') {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<3 && !fnd; x++)
    			for (var y=0; y<4; y++)
    				if (s[x][y] === 0 && s[x+1][y] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
	   		s[xx][yy] = s[xx+1][yy] = 1;
    	}
    	else {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<4 && !fnd; x++)
    			for (var y=0; y<3; y++)
    				if (s[x][y] === 0 && s[x][y+1] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
    		s[xx][yy] = s[xx][yy+1] = 1;
    	}
    	recheck(s);
    }

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

var str = '';
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  str = cmd;
              }).on('close', main);

function recheck(s) {
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[x][y] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[x][y] = 0;
	}
	for (var x=0; x<4; x++) {
		var all_1 = 1;
		for (var y=0; y<4; y++)
			if (s[y][x] !== 1) {
				all_1 = 0;
				break;
			}
		if (all_1 === 1)
			for (var y=0; y<4; y++)
				s[y][x] = 0;
	}
}

function main() {
    //console.log('goodbye!');

/*    var mn = 1000000000;
    for (var code=0; code<(1<<9); code++) {
	var cnt_ones = 0;
	for (var j=0; j<9; j++) cnt_ones += (code>>j)&1;
        var x = N;

    }*/

    var s = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]];

    for (var j=0; j<str.length; j++) {
    	if (str[j] === '0') {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<3 && !fnd; x++)
    			for (var y=0; y<4; y++) if (y===0 || y===3)
    				if (s[x][y] === 0 && s[x+1][y] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
	   		s[xx][yy] = s[xx+1][yy] = 1;
    	}
    	else {
    		var xx, yy, fnd = 0;
    		for (var x=0; x<4 && !fnd; x++)
    			for (var y=0; y<3; y++) if (y===1)
    				if (s[x][y] === 0 && s[x][y+1] === 0) {
    					xx = x;
    					yy = y;
    					fnd = 1;
    					break;
    				}
    		console.log((xx+1) + " " + (yy+1));
    		s[xx][yy] = s[xx][yy+1] = 1;
    	}
    	recheck(s);
    }

    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);


// problem name: Sasha and a Bit of Relax
// problem link: https://codeforces.com/problemset/problem/1109/A
// contest link: https://codeforces.com/contest/1109
// author: reyad
// time: (?)

'use strict';

function main() {
	let m = 1<<20;
	let n = nextInt();

	let count_odd = [];
	let count_even = [];
	for(let i=0; i<=m; i++) {
		count_odd.push(0);
		count_even.push(0);
	}

	let ans = 0;

	let xor = 0;
	count_even[xor]++;

	for(let i=1; i<=n; i++) {
		xor = nextInt() ^ xor;
		if((i&1) == 1) {
			ans = ans + count_odd[xor];
			count_odd[xor]++;
		}
		else {
			ans = ans + count_even[xor];
			count_even[xor]++;
		}
	}
	console.log(ans);
}

// reader and main caller

let readline = require('readline');

let rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

let inputBuf = [];
let inputBufCnt = 0;
let tk = []
let tkCnt = 0;

function nextLine() {
	return inputBuf[inputBufCnt++];
}
function next() {
	if(tkCnt == tk.length) {
		tk = inputBuf[inputBufCnt++].split(' ');
		tkCnt = 0;
	}
	return tk[tkCnt++];
}
function nextInt() {
	return parseInt(next());
}
function nextDouble() {
	return parseFloat(next());
}

rl.on('line', (line) => {
	inputBuf.push(line);
}).on('close', () => {
	main();
});

var n=readline();
var a=readline().split(' ');
a=a.slice(0,n);
var cnt= [];
cnt.length=2;
for(var k=0; k<2; k++){
    cnt[k] = [];
    cnt[k].length=(1<<20)+3;
    cnt[k].fill(0);
}

cnt[1][0]=1;
var res=0;
var x=0;
for(var i=0; i<n; ++i){
    x^=a[i];
    res+=cnt[i%2][x];
    ++cnt[i%2][x];
}

print(res);

var n=readline();
var a=readline().split(' ');
a=a.slice(0,n);
var cnt= [];
cnt.length=2;
for(var k=0; k<2; k++){
    cnt[k] = [];
    cnt[k].length=(1<<20)+3;
    cnt[k].fill(0);
}

cnt[1][0]=1;
var res=0;
var x=0;
for(var i=0; i<n; ++i){
    x^=a[i];
    res+=cnt[i%2][x];
    ++cnt[i%2][x];
    print(res);
}

print(res);


var n = +readline();
for(var i = 0; i < n; i++) {
  var k = +readline();
  var ans = Math.floor(k / 2) + 1;
  var temp = [];
  for(var j = 0, jj = 1; j < k; j++) {
    if(j % 2 === 0) {
      temp.push(ans);
      ans++;
      continue;
    }
    temp.push(jj);
    jj++;
  }
  print(temp.join(' '));
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

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

function evaluateBoard(board)
{

}

function main() {

    let t = parseInt(readLine());

    while(t--)
    {
        const n = parseInt(readLine());

        //let qas = readLine().split("");
        let toprint=[]
        if(n%2==1)
        {
            let cur_number = 1
            let diff_low = Math.floor(n/2)
            let diff_up = Math.ceil(n/2)
            for(let i=1;i<n+1;i++)
            {
                toprint.push(cur_number)
                if(i%2==0)
                    cur_number = cur_number - diff_low
                else
                    cur_number = cur_number + diff_up

            }
        }
        else
        {
            let cur_number = n/2
            let diff_low = n/2+1
            let diff_up = n/2
            for(let i=1;i<n+1;i++)
            {
                toprint.push(cur_number)
                if(i%2==0)
                    cur_number = cur_number - diff_low
                else
                    cur_number = cur_number + diff_up

            }
        }
        console.log(...toprint)

    }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn();
  const mid = Math.ceil(n / 2);
  let l = mid,
      r = n;
  const res = [];
  while (l > 0 && r > mid) {
    res.push(l--, r--);
  }
  if (n & 1) res.push(1);
  return res.join(' ');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var l1 = Number(readline());

    var result = process(l1);
    print(result);
}

function process(max) {
    var perm = [];
    var next = Math.floor(max / 2 + 1);

    for (var i = 0; i < max; i++) {
        var numToInsert = i + 1;
        if (numToInsert < next) {
            perm[(i * 2) + 1] = numToInsert;
        } else {
            perm[(numToInsert-next) * 2] = numToInsert;
        }
    }

    return perm.join(' ');
}

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j < Math.floor(k / 2); j++){
            s += (a + j) + ' ' + Number(j + 1) + ' '
        }
        if(k % 2 == 1){
            s += k;
        }
        console.log(s)
    }
});

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let n=parseInt(line[i]);
        let ans='';
        let a=new Array(n);
        let x;
        if(n&1) x=Math.floor((n+1)/2);
        else x=Math.floor((n+2)/2);
        let z=x;
        for(let i=0;i<n;i+=2) a[i]=z++;
        z=1;
        for(let i=1;i<n;i+=2) a[i]=z++;
        // for(let i=1;i<=n;i++) if(!(i&1)) ans+=i+' ';
        // for(let i=1;i<=n;i++) if(i&1) ans+=i+' ';
        for(let i=0;i<n;i++) ans+=a[i]+' ';
        console.log(ans);
    }
})

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t * 2; i++){
        var n = lines[i];
        var a = Math.floor(n / 2) + 1;
        var ans = '';
        for(j = 0; j < Math.floor(n / 2); j++){
            ans += (a + j) + ' ' + (j + 1) + ' ';
        }
        if(n % 2 == 1){
            ans += n;
        }
        console.log(ans);
    }
});

'use strict';

function solve(max) {
    const perm = [];
    const next = Math.floor(max / 2 + 1);

    for (let i = 0; i < max; i++) {
        const numToInsert = i + 1;
        if (numToInsert < next) {
            perm[(i * 2) + 1] = numToInsert;
        } else {
            perm[(numToInsert-next) * 2] = numToInsert;
        }
    }

    cl(perm.join(' '));
}

function main() {
    const numOfCases = rlsn();

    for (let testCase = 0; testCase < numOfCases; testCase++) {
        const l1 = rlsn();

        solve(l1);
    }
}

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

let inStr = '';
let curLine = 0;
const cl = console.log;

process.stdin.on('data', function(inStdin) {inStr += inStdin;});
process.stdin.on('end', function() {inStr = inStr.split('\n');main();});

function readline() {return inStr[curLine++].replace(/\s+$/g, '');}
function rlsn() {return Number(readline());}
function rlarrstr() {return readline().split(' ');}
function rlarrn() {return rlarrstr().map(Number);}
function makeFreqMap(str) {const m={};for (let char of str) m[char]=m[char]+1||1;return m;}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        output[i] = solve(n)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n) {
    const r = []
    if (n & 1) {
        // for (let i = 0; i < (n - 1) / 2; i++) {
        for (let i = (n - 1) / 2 - 1; i >= 0; i--) {
            r.push(i + 1, i + (n + 1) / 2)
        }
        // r.push((n + 1) / 2)
        r.push(n)
    } else {
        // for (let i = 0; i < n / 2; i++) {
        for (let i = n / 2 - 1; i >= 0; i--) {
            r.push(i + 1, i + n / 2 + 1)
        }
    }
    return r.join(' ')
}

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j < Math.floor(k / 2); j++){
            s += (a + j) + ' ' + Number(j + 1) + ' '
        }
        if(n % 2 == 1){
            s += k;
        }
        console.log(s)
    }
});

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j <= Math.floor(k / 2); j++){
            s += (a + j) + ' ' + Number(j + 1) + ' '
        }

        console.log(s)
    }
});

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j < Math.floor(k / 2); j++){
            s += (a + j) + ' ' + Number(j + 1) + ' '
        }

        console.log(s)
    }
});

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j < Math.floor(k / 2); j++){
            s += (a + j) + ' ' + j + 1 + ' '
        }

        console.log(s)
    }
});

let ryan = '';//.map(saer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(i = 1; i <= n * 2; i++){
        var k = lines[i], a = Math.floor(k / 2) + 1, s = ''
        for(j = 0; j < Math.floor(k / 2); j++){
            s += (a + j) + ' ' + j + ' '
        }

        console.log(s)
    }
});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var k = lines[j]
        e = ''
        for(l = 1; l <= k; l++){
            e += l + ' '
        }
        console.log(e)
    }

});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var k = lines[j], e = ''
        for(j = 1; j <= k; j++){
            e += j + ' '
        }
        console.log(e)
    }

});

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let n=parseInt(line[i]);
        let ans='';
        let a=new Array(n);
        let x=Math.floor((n+1)/2);
        let z=x;
        for(let i=0;i<n;i+=2) a[i]=z++;
        z=1;
        for(let i=1;i<n;i+=2) a[i]=z++;
        // for(let i=1;i<=n;i++) if(!(i&1)) ans+=i+' ';
        // for(let i=1;i<=n;i++) if(i&1) ans+=i+' ';
        for(let i=0;i<n;i++) ans+=a[i]+' ';
        console.log(ans);
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let n=parseInt(line[i]);
        let ans='';
        for(let i=1;i<=n;i++) if(!(i&1)) ans+=i+' ';
        for(let i=1;i<=n;i++) if(i&1) ans+=i+' ';
        console.log(ans);
    }
})

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var a = lines[0].split(' ').map(Number);
    var months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var n = a[0], m = a[1];
    if(months[n] == 31){
        console.log(m > 5 ? 6 : 5);
    }else if(months[n] == 30){
        console.log(m == 7 ? 6 : 5);
    }else{
        console.log(m == 1  ? 4 : 5);
    }
});

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var l1 = Number(readline());

    var result = process(l1);
    print(result);
}

function process(max) {
    var perm = [];
    var next = Math.ceil(max / 2 + 1);

    for (var i = 0; i < max; i++) {
        var numToInsert = i + 1;
        if (numToInsert < next) {
            perm[i * 2] = numToInsert;
        } else {
            perm[(numToInsert - next) * 2 + 1] = numToInsert;
        }
    }

    return perm.join(' ');
}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var l1 = Number(readline());

    var result = process(l1);
    print(result);
}

function process(max) {
    const perm = [];
    var l = 0, r = max - 1;

    var midIndex = Math.floor(max / 2);
    perm[midIndex] = 1;

    var ml = midIndex - 1,
        mr = midIndex + 1;

    for (var i = 2; i <= max; i++) {
        if ((i + 4) % 4 === 2) {
            perm[l] = i;
            l++;
        } else if ((i + 4) % 4 === 3) {
            perm[r] = i;
            r--;
        } else if ((i + 4) % 4 === 0) {
            perm[ml] = i;
            ml--;
        } else if ((i + 4) % 4 === 1) {
            perm[mr] = i;
            mr++;
        }
    }

    return perm.join(' ');
}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var l1 = Number(readline());

    var result = process(l1);
    print(result);
}

function process(max) {
    const perm = [];
    var l = 0, r = max - 1;

    var midIndex = Math.floor(max / 2);
    perm[midIndex] = 1;

    var ml = midIndex - 1,
        mr = midIndex + 1;

    for (var i = 2; i <= max; i++) {
        if ((i + 4) % 4 === 2) {
            perm[l] = i;
            l++;
        } else if ((i + 4) % 4 === 3) {
            perm[r] = i;
            r--;
        } else if ((i + 4) % 4 === 0) {
            perm[ml] = i;
            ml--;
        } else if ((i + 4) % 4 === 1) {
            perm[mr] = i;
            mr++;
        }
    }
    print(perm)

    return perm.join(' ');
}