There are three sticks with integer lengths $$$l_1, l_2$$$ and $$$l_3$$$.You are asked to break exactly one of them into two pieces in such a way that:   both pieces have positive (strictly greater than $$$0$$$) integer length;  the total length of the pieces is equal to the original length of the stick;  it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides. A square is also considered a rectangle.Determine if it's possible to do that.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The only line of each testcase contains three integers $$$l_1, l_2, l_3$$$ ($$$1 \le l_i \le 10^8$$$) — the lengths of the sticks.

For each testcase, print "YES" if it's possible to break one of the sticks into two pieces with positive integer length in such a way that it's possible to construct a rectangle from the resulting four sticks. Otherwise, print "NO". You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as a positive answer).

NoteIn the first testcase, the first stick can be broken into parts of length $$$1$$$ and $$$5$$$. We can construct a rectangle with opposite sides of length $$$1$$$ and $$$5$$$.In the second testcase, breaking the stick of length $$$2$$$ can only result in sticks of lengths $$$1, 1, 2, 5$$$, which can't be made into a rectangle. Breaking the stick of length $$$5$$$ can produce results $$$2, 3$$$ or $$$1, 4$$$ but neither of them can't be put into a rectangle.In the third testcase, the second stick can be broken into parts of length $$$2$$$ and $$$2$$$. The resulting rectangle has opposite sides $$$2$$$ and $$$2$$$ (which is a square).In the fourth testcase, the third stick can be broken into parts of length $$$2$$$ and $$$2$$$. The resulting rectangle has opposite sides $$$2$$$ and $$$5$$$.

var t = +readline()
for(var index = 1; index<=t; index++){
    var test = readline().split(' ')
    var a = +test[0]
    var b = +test[1]
    var c = +test[2]
    print(taskContext1(a,b,c))

}

function taskContext1(a,b,c) {

       if ((b == c && a % 2 == 0) || (a == c && b % 2 == 0) || (b == a && c % 2 == 0)){
    return 'Yes'
  }
  else if (a == b + c || b == c + a || c == a + b){
    return 'Yes'
  }

  return 'No'

}

var tests =parseInt(readline());
for(var i=0 ; i<tests ; i++){

    var data =readline().split(" ").map(i => parseInt(i));
    if((data[0] === data[1] && data[2] %2 == 0) || (data[0] === data[2] && data[1] %2 ==0 ) || (data[1] === data[2] && data[0] %2 ==0)) print("YES");
    else if(data[0] + data[1] == data[2] || data[0] + data[2] == data[1] || data[1] + data[2] == data[0]) print("YES");
    else print("NO");
}

 var t = parseInt(readline());

  function check(val) {
    return val % 2 === 0
  }

  function solve() {
    var input = readline()
      .split(" ")
      .map((data) => +data).sort((a, b) => {
        if (a > b) {
          return 1;
        } else if (a < b) {
          return -1;
        } else {
          return 0;
        }
      });
    var val1 = input[0]
    var val2 = input[1]
    var val3 = input[2]

    if (val1 === val2) {
      if (!check(val3)) {
        return "NO"
      } else {
        return "YES"
      }
    } else if (val2 === val3) {
      if (!check(val1)) {
        return "NO"
      } else {
        return "YES"
      }
    } else if (val3 === val1) {
      if (!check(val2)) {
        return "NO"
      } else {
        return "YES"
      }
    }

    var val = val1 + val2
    if (val === val3) {
      return "YES"
    }
    return "NO"
  }

  while (t--) {
    print(solve())
  }

t = readline()
while (t--) {
    input = readline().split(" ").map(Number).sort(function (a, b) { return a - b });
    if (input[0] === input[1] || input[1] === input[2] || input[0] === input[2]) {
        if (input[0] === input[1]) {
            if (input[2] % 2 === 0) {
                print("YES")
            } else {
                print("NO")
            }
        } else if (input[1] === input[2]) {
            if (input[0] % 2 === 0) {
                print("YES")
            } else {
                print("NO")
            }
        } else if (input[0] === input[2]) {
            if (input[1] % 2 === 0) {
                print("YES")
            } else {
                print("NO")
            }
        }
    } else {
        if (input[2] === input[0] + input[1]) {
            print("YES")
        } else {
            print("NO")
        }
    }
}

const numTestCases = parseInt(readline());

for (var i = 0; i < numTestCases; i++) {
    var inputNums = readline().split(' ');
    var l1 = parseInt(inputNums[0]);
    var l2 = parseInt(inputNums[1]);
    var l3 = parseInt(inputNums[2]);
    if (l1 === l2 + l3 || l2 === l1 + l3 || l3 === l2 + l1) {
        print ("Yes");
        continue;
    }

    if (l1 % 2 === 0 && l2 === l3 || (l2 % 2 === 0 && l1 === l3) || (l3 % 2 === 0 && l1 === l2)) {
        print("Yes");
    } else {
        print("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() {
    var test = readLine();
    while(test--)
    {
        var arr = readLine().split(" ").map((x) => {return parseInt(x)});
        arr.sort();
        var a = arr[0];
        var b = arr[1];
        var c = arr[2];
        var sum = a+b+c;
        if (a+b == c || b+c==a || a+c==b){
        console.log("YES");
        }
        else if (a == b && c % 2 == 0){
            console.log("YES");
        }
        else if (b == c && a % 2 == 0){
            console.log("YES");
        }
        else if (a == c && b % 2 == 0){
            console.log("YES");
        }
        else{
            console.log("NO");
        }

    }
    return 0;
}

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 arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(arr) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(arr) {
    arr.sort((p, q) => p - q)
    return arr[0] + arr[1] === arr[2]
        || (arr[0] === arr[1] && !(arr[2] & 1))
        || (arr[1] === arr[2] && !(arr[0] & 1))
}

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 a = readline().split(" ").map(f => parseInt(f));
        console.log(solve(a))
        function solve(x) {
            if(x[0] == x[1]+x[2] || x[1] == x[0]+x[2] || x[2] == x[0]+x[1]) {
                return 'YES';
            }
            var x1 = x[1]==x[2]
            var x2 = x[0]==x[2]
            var x3 = x[1]==x[0]
            if(x1 && x[0]%2==0) return 'YES';
            if(x2 && x[1]%2==0) return 'YES';
            if(x3 && x[2]%2==0) return 'YES';
            return 'NO';
        }

}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const tsc = parseInt(await getLine());
    for(let nsc = 0; nsc < tsc; nsc++) {
        const l = (await getLine()).split(' ').map(s => parseInt(s));
        l.sort((a,b) => (a - b));
        if (l[1] === l[2]) {
            if (l[0] % 2 === 0)
                console.log('YES');
            else
                console.log('NO');
        }
        else {
           if (l[0] + l[1] === l[2] || (l[0] === l[1] && l[2] % 2 === 0))  {
               console.log('YES');
           } else
               console.log('NO');
        }
    }
}

