The GCD table G of size n × n for an array of positive integers a of length n is defined by formula   Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as . For example, for array a = {4, 3, 6, 2} of length 4 the GCD table will look as follows:  Given all the numbers of the GCD table G, restore array a.

The first line contains number n (1 ≤ n ≤ 500) — the length of array a. The second line contains n2 space-separated numbers — the elements of the GCD table of G for array a.  All the numbers in the table are positive integers, not exceeding 109. Note that the elements are given in an arbitrary order. It is guaranteed that the set of the input data corresponds to some array a.

In the single line print n positive integers — the elements of array a. If there are multiple possible solutions, you are allowed to print any of them.

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	readline();
	var a = List.map(parseInt, readline().split(' '));
	a.sort(function (a, b) { return b - a; });
	var used = {};
	var r = [];
	for (var i = 0; i < a.length && r.length * r.length < a.length; i++) {
	    var k = used[a[i]];
	    if (k > 0) {
	        used[a[i]] -= 1;
	        continue;
	    }
	    r.push(a[i]);
	    for (var j = 0; j < r.length; j++) {
	        var x = Prelude_1.gcd(r[j], a[i]);
	        used[x] = used[x] || 0;
	        used[x] += (j < r.length) ? 2 : 1;
	    }
	}
	print(r.join(" "));

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;
	function gcd(a, b) {
	    var r = a % b;
	    while (r !== 0) {
	        a = b;
	        b = r;
	        r = a % b;
	    }
	    return b;
	}
	exports.gcd = gcd;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function maximum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximum = maximum;
	function minimum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimum = minimum;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;

/***/ }
/******/ ]);

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	readline();
	var a = List.map(parseInt, readline().split(' '));
	a.sort(function (a, b) { return b - a; });
	var used = {};
	var r = [];
	for (var i = 0; i < a.length && r.length * r.length < a.length; i++) {
	    var k = used[a[i]];
	    if (k > 0) {
	        used[a[i]] -= 1;
	        continue;
	    }
	    r.push(a[i]);
	    for (var j = 0; j < r.length; j++) {
	        var x = Prelude_1.gcd(r[j], a[i]);
	        used[x] = used[x] || 0;
	        used[x] += 1;
	    }
	}
	print(r.join(" "));

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;
	function gcd(a, b) {
	    var r = a % b;
	    while (r !== 0) {
	        a = b;
	        b = r;
	        r = a % b;
	    }
	    return b;
	}
	exports.gcd = gcd;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function maximum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximum = maximum;
	function minimum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimum = minimum;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;

/***/ }
/******/ ]);


You are given an array $$$a$$$ of $$$n$$$ positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that $$$a_1 < a_2 < \dots < a_n$$$ holds.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$1 \leq a_i \leq 10^9$$$) — the elements of the array.

For each test case, output "YES" (without quotes) if the array satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

NoteIn the first test case any rearrangement will keep the array $$$[1,1,1,1]$$$, which is not strictly increasing.In the second test case, you can make the array $$$[1,3,4,7,8]$$$.

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

let inputString = "";
let currentLine = 0;

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

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

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().trim().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    if (
      new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size === size
    ) {
      data.push('YES');
    } else {
      data.push('NO');
    }
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size === size
      ? data.push('YES')
      : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];

rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size ===
    parseInt(input[i], 10)
      ? data.push('YES')
      : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
process.stdin.resume();
process.stdin.setEncoding('utf8');
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    const arr = input[i + 1].split(' ').map(x => parseInt(x, 10));
    new Set(arr).size === size ? data.push('YES') : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    rl.close();
    process.exit(0);
  }
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        let length = Number(await read())
        let array = await read().split(' ').map(Number).sort((a, b) => a - b)
        let answer = array.every((e, i) => array.lastIndexOf(e) == i)
        output += (answer ? "YES" : "NO") + '\n'
        amount--
    }
    return output
}

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

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

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }else{
                    a.set(k[l])
                }
            }
            console.log(f === true ? 'NO' : 'YES')
        }

    }
});

        const fs = require('fs');
        const input = fs.readFileSync(0, 'utf8').trim().split('\n');

        let currentline = 0;
        function readline(){
            return input[currentline++];
        }

        let T = readline();
        for(let i = 1; i <= T; i++){
            let N = readline().split(' ');
            let arr = readline().split(' ').map(Number);
            console.log(solve(arr, N));
        }

        function solve(arr, N){
            let itms = new Set();
            for(let i=0;i<arr.length;i++){
                itms.add(arr[i]);
            }
            return (itms.size === arr.length) ? 'YES' : 'NO';
        }

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;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i], a = new Map(), flag = false;
        }else{
            k = lines[i].split(' ').map(Number);
            for(j = 0; j < n; j++){
                if(a.has(k[j])){
                    flag = true;
                    break;
                }else{
                    a.set(k[j]);
                }
            }
            console.log(flag === true ? 'NO' : 'YES');
        }
    }
});

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var n = readline();
    var a = readline().split(' ');
    var repeated = a.filter(function (e, i, a) {
      return a.indexOf(e) !== i;
    })
    if (repeated.length == 0) {
      process.stdout.write('YES\n');
    } else {
      process.stdout.write('NO\n');
    }
  }
}

