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

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

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

		a.sort((x, y) => x - y);

		let ans = n;
		const mp = new Map();
		for (let i = 0; i < n; i++) {
			if (mp.get(a[i]/x) > 0) {
				ans -= 2;
				mp.set(a[i]/x, mp.get(a[i]/x) - 1);
			} else {
				mp.set(a[i], (mp.get(a[i]) || 0) + 1);
			}
		}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var X = nextInt();
		var list = nextIntArray(N);
		var map = getCountMap(list);
		var keys = Object.keys(map);
		keys.sort(function(a,b){
			return b - a;
		});
		for(var i = 0; i < keys.length; i++){
			var L = keys[i];
			var V = map[L];
			if(V > 0 && L % X == 0){
				var R = L / X;
				if(map[R] != null && map[R] > 0){
					V = Math.min(V, map[R]);
					map[L] -= V;
					map[R] -= V;
				}
			}
		}
		var output = 0;
		for(var i = 0; i < keys.length; i++){
			output += map[keys[i]];
		}
		myout(output);
	}
}

'use strict';

function solve(n, m, a) {
  const map = new Map();
  for (let num of a) {
    var _map$get;
    map.set(num, ((_map$get = map.get(num)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
  }
  const keys = [...map.keys()].sort((a, b) => a - b);
  for (let key of keys) {
    const x = map.get(key);
    if (x) {
      const y = map.get(key * m);
      if (y) {
        const min = Math.min(x, y);
        map.set(key, map.get(key) - min);
        map.set(key * m, map.get(key * m) - min);
      }
    }
  }
  let res = 0;
  for (let [i, count] of map) {
    res += count;
  }
  return res;
}

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

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

"use strict";
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] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
    arr.sort((a,b)=>a-b);
    let obj = {};
    for(let i=0;i<n;i++){
      if(obj[arr[i]]) obj[arr[i]]++;
      else obj[arr[i]] = 1;
    }
    let cnt = 0;
    for(let i=0;i<n;i++){
      if(obj[arr[i]]){
        if(obj[arr[i]*x]) obj[arr[i]*x]--;
        else cnt++;
        obj[arr[i]]--;
      }
    }
    console.log(cnt);
};
}
solve();

let inputText = "";

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", (input) => (inputText += input));
process.stdin.on("end", async () => {
  let inputIterator = inputText.split("\n").values();

  let testCases = Number(inputIterator.next().value);
  while (testCases > 0) {
    testCases -= 1;

    const [n, x] = inputIterator
      .next()
      .value.split(" ")
      .map((i) => Number(i));

    let arr = inputIterator
      .next()
      .value.split(" ")
      .map((i) => Number(i));
    arr.sort((x, y) => x - y);

    const used = Array(n).fill(false);
    let ans = 0;
    let j = n - 1;

    for (let i = n - 1; i >= 0; i--) {
      if (used[i]) continue;
      if (arr[i] % x === 0) {
        let f = arr[i] / x;
        while (j >= 0 && (used[j] || arr[j] > f)) {
          j -= 1;
        }
        if (j >= 0 && !used[j] && arr[j] === f) {
          used[i] = true;
          used[j] = true;
          ans += 1;
        }
      }
    }

    console.log(n - 2 * ans);
  }
});

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline();
for(var q=1;q<=T;q++) {
   var [n, x] = readline().split(' ').map(w => parseInt(w));
   var a = readline().split(' ').map(w => parseInt(w));
   var cnt = [];
   a.sort(function(ar, br) { return ar-br })
   var ans = 0;
   var j = 1;
   for(var i=0;i<n && j<n;i++) {
       if(cnt[i] !== undefined) continue;
       while(a[j] <= x*a[i]) {
           if(a[j] == x*a[i]) {
               //console.log(a[i],a[j])
               cnt[j]=true;
               ans++;
               j++;
               break;
           }
           j++;
       }
       //console.log(i,j)
   }
   console.log(n-(2*ans));
}

'use strict';
const { throws } = require('assert');

 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  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 l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

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

const MOD = 1e9+7;

const calc = (n, x, arr)=>{
  let cnt = new Map();
  for (let a of arr)
    cnt.set(a, (cnt.get(a)||0) + 1);
    arr.sort((a, b)=>a-b)
  for (let a of arr){
    if (!cnt.get(a)) continue;
    if (a%x==0){
      let candidate = a/x;
      if (cnt.get(candidate)>0){
        cnt.set(candidate, cnt.get(candidate)-1);
        cnt.set(a, cnt.get(a)-1);
        continue;
      }
    }
    let candidate = a*x;
    if (cnt.get(candidate)>0){
      cnt.set(candidate, cnt.get(candidate)-1);
      cnt.set(a, cnt.get(a)-1);
      continue;
    }
  }
  l(cnt)
  let ans = 0;
  for (let [k, v] of cnt){
    ans += v;
  }
  return ans;
};