solve();

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

        if(a + b == c){
            console.log('YES');
            continue;

        }if(b + c == a){
            console.log('YES');
            continue;

        }if(c + a == b){
            console.log('YES');
            continue;
        }
        console.log('NO');
    }
});

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else 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 list = nextIntArray(3);
		list.sort(function(a,b){
			return a - b;
		});
		var ok = false;
		for(var i = 0; i < list.length; i++){
			var L1 = list[i];
			var L2 = list[(i + 1) % 3];
			var L3 = list[(i + 2) % 3];
			if(L1 == L2 + L3){
				ok = true;
			}
			if(L1 % 2 == 0){
				if(L2 == L3){
					ok = true;
				}
			}
		}
		if(ok){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = nl.nums();
		a.sort((a, b) => a - b);
		ans.push(a[0] + a[1] === a[2] || (a[0] === a[1] && a[2]%2 === 0) || (a[0]%2 === 0 && a[1] === a[2]));
	}
	console.log(ans.map(e => e?"YES":"NO").join('\n'));
};

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

var fs = require('fs'), currentline = 0, input = fs.readFileSync(0, 'utf8').trim().split('\n');
function readline() { return input[currentline++]; }
var T = +readline();
while (T--) {
    //let n = +readline();
    var nums = readline().split(' ').map(function (x) { return Number(x); });
    var l1 = nums[0], l2 = nums[1], l3 = nums[2];
    var ans = (l1 == l2 + l3) || (l2 == l1 + l3) || (l3 == l1 + l2); //lb
    var ans2 = (l1 % 2 == 0 && l2 == l3) || (l2 % 2 == 0 && l1 == l3) || (l3 % 2 == 0 && l1 == l2); //ll
    if (ans || ans2)
        console.log("YES");
    else
        console.log("NO");
}

"use strict";

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

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

// ********** Code Start **********

function main() {

const x=+readline();
let s=[];
for(let i=0;i<x;i++){
    let y=readline().split(" ");
    if(parseInt(y[0])+parseInt(y[1])==parseInt(y[2])||parseInt(y[1])+parseInt(y[2])==parseInt(y[0])||parseInt(y[0])+parseInt(y[2])==parseInt(y[1])) s.push("YES");
    else if(parseInt(y[0])===parseInt(y[1]) && parseInt(y[2])%2===0) s.push("YES");
    else if(parseInt(y[2])===parseInt(y[1]) && parseInt(y[0])%2===0) s.push("YES");
    else if(parseInt(y[0])===parseInt(y[2]) && parseInt(y[1])%2===0) s.push("YES");
    else s.push("NO");
}

for(let i=0;i<s.length;i++){
    console.log(s[i]);

}
}

var count = parseInt(readline());

while (count--){
    var n = readline().split(" ").map(Number).sort();
    if (n[0] + n[1] === n[2]) {
        print("yes");
    }else if (n[0] === n[1] && (n[2] % 2 === 0)) {
        print("yes");
    }else if (n[1] === n[2] && (n[0] % 2 === 0)) {
        print("yes");
    }else{
        print("no");
    }
}

var tests =parseInt(readline());
for(var i=0 ; i<tests ; i++){

    var data =readline().split(" ").map(i => parseInt(i));
    if(((data[0] === data[1]) && data[2] %2 == 0) || ((data[0] === data[2]) && data[1] %2 ==0 ) || ((data[1] === data[2]) && data[0] %2 ==0)) {
        print("YES");

    }
    else{
        var largest = data.sort().reverse();
        if(largest[0] === largest[1]+largest[2]){
            print("YES");
        }
        else{
            print("NO");
        }
    }
}

var t = +readline()
for(var index = 1; index<=t; index++){
    var test = readline().split(' ')
    var a = +test[0]
    var b = +test[1]
    var c = +test[2]
    print(taskContext1(a,b,c))

}

function taskContext1(a,b,c) {

      var test = a+b+c
      if ((test) % 2 == 0 && test >= 4){
            return 'Yes'
      }else {
            return 'No'
      }

}

 var t = parseInt(readline());

  function check(val) {
    return val % 2 === 0
  }

  function solve() {
    var input = readline()
      .split(" ")
      .map((data) => +data).sort((a, b) => {
        if (a > b) {
          return 1;
        } else if (a < b) {
          return -1;
        } else {
          return 0;
        }
      });
    var val1 = input[0]
    var val2 = input[1]
    var val3 = input[2]

    if (val1 === val2) {
      if (!check(val3)) {
        return "NO"
      } else {
        return "YES"
      }
    } else if (val2 === val3) {
      if (!check(val1)) {
        return "NO"
      } else {
        return "YES"
      }
    } else if (val3 === val1) {
      if (!check(val2)) {
        return "NO"
      } else {
        return "YES"
      }
    }

    if (val1 < val3 && val2 < val3) {
      return "YES"
    }
    return "NO"
  }

  while (t--) {
    print(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 main() {
    var test = readLine();
    while(test--)
    {
        var arr = readLine().split(" ").map((x) => {return parseInt(x)});
        arr.sort();
        var a = arr[0];
        var b = arr[1];
        var c = arr[2];
        var sum = a+b+c;
        if (a != b && b != c && a != c) {
            if (arr[2] === arr[1] + arr[0]) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }
        else {
            if ((sum)%2 === 0) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }

    }
    return 0;
}

'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() {
    var test = readLine();
    while(test--)
    {
        var arr = readLine().split(" ").map((x) => {return parseInt(x)});
        arr.sort();
        var a = arr[0];
        var b = arr[1];
        var c = arr[2];
        if (a != b && b != c && a != c) {
            if (arr[2] === arr[1] + arr[0]) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }
        else {
            if ((a+b+c)%2 === 0) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }

    }
    return 0;
}

'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() {
    var test = readLine();
    while(test--)
    {
        var arr = readLine().split(" ").map((x) => {return parseInt(x)});
        arr.sort();
        if (arr[0] != arr[1] && arr[1] != arr[2] && arr[2] != arr[0]) {
            if (arr[2] === arr[1] + arr[0]) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }
        else {
            if ((arr[0] + arr[1] + arr[2])%2 === 0) {
                console.log("YES");
            }
            else{
                console.log("NO");
            }
        }

    }
}

let l1, l2, l3;
if (l1 === l3 && l1 === l2){
    return console.log('Yes');
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const tsc = parseInt(await getLine());
    for(let nsc = 0; nsc < tsc; nsc++) {
        const l = (await getLine()).split(' ').map(s => parseInt(s));
        l.sort((a,b) => (a - b));
        if (l[1] === l[2]) {
            if (l[0] % 2 === 0)
                console.log('YES');
            else
                console.log('NO');
        } else {
           if (l[0] + l[1] === l[2])  {
               console.log('YES');
           } else
               console.log('NO');
        }
    }
}

solve();


You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$.Let's define a transformation of the array $$$a$$$:  Choose any non-negative integer $$$k$$$ such that $$$0 \le k \le n$$$.  Choose $$$k$$$ distinct array indices $$$1 \le i_1 < i_2 < \ldots < i_k \le n$$$.  Add $$$1$$$ to each of $$$a_{i_1}, a_{i_2}, \ldots, a_{i_k}$$$, all other elements of array $$$a$$$ remain unchanged.  Permute the elements of array $$$a$$$ in any order. Is it possible to perform some transformation of the array $$$a$$$ exactly once, so that the resulting array is equal to $$$b$$$?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Descriptions of test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of arrays $$$a$$$ and $$$b$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-100 \le a_i \le 100$$$). The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$-100 \le b_i \le 100$$$).

