var t = +readline();

for(var i = 0; i < t; i++) {
    var input = readline().split(' ').map(Number);
    var area = input[0] * input[1];
    var n = input[2];
    var c = 1;

    while(area % 2 === 0) {
        c *= 2;
        area /= 2;
    }

    print((c >= n) ? 'YES' : '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++];
}

function main() {
  const x = readline();

  for (let i = 0; i < x; i++) {
    let t = readline();
    let [w, h, n] = t.split(' ');
    let ans = 1;

    while (w % 2 === 0) {
      w /= 2;
      ans *= 2;
    }

    while (h % 2 === 0) {
      h /= 2;
      ans *= 2;
    }

    console.log(ans >= n ? 'yes' : 'no');

  }
}

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL).filter((line) => line);
    console.log(processInput(lines));
});

const getNOf2Factors = (number) => {
    let nOf2Factors = 0;
    while (number % 2 === 0) {
        nOf2Factors++;
        number /= 2;
    }
    return nOf2Factors;
};

const processInput = (lines) => {
    return lines
        .slice(1)
        .map((line) => line.split(' '))
        .map(([w, h, n]) => {
            return Math.pow(2, getNOf2Factors(w) + getNOf2Factors(h)) >= n ? 'YES' : 'NO';
        })
        .join('\n');
};

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var found = false;
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var answer = 1;
        while(a % 2 === 0){
            answer *= 2;
            a /= 2;
        }
        while(b % 2 === 0){
            answer *= 2;
            b /= 2;
        }
        if(c <= answer){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
});

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let [w, h, n] = nl.nums();
		let a = 0;
		let b = 0;
		while(w%2 == 0) {
			a++;
			w = Math.round(w/2);
		}
		while(h%2 == 0) {
			b++;
			h = Math.round(h/2);
		}
		var x = Math.pow(2, a) * Math.pow(2, b);

		ans.push(x >= n);

	}
	console.log(ans.map(e => e?'YES':'NO').join('\n'));
};

process.stdin.on('end', sol);

const { EOL } = require('os')
let i = ''
process.stdin.on('data', c => (i += c))
process.stdin.on('end', () => {
  const lines = i.split(EOL).filter(line => line)
  console.log(processInput(lines))
})

const getNOf2Factors = number => {
  let nOf2Factors = 0
  while (number % 2 === 0) {
    nOf2Factors++
    number /= 2
  }
  return nOf2Factors
}

const processInput = lines => {
  return lines
    .slice(1)
    .map(line => line.split(' '))
    .map(([w, h, n]) =>
      Math.pow(2, getNOf2Factors(w) + getNOf2Factors(h)) >= n ? 'YES' : 'NO'
    )
    .join(EOL)
}

const cards = (w, h, n) => {
  let count = 0;
  let mul = w * h;
  while (mul % 2 == 0) {
    count++;
    mul = Math.floor(mul / 2);
  }
  return Math.pow(2, count) >= n;
};

const main = () => {
  let test = parseInt(readline());
  while (test--) {
    const [w, h, n] = readline()
      .split(" ")
      .map(s => parseInt(s));
    if (cards(w, h, n)) console.log("YES");
    else console.log("NO");
  }
};

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 => string.trim());
  main();
});

const readline = () => {
  return inputString[currentLine++];
};

// 1/13/21
//https://codeforces.com/problemset/problem/1472/A

const readline = require("readline");
const leScan = new readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

let inputNum = 0;
leScan.on("line", (input) => {
	if (inputNum == 0)
	{
		inputNum = 1;
	}
	else
	{
		var meetsN = calcPieces(...input.split(" "));

		if (meetsN)
		{
			console.log("YES");
		}
		else
		{
			console.log("NO");
		}
	}
});

/* If the paper we cut for the width will equal w, every value in w can be cut h times. Hence, the total cut is w*h.
*/
const calcPieces = (w, h, n) => {
	let numW = numCuts(+w);
	let numH = numCuts(+h);

	return numW * numH >= +n;
}

//A cut multiplies the paper amount by 2 since we're repeating it for every single piece of cut paper. Hence, 2^i.
//As a demo, 1*2 = 2 paper, 2 paper each * 2 = 4 paper, 4 paper each * 2 = 8 paper... so on. It's exponential
const numCuts = (num) => {
	let i;

	for (i = 0; num % 2 == 0; i++)
	{
		num = num / 2;
	}

	return Math.pow(2, i);
}

'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 a = getStrArray(readline());
        let result = 1;
        while(a[0]%2 == 0) {
            result *=2;
            a[0] = a[0]/2;
        }

        while (a[1] % 2 == 0) {
            result *= 2;
            a[1] = a[1] / 2;
        }
        if(result >= a[2]) {
            console.log('YES');
        } else {
            console.log('NO');
        }
    }
}

const solve = (w, h, n) => {
    let cnt = 0;
    while (w % 2 == 0 || h % 2 == 0) {
        if (2 ** cnt >= n) return console.log('YES');
        if (w % 2 == 0) {
            w /= 2;
            cnt++;
        }
        if (h % 2 == 0) {
            h /= 2;
            cnt++;
        }
    }
    if (2 ** cnt >= n) return console.log('YES');
    console.log('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 = input[0][0];
        let i = 1;
        while (t--) {
            let data = input[i];
            solve(data[0], data[1], data[2]);
            i++;
        }
    });
};

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--) {
		let [a, b, c] = readLine().split(' ').map(Number);
		if (a % 2 !== 0 && b % 2 !== 0 && c > 1) {
			console.log('NO');
		} else {
			let count = 1;
			while ((a && a % 2 === 0) || (b && b % 2 === 0)) {
				count *= 2;
				if (a % 2 === 0) a = Math.floor(a / 2);
				else if (b % 2 === 0) b = Math.floor(b / 2);
			}
			if (count >= c) console.log('YES');
			else console.log('NO');
		}
	}
}

function solve(input) {
    // TYPE YOUR BUGS HERE...
    let [w, h, n] = input.split(' ').map(i => parseInt(i));
    let res = 1;
    while (w % 2 === 0) {
        res *= 2
        w = w / 2;
    }

    while (h % 2 === 0) {
        res *= 2
        h = h / 2;
    }

    console.log(res >= n ? 'YES' : 'NO');
}

/** =========== DEFAULT FORMAT ==============
 *
 * use this format to solve problem that use 1 line input per testcase
 *
**/
const readline = require('readline').createInterface({ input: process.stdin });

let i = 1;
let t = 0;
readline.on('line', line => {
    if (i == 1) {
        // number of test case
        t = parseInt(line)
        i++;
    } else {
        solve(line)
        if (i <= t) i++
        else readline.close()
    }
});

/**
 * =========== DEFAULT FORMAT END ==============
 * */

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

// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        // var n = Number(readline());
        var [w, h, n] = readline().split(' ').map(x => Number(x));
        if (n === 1) return console.log('YES')
        var ans = 1
        var pow = 1
        var i = w * h
        while (i % 2 !== 1) {
            ans += pow
            pow *= 2
            i = i / 2
        }
        // console.log(ans)

        if (ans >= n) return console.log('YES')

        console.log('NO')
    })

}

let i = '';
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);

    const t = parseInt(lines[0]);

    for (let i = 1; i <= t; i++) {
        const split = lines[i].split(' ');
        const w = parseInt(split[0]);
        const h = parseInt(split[1]);
        const n = parseInt(split[2]);

        console.log(solve(w, h, n));
    }
});

function solve(w, h, n) {
    let count = 1;

    while (w % 2 === 0 && count < n) {
        count *= 2;
        w = Math.floor(w / 2);
    }

    while (h % 2 === 0 && count < n) {
        count *= 2;
        h = Math.floor(h / 2);
    }

    return count >= n ? 'YES' : 'NO';
}