function main() {
    let T = +readline()
    while (T--){
      let [n, x] = ra();
      let arr = ra();
      l('ans')
      print(calc(n, x, arr));
    }
}

E.calc = calc;

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline()
for(var q=1;q<=T;q++) {
       let [n, x] = readline().split(" ").map(w => parseInt(w));
       let a = readline().split(" ").map(w => parseInt(w));
       var cnt = [];
       a.sort(function(ar,br) { return ar-br });
       var max = -1000;
       var ans = n;
       for(var i=0;i<n;i++) max = Math.max(max, a[i])
       for(var i=1;i<=max;i++) cnt[i]=0;
       for(var i=0;i<n;i++) {
           cnt[a[i]]++;
           var r = a[i]/x;
           if(cnt[r] !== undefined) {
               if(cnt[r] > 0) {
                   ans -= 2;
                   cnt[r]--;
               }
           }
       }
       console.log(ans);

}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline()
for(var q=1;q<=T;q++) {
       let [n, x] = readline().split(" ").map(w => parseInt(w));
       let a = readline().split(" ").map(w => parseInt(w));
       var cnt = [];
       var max = -1000;
       var ans = n;
       for(var i=0;i<n;i++) max = Math.max(max, a[i])
       for(var i=1;i<=max;i++) cnt[i]=0;
       for(var i=0;i<n;i++) {
           cnt[a[i]]++;
           var r = a[i]/x;
           if(cnt[r] !== undefined) {
               if(cnt[r] > 0) {
                   ans -= 2;
                   cnt[r]--;
               }
           }
       }
       console.log(ans);

}

'use strict';
const { throws } = require('assert');

 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  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 l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

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

const MOD = 1e9+7;

const calc = (n, x, arr)=>{
  let cnt = new Map();
  for (let a of arr)
    cnt.set(a, (cnt.get(a)||0) + 1);
  for (let a of arr){
    if (!cnt.get(a)) continue;
    if (a%x==0){
      let candidate = a/x;
      if (cnt.get(candidate)>0){
        cnt.set(candidate, cnt.get(candidate)-1);
        cnt.set(a, cnt.get(a)-1);
        continue;
      }
    }
    let candidate = a*x;
    if (cnt.get(candidate)>0){
      cnt.set(candidate, cnt.get(candidate)-1);
      cnt.set(a, cnt.get(a)-1);
      continue;
    }
  }
  let ans = 0;
  for (let [k, v] of cnt){
    ans += v;
  }
  return ans;
};

function main() {
    let T = +readline()
    while (T--){
      let [n, x] = ra();
      let arr = ra();
      l('ans')
      print(calc(n, x, arr));
    }
}

E.calc = calc;

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var X = nextInt();
		var list = nextIntArray(N);
		var map = getCountMap(list);
		var keys = Object.keys(map);
		keys.sort(function(a,b){
			return b - a;
		});
		for(var i = 0; i < keys.length; i++){
			var L = keys[i];
			if(map[L] > 0 && L % X == 0){
				var R = L / X;
				if(map[R] != null && map[R] > 0){
					map[L]--;
					map[R]--;
				}
			}
		}
		var output = 0;
		for(var i = 0; i < keys.length; i++){
			output += map[keys[i]];
		}
		myout(output);
	}
}