For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $$$a$$$, so that the resulting array is equal to $$$b$$$. Print "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).

NoteIn the first test case, we can make the following transformation:  Choose $$$k = 2$$$.  Choose $$$i_1 = 1$$$, $$$i_2 = 2$$$.  Add $$$1$$$ to $$$a_1$$$ and $$$a_2$$$. The resulting array is $$$[0, 2, 0]$$$.  Swap the elements on the second and third positions. In the second test case there is no suitable transformation.In the third test case we choose $$$k = 0$$$ and do not change the order of elements.

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

function solve(n, a, b) {
    a.sort((x, y) => x - y)
    b.sort((x, y) => x - y)
    // console.log(a)
    // console.log(b)
    for (let i = 0; i < a.length; i++) {
        const d = b[i] - a[i]
        if (d > 1 || d < 0) return 'NO'
    }
    return 'YES'
}

//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 N = nextInt();
		var alist = nextIntArray(N);
		var blist = nextIntArray(N);
		alist.sort(function(a,b){
			return b - a;
		});
		blist.sort(function(a,b){
			return b - a;
		});
		var isOK = true;
		for(var i = 0; i < N; i++){
			if(blist[i] - alist[i] > 1 || blist[i] - alist[i] < 0){
				isOK = false;
			}
		}
		if(isOK){
			myout("YES");
		}else{
			myout("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;
    var a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(a[j] == b[j] || a[j] + 1 == b[j]){

                }else{
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[j] > a[j] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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;
    var a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var yes = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[j] > a[j] + 1){
                    yes = false;
                    break;
                }
            }
            console.log(yes ? 'YES' : 'NO');
        }
    }
});

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort(function(a,b){
			return b - a;
		});
    d.sort(function(a,b){
			return b - a;
		});
    var point = []
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        point.push(i)
      }
    }
    for(let i = 0; i < point.length;i++){
      if(c[point[i]] != d[i]){
        c[point[i]]++
      }
    }
    var flag = true
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        flag = false
      }
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort(function(a,b){
			return b - a;
		});
    d.sort(function(a,b){
			return b - a;
		});
    var flag = true
    for(let i = 0; i < b;i++){
      if(d[i] - c[i] > 1 || d[i] - c[i] < 0){
				flag = false;
			}
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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();
		const b = rna();

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

		let ans = true;
		for (let i = 0; i < n; i++) {
			if (a[i] - b[i] != 0 && a[i] - b[i] != -1) ans = false;
		}

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

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  let a = parseInt(readline());
  while (a--) {
    let b = parseInt(readline());
    let c = readline().split(" ").map(Number);
    let d = readline().split(" ").map(Number);
    c.sort(function (a, b) {
      return b - a;
    });
    d.sort(function (a, b) {
      return b - a;
    });
    let flag = true;
    for (let i = 0; i < b; i++) {
      if (d[i] - c[i] > 1 || d[i] - c[i] < 0) {
        flag = false;
      }
    }
    flag ? print("YES") : print("NO");
  }
}

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

function solve(n, a, b) {
    a.sort((x, y) => x - y)
    b.sort((x, y) => x - y)
    // console.log(a)
    // console.log(b)
    for (let i = 0; i < a.length; i++) {
        const d = b[i] - a[i]
        if (d > 1) return 'NO'
    }
    return 'YES'
}

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

                }else{
                    flag = false;
                }
            }
            console.log(flag ? '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;
    var a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return b - a});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return b - a});
            if(a[0] >= b[0] - 1){
                console.log('YES');
            }else{
                console.log('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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[i] < a[j] || b[j] > a[j] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[i] < a[i] || b[j] > a[j] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[i] < a[i] || b[i] > a[j] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[i] < a[i] || b[i] > a[i] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[i] || b[i] > a[i] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[i] > a[i] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[j] > a[i] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[j] >= a[j] + 1){
                    flag = false;
                }
            }
            console.log(flag ? '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 a = 0;
    for(i = 1; i <= t * 3; i++){
        if(i % 3 == 1){
            n = lines[i];
        }else if(i % 3 == 2){
            a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
        }else{
            var b = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var flag = true;
            for(j = 0; j < n; j++){
                if(b[j] < a[j] || b[j] >= a[j]){
                    flag = false;
                }
            }
            console.log(flag ? 'YES' : 'NO');
        }
    }
});

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort()
    d.sort()
    var flag = true
    for(let i = 0; i < b;i++){
      if(d[i] - c[i] > 1 || d[i] - c[i] < 0){
				flag = false;
			}
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort()
    d.sort()
    var flag = true
    for(let i = 0; i < b;i++){
      if(d[i] - c[i] > 1 || d[i] - c[i] < 0){
				isOK = false;
			}
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort()
    d.sort()
    var flag =1
    for(let i = 0; i < b;i++){
      flag &= (c[i] == d[i] || c[i] + 1 == d[i])
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort()
    d.sort()
    var point = []
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        point.push(i)
      }
    }
    var flag = 1
    for(let i = 0; i < point.length;i++){
      if(c[point[i]] != d[point[i]]){
        c[point[i]]++
      }
      // flag &= (c[point[i]] == d[point[i]] || c[point[i]] + 1 == d[point[i]])
    }
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        flag = 0
      }
    }
    // for(let i = 0; i < b;i++){
    //   flag &= (c[i] == d[i] || c[i] + 1 == d[i])
    //   print(flag)
    // }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var a = parseInt(readline())
  while(a--){
    var b = parseInt(readline())
    var c = readline().split(' ').map(Number)
    var d = readline().split(' ').map(Number)
    c.sort()
    d.sort()
    var point = []
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        point.push(i)
      }
    }
    for(let i = 0; i < point.length;i++){
      if(c[point[i]] != d[i]){
        c[point[i]]++
      }
    }
    var flag = true
    for(let i = 0; i < b;i++){
      if(c[i] != d[i]){
        flag = false
      }
    }
    if(flag){
      print("YES")
    }
    else print("NO")
  }
}


You are given a string $$$s$$$. You need to find two non-empty strings $$$a$$$ and $$$b$$$ such that the following conditions are satisfied:  Strings $$$a$$$ and $$$b$$$ are both subsequences of $$$s$$$.  For each index $$$i$$$, character $$$s_i$$$ of string $$$s$$$ must belong to exactly one of strings $$$a$$$ or $$$b$$$.  String $$$a$$$ is lexicographically minimum possible; string $$$b$$$ may be any possible string. Given string $$$s$$$, print any valid $$$a$$$ and $$$b$$$.Reminder:A string $$$a$$$ ($$$b$$$) is a subsequence of a string $$$s$$$ if $$$a$$$ ($$$b$$$) can be obtained from $$$s$$$ by deletion of several (possibly, zero) elements. For example, "dores", "cf", and "for" are subsequences of "codeforces", while "decor" and "fork" are not.A string $$$x$$$ is lexicographically smaller than a string $$$y$$$ if and only if one of the following holds:  $$$x$$$ is a prefix of $$$y$$$, but $$$x \ne y$$$;  in the first position where $$$x$$$ and $$$y$$$ differ, the string $$$x$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$y$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first and only line of each test case contains one string $$$s$$$ ($$$2 \le |s| \le 100$$$ where $$$|s|$$$ means the length of $$$s$$$). String $$$s$$$ consists of lowercase Latin letters.