let buf='';

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

process.stdin.on('end',function(){
    const {EOL} = require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    // console.log(EOL);
    for(let z=1;z<=t;z++)
    {
        let n=parseInt(line[2*z-1]);
        let arr=line[2*z].split(' ').map(x=>{return parseInt(x)});
        // console.log(arr);
        const st=new Set();
        for(let i=0;i<arr.length;i++) st.add(arr[i]);
        if(st.size===n) console.log("YES");
        else console.log("NO");
    }
})

const lines = [];
let currentLineIndex = 0;
const readlineInterface = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
readlineInterface.on("line", (line) => {
  if (currentLineIndex > 0 && currentLineIndex % 2 === 0) {
    lines.push(line);
  }
  currentLineIndex++;
});

readlineInterface.on("close", () => {
  const tests = lines.map((line) => line.split(" ").map((e) => +e));

  tests
    .map((numbers) => {
      return new Set(numbers).size === numbers.length ? "YES" : "NO";
    })
    .forEach((e) => console.log(e));
});

/**
 * 10/13/22 morning
 * https://codeforces.com/contest/1742/problem/B
 */

const pr = console.log;

const solve = (n, a) => {
    a.sort((x, y) => x - y);
    for (let i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) return pr("NO");
    }
    pr("YES");
};

const main = () => {
    const readLine = () => input[currentLine++];
    const ni = () => readLine() - '0';
    const nas = () => readLine().split(" ");
    const nai = () => nas().map(Number);
    const nal = () => nas().map(BigInt);
    let input = '', currentLine = 0;
    process.stdin.on('data', (stdin) => input += stdin)
    process.stdin.on('end', () => {
        input = input.split('\n');
        let t = ni();
        while (t--) {
            let n = ni(), a = nai();
            solve(n, a);
        }
    });
};

main()

const readline = require("readline");

var tcn = 0
var isnTurn = true

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

rl.on('line', line => {
  if (!tcn) return tcn = Number(line)

  if (isnTurn) {
    isnTurn = false
  }
  else {
    isnTurn = true
    run(line)
    if (!--tcn) rl.close()
  }

})

function run(line) {
  var vals = line.split(' ').map(val => Number(val)).sort((a, b) => a - b)
  for (let index = 0; index < vals.length - 1; index++) {
    if (vals[index] == vals[index + 1]) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}

/*
** Template
*/

// Common Template Starts //
//*
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 //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let arr = readline().split(' ').map(Number)
        console.log(solve(arr))
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (arr) => {
    let arr2 = uniqueArray( arr )

    if( arr.length === arr2.length ) return 'YES'

    return 'NO'
}

const isOdd = (num) => num & 1
const isEven = (num) => !(num & 1)
const minOfArray = (arr) => Math.min.apply(null, arr)
const maxOfArray = (arr) => Math.max.apply(null, arr)
const uniqueArray = (arr) => [...new Set(arr)]
const sortArray = (arr) => arr.sort((a, b) => a - b)
const sumOfArray = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

// cmd: cat input.txt | node main.js

'use strict';

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

let processIn = '';
let processCurr = 0;

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

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

    JS();
});

function readLine() {
    return processIn[processCurr++];
}
function mergeSort(a) {
    let r = a.length;
    let l = 0;
    let m = Math.round((r - l) / 2);
    if (r === 1) {
        return;   // returns recursively
    }
    let L = [];   // left half of current a
    let R = [];   // right half of current a
    for (let i = l; i < m; i++) {
        L.push(a[i]);
    }
    for (let j = m; j < r; j++) {
        R.push(a[j]);
    }
    mergeSort(L);
    mergeSort(R);
    let i = 0, j = 0, k = 0;
    // Merging part
    while (i < L.length && j < R.length) {
        if (L[i] < R[j]) {
            a[k] = L[i];
            i++;
        } else {
            a[k] = R[j];
            j++;
        }
        k++;
    }
    while (i < L.length) {
        a[k] = L[i];
        i++;
        k++;
    }
    while (j < R.length) {
        a[k] = R[j];
        j++;
        k++;
    }
}