'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let u = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(u = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= u.length
    },
    readLine: i,
    readLineAsNumber: function () {
      return Number(i())
    },
    readIntegersOfLine: function () {
      const t = i().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = i().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function i() {
    return u[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    u = r >> 1,
    o = Buffer.alloc(r)
  let i = 0
  return {
    flush: s,
    print: function (t) {
      c('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      c(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function s() {
    n.write(o.toString(e, 0, i)), (i = 0)
  }
  function c(t) {
    const c = Buffer.byteLength(t, e)
    r - i < c && (s(), c > u) ? n.write(t) : (o.write(t, i, e), (i += c))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = t.readLineAsNumber()
  for (let r = 1; r <= n; ++r) {
    const n = t.readLineAsNumber(),
      r = t.readIntegersOfLine(),
      u = e()
    function e() {
      const t = r.reduce((t, n) => t + (1 & n), 0),
        e = n - t
      if (Math.abs(t - e) > 1) return -1
      let u = Number.MAX_SAFE_INTEGER
      if (t >= e) {
        u = 0
        for (let t = 0, e = 0; t < n; t += 2, ++e) {
          for (; e < n && !(1 & r[e]); ++e);
          u += Math.abs(e - t)
        }
      }
      let o = Number.MAX_SAFE_INTEGER
      if (e >= t) {
        o = 0
        for (let t = 0, e = 0; t < n; t += 2, ++e) {
          for (; e < n && 0 != (1 & r[e]); ++e);
          o += Math.abs(e - t)
        }
      }
      return u < o ? u : o
    }
    t.println(u)
  }
})

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

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

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

		let ocnt = 0, ecnt;
		for (const elm of a) {
			ocnt += elm % 2;
		}
		ecnt = n - ocnt;

		//console.log({ocnt, ecnt});
		if (Math.abs(ocnt - ecnt) > 1) {
			console.log(-1);
			continue;
		}

		let ans = [0, 0];
		for (let start = 0; start < 2; start++) {
			for (let i = 0, pos = start; i < n; i++) {
				if (a[i]%2) {
					ans[start] += Math.abs(pos - i);
					pos += 2;
				}
			}
		}

		//console.log({ans})
		if (ocnt > ecnt)
			ans = ans[0];
		else if (ocnt < ecnt)
			ans = ans[1];
		else
			ans = Math.min(...ans);

		console.log(ans);
	}
}

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

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

const INF = 1e14;

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

		let ocnt = 0, ecnt;
		for (const elm of a) {
			ocnt += elm % 2;
		}
		ecnt = n - ocnt;

		if (Math.abs(ocnt - ecnt) > 1) {
			console.log(-1);
			continue;
		}

		let ans = [0, 0];
		for (let start = 0; start < 2; start++) {
			for (let i = 0, pos = start; i < n; i++) {
				if (a[i]%2) {
					if (pos >= n) {
						ans[start] = INF;
						break;
					}
					ans[start] += Math.abs(pos - i);
					pos += 2;
				}
			}
		}

		ans = Math.min(...ans);

		console.log(ans);
	}
}

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

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

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

		let ecnt = 0;
		for (const x of a) ecnt += x%2 == 0;

		const ocnt = n - ecnt;
		if (Math.abs(ecnt - ocnt) > 1) {
			console.log(-1); continue;
		}

		let ans = [0, 0];
		for (let k = 0; k < 2; k++) {
			b = a.slice();
			for (let i = 0, needevn = k, ep = op = 0; i < n; i++, needevn = !needevn) {
				while(ep < n && b[ep] % 2 != 0) ep++;
				while(op < n && b[op] % 2 != 1) op++;

				if(needevn != b[i]%2 == 0) {
					ans[k] += (needevn ? ep : op) - i;
					[b[ep], b[op]] = [b[op], b[ep]];
					ep++; op++;
				}
			}
		}

		if (ecnt == ocnt)
			ans = Math.min(ans[0], ans[1]);
		else
			ans = ecnt > ocnt ? ans[1] : ans[0];

		console.log(ans);
	}
}


var arr = readline().split(' ');
var n = parseInt(arr[0]);
var m = parseInt(arr[1]);
// var n = parseInt(readline());
var v = Array(n);
var arr = readline().split(' ');
for (var i = 0; i < n; i ++)
{
    v[i] = parseInt(arr[i]);
}
for (var i = 0; i < m; i ++)
{
    var arr = readline().split(' ');
    var l = parseInt(arr[0]);
    var r = parseInt(arr[1]);
    var t = parseInt(arr[2]);
    if (l<=t && t<=r)
    {
        var vs = v.slice(l-1,r);
        // vs.sort(function(a,b){return a-b;});
        var count = 0;
        for (var j = 0; j < r-l+1; j ++)
        {
            if (vs[j] < v[t-1])
            {
                count ++;
            }
        }
        // print(JSON.stringify(vs));
        print(t-l==count?"Yes":"No");
    }
    else
    {
        print("No");
    }
}

a = readline().split(' ');
b = parseInt(a[0]);
c = parseInt(a[1]);
d = readline().split(' ');
l = new Array(b);
for(x = 0; x < b; x++)
{
     l[x] = parseInt(d[x]);
}
for(x = 1; x <= c; x++)
{
     e = readline().split(' ');
     f = parseInt(e[0]);
     g = parseInt(e[1]);
     h = parseInt(e[2]);
     i = l[h - 1];
     j = 0;
     k = h - f;
     for(y = f - 1; y <= g - 1; y++)
     {
          if(l[y] < i)
          {
               j++;
          }
     }
     if(j == k)
     {
          print('Yes');
     }
     else
     {
          print('No');
     }
}

a = readline().split(' ');
b = parseInt(a[0]);
c = parseInt(a[1]);
d = readline().split(' ');
for(x = 1; x <= c; x++)
{
     e = readline().split(' ');
     f = parseInt(e[0]);
     g = parseInt(e[1]);
     h = parseInt(e[2]);
     i = d[h - 1];
     j = 0;
     k = h - f;
     for(y = f - 1; y <= g - 1; y++)
     {
          if(d[y] < i)
          {
               j++;
          }
     }
     if(j == k)
     {
          print('Yes');
     }
     else
     {
          print('No');
     }
}