var t = readline();
for(var i=0;i<t;i++)
{
    var inp = readline().split(" ");
    var w = Number(inp[0]);
    var h = Number(inp[1]);
    var n = Number(inp[2]);
    var k=1;
    while(w % 2 === 0){
        w = w/2;
        k =k*2;
    }
    while(h % 2 === 0)
    {
        h=h/2;
        k=k*2;
    }
    // print(k);
    if(k>=n){
        print("YES");
    }
    else{
        print("NO");
    }
}

test = readline();
while (test--) {
  input = readline()
    .split(" ")
    .map((x) => +x);
  h = input[0];
  w = input[1];
  n = input[2];
  result = 1;
while (h % 2===0) {
    h /= 2;
    result*=2;
  }
  while (w % 2===0) {
    w /= 2;
    result*=2;
  }
  print(result >= n ? "YES" : "NO");
}

var t = Number(readline());

while (t--) {
    var a = readline().split(" ");
    var w = Number(a[0]);
    var h = Number(a[1]);
    var n = Number(a[2]);
    var pieces = 1;

        while (h % 2 == 0) {
            h /= 2;
            pieces *= 2;
        }
        while (w % 2 == 0) {
            w /= 2;
            pieces *= 2;
        }
    pieces >= n ? print("YES") : print("NO");

    }

t = readline()

while(t--) {
	a = readline().split(' ').map(x => +x)
	w = a[0]
	h = a[1]
	n = a[2]

	ans = 1

	if (ans>=n) {
		print('YES')
	}
	else {
		while (w % 2 == 0) {
			ans*=2
			w/=2
		}

		while(h%2==0){
			ans*=2
			h/=2
		}

		if(ans>=n){
			print('YES')
		}
		else{
			print('NO')
		}
	}
}

"use strict"

let iter = parseInt(readline());

for(let i = 0; i < iter; i++){
    let input = readline().split(" ").map(x => parseInt(x));
    let w = input[0];
    let h = input[1];
    let n = input[2];
    let counter = 1;

    while(w % 2 === 0){
        w /= 2;
        counter *= 2;
    }
    while(h % 2 === 0){
        h /= 2;
        counter *= 2;
    }

    if(counter >= n){
        print("YES");
    } else {
        print("NO");
    }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  /***********/
  // string array to number array
  const numArray = (a) => a.split(" ").map((line) => +line);
  const isEven = (a) => (a % 2 == 0 && a > 1 ? true : false);

  // number of test case input
  const tc = readLine();

  // input line
  for (let i = 0; i < tc; i++) {
    const ln1 = numArray(readLine());
    // const ln2 = readLine();
    // const ln3 = readLine();
    // const ln4 = readLine();
    // const ln5 = readLine();
    cards(ln1);
  }
  /************************Solution****************************************/
  function cards([w, h, n]) {
    let c = 1;

    while (w % 2 == 0) {
      w /= 2;
      c *= 2;
    }
    while (h % 2 == 0) {
      h /= 2;
      c *= 2;
    }

    console.log(c >= n || n == 1 ? "Yes" : "No");
    // console.log(c, n);
  }
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  let [w, h, n] = d.split(' ').map(Number);
  let ans = 1;
  let inc = 1;

  while (w % 2 === 0) {
    w /= 2;
    ans += inc;

    if (inc === 1) {
      inc++;
    }
    else {
      inc *= 2;
    }
  }

  while (h % 2 === 0) {
    h /= 2;
    ans += inc;

    if (inc === 1) {
      inc++;
    }
    else {
      inc *= 2;
    }
  }

  if (ans >= n) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

const write = out => process.stdout.write(out + `\n`);

const mainCode = ([l1]) => {
	let [w, h, n] = l1.split(' ').map(Number);
	let total = 1;

	let factor = 1;

	while (w % 2 == 0 || h % 2 == 0) {
		let add = 0;
		if (w % 2 == 0) {
			add += factor;
			factor *= 2;
			w /= 2;
		}
		if (h % 2 == 0) {
			add += factor;
			factor *= 2;
			h /= 2;
		}

		total += add;
	}

	const answer = total >= n ? 'YES' : 'NO';
	write(answer)
}

let counter = 0;
let t = 0;
const t_size = 1;

const cases = [];

const lineInterpreter = (line) => {
	if (counter == 0) t = Number(line)
	else {
		const cursor = (counter - 1) % t_size
		if (cursor == 0) cases.push([line])
		else cases[cases.length - 1].push(line)
	}

	if (counter == (t * t_size)) {
		cases.map(_case => mainCode(_case))
	}
	counter++
}

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

	inputString.map(line => lineInterpreter(line));
});

// For personal use

// const sample = `5
// 2 2 3
// 3 3 2
// 5 10 2
// 11 13 1
// 1 4 4`;
// sample.split(`\n`).map(line => lineInterpreter(line));

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", inputStdin => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});
function readline() {
    return inputString[currentLine++];
}

// var ar = readline().split(' ').map(n => parseInt(n));

//-----------main function-----------

function main() {

    var t = parseInt(readline());

    while (t--) {
        var ar = readline().split(' ').map(n => parseInt(n));
        var w = ar[0];
        var h = ar[1];
        var n = ar[2];
        var total = 1;

        while (w % 2 == 0) {
            total *= 2;
            w = w / 2;
        }
        while (h % 2 == 0) {
            total *= 2;
            h = h / 2;
        }

        //   total = hn + wn;

        if (total >= n) {
            print('YES');
        } else {
            print('NO');
        }

    }

}

const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const sheet = input.slice(1).map(val => val.split(" ").map(v => Number(v)));

    for(let idx in sheet) {
        let piece = 1;
        let w = sheet[idx][0];
        let h = sheet[idx][1];
        let friend = sheet[idx][2];

        while(w % 2 === 0) {
            piece *= 2;
            w /= 2;
        }

        while(h % 2 === 0) {
            piece *= 2;
            h /= 2;
        }

        if(piece >= friend) 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 = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//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();
	for(var i = 0; i < t; i++){
		var W = nextInt();
		var H = nextInt();
		var N = nextInt();
		var wcount = 1;
		var hcount = 1;
		while(W % 2 == 0){
			wcount *= 2;
			W /= 2;
		}
		while(H % 2 == 0){
			hcount *= 2;
			H /= 2;
		}
		myout((hcount * wcount >= N) ? "YES" : "NO");
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        // taking and assingn variables...
        let [w, h, n] = input[z++].split(' ').map(x=>Number(x));
        // intialing out counter variable which will count the division..
        let counter;
        counter = 0;
        // chacking how many times can we divide width and height
        while (w % 2 != 1) {
            w /= 2;
            counter++;
        }
        while (h % 2 != 1) {
            h /= 2;
            counter++;
        }
        // checking the edge cases and making our final output
        console.log((Math.pow(2,counter) >= n || n == 1) ? "YES": "NO");
    }
}

const { EOL } = require('os');

let input = '';
process.stdin.on('data', data => input += data);
process.stdin.on('end', main);

function main() {
    const lines = input.split(EOL);
    for (let i = 1; i < lines.length - 1; i++) {
        let dim = lines[i].split(' ');
        canCut(+dim[0], +dim[1], +dim[2]);
    }
}

function canCut(w, h, n) {
    let sum = 1;
    while (sum < n) {
        if (w % 2 == 0) {
            w /= 2;
            sum *= 2;
        } else if (h % 2 == 0) {
            h /= 2;
            sum *= 2;
        } else {
            console.log("NO");
            return;
        }
    }
    console.log("YES");
    return;
}