function JS() {
    /*

    */
    let tt = parseInt(readLine());
    // let tt = 1;
    for(let t=0;t<tt;++t){
        let n = parseInt(readLine());
        let l = readLine().trim().split(' ').map(string => { return parseInt(string.trim()); });
        mergeSort(l);
        let flag = 1;
        for(let i=0;i<n-1;++i){
            if(l[i] === l[i+1]){
                flag = 0;
            }
        }
        if(flag){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let t = readline();
  for (let i = 0; i < t; i++) {
    let n = readline();
    let arr = readline().split(" ").map(Number);
    const set = new Set();
    for (let i = 0; i < arr.length; i++) {
      if (!set.has(arr[i])) {
        set.add(arr[i]);
      }
    }
    if (set.size === arr.length) {
      console.log("YES");
    } else {
      console.log("NO");
    }
  }
}

'use strict';

var fs = require('fs');

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

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

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

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

const readline = require('readline')

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

function solve(n, arr) {
    const m = {}
    for (let x of arr) {
        if (m[x]) return 'NO'
        m[x] = 1
    }
    return 'YES'
}

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(n, a) {
    // Sort array in ascending order using quicksort
    var quicksort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quicksort(left).concat(pivot, quicksort(right));
    }
    var a = quicksort(a);
    // Check if a is in non-decreasing order
    var isDecreasing = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] > a[i]) {
                return true;
            }
        }
        return false;
    }
    var isEqual = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] == a[i]) {
                return true;
            }
        }
        return false;
    }

    if (isDecreasing(a)) {
        print('NO');
    }
    else if (isEqual(a)) {
        print('NO');
    }
    else {
        print('YES');
    }
}

main();

const tc = readline();
for (var t =0 ; t<tc;t++){
   var n = readline();
   var input = readline().split(" ").map(i=>Number(i));
   input = input.sort();
   var b = true;
   for(var i=1;i<n;i++){
       if(input[i]==input[i-1]){
           if(b)
           print("NO")
           b = false;
       }
   }
   if(b)
   print("YES")
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseArray = readline().split(" ");
    var caseMap = new Map();
    var flag = true;
    for (var j = 0; j < caseLength; j++)
    {
        var current = parseInt(caseArray[j]);
        if (caseMap.has(current))
        {
            flag = false;
            break;
        }
        else
        {
            caseMap.set(current, current);
        }
    }
    if (flag) print("YES"); else print("NO");

}

function begin(nums) {
    nums.sort((a,b) => a - b);
    for(var i = 1; i < nums.length; i++) {
        if(nums[i] == nums[i-1]) {
            print("NO");
            return;
        }
    }
    print("YES");
}

var caseNum = parseInt(readline(), 10);
for (var i = 0; i < caseNum; i++) {
    var n = parseInt(readline(), 10);
    var x = readline()
        .trim()
        .split(' ')
        .map((y) => parseInt(y, 10));
        begin(x);
}

var tests = +readline();

for(var i=0; i<tests; i++) {
    var hash = {};
    var l = +readline();
    var nums = readline().split(" ");
    var pos = true;
    for(var index = 0; index < l; index++) {
        if(hash[nums[index]]) {
            var pos = false;
            print("NO");
            break;
        }else {
            hash[nums[index]] = true
        }
    }
    if(pos) {
        print("YES");
    }
}

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

let inputString = "";
let currentLine = 0;

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

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

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    // const sortElements = cases[i];
    // sortElements.sort((a, b) => a - b);

    // let isSorted = true;
    // for (let j = 0; j < elements.length && isSorted; j++) {
    //   if (elements[j] !== sortElements[j]) {
    //     isSorted = false;
    //   }
    // }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

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

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    console.log("ress nya:", res);

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

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

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

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

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res || (isSorted && elements.length > 1) ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

const readline = require('readline');
const util = require('util');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = util.promisify(rl.question).bind(rl);
const data = [];

rl.question('', async testCaseSize => {
  const dSize = parseInt(testCaseSize, 10);
  for (let i = 0; i < dSize; i++) {
    const size = parseInt(await question(''), 10);
    const arr = (await question('')).split(' ').map(x => parseInt(x, 10));
    new Set(arr).size === size ? data.push('YES') : data.push('NO');
    if (data.length === dSize) {
      console.log(data.join('\n'));
      rl.close();
    }
  }
});

rl.on('close', function () {
  process.exit(0);
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').map(Number).sort((a, b) => a - b)
            while (array.length > 1) {
                let c = array.shift()
                let n = array.shift()
                if (c < n) continue
                break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

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

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').map(Number).sort((a, b) => a - b)
            while (array.length > 0) {
                let c = array.shift()
                let n = array.shift()
                if (c >= n) break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

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

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').sort((a, b) => a - b)
            while (array.length > 0) {
                let c = array.shift()
                let n = array.shift()
                if (c >= n) break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

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

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

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }
            }
            console.log(f === true ? 'NO' : 'YES')
        }

    }
});

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

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }
            }
            console.log(f === true ? 'NO' : 'YES')
            break;
        }

    }
});

    const fs = require('fs');
    const input = fs.readFileSync(0, 'utf8').trim().split('\n');

    let currentline = 0;
    function readline(){
        return input[currentline++];
    }

    let T = readline();
    for(let i = 1; i <= T; i++){
        let N = readline().split(' ');
        let arr = readline().split(' ').map(Number);
        console.log(N, arr);
        console.log(solve(arr, N));
    }

    function solve(arr, N){
        let itms = new Set();
        for(let i=0;i<N;i++){
            itms.add(arr[i]);
        }
        return (itms.size === N) ? 'YES' : 'NO';
    }

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');