/*
* auther yeling
*
*
*/
'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 print(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, nums) {
    nums = nums.map((value) => {
        let ret = [];
        if(value[0] < value[1]) {
            ret = value;
        } else {
            ret = [value[1], value[0]];
        }
        return ret;
    })
    //print(nums.join(' '));
    nums.sort((a,b) => {
        return a[1] - b[1];
    })
    //print(nums);
    let sum = 0;
    for(let i = 0; i < nums.length; i++) {
        if(i == 0 ) {
            sum += nums[i][1];
        }
        if(i == nums.length - 1) {
            sum += nums[i][1];
        }
        sum += 2 * nums[i][0];
        if(i > 0) {
            sum += nums[i][1] - nums[i-1][1];
        }
    }
    print(sum);
}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        let nums = [];
        for(let j = 0; j < n; j++) {
            var x = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
            nums.push(x);
        }
        begin(n, nums);
    }
}

t = +readline();

while(t--) {
    n = +readline();

    a = [];
    b = [];

    while(n--) {
        side = readline().split(' ');

        a.push(+side[0]);
        b.push(+side[1]);
    }

    maxA = Math.max(...a);
    maxB = Math.max(...b);

    height = Math.max(maxA, maxB);

    width = a.reduce((prevVlue, currentValue, index)=>{
        minValue = Math.min(currentValue, b[index]);

        return prevVlue + minValue;
    }, 0);

    print(height*2 + width*2);
}

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]);
    let cnt=0;
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[++cnt]);
        let a=[],b=[];
        let ans=0;
        for(let i=1;i<=n;i++)
        {
            let [x,y]=line[++cnt].split(' ').map(x=>{return parseInt(x)});
            a.push([x,y]);
            b.push(x);
            b.push(y);
            ans+=2*(x+y);
        }
        let mx1=-1,mx2=-1,mx3=-1;
        for(let i=0;i<2*n;i++)
        {
            let x=b[i];
            if(x>mx1)
            {
                mx2=mx1;
                mx3=mx2;
                mx1=x;
            }
            else if(x>mx2)
            {
                mx3=mx2;
                mx2=x;
            }
            else if(x>mx3)
            {
                mx3=x;
            }
        }
        flag=true;
        for(let i=0;i<n;i++)
        {
            let x=Math.max(a[i][0],a[i][1]);
            let y=Math.min(a[i][0],a[i][1]);
            if(flag&&x===mx1)
            {
                flag=false;
                continue;
            }
            if(x<mx1) ans-=2*x;
            else if(y!=mx2) ans-=2*mx2;
            else if(n>1) ans-=2*mx3;
        }
        console.log(ans);
    }
})

let buf='';

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

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    let cnt=0;
    for(let _=1;_<=t;_++)
    {
        let n=parseInt(line[++cnt]);
        let a=[],b=[];
        let ans=0;
        for(let i=1;i<=n;i++)
        {
            let [x,y]=line[++cnt].split(' ').map(x=>{return parseInt(x)});
            a.push([x,y]);
            b.push(x);
            b.push(y);
            ans+=2*(x+y);
        }
        // console.log(a);
        // b.sort(function(x,y){
        //     return x-y;
        // });
        // console.log(b);
        let mx1=-1,mx2=-1,mx3=-1;
        for(let i=0;i<2*n;i++)
        {
            let x=b[i];
            if(x>mx1)
            {
                mx2=mx1;
                mx3=mx2;
                mx1=x;
            }
            else if(x>mx2)
            {
                mx3=mx2;
                mx2=x;
            }
            else if(x>mx3)
            {
                mx3=x;
            }
        }
        flag=true;
        for(let i=0;i<n;i++)
        {
            let x=Math.max(a[i][0],a[i][1]);
            let y=Math.min(a[i][0],a[i][1]);
            // let l=0,r=2*n-1;
            // while(l<r)
            // {
            //     let mid=Math.floor((l+r+1)/2);
            //     if(b[mid]>x) r=mid-1;
            //     else l=mid;
            // }
            // ans-=b[l-1];
            // console.log(b[l-1]);
            if(flag&&x===mx1)
            {
                flag=false;
                continue;
            }
            // console.log(ans);
            if(x<mx1) ans-=2*x;
            else if(y!=mx2) ans-=2*mx2;
            else if(n>1) ans-=2*mx3;
            // flag=false;
        }
        console.log(ans);
    }
})

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;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
    var n = readline();
    var maxY = -inf;
    var x = 0;
    for(var i=0;i<n;i++) {
        var [a,b] = readline().split(" ").map(w => parseInt(w));
        maxY = max(maxY, max(a,b));
        x += min(a,b);
    }
    console.log((2*maxY) + (2*x));
}

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