For each test case, print the strings $$$a$$$ and $$$b$$$ that satisfy the given conditions. If there are multiple answers, print any.

NoteIn the first test case, there are only two choices: either $$$a =$$$ f and $$$b = $$$ c or $$$a = $$$ c and $$$b = $$$ f. And $$$a = $$$c is lexicographically smaller than $$$a = $$$ f.In the second test case, a is the only character in the string.In the third test case, it can be proven that b is the lexicographically smallest subsequence of $$$s$$$. The second string can be of two variants; one of them is given here.

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split('').sort();
        var a = lines[i].split('');
        var l = k[0];
        var ans = l + ' ';
        for(j = 0; j < k.length; j++){
            if(a[j] == l){
                a.splice(j, 1);
                break;
            }
        }
        for(j = 0; j < a.length; j++){
            ans += a[j];
        }
        console.log(ans);
    }
});

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

    }
});

function processData(input) {
    var t = 0;
    while(t < +(input[0])) {
        t++;
        const str = [...input[t]];
        const { val, ind = 0 } = str.reduce((acc, val, ind) => {
            if (val < acc.val) return { val, ind };
            return acc;
        }, { val: '{' });
        str.splice(ind, 1);
        console.log( val, str.join(''));
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
let inputString = '';
process.stdin.on("data", function (input) {
    inputString += input;
});

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

    processData(inputString);
});

//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();
	var alpha = "abcdefghijklmnopqrstuvwxyz";
	while(hasNext()){
		var s = next();
		var L = "";
		var R = "";
		for(var i = 0; i < alpha.length; i++){
			if(s.indexOf(alpha[i]) != -1){
				L = alpha[i];
				for(var j = 0; j < s.length; j++){
					if(s.indexOf(alpha[i]) != j){
						R += s[j];
					}
				}
				break;
			}
		}
		myout(L + " " + R);
	}
}

"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 tc = parseInt(readline());
	const result = [];
	while (tc > 0) {
		tc--;
		const word = readline();
		let min = 0;
		let firstLetter = word.charAt(min);
		for (let i = 1; i < word.length; i++) {
			if (word.charAt(i) < firstLetter) {
				min = i;
				firstLetter = word.charAt(min);
			}
		}
		result.push([
			word[min],
			`${word.slice(0, min)}${word.slice(min + 1)}`,
		]);
	}
	for (let i = 0; i < result.length; i++) {
		console.log(`${result[i][0]} ${result[i][1]}`);
	}
}

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

var currentLine = 0;
var inputString = "";

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

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

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

/******** Main function *************/

function main() {
  const t = +input();

  for (let i = 0; i < t; i++) {
    const str = input();
    const arr = str.split("").sort();
    const b = str.replace(arr[0], "");
    console.log(arr[0], b);
  }
}

const iteration_number = readline();
var s,a,b;

for (i=1; i<=iteration_number; i++){
    s= readline()
    var min = 'z';
    for(j=0; j<s.length; j++){
        if(s[j]<min){
            min = s[j]
        }
    }
    print(min+" "+s.replace(min,''));
}

var n = readline();
var result = 0;
for (; n>0; n--) {
    var x = readline();
    var y = 'z';
    for(i=0;i<x.length;i++)
    {
      if(y >= x[i]) y = x[i];
    }
    var flg = 0;
    var ans = "";
    for(i=0;i<x.length;i++)
    {
      if(y == x[i] && flg == 0) flg = 1;
      else ans = ans + x[i];
    }
    print(y , ans);
 }

var n = readline();
var result = 0;
for (; n>0; n--) {
    var x = readline();
    var y = 'z';
    for(i=0;i<x.length;i++)
    {
      if(y >= x[i]) y = x[i];
    }
    var flg = 0;
    var ans = "";
    for(i=0;i<x.length;i++)
    {
      if(y == x[i] && flg === 0) flg = 1;
      else ans = ans + x[i];
    }
    print(y , ans);
 }

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0].split(' ').map(Number);
    var n = t[0], k = t[1];
    var a = lines[1].split(' ').map(Number);
    var max = 1;
    var cnt = 1;
    for(i = 1; i < n; i++){
        if(a[i] == a[i - 1]){
            max = cnt;
            cnt = 0;
        }
        cnt++;
    }
    max = cnt;
    console.log(max);
});

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], e = 0, g = 0
    for(j = 1; j <= n; j++){
        var k = Number(lines[j])
        e = '', g = ''
        if(k % 2 == 1){
            e = '1' + ' '
            for(l = 1; l < k; l+=2){
                e += (l + 2) + ' ' + (l + 1) + ' '
            }
            console.log(e)
        }else{
            for(l = 2; l <= k; l+=2){
                e += (l) + ' ' + (l - 1) + ' '
            }
            console.log(e)
        }
    }
});

const iteration_number = readline();
var s,a,b;

for (i=1; i<=iteration_number; i++){
    s= readline()
    var min = 'z';
    for(j=0; j<s.length; j++){
        if(s[i]<min){
            min = s[j]
        }
    }
    print(min+" "+s.replace(min,''));
}


Polycarp has a poor memory. Each day he can remember no more than $$$3$$$ of different letters. Polycarp wants to write a non-empty string of $$$s$$$ consisting of lowercase Latin letters, taking minimum number of days. In how many days will he be able to do it?Polycarp initially has an empty string and can only add characters to the end of that string.For example, if Polycarp wants to write the string lollipops, he will do it in $$$2$$$ days:   on the first day Polycarp will memorize the letters l, o, i and write lolli;  On the second day Polycarp will remember the letters p, o, s, add pops to the resulting line and get the line lollipops. If Polycarp wants to write the string stringology, he will do it in $$$4$$$ days:   in the first day will be written part str;  on day two will be written part ing;  on the third day, part of olog will be written;  on the fourth day, part of y will be written. For a given string $$$s$$$, print the minimum number of days it will take Polycarp to write it.

The first line of input data contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of a non-empty string $$$s$$$ consisting of lowercase Latin letters (the length of the string $$$s$$$ does not exceed $$$2 \cdot 10^5$$$) — the string Polycarp wants to construct. It is guaranteed that the sum of string lengths $$$s$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single number — minimum number of days it will take Polycarp to write the string $$$s$$$ from memory.

6

lollipops

stringology

abracadabra

codeforces

test

f

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseString = readline();
    var caseMap = new Map();
    var count = 0;
    for (var j = 0; j < caseString.length; j++)
    {
        if (!caseMap.has(caseString[j]))
        {
            if (caseMap.size === 3)
            {
                count++;
                caseMap.clear();
            }
            caseMap.set(caseString[j], 1);
        }
    }
    if (caseMap.size > 0) count++;
    print(count);
}