var t = readline();
for(var i=0;i<t;i++)
{
    var inp = readline().split(" ");
    var w = Number(inp[0]);
    var h = Number(inp[1]);
    var n = Number(inp[2]);
    var k=0;
    while(w % 2 === 0){
        w = w/2;
        k+=1;
    }
    while(h % 2 === 0)
    {
        h=h/2;
        k+=1;
    }
    if(k>=n){
        print("YES");
    }
    else{
        print("NO");
    }
}

test = readline();
while (test--) {
  input = readline()
    .split(" ")
    .map((x) => +x);
  h = input[0];
  w = input[1];
  n = input[2];
  result = 1;
while (h % 2===0) {
    h /= 2;
    result+=2;
  }
  while (w % 2===0) {
    w /= 2;
    result+=2;
  }
  print(result >= n ? "YES" : "NO");
}

var t = +readline();

for(var i = 0; i < t; i++) {
    var input = readline().split(' ').map(Number);
    var area = input[0] * input[1];
    var n = input[2];
    var c = 0;

    while(area % 2 === 0) {
        c += 2;
        area /= 2;
    }

    print((c >= n) || (n === 1) ? 'YES' : 'NO');
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  /***********/
  // string array to number array
  const numArray = (a) => a.split(" ").map((line) => +line);
  const isEven = (a) => (a % 2 == 0 && a > 1 ? true : false);

  // number of test case input
  const tc = readLine();

  // input line
  for (let i = 0; i < tc; i++) {
    const ln1 = numArray(readLine());
    // const ln2 = readLine();
    // const ln3 = readLine();
    // const ln4 = readLine();
    // const ln5 = readLine();
    cards(ln1);
  }
  /************************Solution****************************************/
  function cards([w, h, n]) {
    let c = 0;
    let s = w * h;

    while (isEven(s)) {
      c += 2;
      s /= 2;
    }
    if (!isEven(w) && !isEven(h)) c = 1;

    console.log(c >= n || n == 1 ? "yes" : "no");
    // console.log(c, n);
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const n = readLine();

  function isPossible([w, h, n]) {
    let output = 1;
    w = parseInt(w);
    h = parseInt(h);
    n = parseInt(n);
    // if (n == 1) return "yes";
    // if (w % 2 !== 0 && h % 2 !== 0) return "no";

    while (w % 2 === 0) {
      output *= w;
      w = w / 2;
    }
    while (h % 2 === 0) {
      output *= h;
      h = h / 2;
    }

    // console.log(w, h, n, output);
    return n <= output ? "yes" : "no";
  }

  for (let i = 0; i < n; i++) {
    console.log(isPossible(readLine().split(" ")));
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const n = readLine();

  function isPossible([w, h, n]) {
    let output = 0;
    w = parseInt(w);
    h = parseInt(h);
    n = parseInt(n);
    if (n == 1) return "yes";
    if (w % 2 !== 0 && h % 2 !== 0) return "no";

    while (w % 2 === 0) {
      output += w;
      w = w / 2;
    }
    while (h % 2 === 0) {
      output += h;
      h = h / 2;
    }

    // console.log(w, h, n, output);
    return n <= output ? "yes" : "no";
  }

  for (let i = 0; i < n; i++) {
    console.log(isPossible(readLine().split(" ")));
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const n = readLine();

  function isPossible([w, h, n]) {
    let output = 0;
    w = parseInt(w);
    h = parseInt(h);
    n = parseInt(n);
    if (n == 1) return "yes";
    if (w % 2 !== 0 && h % 2 !== 0) return "no";

    if (w % 2 === 0) {
      output += w;
    }
    if (h % 2 === 0) {
      output += h;
    }
    return n <= output ? "yes" : "no";
  }

  for (let i = 0; i < n; i++) {
    console.log(isPossible(readLine().split(" ")));
  }
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  let [w, h, n] = d.split(' ').map(Number);
  let ans = 1;
  let incW = 1;
  let incH = 1;

  while (w % 2 === 0) {
    w /= 2;
    ans += incW;

    if (incW === 1) {
      incW++;
    }
    else {
      incW *= 2;
    }
  }

  while (h % 2 === 0) {
    h /= 2;
    ans += incH;

    if (incH === 1) {
      incH++;
    }
    else {
      incH *= 2;
    }
  }

  if (ans >= n) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  let [w, h, n] = d.split(' ').map(Number);
  let ans = 1;
  let incW = 1;
  let incH = 1;

  while (w % 2 === 0) {
    w /= 2;
    incW *= 2;
    ans += incW;
    incW++;
  }

  while (h % 2 === 0) {
    h /= 2;
    incH *= 2;
    ans += incH;
    incH++;
  }

  if (ans >= n) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  let [w, h, n] = d.split(' ').map(Number);
  let ans = 1;

  while (w % 2 === 0) {
    w /= 2;
    ans++;
  }

  while (h % 2 === 0) {
    h /= 2;
    ans++;
  }

  ans **= 2;

  if (ans >= n) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var found = 0;
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        if(k[j] == 3){
            found++
        }
        if(j == n - 1){
            if(found >= 2){
                console.log('YES')
            }else{
                console.log('NO')
            }
        }
    }

});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var found = 0;
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        if(k[j] == 3){
            found++
        }
        if(j == n){
            if(found >= 2){
                console.log('YES')
            }else{
                console.log('NO')
            }
        }
    }

});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var s = 0
    var p = 0
    for(j = 1; j<= lines[0]; j++){
        var a = lines[j]
        var w = a[0]
        var h = a[1]
        var n = a[2]
        if(w % 2 === 0){
            s = w/2 * h
            p++
        }if(h % 2 === 0){
            s = w * h/2
            p++
        }
        if(p > n){
            console.log('YES')
        }else{
            console.log('NO')
        }
    }
});

const write = out => process.stdout.write(out + `\n`);

const mainCode = ([l1]) => {
	let [w, h, n] = l1.split(' ').map(Number);
	let total = 1;

	let factor = 1;

	while (w % 2 == 0 || h % 2 == 0) {
		let add = 0;
		if (w % 2 == 0) {
			add += factor;
			factor *= 2;
			w /= 2;
		}
		if (h % 2 == 0) {
			add += factor;
			factor *= 2;
			h /= 2;
		}

		total += add;
	}

	const answer = total >= n ? 'YES' : 'NO';
	write(total)
}

let counter = 0;
let t = 0;
const t_size = 1;

const cases = [];

const lineInterpreter = (line) => {
	if (counter == 0) t = Number(line)
	else {
		const cursor = (counter - 1) % t_size
		if (cursor == 0) cases.push([line])
		else cases[cases.length - 1].push(line)
	}

	if (counter == (t * t_size)) {
		cases.map(_case => mainCode(_case))
	}
	counter++
}

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

	inputString.map(line => lineInterpreter(line));
});

// For personal use

// const sample = `5
// 2 2 3
// 3 3 2
// 5 10 2
// 11 13 1
// 1 4 4`;
// sample.split(`\n`).map(line => lineInterpreter(line));

const write = out => process.stdout.write(out + `\n`);

const mainCode = ([l1]) => {
	let [w, h, n] = l1.split(' ').map(Number);
	let total = 1;

	let factor = 1;

	while (w % 2 == 0 || h % 2 == 0) {
		let add = 0;
		if (w % 2 == 0) {
			add += factor;
			factor *= 2;
			w /= 2;
		}
		if (h % 2 == 0) {
			add += factor;
			factor *= 2;
			h /= 2;
		}

		total += add;
	}

	const answer = total >= n ? 'YES' : 'NO';
	write(total)
}