// your code goes here

// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;

// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
    input_stdin += data;
});

// standard input is done and stored into an array
process.stdin.on('end', function () {
    lines = input_stdin.split("\n");
    start();
});

function start() {
    const T = parseInt(lines[0])
    let line = 1
    for (let t = 1; t <= T; t++) {
        const n = parseInt(lines[line++].split(' ')[0], 10)
        let sum = 0, max = 0;

        for (let i = 0; i < n; i++) {
            const a = parseInt(lines[line].split(' ')[0], 10)
            const b = parseInt(lines[line++].split(' ')[1], 10)
            sum += Math.min(a, b);
            if (max < Math.max(a, b))
                max = Math.max(a, b)
        }

        sum += max;
        console.log(sum * 2)

    }
}

'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();
  let res = 0,
      max = 0;
  for (let i = 0; i < n; i++) {
    let [x, y] = rns();
    if (x > y) [x, y] = [y, x];
    res += x;
    max = Math.max(max, y);
  }
  return (res + max) * 2;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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


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

	function main() {
		var testCasesNum = +readline();
		for (var i = 0; i < testCasesNum; i++) {
			var count = 0;
			var hasOnes = true;
			var s = readline();
			for (var j = 0; j < s.length; j++) {
				if (s[j] === '0' && hasOnes) {
					hasOnes = false;
					count++;
					if (count === 2) {
						break;
					}
				}
				if (s[j] === '1') {
					hasOnes = true;
				}
			}
			print(count);
		}
	}

	main();

'use strict';

function solve(s) {
  const n = s.length;
  const dp = new Array(n).fill(0);
  for (let i = 0; i < n; i++) {
    var _dp, _dp2;
    if (s[i] !== s[i - 1] && s[i] === '0') dp[i] = ((_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0) + 1;else dp[i] = (_dp2 = dp[i - 1]) !== null && _dp2 !== void 0 ? _dp2 : 0;
  }
  return Math.min(2, dp[n - 1]);
}

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

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

'use strict';

function solve(s) {
  const n = s.length;
  const dp = new Array(n).fill(0);
  for (let i = 0; i < n; i++) {
    var _dp2, _dp3;
    if (s[i] === s[i - 1]) {
      var _dp;
      dp[i] = (_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0;
      continue;
    }
    if (s[i] === '0') dp[i] = ((_dp2 = dp[i - 1]) !== null && _dp2 !== void 0 ? _dp2 : 0) + 1;else dp[i] = (_dp3 = dp[i - 1]) !== null && _dp3 !== void 0 ? _dp3 : 0;
  }
  return Math.min(2, dp[n - 1]);
}

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

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

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

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

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

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    var res = solveMeFirst(b);
    // let out = "";
    // if (res) {
    //   for (let i = 0; i < res.length; i++) {
    //     out += res[i] + " ";
    //   }
    console.log(res);
    // }
  }
}
function solveMeFirst(str) {
  // console.log(str);
  let res,
    res2 = 0;
  if (str.includes("0") && str.includes("1")) res = 2;
  else if (str.includes("0")) res = 1;
  else res = 0;
  let isOne = false;
  for (let i = 0; i < str.length; i++) {
    if (str[i] == "0" && !isOne) {
      res2 += 1;
      isOne = true;
    }
    if (str[i] == "1" && isOne) {
      isOne = false;
    }
  }
  // console.log(res2, res);
  return res > res2 ? res2 : res;
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));

//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] = BigInt(next());
		}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 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 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;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var s = next().split("1");
		var count = 0;
		for(var i = 0; i < s.length; i++){
			if(s[i] != ''){
				count++;
			}
		}
		myout(Math.min(count, 2));
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
let standardInputString = '';
let curLine = 0;

const readLine = () => {
  return standardInputString[curLine++];
};

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

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

  main();
});

/**
 * 7
 * 0000
 * 1111
 * 0101
 * 110
 * 011
 * 1011
 * 1010
 */

// https://codeforces.com/contest/1566/problem/B
const main = () => {
    const t = +readLine();

    for (let _ = 0; _ < t; _ += 1) {
        const str = readLine();

        if (str === '1'.repeat(str.length)) {
            console.log(0);
        } else {
            const withoutOnes = str.replace(/^1+/, '').replace(/1+$/, '');

            if (withoutOnes === '0'.repeat(withoutOnes.length)) {
                console.log(1);
            } else {
                console.log(2);
            }
        }
    }
};

var n = parseInt(readline());

for (var i = 0; i < n; i++) {
    var s = readline();
    var z = s.charAt(0) === '0' ? 1 : 0;
    for (var j = 1; j < s.length; j++) {
        if (s.charAt(j) === '0' && s.charAt(j-1) === '1')
            z += 1;
    }

    print(Math.min(z, 2));
}