let currentline = 0;
function readline(){
    return input[currentline++];
}

let T = readline();
for(let i = 1; i <= T; i++){
    let N = readline().split(' ');
    let arr = readline().split(' ').map(Number);
    console.log(solve(arr, N));
}

function solve(arr, N){
    let itms = new Set();
    for(let i=0;i<N;i++){
        itms.add(arr[i]);
    }
    return (itms.size === N) ? 'YES' : 'NO';
}

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(n, a) {
    // Sort array in ascending order using quicksort
    var quicksort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quicksort(left).concat(pivot, quicksort(right));
    }
    var a = quicksort(a);
    // Check if a is in non-decreasing order
    var isDecreasing = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] > a[i]) {
                return true;
            }
        }
        return false;
    }
    if (!isDecreasing(a)) {
        print('YES');
    }
    else {
        print('NO');
    }
}

main();

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(a) {
    // Sort array in ascending order using quicksort
    var quickSort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quickSort(left).concat(pivot, quickSort(right));
    }
    var a = quickSort(a);
    for (var i = 0; i < a.length; i++) {
        if (a[i] == a[i+1]) {
            print('NO');
            print(a[i]);
            return;
        }
    }
    print('YES');
}

main();

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(a) {
    // Sort array in ascending order using quicksort
    var quickSort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quickSort(left).concat(pivot, quickSort(right));
    }
    var a = quickSort(a);
    for (var i = 0; i < a.length; i++) {
        if (a[i] == a[i+1]) {
            print('NO');
            return;
        }
    }
    print('YES');
}

main();

const tc = readline();
for (var t =0 ; t<tc;t++){
   var n = readline();
   var input = readline().split(" ").map(i=>Number(i));
   input = input.sort();
   var b = true;
   for(var i=1;i<n;i++){
       if(input[i]<=input[i-1]){
           if(b)
           print("NO")
           b = false;
       }
   }
   if(b)
   print("YES")
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseArray = readline().split(" ");
    var caseMap = new Map();
    var flag = true;
    for (var j = 0; j < caseLength; j++)
    {
        var current = parseInt(caseArray[j]);
        if (caseMap.has(current))
        {
            flag = false;
            break;
        }
        else
        {
            caseMap[current] = current;
        }
    }
    if (flag) print("YES"); else print("NO");

}


A class of students wrote a multiple-choice test.There are $$$n$$$ students in the class. The test had $$$m$$$ questions, each of them had $$$5$$$ possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question $$$i$$$ worth $$$a_i$$$ points. Incorrect answers are graded with zero points.The students remember what answers they gave on the exam, but they don't know what are the correct answers. They are very optimistic, so they want to know what is the maximum possible total score of all students in the class.

The first line contains integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) — the number of students in the class and the number of questions in the test. Each of the next $$$n$$$ lines contains string $$$s_i$$$ ($$$|s_i| = m$$$), describing an answer of the $$$i$$$-th student. The $$$j$$$-th character represents the student answer (A, B, C, D or E) on the $$$j$$$-th question. The last line contains $$$m$$$ integers $$$a_1, a_2, \ldots, a_m$$$ ($$$1 \le a_i \le 1000$$$) — the number of points for the correct answer for every question.

Print a single integer — the maximum possible total score of the class.

NoteIn the first example, one of the most optimal test answers is "ABCD", this way the total number of points will be $$$16$$$.In the second example, one of the most optimal test answers is "CCC", this way each question will be answered by exactly one student and the total number of points is $$$5 + 4 + 12 = 21$$$.

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

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

  if (n) {
    strs.push(d);
    n--;
    return;
  }

  points.push(...d.split(' ').map(Number));

  c++;
});

rl.on('close', () => {
  let ans = 0;

  for (let i = 0; i < strs[0].length; i++) {
    const obj = {};
    for (let j = 0; j < strs.length; j++) {
      if (obj[strs[j][i]]) {
        obj[strs[j][i]]++;
      }
      else {
        obj[strs[j][i]] = 1;
      }
    }

    const values = Object.values(obj).sort((a, b) => b - a);
    ans += values[0] * points[i];
  }

  console.log(ans);
});

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const scores = [];
  for (let i = 1; i < lines.length - 2; i++) {
    scores.push(lines[i]);
  }
  let values = lines[lines.length - 2].split(' ');
  values = values.map(val => parseInt(val, 10));
  getMaxScore(scores, values);
});