var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var set = new Set();
        var s = readline();
        var index = 0;
        var ans = 1;
        while (index < s.length) {
            var c = s.charAt(index);
            if (!set.has(c)) {
                if (set.size == 3) {
                    set = new Set();
                    ans++;
                }
                set.add(c);
            }
            index++;
        }
        print(ans);
    }

const main = () => {

	var t = readInt();
	var allans = [];
	for (var zz = 0; zz < t; zz++) {
		var s = readString();
		var cnt = 0;
		var sett = new Set();
		for (var c of s) {
			if (!sett.has(c)) {
				if (sett.size == 3) {
					cnt++;
					sett = new Set();
				}
				sett.add(c);
			}
		}
		cnt++;
		allans.push(cnt);
	}
	multiLineArrayPrint(allans);

	return;
}

const readInt = () => parseInt(readline());
const readString = () => readline();
const readIntArr = () => readline().split(" ").map(zzzz => parseInt(zzzz));
const parseLong = (string) => { // javascript's largest long is < (1<<62)
	var n = string.length;
	var res = 0;
	for (var i = 0; i < n; i++) {
		res *= 10;
		res += parseInt(string[i]);
	}
	return res;
}
const readLong = () => parseLong(readLong());
const readLongArr = () => readline().split(" ").map(zzzz => parseLong(zzzz));
const oneLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join(' '));
const multiLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join('\n'));
const multiLineArrayOfArraysPrint = (arr) => print(arr.map(yyyy => yyyy.map(zzzz => zzzz.toString()).join(' ')).join('\n'));
const makeArr = (defaultVal, dimensionsArr) => {
	var n = dimensionsArr.length;
	if (n === 1) return Array(dimensionsArr[0]).fill(defaultVal);
	else {
		var temp = [];
		for (var i = 0; i < dimensionsArr[0]; i++)
			temp.push(makeArr(defaultVal, dimensionsArr.slice(1)));
		return temp;
	}
}

for (_ = 0; _ < 1; _++) {
	main();
}

// newline for testing
 //newline for testing
// codeforces js cannot use "let" keyword. use "var" instead
// codeforces js cannot destructure arrays

T = readline()
while(T--){
   str = readline().split('')

   acc = []
   ans = 0

   for(i = 0; i < str.length; i++){
      if(acc.indexOf(str[i]) === -1){
         if(acc.length === 3){

            ans++
            acc = []
acc.push(str[i])
         }
         else{
            acc.push(str[i])
         }
      }
   }

   if(acc.length){
      ans++
   }

   print(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;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  var n = readline()//.split(' ').map((x) => parseInt(x));
  // var a = readline().split(' ').map((x) => parseInt(x));
  var mp = new Map();
  var f = alph();
  for(var i=0;i<f.length;i++) {
    mp.set(f[i], 0)
  }
  var cnt = 0;
  var ans = 1;
  for(var i=0;i<n.length;i++) {
    if(mp.get(n[i]) == 0) cnt++;
    mp.set(n[i], 1)
    if(cnt == 4) {
      // console.log(["p", i])
      ans++;
      for(var h=0;h<f.length;h++) {
        mp.set(f[h], 0)
      }
      cnt = 1;
      mp.set(n[i], 1)
      // if(i == n.length-1) ans++;
    }
    // if(i == n.length-1 && cnt >= 1) ans++;
  }
  // ans = max(ans, 1);
  console.log(ans)
}

const readline = require('readline');

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

function getStr(str) {
    const letters = []
    let days = 1
    for (let i = 0; i < str.length; i++) {
        if ( !letters.includes(str[i])) {
            if (letters.length === 3) {
                days++;
                letters.pop();
                letters.pop();
                letters.pop();
            }
            letters.push(str[i])
        }
    }
    return days
}
let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    const [n,...values] = lines
    for (let i = 0; i< n; i++) {
        const ans = getStr(values[i])
        console.log(ans)
    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var n = lines[i].split('');
        var ans = 0;
        var st = new Map();
        for(j = 0; j < n.length; j++){
            st.set(n[j], 1);
            if(st.size == 4){
                ans++;
                st = new Map();
                st.set(n[j], 1);
            }
        }
        if(st.size !== 0){
            ans++;
        }
        console.log(ans);
    }
});

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

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

// ********** Code Start **********

function main() {
    var tests = parseInt(readline());
    for (let t = 0;t < tests; ++t) {
        var s = readline();
        var st = [];
        let ans = 1;
        for (let i = 0;i < s.length-1;++i) {
          let flag = true;
          for (let j = 0;j < st.length; ++j) {
            if (s.charAt(i) == st[j]) {
              flag = false;break;
            }
          }
          if (flag) {
            st.push(s.charAt(i));
          }
          if (st.length > 3) {
            // console.log(st);
            st.splice(0,st.length);
            st.push(s.charAt(i));
            ans++;
          }
        }
        console.log(ans);
    }
}

"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 arr = readline().trim().split("");
    if (arr.length <= 3) {
      console.log(1);
      continue;
    }
    let obj = {},
      cnt = 0,
      day = 0,
      i = 0;
    while (i < arr.length) {
      while (true) {
        if (i >= arr.length) {
          day++;
          break;
        }
        if (!obj[arr[i]]) {
          obj[arr[i]] = 1;
          cnt++;
        }
        if (cnt === 3) {
          day++;
          break;
        }
        i++;
      }
      i++;
      while (obj[arr[i]]) i++;
      obj = {};
      cnt = 0;
    }
    console.log(day);
  }
};
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 test = 0; test < N; test++) {
        let target = readline();
        let days = 1;
        let thisDay = 0;
        let chars = {};
        target.split('').forEach((char, i) => {
            if (chars[char] === undefined) {
                thisDay++;
                chars[char] = true;
                if (thisDay === 4) {
                    thisDay = 1;
                    chars = {};
                    chars[char] = true;
                    days++;
                }
            }
        });
        output(days);
    }
}

'use strict';

function solve(s) {
  const n = s.length;
  let res = 0;
  for (let i = 0, j = 0; i < n; i = ++j) {
    let set = new Set([s[i]]);
    while (j + 1 < n && (set.has(s[j + 1]) || set.size < 3)) set.add(s[++j]);
    res++;
  }
  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 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);
});

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 str = lines[l++]
        output[i] = solve(str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    let ans = 0
    let now = 3
    let map = {}
    for (let i = 0; i < str.length; i++) {
        const x = str[i]
        if (!map[x]) {
            if (now === 3) {
                ans++
                now = 0
                map = {}
            }
            map[x] = 1
            now++
        }
    }
    return 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 S = next();
		var N = S.length;
		var output = 1;
		var set = new Set();
		for(var i = 0; i < N; i++){
			if(!set.has(S[i])){
				if(set.size == 3){
					set = new Set();
					output++;
				}
				set.add(S[i]);
			}
		}
		myout(output);
	}
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseString = readline();
    var caseMap = new Map();
    var count = 0;
    for (var j = 0; j < caseString.length; j++)
    {
        if (!caseMap.has(caseString[j]))
        {
            if (caseMap.length === 3)
            {
                count++;
                caseMap.clear();
            }
            caseMap.set(caseString[j], 1);
        }
    }
    if (caseMap.length > 0) count++;
    print(count);
}

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;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  var n = readline()//.split(' ').map((x) => parseInt(x));
  // var a = readline().split(' ').map((x) => parseInt(x));
  var mp = new Map();
  var f = alph();
  for(var i=0;i<f.length;i++) {
    mp.set(f[i], 0)
  }
  var cnt = 0;
  var ans = 0;
  for(var i=0;i<n.length;i++) {
    if(mp.get(n[i]) == 0) cnt++;
    mp.set(n[i], 1)
    if(cnt == 4) {
      // console.log(["p", i])
      ans++;
      for(var h=0;h<f.length;h++) {
        mp.set(f[h], 0)
      }
      cnt = 1;
      mp.set(n[i], 1)
      if(i == n.length-1) ans++;
    }
    if(i == n.length-1 && cnt > 1) ans++;
  }
  ans = max(ans, 1);
  console.log(ans)
}