'use strict';

function solve(s) {
  const n = s.length
  const dp = new Array(n + 1).fill(0)
  for (let i = 1; i <= n; i++) {
    if (s[i - 1] === s[i - 2]) continue
    if (s[i - 1] === '1') dp[i] = dp[i - 1]
    else dp[i] = dp[i - 1] + 1
  }
  return Math.min(2, dp[n])
}

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

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

'use strict';

function solve(s) {
  const n = s.length
  const dp = new Array(n + 1).fill(0)
  for (let i = 1; i <= n; i++) {
    if (s[i - 1] === '1') dp[i] = dp[i - 1]
    else dp[i - 1] = dp[i - 1] + 1
  }
  return Math.min(2, dp[n])
}

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

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

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

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

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

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    var res = solveMeFirst(b);
    // let out = "";
    // if (res) {
    //   for (let i = 0; i < res.length; i++) {
    //     out += res[i] + " ";
    //   }
    console.log(res);
    // }
  }
}
function solveMeFirst(str) {
  // console.log(str);
  let res,
    res2 = 0;
  if (str.includes("0") && str.includes("1")) res = 2;
  else if (str.includes("0")) res = 1;
  else res = 0;
  for (let i = 0; i < str.length; i++) {
    if (str[i] == "0") res2 += 1;
  }
  // console.log(res2);
  return res > res2 ? res2 : res;
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));

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

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

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

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    var res = solveMeFirst(b);
    // let out = "";
    // if (res) {
    //   for (let i = 0; i < res.length; i++) {
    //     out += res[i] + " ";
    //   }
    console.log(res);
    // }
  }
}
function solveMeFirst(str) {
  console.log(str);
  let res,
    res2 = 0;
  if (str.includes("0") && str.includes("1")) res = 2;
  else if (str.includes("0")) res = 1;
  else res = 0;
  for (let i = 0; i < str.length; i++) {
    if (str[i] == "0") res2 += 1;
  }
  // console.log(res2);
  return res > res2 ? res2 : res;
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));


function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}

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

var extract = 1;
c.forEach(function(num) {
    num /= gcd(num, extract);
    var temp = gcd(num, k);
    k /= temp;
    extract *= temp;
});
print((k === 1) ? 'Yes' : 'No');

'use strict';

// var inpArr = `
// 15 91
// 49 121 83 67 128 125 27 113 41 169 149 19 37 29 71
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}
function lcm(a, b) {
  return (a * b) / gcd(a, b);
}

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

var req = k, acc = 1;
for (var i = 0; i < arr.length; i++) {
  arr[i] /= gcd(arr[i], acc);
  var extract = gcd(req, arr[i]);
  req /= extract; acc *= extract;
  if (req === 1) {
    break;
  }
}

print((req === 1) ? 'Yes' : 'No')

'use strict';

// var inpArr = `
// 2 7
// 2 3
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}
function lcm(a, b) {
  return (a * b) / gcd(a, b);
}

var nk = readline().split(' ').map(Number),
    n = nk[0], k = nk[1]
var arr = readline().split(' ').map(Number),
    lcmArr = arr.reduce((res,x)=>lcm(res,x), 1);
print((lcmArr % k === 0) ? 'Yes' : 'No')

'use strict';

// var inpArr = `
// 15 91
// 49 121 83 67 128 125 27 113 41 169 149 19 37 29 71
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}
function lcm(a, b) {
  return (a * b) / gcd(a, b);
}

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

var req = k;
for (var i = 0; i < arr.length; i++) {
  var extract = gcd(req, arr[i]);
  req /= extract;
  if (req === 1) {
    break;
  }
}

print((req === 1) ? 'Yes' : 'No')

function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}
function lcmOfTwo(a, b) {
    return (a * b) / gcd(a, b);
}

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

var lcm = 1;
c.forEach(function(num) {
    lcm = lcmOfTwo(lcm, gcd(num, k));
});
print(lcm)
print((lcm%k === 0) ? 'Yes' : 'No');

function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}
function lcmOfTwo(a, b) {
    return (a * b) / gcd(a, b);
}

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

var lcm = 1;
c.forEach(function(n) {
    lcm = lcmOfTwo(lcm, n);
});
print((lcm%k === 0) ? 'Yes' : 'No');

function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}

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

var extract = 1;
c.forEach(function(num) {
    num /= gcd(num, extract);
    k /= gcd(num, k);
    extract *= gcd(num, k);
});
print((k === 1) ? 'Yes' : 'No');

function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
}
function lcmOfTwo(a, b) {
    return (a * b) / gcd(a, b);
}

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

c.forEach(function(num) {
    k /= gcd(num, k);
});
print((k === 1) ? 'Yes' : 'No');