function getMaxScore(scores, values) {
  const buckets = [];
  buckets.length = 5;
  buckets.fill(0);

  const mapping = {
    A: 0,
    B: 1,
    C: 2,
    D: 3,
    E: 4,
  };

  let score = 0;
  for (let i = 0; i < scores[0].length; i++) {
    for (let j = 0; j < scores.length; j++) {
      const answer = scores[j][i];
      buckets[mapping[answer]]++;
    }
    const max = Math.max(...buckets);
    score += (max * values[i]);
    buckets.fill(0);
  }
  console.log(score);
}

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

const solution = () => {
	let line = data.split('\n');
	let [n, k] = line.shift().split(' ').map(v  => parseInt(v,10));
	let ans = [];
	for(let i = 0; i < n; i++){
		ans.push(line.shift());
	}
	let point = line.shift().split(' ').map(v => parseInt(v, 10));

	let sum = 0;
	let a = 'A'.charCodeAt(0);
	for(let i = 0; i < k; i++){
		let o = [0,0,0,0,0];
		for(let j = 0 ; j < n; j++){
			o[ans[j].charCodeAt(i) - a]++;
		}

		sum +=  Math.max(...o) * point[i];
	}
	console.log(sum);
}

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

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

const solution = () => {
	let line = data.split('\n');
	let [n, k] = line.shift().split(' ').map(v  => parseInt(v,10));
	let ans = [];
	for(let i = 0; i < n; i++){
		ans.push(line.shift());
	}
	let point = line.shift().split(' ').map(v => parseInt(v, 10));

	let sum = 0;
	for(let i = 0; i < k; i++){
		let o = {A: 0, B: 0, C: 0, D: 0, E: 0};
		for(let j = 0 ; j < n; j++){
			o[ans[j][i]]++;
		}

		let max = 0;
		for(let m in o){
			max = Math.max(o[m], max);
		}
		sum +=  max * point[i];
	}
	console.log(sum);
}

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

var keys = { A: 0, B: 1, C: 2, D: 3, E: 4 };

var nm = readline().split(' ').map(item => +item);

var answers = [];
for(var i = 0; i < nm[0]; i++) {
  answers.push(readline());
}

var sum = 0, vals = readline().split(' ').map(item => +item), ans = new Array(5);

for(var i = 0; i < nm[1]; i++) {
  ans.fill(0);
  for(var j = 0; j < nm[0]; j++) {
    ans[keys[answers[j][i]]]++;
  }
  sum += Math.max(...ans) * vals[i];
}

print(sum);

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var input = rdArN();
    var n = input[0];
    var m = input[1];
    var M = crAr(m);
    for (var i = 0; i < M.length; ++i) {
        M[i] = {};
        M[i]['A'] = 0;
        M[i]['B'] = 0;
        M[i]['C'] = 0;
        M[i]['D'] = 0;
        M[i]['E'] = 0;
    }
    for (var i = 0; i < n; ++i) {
        var s = rdS();
        for (var j = 0; j < s.length; ++j) {
            ++M[j][s[j]];
        }
    }
    //prOb(M);
    var A = rdArN();
    var res = 0;
    for (var i = 0 ; i < m; ++i) {
        var max = -Infinity;
        for (var key in M[i]) {
            max = Math.max(max, M[i][key]);
        }
        res += max*A[i];
        //pr(max*A[i])
    }
    wr(res);
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const scores = [];
  for (let i = 1; i < lines.length - 1; i++) {
    scores.push(lines[i]);
  }
  let values = lines[lines.length - 1].split(' ');
  values = values.map(val => parseInt(val, 10));
  getMaxScore(scores, values);
});

function getMaxScore(scores, values) {
  const buckets = [];
  buckets.length = 5;
  buckets.fill(0);

  const mapping = {
    A: 0,
    B: 1,
    C: 2,
    D: 3,
    E: 4,
  };

  let score = 0;
  for (let i = 0; i < scores[0].length; i++) {
    for (let j = 0; j < scores.length; j++) {
      const answer = scores[j][i];
      buckets[mapping[answer]]++;
    }
    const max = Math.max(...buckets);
    score += (max * values[i]);
    buckets.fill(0);
  }
  console.log(score);
}