const readline = require('readline');

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

function getStr(str) {
    const letters = []
    let days = 1
    for (let i = 0; i < str.length; i++) {
        if (letters.length === 3) {
           days++;
           letters.pop();
            letters.pop();
            letters.pop();
        }
        if ( !letters.includes(str[i])) {
            letters.push(str[i])
        }
    }
    return days
}
let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    const [n,...values] = lines
    for (let i = 0; i< n; i++) {
        const ans = getStr(values[i])
        console.log(ans)
    }
});


A batch of $$$n$$$ goods ($$$n$$$ — an even number) is brought to the store, $$$i$$$-th of which has weight $$$a_i$$$. Before selling the goods, they must be packed into packages. After packing, the following will be done:   There will be $$$\frac{n}{2}$$$ packages, each package contains exactly two goods;  The weight of the package that contains goods with indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$) is $$$a_i + a_j$$$. With this, the cost of a package of weight $$$x$$$ is always $$$\left \lfloor\frac{x}{k}\right\rfloor$$$ burles (rounded down), where $$$k$$$ — a fixed and given value.Pack the goods to the packages so that the revenue from their sale is maximized. In other words, make such $$$\frac{n}{2}$$$ pairs of given goods that the sum of the values $$$\left \lfloor\frac{x_i}{k} \right \rfloor$$$, where $$$x_i$$$ is the weight of the package number $$$i$$$ ($$$1 \le i \le \frac{n}{2}$$$), is maximal.For example, let $$$n = 6, k = 3$$$, weights of goods $$$a = [3, 2, 7, 1, 4, 8]$$$. Let's pack them into the following packages.   In the first package we will put the third and sixth goods. Its weight will be $$$a_3 + a_6 = 7 + 8 = 15$$$. The cost of the package will be $$$\left \lfloor\frac{15}{3}\right\rfloor = 5$$$ burles.  In the second package put the first and fifth goods, the weight is $$$a_1 + a_5 = 3 + 4 = 7$$$. The cost of the package is $$$\left \lfloor\frac{7}{3}\right\rfloor = 2$$$ burles.  In the third package put the second and fourth goods, the weight is $$$a_2 + a_4 = 2 + 1 = 3$$$. The cost of the package is $$$\left \lfloor\frac{3}{3}\right\rfloor = 1$$$ burle. With this packing, the total cost of all packs would be $$$5 + 2 + 1 = 8$$$ burles.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases in the test. The descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ ($$$2 \le n \le 2\cdot10^5$$$) and $$$k$$$ ($$$1 \le k \le 1000$$$). The number $$$n$$$ — is even. The second line of each test case contains exactly $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all the test cases does not exceed $$$2\cdot10^5$$$.

For each test case, print on a separate line a single number — the maximum possible total cost of all the packages.

NoteThe first test case is analyzed in the statement.In the second test case, you can get a total value equal to $$$4$$$ if you put the first and second goods in the first package and the third and fourth goods in the second package.In the third test case, the cost of each item is $$$0$$$, so the total cost will also be $$$0$$$.

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

function solve(n, k, arr) {
    let ans = 0
    const map = Array(k).fill(0)
    arr.forEach(x => {
        const r = x % k
        ans += (x - r) / k
        map[r]++
    })
// console.log(map)
    //
    let i = 1
    let j = k - 1
    while (1) {
        while (i < j && !map[j]) j--
        if (i >= j) break
        while (i < j && (!map[i] || i + j < k)) i++
        if (i >= j) break
        //
        const now = Math.min(map[i], map[j])
        ans += now
        map[i] -= now
        map[j] -= now
    }
    // console.log(map, i, j)
    return ans + (i + i >= k ? Math.floor((map[i] || 0) / 2) : 0)
}

'use strict';

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