"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let obj = {};
    let res = [],
      flag = 0;
    for (let i = 0; i < n; i++) {
      if (arr[i] === 0 && flag === 0) {
        flag = 1;
        res.push(0);
      } else if (arr[i] === 0 && flag === 1) continue;
      else res.push(arr[i]);
    }
    if (res.length === 1) console.log("YES");
    else if (res.length > 5) console.log("NO");
    else {
      for (let i = 0; i < res.length; i++) {
        if (obj[res[i]] === undefined) obj[res[i]] = 1;
      }
      flag = 0;
      for (let i = 0; i < res.length; i++) {
        for (let j = i + 1; j < res.length; j++) {
          for (let k = j + 1; k < res.length; k++) {
            let sum = res[i] + res[j] + res[k];
            if (obj[sum] !== 1) {
              flag = 1;
            }
          }
        }
      }
      if (flag === 1) console.log("NO");
      else console.log("YES");
    }
  }
};
solve();

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m) {
                        if (!lookup[(test[l] + test[m] + test[n]).toString()]) {
                            result = 'NO';
                        }
                    }
                }
            }
        }
        output(result);
    }
}

'use strict';

function solve(n, a) {
  const nums = [],
        map = new Map();
  for (let num of a) {
    var _map$get;
    map.set(num, ((_map$get = map.get(num)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
    if (num !== 0 && map.get(num) > 2) return 'NO';
    if (map.get(num) <= 2) nums.push(num);
  }
  const N = nums.length;
  for (let i = 0; i < N; i++) {
    for (let j = i + 1; j < N; j++) {
      for (let k = j + 1; k < N; k++) {
        if (!map.has(nums[i] + nums[j] + nums[k])) return 'NO';
      }
    }
  }
  return 'YES';
}

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

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

'use strict';

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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        if (i === 750) {
            output(arr.filter(num => num !== 0));
            return;
        }
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        if (i === 750) {
            output(arr.filter(num => num !== 0).length);
            return;
        }
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        if (i === 750) {
            output(arr.join(','));
            return;
        }
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        if (i === 750) {
            output(n);
            return;
        }
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        if (i === 750) {
            output(n + ' ' + arr.join(','));
            return;
        }
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[(arr[l] + arr[m] + arr[n]).toString()]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        const zero = arr.filter(num => num === 0).slice(0, 2);
        const test = nonZero.concat(zero);
        if (nonZero.length > 4) {
            output('NO');
            continue;
        }
        let result = 'YES';
        for (let l = 0; l < test.length; l++) {
            for (let m = 1; m < test.length; m++) {
                for (let n = 2; n < test.length; n++) {
                    if (l !== m && l !== n && n !== m && !lookup[arr[l] + arr[m] + arr[n]]) {
                        result = 'NO';
                    }
                }
            }
        }
        output(result);
    }
}

'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 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 i = 0; i < N; i++) {
        const n = Number(readline());
        let arr = readline().split(' ').map(Number);
        const lookup = {};
        for (let num of arr) lookup[num] = true;
        if (n === 3) {
            output(lookup[arr[0] + arr[1] + arr[2]] ? 'YES': 'NO');
            continue;
        }
        const nonZero = arr.filter(num => num !== 0);
        if (nonZero.length < 2) {
            output('YES');
        } else if (nonZero.length === 2) {
            const areInverse = nonZero[0] === -1 * nonZero[1];
            output(areInverse ? 'YES' : 'NO');
        } else {
            output('NO');
        }
    }
}

'use strict';