In Berland, there is the national holiday coming — the Flag Day. In the honor of this event the president of the country decided to make a big dance party and asked your agency to organize it. He has several conditions:  overall, there must be m dances; exactly three people must take part in each dance; each dance must have one dancer in white clothes, one dancer in red clothes and one dancer in blue clothes (these are the colors of the national flag of Berland). The agency has n dancers, and their number can be less than 3m. That is, some dancers will probably have to dance in more than one dance. All of your dancers must dance on the party. However, if some dance has two or more dancers from a previous dance, then the current dance stops being spectacular. Your agency cannot allow that to happen, so each dance has at most one dancer who has danced in some previous dance. You considered all the criteria and made the plan for the m dances: each dance had three dancers participating in it. Your task is to determine the clothes color for each of the n dancers so that the President's third condition fulfilled: each dance must have a dancer in white, a dancer in red and a dancer in blue. The dancers cannot change clothes between the dances.

The first line contains two space-separated integers n (3 ≤ n ≤ 105) and m (1 ≤ m ≤ 105) — the number of dancers and the number of dances, correspondingly. Then m lines follow, describing the dances in the order of dancing them. The i-th line contains three distinct integers — the numbers of the dancers that take part in the i-th dance. The dancers are numbered from 1 to n. Each dancer takes part in at least one dance.

Print n space-separated integers: the i-th number must represent the color of the i-th dancer's clothes (1 for white, 2 for red, 3 for blue). If there are multiple valid solutions, print any of them. It is guaranteed that at least one solution exists.

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 data = tokenizeIntegers(readline());
	var dancerNum = data[0], partyNum = data[1];

	var colors = new Array(dancerNum);
	var colorVariety = 3;
	var initialAssignment = [];
	for (var color = 0; color < colorVariety; ++color) {
		initialAssignment.push(color);
	}

	for (var partyIx = 0; partyIx < partyNum; ++partyIx) {
		var party = tokenizeIntegers(readline());
		var assignment = initialAssignment.slice(0);
		for (var dancerIx = 0; dancerIx < colorVariety; ++dancerIx) {
			var dancer = party[dancerIx]-1;
			if (colors[dancer] != undefined) {
				assignment[dancerIx] = colors[dancer];
				assignment[colors[dancer]] = dancerIx;
				break;
			}
		}
		for (dancerIx = 0; dancerIx < colorVariety; ++dancerIx) {
			colors[party[dancerIx]-1] = assignment[dancerIx];
		}
	}

	for (var colorIx = 0; colorIx < dancerNum; ++colorIx) {
		colors[colorIx] += 1;
	}
	print(colors.join(" "));
}

main();


Let's denote correct match equation (we will denote it as CME) an equation $$$a + b = c$$$ there all integers $$$a$$$, $$$b$$$ and $$$c$$$ are greater than zero.For example, equations $$$2 + 2 = 4$$$ (||+||=||||) and $$$1 + 2 = 3$$$ (|+||=|||) are CME but equations $$$1 + 2 = 4$$$ (|+||=||||), $$$2 + 2 = 3$$$ (||+||=|||), and $$$0 + 1 = 1$$$ (+|=|) are not.Now, you have $$$n$$$ matches. You want to assemble a CME using all your matches. Unfortunately, it is possible that you can't assemble the CME using all matches. But you can buy some extra matches and then assemble CME!For example, if $$$n = 2$$$, you can buy two matches and assemble |+|=||, and if $$$n = 5$$$ you can buy one match and assemble ||+|=|||.   Calculate the minimum number of matches which you have to buy for assembling CME.Note, that you have to answer $$$q$$$ independent queries.

The first line contains one integer $$$q$$$ ($$$1 \le q \le 100$$$) — the number of queries. The only line of each query contains one integer $$$n$$$ ($$$2 \le n \le 10^9$$$) — the number of matches.

For each test case print one integer in single line — the minimum number of matches which you have to buy for assembling CME.

NoteThe first and second queries are explained in the statement.In the third query, you can assemble $$$1 + 3 = 4$$$ (|+|||=||||) without buying matches.In the fourth query, buy one match and assemble $$$2 + 4 = 6$$$ (||+||||=||||||).

(function() {
    var q = Number(readline());
    while (q--) {
        var n = parseInt(readline());
        if (n == 2)
            print(2);
        else
            print(n % 2);
    }
})();

'use strict'

let n; readline();
while(n = parseInt(readline())) { write((n < 5 ? 4 - n : n % 2) + '\n'); }

'use strict';

main();

function main() {
  let cases = parseInt(readline());
  while ( cases-- > 0 ) {
    print(solve());
  }
}

function solve() {
  let matches = parseInt(readline());
  matches -= 4; // 1 + 1 = 2, basic equation

  return ( ( matches < 0 ) ? -1 * matches : matches % 2 );
}

var q = parseInt(readline());
var input = []
while (q != 0) {
    q--;
    input.push(parseInt(readline()));
}
input
    .map(n => n == 2 ? 2 : n % 2)
    .forEach(z => print(z))