let counter = 0;
let t = 0;
const t_size = 1;

const cases = [];

const lineInterpreter = (line) => {
	if (counter == 0) t = Number(line)
	else {
		const cursor = (counter - 1) % t_size
		if (cursor == 0) cases.push([line])
		else cases[cases.length - 1].push(line)
	}

	if (counter == (t * t_size)) {
		cases.map(_case => mainCode(_case))
	}
	counter++
}

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

// 	inputString.map(line => lineInterpreter(line));
// });

// For personal use

const sample = `5
2 2 3
3 3 2
5 10 2
11 13 1
1 4 4`;
sample.split(`\n`).map(line => lineInterpreter(line));

const mainCode = ([l1]) => {
	let [w, h, n] = l1.split(' ').map(Number);
	let total = 1;

	let w_factor = 1, h_factor = 1;

	while (w % 2 == 0 || h % 2 == 0) {
		let add = 0;
		if (w % 2 == 0) {
			add += w_factor;
			w_factor *= 2;
			w /= 2;
		}
		if (h % 2 == 0) {
			add += h_factor;
			h_factor *= 2;
			h /= 2;
		}

		total += add;
	}

	// console.log(total >= n ? 'YES' : 'NO');
	process.stdout.write(total >= n ? 'YES' : 'NO')
	process.stdout.write(`\n`)
}

/************* KEEP BELOW CODE AS IT IS *********************/
/**
 * This code has been taken from: https://codeforces.com/blog/entry/69610
 * I am not the owner of the readLine function below, understanding them require knowledge of basic NodeJS I/O and streams
 */
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();
});

/****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION   ***************************************/
/**
 * Use "readLine()" function for input, which will return a string consisting the entire line, so accordingly split the string
 * when required.
 *
 * I am using console.log() to output
 */
const main = () => {
	let counter = 0;
	let t = 0;
	const t_size = 1;

	const cases = [];

	const lineInterpreter = (line) => {
		if (counter == 0) t = Number(line)
		else {
			const cursor = (counter - 1) % t_size
			if (cursor == 0) cases.push([line])
			else cases[cases.length - 1].push(line)
		}

		if (counter == (t * t_size)) {
			cases.map(_case => mainCode(_case))
		}
		counter++
	}

	// For CODEFORCES submission
	inputString.map(line => lineInterpreter(line));

	// For personal use

	// const sample = `5
	// 2 2 3
	// 3 3 2
	// 5 10 2
	// 11 13 1
	// 1 4 4`;
	// sample.split(`\n`).map(line => lineInterpreter(line));
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", inputStdin => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});
function readline() {
    return inputString[currentLine++];
}

// var ar = readline().split(' ').map(n => parseInt(n));

//-----------main function-----------

function main() {

    var t = parseInt(readline());

while (t--) {
  var ar = readline().split(' ').map(n => parseInt(n));
  var w = ar[0];
  var h = ar[1];
  var n = ar[2];
  var hn=0, wn=0, total;

  var res;

  while (w % 2 == 0) {
    wn = wn + w / 2 + 1;
    w = w / 2;
  }
  while (h % 2 == 0) {
    hn = hn + h / 2 + 1;
    h = h / 2;
  }

  total = hn + wn;

  if (total >= n) {
    res = 'YES';
  } else {
    res = 'NO';
  }

  console.log(res);
}

}

const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const sheet = input.slice(1).map(val => val.split(" ").map(v => Number(v)));

    for(let idx in sheet) {
        let piece = 1;
        let w = sheet[idx][0];
        let h = sheet[idx][1];
        let friend = sheet[idx][2];

        while(piece < friend) {
            if(w % 2 === 0) {
                piece += w === sheet[idx][0] ? 1 : 2;
                w /= 2;
            } else if(h % 2 === 0) {
                piece+= h === sheet[idx][1] ? 1 : 2;
                h /= 2;
            } else if(w % 2 !== 0 && h % 2 !== 0) break;
        }

        if(piece >= friend) console.log("YES");
        else console.log("NO");
    }
}

const { RSA_X931_PADDING } = require("constants");
const { maxHeaderSize } = require("http");
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const sheet = input.slice(1).map(val => val.split(" ").map(v => Number(v)));

    for(let idx in sheet) {
        let piece = 1;
        let w = sheet[idx][0];
        let h = sheet[idx][1];
        let friend = sheet[idx][2];

        while(piece < friend) {
            if(w % 2 === 0) {
                piece += w === sheet[idx][0] ? 1 : 2;
                w /= 2;
            } else if(h % 2 === 0) {
                piece+= w === sheet[idx][1] ? 1 : 2;
                h /= 2;
            } else if(w % 2 !== 0 && h % 2 !== 0) break;
        }

        if(piece >= friend) 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 = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//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();
	for(var i = 0; i < t; i++){
		var W = nextInt();
		var H = nextInt();
		var N = nextInt();
		var count = 1;
		var wcount = 1;
		var hcount = 1;
		while(W % 2 == 0){
			count += wcount;
			wcount *= 2;
			W /= 2;
		}
		while(H % 2 == 0){
			count += hcount;
			hcount *= 2;
			H /= 2;
		}
		myout((count >= N) ? "YES" : "NO");
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//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();
	for(var i = 0; i < t; i++){
		var W = nextInt();
		var H = nextInt();
		var N = nextInt();
		var count = 1;
		var wcount = 1;
		var hcount = 1;
		while(W % 2 == 0){
			count += wcount;
			wcount++;
			W /= 2;
		}
		while(H % 2 == 0){
			count += hcount;
			hcount++;
			H /= 2;
		}
		myout((count >= N) ? "YES" : "NO");
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        // taking and assingn variables...
        let [w, h, n] = input[z++].split(' ').map(x=>Number(x));
        // intialing out counter variable which will count the division..
        let counter = 0;
        // chacking how many times can we divide width and height
        while (w % 2 !== 1) {
            w /= 2;
            counter++;
        }
        while (h % 2 !== 1) {
            h /= 2;
            counter++;
        }
        // checking the edge cases and making our final output
        console.log(((counter * 2 >= n) || n == 1) ? "YES": "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++];
}

function main() {
  const x = readline();

  for (let i = 0; i < x; i++) {
    let t = readline();
    let [w, h, n] = t.split(' ');
    let ans = 1;

    while (w % 2 === 0) {
      w /= 2;
      ans *= 2;
    }

    while (h % 2 === 0) {
      h /= 2;
      ans *= 2;
    }

    console.log(ans);
    console.log(ans >= n ? 'yes' : 'no');

  }
}

let i = '';
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL).filter((line) => line);
    console.log(processInput(lines));
});

const getNOf2Factors = (number) => {
    let nOf2Factors = 0;
    while (number % 2 === 0) {
        nOf2Factors++;
        number /= 2;
    }
    return nOf2Factors;
};