function solve(n, a) {
  if (n === 3) return new Set(a).has(a.reduce((a, b) => a + b, 0)) ? 'YES' : 'NO';
  let nums = [],
    map = new Map(),
    zero = 0;
  for (let i = 0; i < n; i++) {
    if (a[i] !== 0) {
      var _map$get;
      nums.push(a[i]);
      map.set(a[i], ((_map$get = map.get(a[i])) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
    } else zero++;
  }
  if (zero) {
    if (nums.length < 2) return 'YES';
    if (nums.length === 2) {
      return nums[0] + nums[1] === 0 ? 'YES' : 'NO';
    } else {
      return 'NO';
    }
  } else {
    if (map.size !== 2) return 'NO';
    const [x, y] = [...map];
    if (x[0] + y[0] !== 0) return 'NO';
    if (x[1] > 2 || y[1] > 2) return 'NO';
    return 'YES';
  }
}

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

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

'use strict';

function solve(n, a) {
  if (n === 3) return new Set(a).has(a.reduce((a, b) => a + b, 0)) ? 'YES' : 'NO';
  let nums = [],
      set = new Set(),
      zero = 0;
  for (let i = 0; i < n; i++) {
    if (a[i] !== 0) {
      nums.push(a[i]);
      set.add(a[i]);
    } else zero++;
  }
  if (zero) {
    if (nums.length < 2) return 'YES';
    if (nums.length === 2) {
      return nums[0] + nums[1] === 0 ? 'YES' : 'NO';
    } else {
      return 'NO';
    }
  } else {
    if (set.size > 2) return 'NO';
    const [x, y] = [...set];
    if (x + y === 0) return 'YES';
    return 'NO';
  }
}

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

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

'use strict';

function solve(n, a) {
  if (n === 3) return new Set(a).has(a.reduce((a, b) => a + b, 0)) ? 'YES' : 'NO';
  let nums = [],
      set = new Set(),
      zero = 0;
  for (let i = 0; i < n; i++) {
    if (a[i] !== 0) {
      nums.push(a[i]);
      set.add(a[i]);
    } else zero++;
  }
  if (zero) {
    if (nums.length === 2) {
      return nums[0] + nums[1] === 0 ? 'YES' : 'NO';
    } else if (nums.length > 2) {
      return 'NO';
    }
  } else {
    if (set.size > 2) return 'NO';
    const [x, y] = [...set];
    if (x + y !== 0) return 'NO';
  }
  return 'YES';
}

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

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

'use strict';

function solve(n, a) {
  if (n === 3) return new Set(a).has(a.reduce((a, b) => a + b, 0)) ? 'YES' : 'NO';
  let nums = [];
  for (let i = 0; i < n; i++) {
    if (a[i] !== 0) nums.push(a[i]);
  }
  if (nums.length === 2) {
    return nums[0] + nums[1] === 0 ? 'YES' : 'NO';
  } else if (nums.length > 2) {
    return 'NO';
  }
  return 'YES';
}

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

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

'use strict';

function solve(n, a) {
  if (n === 3) return a.reduce((a, b) => a + b, 0) === 0 ? 'YES' : 'NO';
  let nums = [];
  for (let i = 0; i < n; i++) {
    if (a[i] !== 0) nums.push(a[i]);
  }
  if (nums.length === 2) {
    return nums[0] + nums[1] === 0 ? 'YES' : 'NO';
  } else if (nums.length > 2) {
    return 'NO';
  }
  return 'YES';
}

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

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

'use strict';

function solve(n, a) {
  let nums = [];
  for (let i = 0; i < n; i++) {
    if (a[i] === 0) ;else nums.push(a[i]);
  }
  if (nums.length > 2) return 'NO';
  if (nums.length <= 1) return 'YES';
  if (nums[0] + nums[1] === 0) return 'YES';
  return 'NO';
}

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

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

'use strict';

function solve(n, a) {
  const set = new Set(a);
  a.sort((a, b) => a - b);
  for (let i = 2; i < n; i++) {
    const sum = a[i] + a[i - 1] + a[i - 2];
    if (!set.has(sum)) return 'NO';
  }
  return 'YES';
}

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

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

"use strict";
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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let obj = {};
    let res = [],
      flag = 0;
    for (let i = 0; i < n; i++) {
      if (arr[i] === 0 && flag === 0) {
        flag = 1;
        res.push(0);
      }
      res.push(arr[i]);
    }
    if (res.length > 5) console.log("NO");
    else {
      for (let i = 0; i < res.length; i++) {
        if (obj[res[i]] === undefined) obj[res[i]] = 1;
      }
      flag = 0;
      for (let i = 0; i < res.length; i++) {
        for (let j = i + 1; j < res.length; j++) {
          for (let k = j + 1; k < res.length; k++) {
            let sum = res[i] + res[j] + res[k];
            if (obj[sum] !== 1) {
              flag = 1;
            }
          }
        }
      }
      if (flag === 1) console.log("NO");
      else console.log("YES");
    }
  }
};
solve();

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let obj = {};
    let res = [];
    if (arr.length === 3) {
      let k = arr[0] + arr[1] + arr[2];
      if (k === arr[0] || k === arr[1] || k === arr[2]) console.log("YES");
      else console.log("NO");
      continue;
    }
    for (let i = 0; i < n; i++) if (arr[i] !== 0) res.push(arr[i]);
    if (res.length === 0) console.log("YES");
    else {
      if (res.length > 2) console.log("NO");
      else {
        if (Math.abs(res[0]) === Math.abs(res[1])) console.log("YES");
        else console.log("NO");
      }
    }
  }
};
solve();

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let obj = {};
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]] === undefined) obj[arr[i]] = 1;
    }
    let k = arr[0] + arr[1] + arr[2];
    if (obj[k] !== 1) {
      console.log("NO");
      continue;
    }
    let flag = 1;
    for (let i = 3; i < n; i++) {
      if (arr[i] !== 0) {
        flag = 0;
        break;
      }
    }
    if (flag === 1) console.log("YES");
    else console.log("NO");
  }
};
solve();