var q = parseInt(readline())
var mass = []
mass.length = q
for (var i = 0; i < q; i++) mass[i] = parseInt(readline())
for (var i = 0; i < q; i++) {
    var n = mass[i]
    if (n == 2) print(2)
    else if (n % 2 == 0)
        print(0)
    else print(1)
}

n = +readline();
var q;
for (var i = 0; i < n;i ++){
    q = +readline();
    if (q === 1) { print(2)}
    else if (q === 2) { print(2)}
    else {
        if (q % 2 === 0){
            print(0);
        }
        else { print(1)}
    }
}

var q = readline();
var n;
for (var i = 0; i<q; i++) {
    n = readline();
    if (n%2 == 1) n = 1;
    else if (n == 2) n = 2;
    else n = 0;
    print(n);
};

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

let t = Date.now();

let currentLine = 0;
let i = '';
process.stdin.on('data', c => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  i = i.trim()
    .split('\n')
    .map(string => {
      return string.trim();
    });
  main();
});

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

function main() {
  var x = readLine();
  let j = 0;
  for (j = 0; j < x; j++) {
    var cq = readLine();
    //console.log('current query' + cq);
    if (cq == 2) {
      console.log(2);
    } else {
      var rs = cq - Math.floor(cq / 2); //console.log('rs ' + rs);
      var ls = Math.floor(cq / 2); //console.log('ls ' + ls);
      if (ls === rs)
        console.log('0');
      else {
        console.log(rs - ls);
      }
    }
  }
}

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

const input = [];
readline.on('line', line => { input.push(line); });

readline.on('close', () => {
    const n = Number(input[0]);
    const queries = input.slice(1).map(Number);
    queries.forEach(v => {
        if (v === 1) console.log(3);
        else if (v === 2) console.log(2);
        else {
            if (v % 2 === 1) console.log(1);
            else console.log(0);
        }
    })
});

const readline = require("readline").createInterface(process.stdin, process.stdout);
var linesLeft,
    result = '';
readline.on("line", line => {
  if (linesLeft === undefined)
    linesLeft = parseInt(line);
  else{
    solution(line);
    if (!(--linesLeft > 0))
    readline.close();
  }
}).on("close",() => {
  console.log(result)
  process.exit(0);
});

function solution (input){
    result += (input > 2 ? input % 2 : 2) + '\n';
    return input % 2;
}

const readline = require('readline');

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

let cases, arr = [], toBuy = [];

rl.on('line', n => {
  if (!cases) { cases = n } else {
    arr.push(n);
    cases--;
    if (cases === 0) {
      arr.map(Number).forEach(num => {
        num < 4 ? toBuy.push(4 - num) : num % 2 === 0 ? toBuy.push(0) : toBuy.push(1);
      });
      toBuy.forEach(num => console.log(num));
      rl.close();
    }
  }
});

//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 (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    if(N == 2){
      output[i] = 2;
    }else{
      output[i] = N % 2;
    }
  }
  myout(myconv(output, 9));
}

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

  const n = +d;

  if (n === 2) {
    console.log(2);
  }
  else if (n % 2 === 0) {
    console.log(0);
  }
  else {
    console.log(1);
  }

  c++;
});

let fs=require('fs');
let txt=fs.readFileSync(0,"utf-8").split("\r\n").filter(data=>{return data.length>0});
txt.shift()

txt.forEach(data=>{
     matches(data*1);
})

function matches(num){
     let res=Math.ceil(num/2);
     let other=Math.floor(num/2);
     let add=0
     if(other<res){
          ++other;
          ++add;
     }
     let nums=[Math.ceil(other/2),Math.floor(other/2)];
     if(nums[1]<1){
         add+=2;
     }

     console.log(add);

}

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let [k, ...nums] = data.trim().split('\n').map(v => Number(v));
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

var s = '';
var n = 0;

process.stdin.on('data', function (c) {
    s += c;
});

process.stdin.on('end', function () {
    s = s.trim().split('\n');
    main();
});

function readline() {
    return s[n++];
}

function main() {
    var T = parseInt(readline());
    for (var t = 0; t < T; ++t) {
        var n = parseInt(readline());
        if (n === 2) {
            console.log(2);
        } else if (n % 2 == 1) {
            console.log(1);
        } else {
            console.log(0);
        }
    }
}

'use strict'

let n; readline();
while(n = parseInt(readline())) { write(n < 5 ? 4 - n : n % 2); }

'use strict'

let n; readline();
while(n = parseInt(readline())) { write(n < 5 ? 4 - n : n % 2 + '\n'); }

var q = parseInt(readline());
var input = []
while (q != 0) {
    q--;
    input.push(parseInt(readline()));
}
input
    .map(num => (num % 2) + (num < 4 ? (4 - num) : 0))
    .forEach(z => print(z))

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