const processInput = (lines) => {
    return lines
        .slice(1)
        .map((line) => line.split(' '))
        .map(([w, h, n]) => {
            return Math.pow(2, getNOf2Factors(w) + getNOf2Factors(h)) >= n ? 'YES' : '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");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return 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 one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var list = nextIntArray();
  var count = 0;
  for(var i = 0; i < N; i++){
    if(list[i] <= 5 - K){
      count++;
    }
  }
  myout(Math.floor(count / 3));
}

var s = readline().split(" ");
var str = readline().split(" ");
var temp=0; var res = 0;

	for (var i=0; i<+s[0]; i++){
		if(+str[i]+Number(s[1])<=5){
			temp++;
			if (temp%3==0){
				res++
			}
		}
	}
	print(res);

var s = readline().split(' ');
var n = Number(s[0]), k = Number(s[1]);
var people = readline().split(' ').map(Number);

var team = 0;
var teamMate = 0;

for (var i=0; i<people.length; i++) {
    if (people[i] + k <= 5) {
        teamMate++;
    }
    team = Math.floor(teamMate/3);
}

print(team);

if (!this.readline) print = console.log, readline = require('./readline');

function readNums() {
	return readline().split(' ').map(Number);
}

print(function(n, k) {

	return Math.floor(readNums().filter(function(v) {
		return v <= 5 - k;
	}).length / 3);

}.apply(0, readNums()));

if (!this.readline) print = console.log, readline = require('./readline');

function readNums() {
	return readline().split(' ').map(Number);
}

print(function(n, k) {
	k = 5 - k;
	var a = readNums();
	var x = 0;

	for (var i = 0; i < a.length; i++)
		if (a[i] <= k) x++;

	return Math.floor(x / 3);

}.apply(0, readNums()));

var input = readline().split(" "), n = +input[0], k = +input[1], y = readline().split(" ").filter(function(a){return ((+a + k) <= 5)});

write(Math.floor(y.length/3));

"use strict";

var input = readline().split(' ').map(value => +value);
var n = input[0];
var k = input[1];
var y = readline().split(' ').map(value => +value);

var result = 0;
for (var i = 0; i < y.length; ++i) {
   result += y[i] + k <= 5;
}

write(~~(result/3));

var read_ =readline();
var read_2 = readline();
var n=read_.split(" ")[0],
k=read_.split(" ")[1],
a=read_2.split(" "),
b=0 ;
    	for	(var i = 0; i<n; i++) {
    		if	(a[i]<=5-k) b++;
    	}
    	print(Math.floor(b/3));

X=readline().split(' ').map(Number)
n=X[0],k=X[1]
print(Math.floor(readline().split(' ').map(Number).filter(x => 5-x>=k).length/3))

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		numPeople = data[0], minTimes = data[1],
		people = tokenizeIntegers(readline());
	people.sort(function(a, b) {
		return a-b;
	});
	var teamCount = 0,
		teamSize = 0;
	for (var i = 0; i < people.length; ++i) {
		var previous = people[i];
		if (previous + minTimes > 5) {
			break;
		}
		if (++teamSize == 3) {
			++teamCount;
			teamSize = 0;
		}
	}
	print(teamCount);
}

main();

var tokenizer;
var index = 0;

function next(){
    while(tokenizer == null || index == tokenizer.length){
        tokenizer = readline().split(" ");
        index = 0;
    }
    var res = tokenizer[index++];
    return res;
}

function nextInt(){
    return parseInt(next());
}

function nextFloat(){
    return parseFloat(next());
}

function solve(){
    var n = nextInt();
    var k = nextInt();
    var a = [];
    for(var i = 0; i < n; ++i){
        a.push(nextInt());
    }
    a.sort();
    var res = 0;
    for(var i = 2; i < n; i += 3){
        if(5 - a[i] >= k){
            ++res;
        }
    }
    print(res);
}
solve();

var nk=readline().split(' ').map(function(x){return parseInt(x);});
var p=readline().split(' ').map(function(x){return parseInt(x);});
var ans=0;
for(var i= 0;i<nk[0];i++)
{
    if(5-p[i]>=nk[1])ans++;
}
print(parseInt(ans/3));

'use strict'

String.prototype.getNumber = function() {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  })[0];
};
String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  let array_1 = readline().getNumArray(),
      k = array_1[1],
      array_2 = readline().getNumArray(),
      counter = 0;

  for (let i = 0; i < array_2.length; i++) {
    if (5 - k >= array_2[i] ) {
      counter++;
    }
  }
  write(parseInt(counter/3));
})();

var inputInfo = readline().split(' ').map(Number);
var inputTeam = readline().split(' ').map(Number);
var numofApproved = 0;
for (var i=0; i<inputInfo[0]; i++) {
    if ((inputTeam[i] + inputInfo[1]) <= 5) {
        numofApproved = numofApproved + 1;
        }
};
    var numofTeams = Math.floor(numofApproved / 3);
print(numofTeams);

if (!readline) {
    var _i = 0;
    var readline = function() {
        _i ++;

        switch (_i) {
            case 1: return '6 5';
            case 2: return '0 0 0 0 0 0';
        }
    }

    var write = console.log;
}

var l = readline().split(' ').map(function(currentValue) {
    return parseInt(currentValue);
});

var n = parseInt(l[0]);
var k = parseInt(l[1]);

var s = 0;

var a = readline().split(' ').map(function(currentValue) {
    return parseInt(currentValue);
});

a.sort(function(x, y) {
    return x - y;
});

for (var i = 0; i + 3 <= n; i += 3) {
    s += 5 - a[i+2] >= k;
}

write(s);

;(function () {

	var k = +readline().split(' ')[1];

	print( Math.floor(readline().split(' ').map(Number).filter(function (e) { return (e+k) < 6; }).length / 3) );

}).call(this);

var line = readline().split(' ')
var n = parseInt(line[0])
var k = parseInt(line[1])
var a = readline().split(" ");

var cnt = 0;

for(var i = 0; i < n; i++) {
    if (5 - a[i] >= k) {
      cnt++;
    }
}

var ans = Math.floor(cnt / 3);

print(ans);

const readline = require('readline');

let secondLine = false;

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const line1 = inputs[0].split(' ');
    let members = parseInt(line1[0]);
    const k = parseInt(line1[1]);
    const participations =
        inputs[1]
            .split(' ')
            .filter((participation, i) => 5 - parseInt(participation) >= k);

    return console.log(Math.floor(participations.length/3));

});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, k;

rl.on('line', (d) => {
  if (c === 0) {
    [n, k] = d.split(' ').map(Number);
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  const ans = [];

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] + k <= 5) {
      ans.push(arr[i]);
    }
  }

  console.log(Math.floor(ans.length / 3));
  c++;
});

(function (){
    var line = readline().split(' ');
    var i, n = parseInt(line[0]);
    var k = parseInt(line[1]);
    var y = readline().split(' ');
    y.sort(function(a,b){
        return parseInt(a)-parseInt(b);
    });
    var team = 0;
    for(i = 2 ; i < n ; i += 3){
        if ( (5 - parseInt(y[i]))>=k ){
            ++team;
        }else{
            break;
        }
    }
    print(team);
})();

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let stParticipate = inputs[0].trim().split(' ');
    let students = +stParticipate[0];
    let kTimes = +stParticipate[1];
    let stParticipated = strToNumArr(splitter(inputs[1], ' '));
    let teams = 0;
    for (const iterator of stParticipated) {
        if ((5 - iterator) >= kTimes) {
            teams++;
        }
    }

    teams = Math.floor(teams / 3);
    return teams.toString();
}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let nk = readLine().split(' ').map(v => parseInt(v));
    let arr = readLine().split(' ').map(v => parseInt(v));
    let n = nk[0];
    let k = nk[1];
    let ans = arr.filter(item => {
        return item <= 5 - k;
    })
    console.log(Math.floor(ans.length / 3));
}

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
  const [n, k] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  let answ = 0, com = 0;
  nums.sort((a, b) => a - b);
  nums.forEach(x => {
    if (x+k <= 5) {
      com +=1;
      if (com === 3) {
        answ += 1; com = 0;
      }
    }
  });

  console.log(answ);
});

'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 gcd = (a, b) => a ? gcd(b % a, a) : b;
var lcm = (a, b) => a * b / gcd(a, b);

function main(){
    let [a,b] = readLine().split(" ");
    let arr = readLine().split(" ").map(x=>Number(x));

    let ans = parseInt(arr.filter(x=> x<(6-b)).length / 3);

    console.log(ans)

}