function solve(n, m, a) {
  const map = new Map();
  for (let num of a) {
    const b = num % m;
    if (!map.has(b)) map.set(b, []);
    map.get(b).push(num);
  }
  let res = 0;
  for (let [b, arr] of map) {
    const b1 = (m - b) % m;
    if (b === b1) {
      while (arr.length > 1) {
        const c = arr.pop(),
              d = arr.pop();
        res += (c + d) / m;
      }
    } else {
      while (arr.length && (_map$get = map.get(b1)) !== null && _map$get !== void 0 && _map$get.length) {
        var _map$get;
        const c = arr.pop(),
              d = map.get(b1).pop();
        res += (c + d) / m;
      }
    }
  }
  const keys = [...map.entries()].filter(([, values]) => values.length > 0).map(([k]) => k).sort((a, b) => b - a);
  const bst = new BinarySearchTree();
  for (let k of keys) {
    bst.insert(k);
  }
  for (let k of keys) {
    const arr = map.get(k);
    let t = bst.ceiling(m - k);
    while (arr.length && (k === t ? arr.length > 1 : (_map$get2 = map.get(t)) === null || _map$get2 === void 0 ? void 0 : _map$get2.length)) {
      var _map$get2, _map$get3;
      const c = arr.pop(),
            d = map.get(t).pop();
      res += Math.floor((c + d) / m);
      if (!arr.length) {
        bst.delete(k);
      }
      if (k !== t && !((_map$get3 = map.get(t)) !== null && _map$get3 !== void 0 && _map$get3.length)) {
        bst.delete(t);
      }
      t = bst.ceiling(m - k);
    }
  }
  const nums = [...map.entries()].filter(([, values]) => values.length > 0).sort((a, b) => b[0] - a[0]).map(([, values]) => values).flat();
  for (let i = 0; i < nums.length; i += 2) {
    res += Math.floor((nums[i] + nums[i + 1]) / m);
  }
  return res;
}
class BinarySearchTree {
  constructor(_compare = (a, b) => a - b) {
    _defineProperty(this, "root", null);
    _defineProperty(this, "length", 0);
    _defineProperty(this, "min", null);
    _defineProperty(this, "max", null);
    _defineProperty(this, "minCache", true);
    _defineProperty(this, "maxCache", true);
    this._compare = _compare;
    this.compare = this.compare.bind(this);
  }
  isT(t) {
    return t !== undefined && t !== null;
  }
  compare(a, b) {
    const {
      isT
    } = this;
    if (isT(a) && isT(b)) return this._compare(a, b);
    if (isT(a)) return 1;
    if (isT(b)) return -1;
    return 0;
  }
  isEmpty() {
    return !this.root;
  }
  size() {
    return this.root ? this.root.size : 0;
  }
  getRoot() {
    return this.root;
  }
  getMin() {
    if (this.minCache) {
      return this.min;
    }
    const min = this.searchKth(this.size());
    this.min = min;
    this.minCache = true;
    return min;
  }
  getMax() {
    if (this.maxCache) {
      return this.max;
    }
    const max = this.searchKth(1);
    this.max = max;
    this.maxCache = true;
    return max;
  }
  balance(node) {
    node.height = this.getHeight(node);
    const blance = this.getBalance(node);
    let res;
    if (Math.abs(blance) === 2) {
      if (blance > 0) {
        var _node$left$left$heigh, _node$left, _node$left$left, _node$left$right$heig, _node$left2, _node$left2$right;
        const heightDif = ((_node$left$left$heigh = (_node$left = node.left) === null || _node$left === void 0 ? void 0 : (_node$left$left = _node$left.left) === null || _node$left$left === void 0 ? void 0 : _node$left$left.height) !== null && _node$left$left$heigh !== void 0 ? _node$left$left$heigh : 0) - ((_node$left$right$heig = (_node$left2 = node.left) === null || _node$left2 === void 0 ? void 0 : (_node$left2$right = _node$left2.right) === null || _node$left2$right === void 0 ? void 0 : _node$left2$right.height) !== null && _node$left$right$heig !== void 0 ? _node$left$right$heig : 0);
        if (heightDif > 0) {
          res = this.rotateRight(node);
        } else if (heightDif < 0) {
          res = this.rotateLeftRight(node);
        }
      } else {
        var _node$right$left$heig, _node$right, _node$right$left, _node$right$right$hei, _node$right2, _node$right2$right;
        const heightDif = ((_node$right$left$heig = (_node$right = node.right) === null || _node$right === void 0 ? void 0 : (_node$right$left = _node$right.left) === null || _node$right$left === void 0 ? void 0 : _node$right$left.height) !== null && _node$right$left$heig !== void 0 ? _node$right$left$heig : 0) - ((_node$right$right$hei = (_node$right2 = node.right) === null || _node$right2 === void 0 ? void 0 : (_node$right2$right = _node$right2.right) === null || _node$right2$right === void 0 ? void 0 : _node$right2$right.height) !== null && _node$right$right$hei !== void 0 ? _node$right$right$hei : 0);
        if (heightDif > 0) {
          res = this.rotateRightLeft(node);
        } else if (heightDif < 0) {
          res = this.rotateLeft(node);
        }
      }
    }
    return res ? res : node;
  }
  rotateRight(node) {
    const left = node.left;
    const leftRight = left.right;
    left.right = node;
    node.left = leftRight;
    node.height = this.getHeight(node);
    left.height = this.getHeight(left);
    node.size = this.getSize(node);
    left.size = this.getSize(left);
    return left;
  }
  rotateLeft(node) {
    const right = node.right;
    const rightLeft = right.left;
    right.left = node;
    node.right = rightLeft;
    node.height = this.getHeight(node);
    right.height = this.getHeight(right);
    node.size = this.getSize(node);
    right.size = this.getSize(right);
    return right;
  }
  rotateLeftRight(node) {
    node.left = this.rotateLeft(node.left);
    return this.rotateRight(node);
  }
  rotateRightLeft(node) {
    node.right = this.rotateRight(node.right);
    return this.rotateLeft(node);
  }
  getBalance(node) {
    return this.getHeight(node.left) - this.getHeight(node.right);
  }
  getHeight(node) {
    var _node$left$height, _node$left3, _node$right$height, _node$right3;
    if (!node) return 0;
    return Math.max((_node$left$height = (_node$left3 = node.left) === null || _node$left3 === void 0 ? void 0 : _node$left3.height) !== null && _node$left$height !== void 0 ? _node$left$height : 0, (_node$right$height = (_node$right3 = node.right) === null || _node$right3 === void 0 ? void 0 : _node$right3.height) !== null && _node$right$height !== void 0 ? _node$right$height : 0) + 1;
  }
  getSize(node) {
    var _node$left$size, _node$left4, _node$right$size, _node$right4;
    if (!node) return 0;
    return ((_node$left$size = (_node$left4 = node.left) === null || _node$left4 === void 0 ? void 0 : _node$left4.size) !== null && _node$left$size !== void 0 ? _node$left$size : 0) + ((_node$right$size = (_node$right4 = node.right) === null || _node$right4 === void 0 ? void 0 : _node$right4.size) !== null && _node$right$size !== void 0 ? _node$right$size : 0) + node.count;
  }
  createNode(val) {
    return {
      id: Math.random() * new Date().valueOf(),
      val,
      left: null,
      right: null,
      size: 1,
      height: 1,
      count: 1
    };
  }
  insert(val) {
    let cur = this.createNode(val);
    if (this.isEmpty()) {
      this.root = cur;
      this.length++;
    } else {
      [, cur] = this.insertNode(this.root, cur);
    }
    if (this.min === null || this.compare(this.min, val) > 0) {
      this.min = val;
    }
    if (this.max === null || this.compare(this.max, val) < 0) {
      this.max = val;
    }
  }
  insertNode(node, cur, parent = null) {
    node.size++;
    const compareResult = this.compare(cur.val, node.val);
    let res;
    if (compareResult === 0) {
      node.count++;
      return [false, node];
    } else if (compareResult > 0) {
      if (node.right) {
        res = this.insertNode(node.right, cur, node);
        if (!res[0]) return res;
      } else {
        node.right = cur;
        this.length++;
        res = [true, cur];
      }
    } else {
      if (node.left) {
        res = this.insertNode(node.left, cur, node);
        if (!res[0]) return res;
      } else {
        node.left = cur;
        this.length++;
        res = [true, cur];
      }
    }
    let preHeight = node.height;
    const newNode = this.balance(node);
    if (newNode === node && node.height === preHeight) {
      res = [false, res[1]];
    } else if (newNode !== node) {
      if (parent) {
        parent.left === node ? parent.left = newNode : parent.right = newNode;
      } else {
        this.root = newNode;
      }
      res = [false, res[1]];
    }
    return res;
  }
  delete(val) {
    if (!this.root) return;
    this.deleteNode(val, this.root, null);
  }
  deleteNode(val, node, parent) {
    if (!node) return null;
    let res = this.compare(val, node.val);
    if (res === 0) {
      node.count--;
      node.size--;
      if (node.count > 0) return node;
      if (!node.left || !node.right) {
        if (this.min === val) {
          this.minCache = false;
        }
        if (this.max === val) {
          this.maxCache = false;
        }
        this.length--;
        if (!parent) {
          var _node$left5;
          this.root = (_node$left5 = node.left) !== null && _node$left5 !== void 0 ? _node$left5 : node.right;
          return this.root;
        } else {
          var _node$left6;
          return (_node$left6 = node.left) !== null && _node$left6 !== void 0 ? _node$left6 : node.right;
        }
      } else {
        const selectLeft = node.left.height > node.right.height;
        let replaceNode = selectLeft ? this.pre(node) : this.next(node),
            name = selectLeft ? 'left' : 'right';
        node.val = replaceNode.val;
        node.count = replaceNode.count;
        replaceNode.count = 0;
        node[name] = this.deleteNode(replaceNode.val, node[name], node);
      }
    } else if (res > 0) {
      node.right = this.deleteNode(val, node.right, node);
    } else {
      node.left = this.deleteNode(val, node.left, node);
    }
    node.size = this.getSize(node);
    node.height;
    const newNode = this.balance(node);
    if (parent) {
      parent.left === node ? parent.left = newNode : parent.right = newNode;
    } else {
      this.root = newNode;
    }
    return newNode;
  }
  next(node) {
    let next = node.right;
    while ((_next = next) !== null && _next !== void 0 && _next.left) {
      var _next;
      next = next.left;
    }
    return next;
  }
  pre(node) {
    let pre = node.left;
    while ((_pre = pre) !== null && _pre !== void 0 && _pre.right) {
      var _pre;
      pre = pre.right;
    }
    return pre;
  }
  search(val, compare) {
    if (this.isEmpty()) {
      return null;
    }
    const [, node] = this.searchCeilingNode(this.root, val, compare !== null && compare !== void 0 ? compare : this.compare);
    return node.val;
  }
  searchCeilingNode(node, val, compare, parent = null) {
    const res = compare(val, node.val);
    if (res === 0) {
      return [parent, node];
    } else if (res > 0) {
      if (node.right) {
        return this.searchCeilingNode(node.right, val, compare, node);
      } else {
        return [parent, node];
      }
    } else {
      if (node.left) {
        const [p, value] = this.searchCeilingNode(node.left, val, compare, node);
        if (compare(value.val, val) < 0) {
          return [parent, node];
        } else {
          return [p, value];
        }
      } else {
        return [parent, node];
      }
    }
  }
  ceiling(val) {
    if (this.isEmpty()) {
      return null;
    }
    const [, node] = this.searchCeilingNode(this.root, val, this.compare);
    return this.compare(node.val, val) >= 0 ? node.val : null;
  }
  searchFloorNode(node, val, compare, parent = null) {
    const res = compare(val, node.val);
    if (res === 0) {
      return [parent, node];
    } else if (res > 0) {
      if (node.right) {
        const [p, value] = this.searchFloorNode(node.right, val, compare, node);
        if (compare(value.val, val) > 0) {
          return [parent, node];
        } else {
          return [p, value];
        }
      } else {
        return [parent, node];
      }
    } else {
      if (node.left) {
        return this.searchFloorNode(node.left, val, compare, node);
      } else {
        return [parent, node];
      }
    }
  }
  floor(val) {
    if (this.isEmpty()) {
      return null;
    }
    const [, node] = this.searchFloorNode(this.root, val, this.compare);
    return this.compare(node.val, val) <= 0 ? node.val : null;
  }
  searchKth(k) {
    if (this.isEmpty()) {
      return null;
    }
    if (k <= 0 || k > this.size()) {
      return null;
    }
    const node = this.searchNodeKth(this.root, k);
    return node.val;
  }
  searchNodeKth(node, k) {
    var _node$right$size2, _node$right5, _node$right$size3, _node$right6;
    const rSize = (_node$right$size2 = (_node$right5 = node.right) === null || _node$right5 === void 0 ? void 0 : _node$right5.size) !== null && _node$right$size2 !== void 0 ? _node$right$size2 : 0;
    if (rSize === k - 1 || rSize < k && rSize + node.count >= k) return node;
    if (node.right && rSize > k - 1) return this.searchNodeKth(node.right, k);else return this.searchNodeKth(node.left, k - ((_node$right$size3 = (_node$right6 = node.right) === null || _node$right6 === void 0 ? void 0 : _node$right6.size) !== null && _node$right$size3 !== void 0 ? _node$right$size3 : 0) - node.count);
  }
  countGreaterThanEq(val) {
    if (!this.root) return 0;
    return this.countCompare(val, (a, b) => this._compare(a, b), this.root);
  }
  countCompare(val, compare, node, pre = 0) {
    const res = compare(val, node.val);
    if (res === 0) {
      var _node$right$size4, _node$right7;
      return pre + ((_node$right$size4 = (_node$right7 = node.right) === null || _node$right7 === void 0 ? void 0 : _node$right7.size) !== null && _node$right$size4 !== void 0 ? _node$right$size4 : 0) + node.count;
    } else if (res > 0) {
      if (node.right) {
        return this.countCompare(val, compare, node.right, pre);
      } else {
        return pre;
      }
    } else {
      var _node$right$size5, _node$right8;
      let count = pre + ((_node$right$size5 = (_node$right8 = node.right) === null || _node$right8 === void 0 ? void 0 : _node$right8.size) !== null && _node$right$size5 !== void 0 ? _node$right$size5 : 0) + node.count;
      if (node.left) {
        return this.countCompare(val, compare, node.left, count);
      } else {
        return count;
      }
    }
  }
  toArray() {
    if (!this.root) return [];
    const res = [];
    const dfs = node => {
      if (node.left) dfs(node.left);
      res.push(node.val);
      if (node.right) dfs(node.right);
    };
    dfs(this.root);
    return res;
  }
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      res.push(solve(n, m, a));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

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

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

function solve(n, k, arr) {
    let ans = 0
    const map = Array(k).fill(0)
    arr.forEach(x => {
        const r = x % k
        ans += (x - r) / k
        map[r]++
    })
// console.log(map)
    //
    let i = 1
    let j = k - 1
    while (1) {
        while (i < j && !map[j]) j--
        if (i >= j) break
        while (i < j && (!map[i] || i + j < k)) i++
        if (i >= j) break
        //
        const now = Math.min(map[i], map[j])
        ans += now
        map[i] -= now
        map[j] -= now
    }
    // console.log(map, i, j)
    return ans + Math.floor((map[i] || 0) / 2)
}

'use strict';

function solve(n, m, a) {
  const map = new Map();
  for (let num of a) {
    const b = num % m;
    if (!map.has(b)) map.set(b, []);
    map.get(b).push(num);
  }
  let res = 0;
  for (let [b, arr] of map) {
    const b1 = (m - b) % m;
    if (b === b1) {
      while (arr.length > 1) {
        const c = arr.pop(),
              d = arr.pop();
        res += (c + d) / m;
      }
    } else {
      while (arr.length && (_map$get = map.get(b1)) !== null && _map$get !== void 0 && _map$get.length) {
        var _map$get;
        const c = arr.pop(),
              d = map.get(b1).pop();
        res += (c + d) / m;
      }
    }
  }
  const nums = [...map.entries()].filter(([, values]) => values.length > 0).sort((a, b) => b[0] - a[0]).map(([, values]) => values).flat();
  for (let i = 0; i < nums.length; i += 2) {
    res += Math.floor((nums[i] + nums[i + 1]) / m);
  }
  return res;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      res.push(solve(n, m, a));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

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