let t = Date.now();

let currentLine = 0;
let i = '';
process.stdin.on('data', c => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  i = i.trim()
    .split('\n')
    .map(string => {
      return string.trim();
    });
  main();
});

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

function main() {
  var x = readLine();
  console.log(x);
  let j = 0;
  for (j = 0; j < x; j++) {
    var cq = readLine();
    //console.log('current query' + cq);
    if (cq == 2) {
      console.log(2);
    } else {
      var rs = cq - Math.floor(cq / 2); //console.log('rs ' + rs);
      var ls = Math.floor(cq / 2); //console.log('ls ' + ls);
      if (ls === rs)
        console.log('0');
      else {
        console.log(rs - ls);
      }
    }
  }
}

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

const input = [];
readline.on('line', line => { input.push(line); });

readline.on('close', () => {
    const n = Number(input[0]);
    const queries = input.slice(1).map(Number);
    console.log(queries);
    queries.forEach(v => {
        if (v === 1) console.log(3);
        else if (v === 2) console.log(2);
        else {
            if (v % 2 === 1) console.log(1);
            else console.log(0);
        }
    })
});

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let nums = data.split('\n').map(v => Number(v));
   nums.shift();
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let [k, ...nums] = data.split('\n').map(v => Number(v));
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let nums = data.split('\n').map(v => parseInt(v,10));
   nums.shift();
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);


You are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor.You must paint a fence which consists of $$$10^{100}$$$ planks in two colors in the following way (suppose planks are numbered from left to right from $$$0$$$):   if the index of the plank is divisible by $$$r$$$ (such planks have indices $$$0$$$, $$$r$$$, $$$2r$$$ and so on) then you must paint it red;  if the index of the plank is divisible by $$$b$$$ (such planks have indices $$$0$$$, $$$b$$$, $$$2b$$$ and so on) then you must paint it blue;  if the index is divisible both by $$$r$$$ and $$$b$$$ you can choose the color to paint the plank;  otherwise, you don't need to paint the plank at all (and it is forbidden to spent paint on it). Furthermore, the Government added one additional restriction to make your punishment worse. Let's list all painted planks of the fence in ascending order: if there are $$$k$$$ consecutive planks with the same color in this list, then the Government will state that you failed the labor and execute you immediately. If you don't paint the fence according to the four aforementioned conditions, you will also be executed.The question is: will you be able to accomplish the labor (the time is not important) or the execution is unavoidable and you need to escape at all costs.

The first line contains single integer $$$T$$$ ($$$1 \le T \le 1000$$$) — the number of test cases. The next $$$T$$$ lines contain descriptions of test cases — one per line. Each test case contains three integers $$$r$$$, $$$b$$$, $$$k$$$ ($$$1 \le r, b \le 10^9$$$, $$$2 \le k \le 10^9$$$) — the corresponding coefficients.

Print $$$T$$$ words — one per line. For each test case print REBEL (case insensitive) if the execution is unavoidable or OBEY (case insensitive) otherwise.

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

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

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

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    let [r, b, k] = arr[j].split(' ').map(a => parseInt(a))
    let x = 0

    let gc = gcd(r, b)
    r /= gc
    b /= gc

    if(r == b) {
      wr('OBEY')
      continue
    }
    if(r > b) {
      let temp = r
      r = b
      b = temp
    }

    let mod = b % r
    if(mod <= 1) x = Math.floor(b / r)
    else x = Math.ceil(b / r)

    if((k - 1) * r + 1 < b) wr('REBEL')
    else wr('OBEY')
  }
})

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

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

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

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

  return gcd(b, a % b);
}

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

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

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

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    const [r, b, k] = arr[j].split(' ').map(a => parseInt(a))
    let x = 0

    if(r == b) {
      wr('OBEY')
      continue
    }
    else if(r < b) {
      let mod = b % r
      if(mod <= 1) x = Math.floor(b / r)
      else x = Math.ceil(b / r)
    }
    else {
      let mod = r % b
      if(mod <= 1) x = Math.floor(r / b)
      else x = Math.ceil(r / b)
    }

    if(x >= k) wr('REBEL')
    else wr('OBEY')
  }
})

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

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

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

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

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

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

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    let [r, b, k] = arr[j].split(' ').map(a => parseInt(a))
    let x = 0

    let gc = gcd(r, b)
    r /= gc
    b /= gc

    if(r == b) {
      wr('OBEY')
      continue
    }
    if(r > b) {
      let temp = r
      r = b
      b = temp
    }

    let mod = b % r
    if(mod <= 1) x = Math.floor(b / r)
    else x = Math.ceil(b / r)

    if((k - 1) * r + 1 < b) wr('OBEY')
    else wr('REBEL')
  }
})

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

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

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

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

  return gcd(b, a % b);
}