var p = readline().split(" ").map(function(x) { return parseInt(x); });
var a = readline().split(" ").map(function(x) { return parseInt(x); });
var n = 0;
for (var i = 0; i < a.length; i++) {
	if (5 - a[i] >= p[1]) n++;
}
print (Math.floor (n / 3));

var line = readline().split(' ').map(Number);

var n = line[0];
var k = line[1];

var students = readline().split(' ').map(Number);

var eligible = 0;

for(i=0;i<n;i++){
    if(students[i]+k<=5){
	eligible+=1;
    }
}

print(Math.floor(eligible/3));

// var _i = 0;
//
// function readline() {
//     _i ++;
//
//     switch (_i) {
//         case 1: return '6 5';
//         case 2: return '0 0 0 0 0 0';
//     }
// }
//
// function write(value) {
//     console.log(value);
// }

var n = readline().split(' ').map(function(currentValue) {
    return parseInt(currentValue);
});

var s = 0;

readline().split(' ').forEach(function(currentValue) {
    var a = parseInt(currentValue);
    s += a <= n[1];
});

write(Math.floor(s / 3));

var line = readline().split(' ')
var n = parseInt(line[0])
var k = parseInt(line[1])
var a = readline().split(" ");

var cnt = 0;

for(var i = 0; i < n; i++) {
    if (5 - a[i] >= k) {
      cnt++;
    }
}

var ans = cnt / 3;

print(ans);

var line = readline().split(' ')
var n = parseInt(line[0])
var k = parseInt(line[1])
var a = readline().split(" ");

var cnt = 0;

for(var i = 0; i < n; i++) {
    if (5 - a[i] >= k) {
      cnt++;
    }
}

var ans = cnt / 3;

ans;


'use strict';

function solve(n, m, a, b) {
  const sum = b.reduce((a, b) => a + b, 0) % n;
  return a[sum];
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      const m = Number(await read());
      const b = (await read()).split(' ').map(Number);
      res.push(solve(n, m, a, b));
    }
    console.log(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', () => {
  inputs = str.split('\n').values();
  main(read);
});

// NOTE: nodeJS printing to console & not to outputf.txt
process.stdin.resume()
process.stdin.setEncoding('utf8')

let fs = require("fs")
let data = fs.readFileSync(0, "utf-8")  // online judge
// let data = fs.readFileSync("inputf.txt", "utf-8")   // local
let idx = 0
data = data.split("\n")
function input() {
  return data[idx++]
}

let tcs = parseInt(input())
for (let tc = 0; tc < tcs; tc++) {
    let n = parseInt(input())
    let arr1 = input().split(" ").map(Number)
    let m = parseInt(input())
    let arr2 = input().split(" ").map(Number)
    let tot = 0
    for (let i = 0; i < m; i++) {
        tot += arr2[i];
    }
    let summ = 0
    for (let j = 0; j < n; j++) {
        summ += arr1[j];
    }
    console.log(arr1[tot % n])
}

// NOTE: nodeJS printing to console & not to outputf.txt
process.stdin.resume()
process.stdin.setEncoding('utf8')

let fs = require("fs")
let data = fs.readFileSync(0, "utf-8")
let idx = 0
data = data.split("\n")
function input() {
  return data[idx++]
}

let tcs = parseInt(input())
for (let tc = 0; tc < tcs; tc++) {
    let n = parseInt(input())
    let arr1 = input().split(" ").map(Number)
    let m = parseInt(input())
    let arr2 = input().split(" ").map(Number)
    let tot = 0
    for (let i = 0; i < m; i++) {
        tot += arr2[i];
    }
    let summ = 0
    for (let j = 0; j < n; j++) {
        summ += arr1[j];
    }
    console.log(arr1[tot % n])
}

const rl = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

let input = [];
rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solution(input);
  process.exit();
});

function solution(_input) {
  const input = _input[Symbol.iterator]();
  const T = Number(input.next().value);

  const results = [];
  for (let t = 0; t < T; t++) {
    input.next();
    const cards = input.next().value.split(" ").map(Number);
    input.next();
    const shuffles = input.next().value.split(" ").map(Number);
    results.push(cards[shuffles.reduce((acc, v) => (acc += v), 0) % cards.length]);
  }
  console.log(results.join("\n"));
}

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

var arr = "";

process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const n = parseInt(arr.shift()); // no of test cases

  for (let i = 0; i < 4 * n; ) {
    const noOfCard = arr[i++];
    const cards = arr[i++].split(" ").map((el) => parseInt(el));

    const noOfOperation = arr[i++];
    const operations = arr[i++].split(" ").map((el) => parseInt(el));

    let sum = 0;
    operations.forEach((operation) => (sum += operation));

    let ans = cards[sum % noOfCard];

    console.log(ans);
  }
});

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	// console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
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';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//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;}}

function Main(){
    // test case in nodeJs
	var t = nextInt();
	while(hasNext()){
		solve();
	}
}

function solve() {
	const deckNum = nextInt();
    const deckArr = nextIntArray(deckNum);
    const shuffleNum = nextInt();
    const shuffleArr = nextIntArray(shuffleNum);
    const sum = shuffleArr.reduce((sum, ele) => {
        return sum + ele;
    }, 0);
    const index = sum % deckArr.length;
    myout(deckArr[index]);
}

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];
    var n = 0, m = 0;
    var a = 0;
    for(i = 1; i <= t * 4; i++){
        var b = lines[i].split(' ').map(Number);
        if(i % 4 == 1){
            n = b[0];
        }else if(i % 4 == 2){
            a = b;
        }else if(i % 4 == 3){
            m = b[0];
        }else{
            var sum = 0;
            for(j = 0; j < m; j++){
                sum += b[j];
            }
            console.log(a[sum % n]);
        }
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);
        let m = parseInt(readline(), 10);
        let B = readline().split(' ').map(Number);

        let ss = B.reduce((a, b) => a + b, 0);

        let i = ss % n;

        output(arr[i]);
    }
}

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++) {
        l++
        const sa = lines[l++].trim().split(' ').map(Number)
        l++
        const sb = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(sa, sb)
    }
    console.log(output.join('\n'))
// })()
})

function solve(sa, sb) {
    let now = 0
    sb.forEach(x => {
        now = (now + x) % sa.length
    })
    return sa[now]
}

const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const calc = (t)=>{
    /* read */
    let n = +readline();
    let a = ra();
    let m = +readline();
    let b = ra();

    let idx = 0;

    for (let i = 0; i < m; i++) {
        idx = (idx + b[i]) % n;
    }

    return a[idx];
};

function main() {
    let T = +readline();
    let out = [];
    for (let t = 1; t <= T; t++){
        out.push(calc(t));
        // process.stdout.write(`${calc(n, a)}\n`);
    }
    process.stdout.write(out.join('\n')+'\n');
}

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

const solve = (cards, shuffles) => {
  console.log(
    cards[shuffles.reduce((index, shuff) => (index + shuff) % cards.length, 0)]
  );
};
let T = -1;
let cards;
let shuffles;

rl.on("line", function (line) {
  if (T !== -1) {
    switch (T % 4) {
      case 1:
        cards = line.split(" ").map(Number);
        break;
      case 3:
        shuffles = line.split(" ").map(Number);
        if (cards !== undefined && shuffles !== undefined)
          solve(cards, shuffles);
        break;
      default:
        break;
    }
  }
  T++;
});

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
var T = readline();
for(var qe=1;qe<=T;qe++) {
  var n = parseInt(readline());
  var a = readline().split(' ').map((x) => parseInt(x));
  var m = readline();
  var b = readline().split(' ').map((x) => parseInt(x));
  var id = 0;
  for(var i=0;i<m;i++) {
    id = (id+b[i])%n;
  }
  var ans = a[id]

  console.log(ans);
  //fs.appendFileSync('output.txt', ans+'\r\n');

}
//

'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(testN, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`\nTest #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

tests = [
``, // Test #1
``, // Test #2
``, // Test #3
``, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = true;

const calc = (testN)=>{
  // READING:
  let [n] = ra();
  let A = ra();
  let [m] = ra();
  let B = ra();
  LT({n, A});
  // PROCESSING:
  let sum = 0;
  for (let i=m-1; i>=0; i--){
    sum += B[i]

  }
  return A[sum%n]

  return ans;
};

var test = parseInt( readline(), 10 )

function total_move_counter(acc,a){
   return parseInt(acc) + parseInt(a);
}

for(var i = 0 ; i < test ; i++ ){
   var num_of_deck_cards = parseInt( readline(), 10 );
   var deck_cards = readline().split(' ');

   var num_of_shuffles = parseInt(readline(), 10 )
   var num_of_cards_to_move = readline().split(' ');

   total_move = num_of_cards_to_move.reduce(total_move_counter,0);

   top_card_idx = total_move % num_of_deck_cards

   print(deck_cards[top_card_idx])

}

var num = parseInt(readline(), 10);

for(var i = 0; i < num; i++) {
    var cardsNum = parseInt(readline(), 10);
    var cards = readline().split(" ");

    var shuffleNum = parseInt(readline(), 10);
    var shuffles = readline().split(" ");

    var count = 0;
    for(var k = 0; k < shuffleNum; k++) {
        count += parseInt(shuffles[k], 10);
    }

    var mod = count % cardsNum;

    print(cards[mod]);
}

const { Console } = require("console");

const rl = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

let input = [];
rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solution(input);
  process.exit();
});

function solution(_input) {
  const input = _input[Symbol.iterator]();
  const T = Number(input.next().value);

  const results = [];
  tcloop: for (let t = 0; t < T; t++) {
    const N = Number(input.next().value);
    const A = input.next().value.split(" ").map(Number);
    const B = input.next().value.split(" ").map(Number);

    const AB = [];
    for (let i = 0; i < N; i++) {
      AB.push([A[i], B[i]]);
    }
    AB.sort(([a1, b1], [a2, b2]) => (a1 < a2 ? -1 : b1 < b2 ? -1 : 0));
    for (let i = 1; i < N; i++) {
      if (AB[0][i - 1] > AB[0][i] || AB[1][i - 1] > AB[1][i]) {
        results.push("-1");
        continue tcloop;
      }
    }

    ops = [];
    for (let i = 0; i < N; i++) {
      for (let j = i + 1; j < N; j++) {
        if (A[i] > A[j] || B[i] > B[j]) {
          [A[i], A[j]] = [A[j], A[i]];
          [B[i], B[j]] = [B[j], B[i]];
          ops.push([j + 1, i + 1].join(" "));
        }
      }
    }

    for (let i = 0; i < N; i++) {
      for (let j = i + 1; j < N; j++) {
        if (A[i] > A[j] || B[i] > B[j]) {
          [A[i], A[j]] = [A[j], A[i]];
          [B[i], B[j]] = [B[j], B[i]];
          ops.push([j + 1, i + 1].join(" "));
        }
      }
    }

    results.push(ops.length);
    for (let i = 0; i < ops.length; i++) {
      results.push(ops[i]);
    }
  }
  console.log(results.join("\n"));
}

var number_of_test = readline();

function get_card_on_the_top(){
   var total_cards = readline();
   var serial = readline().split(' ');

   var num_of_shuffle = readline();
   var cards_to_move = readline().split(' ');

   var i = 0, j = 0;
   while( i < num_of_shuffle ){
      print(i)
      while( j < cards_to_move[i] ){
         serial.push( serial.shift() )
         j++;
      }
      i++;
   }
   print(serial[1]);
}

for(var i = 0 ; i < number_of_test ; i++ ) {
   get_card_on_the_top();
}


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; i++){
        var k = lines[i].split(' ').map(Number);
        var n = Math.max(k[1], k[2]);
        var m = Math.min(k[1], k[2]);
        var g = k[0] - 1;
        if(n === 0 || m !== 0 || g % n !== 0){
            console.log(-1);
        }else{
            var ans = '';
            for(j = 0; j < g; j++){
                ans += 2 + Math.floor(j / n) * n + ' ';
            }
            console.log(ans);
        }
    }
});

'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 = () => Number(read());
  let n = rn(),
      x = rn(),
      y = rn();
  if (x !== 0 && y !== 0 || x === 0 && y === 0) return -1;
  if (y === 0) y = x;
  if ((n - 1) % y !== 0) return -1;
  const res = new Array(n - 1);
  let cur = 2;
  for (let i = 0; i < n - 1; i += y) {
    for (let j = 0; j < y && i + j < n - 1; j++) {
      res[i + j] = cur;
    }
    cur += y;
  }
  return res.join(' ');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

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++];
}
// Common Template Ends //

function getResult(n,x,y){
	if( (x !== 0 && y !== 0) || (x === 0 && y === 0) ) return -1

	let res = []
	let w = 1
	let c = 0
	let max = Math.max(x,y)
	let flag = 0

	while(1)
	{
	    for(let i=0; i<max; i++)
	    {
	        res.push(w+1);
	    }

	    w += max
	    if(w == n)
	    {
	        flag = 1
	        break
	    }
	    else if(w>n) break
	}

	if(!flag) return -1

	return res
}

function main() {
    let testcases = parseInt( readline() )
    while(testcases--){
    	let inputs = readline().split(' ').map(Number)
    	let n = inputs[0]
    	let x = inputs[1]
    	let y = inputs[2]

    	let res = getResult(n, x, y)
    	res = (res === -1 ) ? res : res.join(' ')
    	console.log( res )
    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let [n,x,y] = readline().trim().split(" ").map(cur=>parseInt(cur));
          const helper = ()=>{
               if((x!==0)&&(y!==0)) console.log(-1);
          else if((x===0)&&(y===0)) console.log(-1);
          else{
               let arr = [];
               for(let i=0;i<n;i++) arr.push(i+1);
               let i = 1,res = [],c = 1,k = Math.max(x,y);
               while(i<n){
                    let j = i,t = 0;
                    while(t<k){
                         if(j>=n){
                              console.log(-1);
                              return;
                         }
                         else res.push(c);
                         j++;
                         t++;
                    }
                    i = j;
                    c = arr[i];
               }
               console.log(res.join(" "));
          }
          }
          helper();
     }
};
solve();

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n_x_y = readLine().split(' ').map(p => +p);
        let result = myFunc(n_x_y[0], n_x_y[1], n_x_y[2]);
        console.log(result);
    }
}

function myFunc(n, x, y){
    let sum = 0;
    let contx = n-1, conty = 0;
    let resp = [];

    if(x != 0 && y != 0) return -1;
    if(x > y) [x, y] = [y, x]

    for(let i = 0; i < n-1; i++){
        sum += x;
    }

    for(let i = 0; i < n-1; i++){
        contx--;
        conty++;
        sum += y - x;
        if(sum == n-1) break;
    }
    if(sum != n-1) return -1;

    let ind = 2;

    while(conty-- > 0 && y > 0){
        for(let i = 0; i < y; i++){
            resp.push(ind);
        }
        ind+=y;
    }

    return resp.join(' ');
}

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; i++){
        var k = lines[i].split(' ').map(Number);
        var n = Math.max(k[1], k[2]);
        var m = Math.min(k[1], k[2]);
        var g = k[0] - 1;
        if(n === 0 || m !== 0 || g % n !== 0){
            console.log(-1);
        }else{
            var ans = '';
            for(j = 0; j < g; j++){
                ans += 2 + j / n * n + ' ';
            }
            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; i++){
        var k = lines[i].split(' ').map(Number);
        var n = Math.max(k[1], k[2]);
        var m = Math.min(k[1], k[2]);
        var g = k[0] - 1;
        if(n === 0 || m !== 0 || g % n !== 0){
            console.log(-1);
        }else{
            var ans = '';
            for(j = 0; j < g; j++){
                ans += 2 + j + ' ';
            }
            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; i++){
        var a = lines[i];
        for(l = 1; l <= a; l++){
            var ans = '';
            for(j = 1; j <= l; j++){
                if(j == 1 || j == l){
                    ans += 1 + ' ';
                }else{
                    ans += 0 + ' ';
                }
            }
            console.log(ans);
        }
    }
});

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n_x_y = readLine().split(' ').map(p => +p);
        let result = myFunc(n_x_y[0], n_x_y[1], n_x_y[2]);
        console.log(result);
    }
}

function myFunc(n, x, y){
    let sum = 0;
    let contx = n-1, conty = 0;
    let resp = [];
    if(x > y) [x, y] = [y, x]

    for(let i = 0; i < n-1; i++){
        sum += x;
    }

    for(let i = 0; i < n-1; i++){
        contx--;
        conty++;
        sum += y - x;
        if(sum == n-1) break;
    }
    if(sum != n-1) return -1;

    let ind = 2;
    // console.log(contx, conty);
    while(contx-- > 0 && x > 0){
        for(let i = 0; i < x; i++){
            resp.push(ind);
        }
        ind+=x;
    }

    while(conty-- > 0 && y > 0){
        for(let i = 0; i < y; i++){
            resp.push(ind);
        }
        ind+=y;
    }

    return resp.join(' ');
}

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const n_x_y = readLine().split(' ').map(p => +p);
        // const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n_x_y[0], n_x_y[1], n_x_y[2]);
        console.log(result);
    }
}

function myFunc(n, x, y){

    let resp = rec(0, 0, '');
    if(resp == -1) return -1;
    resp = resp.split('').map(p => p == 'x' ? x : y)
    return resp.join(' ')

    function rec(jog, sum, str){
        // console.log(jog, sum, str);
        if(sum + x == n-1 && jog == n-1) return str + 'x';
        if(sum + y == n-1 && jog == n-1) return str + 'y';

        if(sum + x <= n-1 && jog + 1 <= n-1)
            return rec(jog + 1, sum + x, str + 'x');

        if(sum + y <= n-1 && jog + 1 <= n-1)
            return rec(jog + 1, sum + y, str + 'y');

        return -1;
    }

}

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const n_x_y = readLine().split(' ').map(p => +p);
        // const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n_x_y[0], n_x_y[1], n_x_y[2]);
        console.log(result);
    }
}

function myFunc(n, x, y){

    let resp = rec(0, 0, '');
    if(resp == -1) return -1;
    return resp.split('').map(p => p == 'x' ? x : y)

    function rec(jog, sum, str){
        // console.log(jog, sum, str);
        if(sum + x == n-1 && jog == n-1) return str + 'x';
        if(sum + y == n-1 && jog == n-1) return str + 'y';

        if(sum + x <= n-1 && jog + 1 <= n-1)
            return rec(jog + 1, sum + x, str + 'x');

        if(sum + y <= n-1 && jog + 1 <= n-1)
            return rec(jog + 1, sum + y, str + 'y');

        return -1;
    }

}

'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 = () => Number(read());
  let n = rn(),
      x = rn(),
      y = rn();
  if (x !== 0 && y !== 0 || x === 0 && y === 0) return -1;
  if (y === 0) y = x;
  if (y !== 1 && n % 2 === 0) return -1;
  if (n & 1 && y > (n - 1) / 2) return -1;
  const res = new Array(n - 1);
  let cur = 2;
  for (let i = 0; i < n - 1; i += y) {
    for (let j = 0; j < y; j++) {
      res[i + j] = cur;
    }
    cur += y;
  }
  return res.join(' ');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

'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 = () => Number(read());
  let n = rn(),
      x = rn(),
      y = rn();
  if (x !== 0 && y !== 0 || x === 0 && y === 0) return -1;
  if (y === 0) y = x;
  if (y !== 1 && n % 2 === 0) return -1;
  const res = new Array(n - 1);
  let cur = 2;
  for (let i = 0; i < n - 1; i += y) {
    for (let j = 0; j < y; j++) {
      res[i + j] = cur;
    }
    cur += y;
  }
  return res.join(' ');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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


// require('./config');

var line = readline();

var i, j;
var n = Number(line);
var a = [];
var b = [];
for (i = 0; i < n; i++) {
    line = readline().split(' ');
    a.push(Number(line[0]));
    b.push(Number(line[1]));
}

var r1 = [];
var r2 = [];
for (i = 0; i < n; i++) {
    if (i < (n - 1)/2) {
        r1[i] = 1;
        r2[i] = 1;
    } else {
        r1[i] = 0;
        r2[i] = 0;
    }
}
var count = 0;
i = 0;
j = 0;

while (count < n) {
    if (a[i] < b[j]) {
        r1[i] = 1;
        i++;
    } else {
        r2[j] = 1;
        j++
    }
    count++;
}

print(r1.join(''));
print(r2.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 main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push([integers[round], round, rank]);
			feasible[round].push(rank+1 <= quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a[0] - b[0];
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record[1]][record[2]] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

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 main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push({score: integers[round], round: round, rank: rank});
			feasible[round].push(rank+1 <= quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a.score - b.score;
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record.round][record.rank] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

main();

    var n = parseInt(readline());
    var a = [], b = [], au = [], bu =[];
    for(var i=0; i<n; i++)
    {
        var str = readline().split(' ');
        a.push(str[0]);
        b.push(str[1]);
        au.push('0');
        bu.push('0');
    }
    var ap= 0, bp= 0, place=0;
    while(ap<n && bp<n)
    {
        if(bp==n || Math.min(a[ap],b[bp])==a[ap])
        {
            a[ap]=place;
            ap++;
            place++;
        }
        else if(ap==n || Math.min(a[ap],b[bp])==b[bp])
        {
            b[bp]=place;
            bp++;
            place++;
        }
    }
    for(var i=0; i<n; i++)
    {
        if((i+1)*2<=n || a[i]<n) au[i]='1';
        if((i+1)*2<=n || b[i]<n) bu[i]='1';
    }

    print(au.join(''));
    print(bu.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 main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push({score: integers[round], round: round, rank: rank});
			feasible[round].push(rank < quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a.score - b.score;
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record.round][record.rank] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

main();

// require('./config');

var line = readline();

var i, j;
var n = Number(line);
var a = [];
var b = [];
for (i = 0; i < n; i++) {
    line = readline().split(' ');
    a.push(line[0]);
    b.push(line[1]);
}

var r1 = [];
var r2 = [];
for (i = 0; i < n; i++) {
    if (i < (n - 1)/2) {
        r1[i] = 1;
        r2[i] = 1;
    } else {
        r1[i] = 0;
        r2[i] = 0;
    }
}
var count = 0;
i = 0;
j = 0;

while (count < n - 1) {
    if (a[i] < b[j]) {
        r1[i] = 1;
        i++;
    } else {
        r2[j] = 1;
        j++
    }
    count++;
}

print(r1.join(''));
print(r2.join(''));