const tests = readline().split(" ").map(x => parseInt(x));
const t = tests[0];
for (var i=0; i<t; i++) {
    var data = readline().split(" ").map(x => parseInt(x));
    var n = data[0];
    var k1 = data[1];
    var k2 = data[2];
    var k1nums = readline().split(" ").map(x => parseInt(x));
    var k2nums = readline().split(" ").map(x => parseInt(x));
    var k1max = Math.max(k1nums);
    (Math.max(...k1nums) > Math.max(...k2nums)) ? print("YES") : print("NO");
}

let finalInput = '';

process.stdin.setEncoding('utf-8').on('data', input => {
    finalInput += input;
});

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let cardsA = lines[i+1].split(' ').map(Number);
        let cardsB = lines[i+2].split(' ').map(Number);
        // console.log('cardsA', cardsA);
        // console.log('cardsB', cardsB);
        let maxA = cardsA.reduce((acc, v) => Math.max(acc, v), Number.MIN_VALUE);
        let maxB = cardsB.reduce((acc, v) => Math.max(acc, v), Number.MIN_VALUE);
        console.log(maxA > maxB ? 'YES' : 'NO');
    }
});

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

process.stdin.on('end', () => {

    var lines = i.split("\n");
    var problems = +lines[0];

    for(let i = 2; i < lines.length; i+=3) a(lines[i].split(" ").map(x => +x), lines[i+1].split(" ").map(x => +x));
});

function a(one, two) {

    one = one.sort((a, b) => a - b);
    two = two.sort((a, b) => a - b);

    if(one[one.length-1] > two[two.length-1]) console.log("yes");
    else console.log("no");
}

let fs=require('fs');

let txt=fs.readFileSync(0,"utf-8").split(/[\r\n]/).filter(data=>data.length>0);

txt.shift();

for (let i = 0; i < txt.length; i+=3) {
    doit(txt[i+1].split(" ").filter(data=>data.length>0).map(data=>data*1).sort((a,b)=>b-a),txt[i+2].split(" ").filter(data=>data.length>0).map(data=>data*1).sort((a,b)=>b-a));

}

function doit(tab,tab1){
    if(tab[0]>tab1[0]){
        console.log("YES");
    }else{
        console.log("NO");

    }

}

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

for(var i=1; i<=t; i++) {
    var inputs = readline().split(' ').map(el => parseInt(el, 10));
    var n = inputs[0], k1 = inputs[1], k2 = inputs[2];
    var a = readline().split(' ').map(el => parseInt(el, 10));
    var b = readline().split(' ').map(el => parseInt(el, 10));

    print(a.sort((a,b) => a-b).pop() > b.sort((a,b) => a-b).pop() ? 'YES' : 'NO');
}

t = +readline();
while (t-->0){
    n = readline().split(' ')[0];
    n = +n;
    found = false;
    readline().split(' ').map(Number).forEach(x => found |= x === n);
    readline();
    if (found){
        print('YES');
    } else {
        print('NO');
    }

}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var data = readline();
    var first = readline().split(' ').map(Number);
    var second = readline().split(' ').map(Number);

    print(getMaxOfArray(first) > getMaxOfArray(second) ? "YES" : "NO");
  }
}

function getMaxOfArray(numArray) {
  return Math.max.apply(null, numArray);
}

main()

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

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

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

  const t  = readInt(arr)

  for(let j = 0; j < t; j++) {
    const [n, k1, k2] = readInts(arr, 3 * j)
    const a = readInts(arr, 3 * j + 1)
    const b = readInts(arr, 3 * j + 2)

    let t = 'NO'
    for(let i = 0; i < k1; i++) {
      if(a[i] == n) {
        t = 'YES'
        break
      }
    }
    wr(t)
  }
})

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

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    var n = one[0];
    var k1 = one[1];
    var k2 = one[2];
    var first = Math.max.apply(null, nextIntArray());
    var second = Math.max.apply(null, nextIntArray());
    if(first > second){
      output[i] = "YES";
    }else{
      output[i] = "NO";
    }
  }
  myout(myconv(output, 9));
}

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

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

  if (c % 3 === 0) {
    c++;
    return;
  }

  if (c % 3 === 1) {
    player1 = Math.max(...d.split(' ').map(Number));
    c++;
    return;
  }

  player2 = Math.max(...d.split(' ').map(Number));

  if (player1 > player2) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));
    main();
});

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

function parseIntArrLine() {
  return readLine().split(' ').map(cTemp => parseInt(cTemp, 10));
}

function main() {
    const numberOfTestCases = parseInt(readLine(), 10);
    const results = [];
    let n, k1, k2, k1Cards, k2Cards, k1Max, k2Max;
    for (let i = 1; i <= numberOfTestCases; i++) {
      [n, k1, k2] = parseIntArrLine();
      k1Cards = parseIntArrLine();
      k2Cards = parseIntArrLine();
      k1Max = Math.max(...k1Cards);
      k2Max = Math.max(...k2Cards);
      results.push(k1Max > k2Max ? "YES" : "NO");
    }
    results.forEach(item => {
      process.stdout.write(item + "\n");
    });
    process.stdout.end();
}

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let t = parseInt(readLine(), 10);

    for(let i=1; i<=t; i++) {
        let inputs = readLine();
        inputs = inputs.split(' ');
        let n = parseInt(inputs[0], 10);
        let k1 = parseInt(inputs[1], 10);
        let k2 = parseInt(inputs[2], 10);

        inputs = readLine();
        inputs = inputs.split(' ');
        let a = inputs.map(el => parseInt(el, 10));

        inputs = readLine();
        inputs = inputs.split(' ');
        let b = inputs.map(el => parseInt(el, 10));

        console.log(a.sort((a,b) => a-b).pop() > b.sort((a,b) => a-b).pop() ? 'YES' : 'NO');
    }
}

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

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

  if (c % 3 === 0) {
    c++;
    return;
  }

  if (c % 3 === 1) {
    player1 = Math.max(d.split(' ').map(Number));
    c++;
    return;
  }

  player2 = Math.max(d.split(' ').map(Number));

  if (player1 > player2) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let t = parseInt(readLine(), 10);

    for(let i=1; i<=t; i++) {
        let inputs = readLine();
        inputs = inputs.split(' ');
        let n = parseInt(inputs[0], 10);
        let k1 = parseInt(inputs[1], 10);
        let k2 = parseInt(inputs[2], 10);

        inputs = readLine();
        inputs = inputs.split(' ');
        let a = inputs.map(el => parseInt(el, 10));

        inputs = readLine();
        inputs = inputs.split(' ');
        let b = inputs.map(el => parseInt(el, 10));

        console.log(a.reduce((a, b) => a+b) > b.reduce((a, b) => a+b) ? 'YES' : 'NO' );
    }
}

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let t = parseInt(readLine(), 10);

    for(let i=1; i<=t; i++) {
        let inputs = readLine();
        inputs = inputs.split(' ');
        let n = parseInt(inputs[0], 10);
        let k1 = parseInt(inputs[1], 10);
        let k2 = parseInt(inputs[2], 10);

        inputs = readLine();
        inputs = inputs.split(' ');
        let a = inputs.map(el => parseInt(el, 10));

        inputs = readLine();
        inputs = inputs.split(' ');
        let b = inputs.map(el => parseInt(el, 10));

        console.log(a.sort().pop() > b.sort().pop() ? 'YES' : 'NO');
    }
}

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

process.stdin.on('end', () => {

    var lines = i.split("\n");
    var problems = +lines[0];

    for(let i = 2; i < lines.length; i+=3) a(lines[i].split(" ").map(x => +x), lines[i+1].split(" ").map(x => +x));
});

function a(one, two) {

    one = one.sort();
    two = two.sort();

    if(one[one.length-1] > two[two.length-1]) console.log("yes");
    else console.log("no");
}

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

process.stdin.on('end', () => {

    var lines = i.split("\n");
    var problems = +lines[0];

    for(let i = 3; i < lines.length; i+=3) a(lines[i].split(" ").map(x => +x), lines[i+1].split(" ").map(x => +x));
});

function a(one, two) {

    one = one.sort();
    two = two.sort();

    if(one[one.length-1] > two[two.length-1]) console.log("yes");
    else console.log("no");
}

const tests = readline().split(" ").map(x => parseInt(x));
const t = tests[0];
for (var i=0; i<t; i++) {
    var data = readline().split(" ").map(x => parseInt(x));
    var n = data[0];
    var k1 = data[1];
    var k2 = data[2];
    var k1nums = readline().split(" ").map(x => parseInt(x));
    var k2nums = readline().split(" ").map(x => parseInt(x));
    var k1max = Math.max(k1nums);
    (Math.max(k1nums) > Math.max(k2nums)) ? print("YES") : print("NO");
}

const tests = readline().split(" ").map(x => parseInt(x));
const t = tests[0];
for (var i=0; i<t; i++) {
    const data = readline().split(" ").map(x => parseInt(x));
    const n = data[0];
    const k1 = data[1];
    const k2 = data[2];
    const k1nums = readline().split(" ").map(x => parseInt(x));
    const k2nums = readline().split(" ").map(x => parseInt(x));
    const k1max = Math.max(k1nums);
    (Math.max(k1nums) > Math.max(k2nums)) ? print("YES") : print("NO");
}


const readline = require('readline');

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

var findMaxFrom = function (from) {
    let ans = cont[from];
    for (let i = from; i < n; i++) {
        if (cont[i] > ans)
            ans = cont[i];
    }
    return ans;
}
var n, rub, cont = [], indicator = 0;

rl.on('line', (input) => {
    if (indicator == 0) {
        let temp = input.split(' ').map(item => parseInt(item));
        n = temp[0];
        rub = temp[1];
        indicator++;
    } else {
        cont = input.split(' ').map(item => parseInt(item));
        let maxRubl = rub;
        for (let i = 0; i < n - 1; i++) {
            let dollars = Math.floor(rub / cont[i]);
            let remRub = rub % cont[i];
            let helper = findMaxFrom(i + 1);
            let currentRubl = dollars * helper + remRub;
            if (maxRubl < currentRubl)
                maxRubl = currentRubl;
        }
        console.log(maxRubl);
        rl.close();
    }

});

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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var numDays = integers[0], numDollars = integers[1];
	var best = numDollars;
	var prices = tokenizeIntegers(readline());
	for (var buyDay = 0; buyDay < numDays; ++buyDay) {
		var martian = Math.floor(numDollars/prices[buyDay]);
		var human = numDollars - martian*prices[buyDay];
		for (var sellDay = buyDay+1; sellDay < numDays; ++sellDay) {
			best = Math.max(best, human + martian*prices[sellDay]);
		}
	}
	print(best);
}

main();

'use strict'

let lll = readline().split(' ').map(v => parseInt(v))
let N = lll[0]
let b = lll[1]
let ps = readline().split(' ').map(v => parseInt(v))

let bst = b

for (let i = 0; i < ps.length; i++) {
  for (let j = i; j < ps.length; j++) {
    let md = b / ps[i] | 0
    let rb = b % ps[i] + md * ps[j]
    bst = Math.max(bst, rb)
  }
}

print(bst)


var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ').map(item => +item);
  var vals = readline().split(' ').map(item => +item);

  var elems = [];

  vals.forEach((item, index) => {
    if(item % 2 > 0) {
      elems.push(index);
    }
  });

  if(elems.length < arr[1] || elems.length % 2 !== arr[1] % 2) {
    print('NO');
  } else {
    print('YES');
    var res = [];
    for(var j = 0; j < arr[1] - 1; j++){
      res.push(elems[j] + 1);
    }
    res.push(arr[0]);
    print(res.join(' '));
  }
}

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

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 1;

        while (end < data.length && count <= k) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) answer += "NO\n";
        else {
            answer += "YES\n";
            answer += result.join(" ") + "\n";
        }
        testCount++;
    }
    console.log(answer);
})

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

var main = function() {"use strict";
    // TODO
    var q = rdN();
    while (q --> 0) {
        var input = rdArN();
        var n = input[0];
        var k = input[1];
        var A = rdArN();
        var res = [];
        var sum = 0;
        for (var i = 0; i < A.length && res.length < k - 1; ++i) {
            sum += A[i];
            if (sum%2 === 1) {
                res.push(i+1);
                sum = 0;
            }
        }
        if (i === A.length) {
            pr('NO');
        } else {
            sum = A.slice(i).reduce((a,v) => a+v, 0);
            if (sum%2 === 1) {
                pr('YES');
                prAr(res.concat([n]));
            } else {
                pr('NO');
            }
        }
    }
};

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

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

var firstLine = +readline();
var i = 0;

while(i < firstLine) {
	var firstArray = readline().split(' ').map(x=>{return +x});
	var secondArray = readline().split(' ').map(x=>{return +x});
	var k = firstArray[1];

	var oddCount = 0;
	var resArray = secondArray.map(x=>{ oddCount +=x%2; return x%2});

	if(
		oddCount >= k &&
		((oddCount%2 === 0 && k%2 === 0) ||
		(oddCount%2 === 1 && k%2 === 1))
	) {
		print("YES");
		var r = [];

		if(k == 1) {
			r.push(firstArray[0]);
		} else {
			resArray.some((x, p)=>{
				if(x != 0) {
					r.push(p+1);
					k--;
					if(k == 1) {
						r.push(firstArray[0]);
						return true;
					}
				}

			});
		}
		print(r.join(' '));
	} else {
		print("NO");
	}
	i++;
}

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

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        console.log(foo(data, k));
        testCount++;
    }
})

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

    function foo (data) {
        let reserv = 0;
        let result = data.reduce((agr, value) => {
            let str = String(value);
            if (str[str.length - 1] % 2) {
                reserv++;
                value = value - 1;
            }
            return agr + value;
        }, 0);
        let resultArray = String(result / 2).split("");
        let last = +resultArray[resultArray.length - 1] + Math.floor(reserv / 2);
        resultArray.splice(- 1, 1, last);

        return +resultArray.join("");
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount].split(" ").map(Number);
        //console.log(data)
        console.log(foo(data));
        testCount++;
    }
})

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

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                //console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        let result = foo(data, k);
        if (result.length !== k) console.log("NO");
        else {
            console.log("YES");
            console.log(result.join(" "));
        }
        testCount++;
    }
})

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

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;
            count++;

            if (count === k) {
                end = data.length;
            }

            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                //console.log(start, end)
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        let result = foo(data, k);
        if (result.length !== k) console.log("NO");
        else result.join(" ");
        testCount++;
    }
})

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

    function foo (data, k) {
        let start = 0;
        let end = 0;
        let result = [];
        let count = 0;

        while (end < data.length) {
            end++;

            if (count === k) {
                end = data.length;
            }

            //console.log(start, end)
            if (data.slice(start, end).reduce((a, b) => a + b) % 2) {
                count++;
                result.push(end);
                start = end;
            }
        }
        return result;
    }

    let testCount = 1;

    while(testCount <= +lines[0]) {
        let data = lines[testCount * 2].split(" ").map(Number);
        let k = lines[testCount * 2 - 1].split(" ").map(Number)[1];
        //console.log(data, k)
        let result = foo(data, k);
        //console.log(result)
        if (result.length !== k) console.log("NO");
        else {
            console.log("YES");
            console.log(result.join(" "));
        }
        testCount++;
    }
})

var firstLine = +readline();
var i = 0;

while(i < firstLine) {
    var firstArray = readline().split(' ').map(x=>{return +x});
    var secondArray = readline().split(' ').map(x=>{return +x});
    var n = firstArray[0];
    var k = firstArray[1];

    var oddCount = 0;
    var resArray = secondArray.map(x=>{ oddCount +=x%2; return x%2});

    if(
        oddCount >= k &&
        (oddCount%2 === 0 && k%2 === 0) ||
        (oddCount%2 === 1 && k%2 === 1)
    ) {
        print("YES");
        var r = [];

        if(k == 1) {
            r.push(n);
        } else {
            resArray.some((x, p)=>{
                if(x != 0) {
                    r.push(p+1);
                    k--;
                    if(k == 1) {
                        r.push(n);
                        return true;
                    }
                }

            });
        }
        print(r.join(' '));
    } else {
        print("NO");
    }
    i++;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var k = readline().split(' ').map(item => +item)
  var arr = readline().split(' ').map(item => +item);
  var index = [];

  for(var j = 0; j < k[0]; j++) {
    if(arr[j] % 2 > 0) {
      index.push(j + 1);
    }
  }

  if(index.length < k[1] || index.length === k[1] + 1) {
    print('NO');
  } else {
    print('YES');

    var res = [ ];

    for(var c = 0; c < k[1] - 1; c++) {
      res.push(index[c]);
    }

    res.push(k[0]);

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


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

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

  if (str.includes('0')) {
    cur++;
  }
  else {
    max = Math.max(max, cur);
    cur = 0;
  }

  c++;
});

rl.on('close', () => {
  max = Math.max(max, cur);
  console.log(max);
});

var input = readline().split(" ").map(Number);
var n = input[0], d = input[1];

var cnt = 0;
var max = 0;
for(var i = 0; i < d; i++){
    var enemies = readline().split("");

    if(enemies.every(function(a){ return (+a)&1 })){
        cnt = 0;
    }else{
        cnt++;
        max = Math.max(max, cnt);
    }
}

write(max);

'use strict';

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

var nd = readline().split(' ').map(Number),
    n = nd[0], d = nd[1], dArr = [];

var loseCase = '';
for (var i = 0; i < n; i++) {
  loseCase += '1';
}

for (var i = 0; i < d; i++) {
  dArr.push(readline().trim());
}

print(Math.max.apply(null, dArr.map(x => Number(x !== loseCase)).join('').split(0).map(x => x.length)))

var n=readline().split(' ').map(Number);
var ss = ((xs)=>{for (var i=0;i<n[1];i++) {xs.push(readline().split('').map(Number));} return xs;})([]);
var m= ss.map(xs=>xs.reduce((x,y)=>x+y)).reduce((x,y)=>{if (y!=n[0]) {x[0]=x[0]+1; x[1]=Math.max(x[0],x[1]);} else {x[0]=0;} return x},[0,0]);
print(m[1]);

var nd = readline().split(' ').map(Number);
var consecutive_wins = 0;
var max_consecutive_wins = 0;
var prev_val = 0;

for(var i = 0; i < nd[1]; i++) {

    var current_val = readline().split('').map(Number).reduce(function(prevVal, currVal){ return prevVal && currVal });
    if(current_val === 0 && prev_val === 0) {
        consecutive_wins++;
    } else if(current_val === 0 && prev_val === 1){
        consecutive_wins = 1;
    } else {
        consecutive_wins = 0;
    }

    if(consecutive_wins > max_consecutive_wins)
            max_consecutive_wins = consecutive_wins;

    prev_val = current_val;
}

print(max_consecutive_wins);

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

var line = [], day, total = [], max = 0, current = 0;
line = readline().split(' ').map(Number);
function check (value) {
    if (value == 1) {
        current++;
    } else {
        if (current > max) {
            max = current;
        }
        current = 0;
    }
}

for (i = 0; i < line[1]; i++) {
    total.push(0);
}

for (i = 0; i < line[1]; i++) {

    day = readline().replace(/\r$/, '').split('').map(Number);

    if (day.includes(0)) {
        total[i] = 1;
    }
}

total.push(0);
total.forEach(check);
print(max);

// načtu první řádek
var counts = readline().split(" ");

// Seznam dnů
var days = [];

// Načtu dny
for (var i = 0; i < counts[1]; i++) {
	days.push(readline());
}

// Procházím den po dni
var maximum = 0;
var actual = 0;
for (var den = 0; den < counts[1]; den++) {
	var nula = false;

	for (var bojovnik = 0; bojovnik<counts[0]; bojovnik++) {
		if (days[den][bojovnik] == "0") {
			nula = true;
			break;
		}
	}

	if (nula) {
		actual++;
	} else {
		if (maximum < actual) {
			maximum = actual;
		}
			actual = 0;
	}
}

		if (maximum < actual) {
			maximum = actual;
			actual = 0;
		}

write(maximum);

function constructOnes(n) {
  var str = "";
  for (var i = 0; i < n; i++) {
    str += '1';
  }
  return str;
}

var input = readline().trim().split(' ').map(Number);
var n = input[0], d = input[1], result = [0], matchStr = constructOnes(n), consecutive = false;

for (var i = 0; i < d; i++) {
  var str = readline().trim();
  if (str != matchStr) {
    if (consecutive) {
      result[result.length-1]++;
    } else {
      result.push(1);
      consecutive = true;
    }
  } else {
    consecutive = false;
  }
}

print(result.sort(function (a, b) {
  return a-b;
}).pop());

input = readline().split(' ');
n = parseInt(input[0]);
m = parseInt(input[1]);
var ans = 0;
var cnt = 0;
for(var i = 0 ; i < m ; i++)
{
	var c = readline();
	var flag = false
	for(var j = 0 ; j < c.length ; j++)
	{
		if(c[j] == '0')
		{
			flag = true;
			break;
		}
	}
	if(flag) cnt++;
	else cnt=0;
	ans = Math.max(ans,cnt);
}
print(ans);

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

var line = [], day, total = [], max = 0, current = 0;
line = readline().split(' ').map(Number);
function check (value) {
    if (value == 1) {
        current++;
    } else {
        if (current > max) {
            max = current;
            current = 0;
        }
    }
}

for (i = 0; i < line[1]; i++) {
    total.push(0);
}

for (i = 0; i < line[1]; i++) {

    day = readline().replace(/\r$/, '').split('').map(Number);

    if (day.includes(0)) {
        total[i] = 1;
    }
}

total.push(0);
total.forEach(check);
print(max);

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

//test for readline

var a, b, c;

a = readline();
b = readline().split('').length;
c = readline().split('');

print(a);
print(b);
print(c);

// načtu první řádek
var counts = readline().split(" ");

// Seznam bojovníků
var days = [];

// Načtu dny
for (var i = 0; i < counts[1]; i++) {
	days.push(readline());
}

// Procházím den po dni
var maximum = 0;
var actual = 0;
for (var den = 0; den < counts[1]; den++) {
	var nula = false;

	for (var bojovnik = 0; bojovnik<counts[0]; bojovnik++) {
		if (days[den][bojovnik] == "0") {
			nula = true;
			break;
		}
	}

	if (nula) {
		actual++;
	} else {
		if (maximum < actual) {
			maximum = actual;
			actual = 0;
		}
	}
}

		if (maximum < actual) {
			maximum = actual;
			actual = 0;
		}

write(maximum);

function constructOnes(n) {
  var str = "";
  for (var i = 0; i < n; i++) {
    str += '1';
  }
  return str;
}

var input = readline().trim().split(' ').map(Number);
var n = input[0], d = input[1], result = [], matchStr = constructOnes(n), consecutive = false;

for (var i = 0; i < d; i++) {
  var str = readline().trim();
  if (str != matchStr) {
    if (consecutive) {
      result[result.length-1]++;
    } else {
      result.push(1);
      consecutive = true;
    }
  } else {
    consecutive = false;
  }
}

print(result.sort(function (a, b) {
  return a-b;
}).pop());

function constructOnes(n) {
  var str = "";
  for (var i = 0; i < n; i++) {
    str += '1';
  }
  return str;
}

var input = readline().trim().split(' ').map(Number);
var n = input[0], d = input[1], result = [], matchStr = constructOnes(n), consecutive = false;

for (var i = 0; i < d; i++) {
  var str = readline();
  if (str !== matchStr) {
    if (consecutive) {
      result[result.length-1]++;
    } else {
      result.push(1);
      consecutive = true;
    }
  } else {
    consecutive = false;
  }
}

print(result.sort(function (a, b) {
  return a-b;
}).pop());

input = readline().split(' ');
n = parseInt(input[0]);
m = parseInt(input[1]);
var ans = 1;
var cnt = 0;
for(var i = 0 ; i < m ; i++)
{
	var c = readline();
	var flag = false
	for(var j = 0 ; j < c.length ; j++)
	{
		if(c[j] == '0')
		{
			flag = true;
			break;
		}
	}
	if(flag) cnt++;
	else cnt=0;
	ans = Math.max(ans,cnt);
}
print(ans);

input = readline().split(' ');
n = parseInt(input[0]);
m = parseInt(input[1]);
var ans = 1;
var cnt = 0;
for(var i = 0 ; i < m ; i++)
{
	var c = readline();
	var flag = false
	for(var j = 0 ; j < c.length ; j++)
	{
		if(c[j] == '0')
		{
			flag = true;
			break;
		}
	}
	if(flag) cnt++;
	else
	{
		ans = Math.max(ans,cnt);
		cnt=0;
	}
}
print(ans);


var cnt = readline()
while(cnt--){
    var x = readline().split(' ')

    a = parseInt(x[0])
    b = parseInt(x[1])
    if(a%b===0){
          print(0)
    }
    else
        print(b-(a%b))
}

t = +readline();
while (t-->0){
    ip = readline().split(' ').map(Number);
    a = ip[0];
    b = ip[1];
    if (a >= b){
        if (a%b == 0){
            print(0);
        } else
            print(b - (a%b));
    } else {
        print(b-a);
    }
}

var cases = readline();

for(var i=0;i < cases; i++)
{
    input = readline().split(" ").map(function(x){return parseInt(x);});

    a = input[0];
    b = input[1];

    var x =b - (a%b);
    if(x === b)
    {
        x = 0;
    }
    print(x)
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const inp = getInts()
    const a = inp[0]
    const b = inp[1]

    if (a < b) {
      print(b - a)
    } else {
      const k = parseInt(Math.ceil(a / b))
      print((k * b) - a)
    }
  }
}

var input = parseInt(readline());
for(var i =0; i< input; i++){
    var count = 0;
    var ab = readline().split(" ").map(x=>parseInt(x));
    var a = ab[0];
    var b = ab[1];
    if(a%b===0);
    else if(a>b) count += b-a%b;
    else if(a<b) count += b-a;
    print(count);
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var a = readline().trim().split(/\s/).map(x=>Number(x));
 var c = a[0]%a[1];
 print(c?(a[1]-c):0);
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var tmp = nextIntArray();
        var a = tmp[0];
        var b = tmp[1];
        if(a % b == 0){
            output[i] = 0;
        }else{
            output[i] = b - (a % b);
        }

    }
    myout(myconv(output,9));
}

var n = Number(readline());
var input = [] ;
var a,b ;
for(var i =0 ;i<n ; i++)
{
    input = readline().split(' ');
    a = Number(input[0]);
    b = Number(input[1]);
    print((b-(a%b))%b);
}

function main(a, b) {
    a = Math.abs(a);
    if(a === b) {
        return 0;
    }
    if (a < b) {
        return b - a;
    } else {
        var r = b - (a % b);
        if (r === b) {
            return 0;
        } else {
            return r;
        }
    }
}

var n = readline();
var input = [];
var output = '';

for (var i = 1; i <= n; i++) {
    input = readline().split(' ');

    output += main(parseInt(input[0]), parseInt(input[1])) + '\n';
}

print(output);

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

const lines = [];
let lineIndex = -1;

readline.on("line", line => {
  lines.push(line);
});

readline.on("close", () => {
  run();
});

const getNextLine = () => {
  return lines[++lineIndex];
};

// ====================================================================

const run = () => {
  const t = Number.parseInt(getNextLine());
  for (let i = 0; i < t; i++) {
    const [a, b] = getNextLine()
      .split(" ")
      .map(s => Number.parseInt(s));
    solve(a, b);
  }
};

const solve = (a, b) => {
  if (a % b === 0) {
    console.log(0);
    return;
  }
  const y = (Math.floor(a / b) + 1) * b - a;
  console.log(y);
};

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

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

  let [a, b] = d.split(' ').map(Number);
  let ans = 0;

  if (a % b !== 0) {
    ans = b - a % b;
  }

  console.log(ans);

  c++;
});

var t = readline()
while(t--){
    var x = readline().split(' ')

    a = parseInt(x[0])
    b = parseInt(x[1])

    if(a%b === 0) print('0 \n')
    else{
        print(b-a%b + '\n')
    }
}

"use strict";
exports.__esModule = true;
var str = "", lines = [], idxLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (x) { str += x; });
process.stdin.on('end', function () {
    lines = str.trim().split('\n').map(function (x) { return x.trim(); });
    main();
});
function readline() {
    return lines[idxLine++];
}
var print = console.log;
//===============================
//===============================
function main() {
    var t = parseInt(readline());
    for (var _ = 0; _ < t; _++) {
        var _a = readline().split(" ").map(function (e) { return parseInt(e); }), a = _a[0], b = _a[1];
        var x = a % b;
        if (x == 0)
            print(0);
        else {
            print(b - x);
        }
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
  inputString = inputString.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));
  main();
});

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

function solve(n, x, a) {
  a.sort((a, b) => b - a);
  let sum = 0;
  for(let i = 0; i < n; ++i) {
    sum += a[i];
    if (sum < x * (i + 1)) return i;
  }
  return n;
}

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let [a, b] = readLine().split(' ').map((val) => parseInt(val));
    var m = a % b;
    console.log((m === 0) ? 0 : b - m);
  }
  //process.stdout.write("hello: ");
}

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  const t = parseInt(input[0]);

  for (let i = 1; i <= t; i += 1) {
    const [a, b] = splitAndParseInt(input[i]);
    if (a % b === 0) console.log(0);
    else {
      const d = Math.ceil(a / b);
      console.log(d * b - a);
    }
  }
});

// imports
//end imports
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = '';
var currentLine = 0;
process.stdin.on('data', function (input) { inputString += input; });
process.stdin.on('end', function (_) { inputString = inputString.split('\n'); main(); });
var readline = function () { return inputString[currentLine++]; };
function main() {
    var tests = parseInt(readline());
    while (tests--) {
        var _a = readline().split(' ').map(function (x) { return parseInt(x); }), a = _a[0], b = _a[1];
        if (a < b)
            console.log(b - a);
        else if (a == b)
            console.log(0);
        else {
            var ans = void 0;
            a = a % b;
            if (a == 0)
                ans = 0;
            else
                ans = b - a;
            console.log(ans);
        }
    }
}

// imports
//end imports
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = '';
var currentLine = 0;
process.stdin.on('data', function (input) { inputString += input; });
process.stdin.on('end', function (_) { inputString = inputString.split('\n'); main(); });
var readline = function () { return inputString[currentLine++]; };
function main() {
    var tests = parseInt(readline());
    var ansStr = '';
    while (tests--) {
        var _a = readline().split(' ').map(function (x) { return parseInt(x); }), a = _a[0], b = _a[1];
        if (a < b)
            ansStr += ((b - a).toString() + '\n');
        else if (a == b)
            ansStr += ('0' + '\n');
        else {
            var ans = void 0;
            a = a % b;
            if (a == 0)
                ans = 0;
            else
                ans = b - a;
            ansStr += (ans + '\n');
        }
    }
    console.log(ansStr);
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [a, b] = lines[j+1].split(' ').map(x => +x)
    const r = (a%b)
    console.log(r > 0 ? b - r : 0)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

function solve(a, b) {
  const m = (a % b);
  return (m === 0) ? 0 : (b - m);
}

function main(lines) {
  const whitespace = /\s+/;
  lines.shift();
  for (const line of lines) {
    const [a, b] = line.split(whitespace).map(Number);
    console.log(solve(a, b));
  }
}

function trim_line(s) {
  return s.trim();
}

function has_content(s) {
  return (s.length > 0);
}

async function processLinesFromStream(rs, pf) {
  const chunks = [];
  const encoding = 'utf-8';
  rs.setEncoding(encoding);
  for await (let chunk of rs) {
    chunks.push(chunk);
  }
  const empty = '';
  const newline = /\n/;
  const lines = chunks.join(empty)
                      .split(newline)
                      .map(trim_line)
                      .filter(has_content);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

function solve(a, b) {
  const m = (a % b);
  return (m === 0) ? 0 : (b - m);
}

function main(lines) {
  lines.shift();
  for (const line of lines) {
    let t = line.trim();
    if (line.length > 0) {
      const [a, b] = t.split(/\s+/).map(Number);
      console.log(solve(a, b));
    }
  }
}

async function processLinesFromStream(rs, pf) {
  const content = [];
  rs.setEncoding("utf-8");
  for await (let chunk of rs) {
    content.push(chunk);
  }
  const lines = content.join('').split(/\n/);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

var tc = parseInt(readline());

for(var i = 0; i < tc; i++){
    var line = readline().split(' ');
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);

    if(a%b === 0) print(0);
    else{
        print(b - a%b);
    }
}

var numberTests = +readline();
for (var test = 0; test<numberTests; test++) {
    var twoNumber = readline().split(" ");
    if (+twoNumber[0]<+twoNumber[1]){
        print(twoNumber[1]-twoNumber[0]);
    } else if (+twoNumber[0]>+twoNumber[1]) {
       print( Math.ceil(twoNumber[0]/twoNumber[1]) * twoNumber[1] - twoNumber[0]);
    } else print(0);
}

// Sample code to perform I/O:

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

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

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

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

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

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

    let inputs = str.trim().split('\n');
    let testCases = inputs.slice(1);
    let moves = [];
    for (let index = 1; index <= +inputs[0]; index++) {

        let testCase = inputs[index].trim().split(' ').map(num => Number(num));
        move = 0;
        let modulo = testCase[0] % testCase[1];
        move = modulo == 0 ? modulo : testCase[1] - modulo;
        moves.push(move);

    }

    return moves.join('\n').toString();
}

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

const input = [];
readLine.on('line', line => input.push(line));
const divisibility = () => {
    input.shift();
    for (const x of input) {
        let [z,y] = x.split(' ').map(x => +x);
        if (z % y !== 0) {
            console.log(y - (z % y))
        }
        else {
            console.log(0);
        }
    }
};
readLine.on('close', divisibility);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    for (var i = 0; i < n; i++) {
        let ab = readLine().split(' ').map(value => parseInt(value));
        let a = ab[0];
        let b = ab[1];
        if (a % b == 0) {
            console.log(0)
        } else console.log(b - (a % b));
    }
}

var s = '';
var n = 0;

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

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

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

function main() {
    var T = parseInt(readline());
    for (var t = 0; t < T; ++t) {
        var ls = readline().split(' ');
        var a = parseInt(ls[0]), b = parseInt(ls[1]);
        var m = a % b;
        console.log((m === 0) ? 0 : b - m);
    }
}

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

var first, current = 0;

var data = [];

rl.on('line', function(line){
    if (first === undefined) {
        first = +line;
    } else {
        data.push(line.split(' '));
        current++;
    }

    if (first === current) rl.close();
});

rl.on('close', function() {
    data.forEach(pair => {
       const a = pair[0];
       const b = pair[1];

       const os = a % b;
       const diff = os ? b - a % b : 0;
       console.log(diff);
    });
});

'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(/\W+/) // splits at spaces or new lines
    .map(string => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  var n = readline();

  for (let i = 0; i < n; i++) {
    var a = readline();
    var b = readline();
    console.log(findDivisibility2(a, b));
  }
}

function findDivisibility2(a, b) {
  if (a % b === 0) return 0;
  else {
    return b - (a % b);
  }
}

// function findDivisibility(a, b) {
//   let count = 0;
//   while (a % b !== 0) {
//     if (a % b === 0) {
//       return count;
//     } else {
//       a++;
//       count++;
//     }
//   }
//   return count;
// }

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

let tc
let input;
r.on('line', (line) => {
    if (!tc) { tc = line; }
    else  {

        let nums = line.split(" ").map(n =>+n);
         console.log(f(nums[0],nums[1]));

    }
});

function f(a,b) {
    let r= a%b;
    if(r==0) return 0;
    else return (b-r);
}

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

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const [a, b] = readInts()
    let r = a % b
    if(r === 0) wr(0)
    else wr(b - r)
  }
}

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

function outResult(data) {
    data.forEach(num => console.log(num))
}

let count = null
let data = []

rl.on('line', function(line) {
    if (count === null) {
        count = Number(line.split(' ')[0]);
        return false
    }

    if (count > 0) {
        let arr = line.split(' ');
        let a = Number(arr[0]);
        let b = Number(arr[1]);
        let move = 0;
        move = (b - (a % b)) % b;
        data.push(move);
        count--;
    }

    if (count === 0) {
        outResult(data)
    }
})

function findDivisibility(a, b) {
  let count = 0;
  while (a % b !== 0) {
    if (a % b === 0) {
      return count;
    } else {
      a++;
      count++;
    }
  }
  return count;
}

findDivisibility(10, 4);
findDivisibility(13, 9);
findDivisibility(100, 13);
findDivisibility(123, 456);
findDivisibility(92, 46);

function findDivisibility(n, a, b) {
  let count = 0;
  while (a % b !== 0) {
    if (a % b === 0) {
      return count;
    } else {
      a++;
      count++;
    }
  }
  return count;
}

function findDivisibility(a, b) {
  let count = 0;
  while (a % b !== 0) {
    if (a % b === 0) {
      return count;
    } else {
      a++;
      count++;
    }
  }
  return count;
}

console.log(findDivisibility(10, 4));

function findDivisibility(a, b) {
  let count = 0;
  while (a % b !== 0) {
    if (a % b === 0) {
      return count;
    } else {
      a++;
      count++;
    }
  }
  return count;
}

console.log(findDivisibility(13, 9));

function findDivisibility(n, a, b) {
  for (let i = 0; i < n; i++) {
    let count = 0;
    while (a % b !== 0) {
      if (a % b === 0) {
        return count;
      } else {
        a++;
        count++;
      }
    }
    return count;
  }
}

process.stdin.on('data', n => {
  for (let i = 0; i < n; i++) {
    let count = 0;
    while (a % b !== 0) {
      if (a % b === 0) {
        return count;
      } else {
        a++;
        count++;
      }
    }
    return count;
  }
});
// function findDivisibility(a, b) {
//   let count = 0;
//   while (a % b !== 0) {
//     if (a % b === 0) {
//       return count;
//     } else {
//       a++;
//       count++;
//     }
//   }
//   return count;
// }

// console.log(findDivisibility(10, 2));

process.stdin.on('data', (n, a, b) => {
  for (let i = 0; i < n; i++) {
    console.log(findDivisibility(a, b));
  }
});
function findDivisibility(a, b) {
  let count = 0;
  while (a % b !== 0) {
    if (a % b === 0) {
      return count;
    } else {
      a++;
      count++;
    }
  }
  return count;
}

// imports
//end imports
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = '';
var currentLine = 0;
process.stdin.on('data', function (input) { inputString += input; });
process.stdin.on('end', function (_) { inputString = inputString.split('\n'); main(); });
var readline = function () { return inputString[currentLine++]; };
function main() {
    var tests = parseInt(readline());
    while (tests--) {
        var _a = readline().split(' ').map(function (x) { return parseInt(x); }), a = _a[0], b = _a[1];
        if (a < b)
            console.log(b - a);
        else if (a == b)
            console.log(0);
        else {
            a = a % b;
            console.log(b - a);
        }
    }
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const [a, b] = lines[j+1].split(' ').map(x => +x)
    console.log(b-a%b)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

t = +readline();
while (t-->0){
    ip = readline().split(' ').map(Number);
    a = ip[0];
    b = ip[1];
    if (a >= b){
        print(b%a);
    } else {
        print(b-a);
    }
}

t = +readline();
while (t-->0){
    ip = readline().split(' ').map(Number);
    a = ip[0];
    b = ip[1];
    if (a >= b){
        print(a%b);
    } else {
        print(b-a);
    }
}

t = +readline();
while (t-->0){
    ip = readline().split(' ').map(Number);
    a = ip[0];
    b = ip[1];
    if (a >= b){
        print(b - (a%b));
    } else {
        print(b-a);
    }
}

var cases = readline();

for(var i=0;i < cases; i++)
{
    input = readline().split(" ").map(function(x){return parseInt(x);});

    a = input[0];
    b = input[1];

    var x =b - (a%b);
    print(x)
}

var cases = readline();

function input()
{
    var input = readline().split(" ").map(function(x){return parseInt(x);});
}

for(var i=0;i < cases; i++)
{
    var add = 0;
    input()

    a = input[0];
    b = input[1];
    if(a % b === 0)
    {
        print(add);
    }
    else
    {
        a++;
        add++;
    }
}

var cases = readline();
var input = readline().split(" ").map(function(x){return parseInt(x);});

for(var i=0;i < cases; i++)
{
    var add = 0;

    a = input[0];
    b = input[1];
    while(a % b !== 0)
    {
        a++;
        add++;
    }
    if(a % b === 0)
    {
        print(add);
    }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const inp = getInts()
    const a = inp[0]
    const b = inp[1]
    let t = parseInt(a / b)
    while (t * b < a) {
      t ++
    }
    print((t * b) - a)
  }
}

var input = parseInt(readline());
for(var i =0; i< input.length; i++){
    var count = 0;
    var ab = readline().split("");
    var a = ab[0];
    var b = ab[1];
    if(a%b) count++;
    else count +=b-a;
    print(count);
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var a = readline().trim().split(/\s*/).map(x=>Number(x));
 var c = a[0]%a[1];
 print(c?(a[1]-c):0);
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var a = readline().trim().split(/\s*/).map(x=>Number(x));
 print((-a[0])%a[1]);
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var a = readline().trim().split(/\s*/).map(x=>Number(x));
 var c = a[0]%a[1];
 print((c==0)?0:(a[1]-c));
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var a = readline().trim().split(/\s*/).map(x=>Number(x));
 var c = a[0]%a[1];
 print(c?0:(a[1]-c));
}

function main(a, b) {
    a = Math.abs(a);
    if(a === b) {
        return 0;
    }
    if (a < b) {
        return b - a;
    } else {
        return b - (a % b);
    }
}

var n = readline();
var input = [];
var output = '';

for (var i = 1; i <= n; i++) {
    input = readline().split(' ');

    output += main(parseInt(input[0]), parseInt(input[1])) + '\n';
}

print(output);

var t = readline()
while(t--){
    a = readline()
    b = readline
    a = parseInt(a)
    b = parseInt(b)

    if(a%b === 0) print('0 \n')
    else{
        print(b-a%b + '\n')
    }
}

var t = readline()
while(t--){
    a = readline()
    b = readline()
    a = parseInt(a)
    b = parseInt(b)

    if(a%b === 0) print('0 \n')
    else{
        print(b-a%b + '\n')
    }
}

var t = readline();
while(t--){
    a = readline();
    b = readline
    if(a%b === 0) print('0
')
    else{
        print(b-a%b + '
')
    }
}

var cnt = readline()
while(cnt--){
    var x = readline().split(' ')

    a = parseInt(x[0])
    b = parseInt(x[1])
    if(a>b)b=a
    print(b-(a%b))
}

var cnt = readline()
while(cnt--){
    var x = readline().split(' ')

    a = parseInt(x[0])
    b = parseInt(x[1])
    if(a>b){
            a = a ^ b
                b = a ^ b
                a = a ^ b
    }
    print(b-(a%b))
}

var cnt = readline()
while(cnt--){
    var x = readline().split(' ')

    a = parseInt(x[0])
    b = parseInt(x[1])

    print(b-(a%b))
}

var tc = parseInt(readline());

for(var i = 0; i < tc; i++){
    var line = readline().split(' ');
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);

    if(a%b === 0) print(0);
    else{
        print(a - (a%b) - Math.floor(a/b) * b);
    }
}

var tc = parseInt(readline());

for(var i = 0; i < tc; i++){
    var line = readline().split(' ');
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);

    if(a%b === 0) print(0);
    else{
        print(a%b);
    }
}

var tc = parseInt(readline());

for(var i = 0; i < tc; i++){
    var line = readline().split(' ');
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);

    if(a%b === 0) print(0);
    else{
        print(a - (a%b) - Math.floor(a%b) * b);
    }
}

var numberTests = +readline();
for (var test = 0; test<numberTests; test++) {
    var twoNumber = readline().split(" ");
    if (twoNumber[0]<twoNumber[1]){
        print(twoNumber[1]-twoNumber[0]);
    } else if (twoNumber[0]>twoNumber[1]) {
       print( Math.ceil(twoNumber[0]/twoNumber[1]) * twoNumber[1] - twoNumber[0]);
    } else print(0);
}


"use strict";

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

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

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

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

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

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

function main() {
  var t = readline();

  var _loop = function _loop() {
    var _readline$split$map = readline().split(" ").map(function (num) {
      return parseInt(num);
    }),
        _readline$split$map2 = _slicedToArray(_readline$split$map, 2),
        n = _readline$split$map2[0],
        m = _readline$split$map2[1];

    var arr = new Array(n).fill(null);
    arr = arr.map(function (elem) {
      return new Array(m).fill('B');
    });
    arr[0][0] = 'W';

    for (var i = 0; i < n; i++) {
      print(arr[i].join(''));
    }
  };

  while (t--) {
    _loop();
  }
}

main();

const ascending = (x, y) => x - y;
const descending = (x, y) => y - x;
const log = console.log;

const row0 = 'WBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB';
const row =  'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB';

function solve(input) {
    input = input.toString().split(/\r?\n/);

    let T = +input[0];
    let res = [];

    for (let t = 1, inputRow = 1; t <= T; t++) {

        let nm = input[inputRow++].split(' ');
        let n = +nm[0];
        let m = +nm[1];

        res.push(row0.substr(0, m));

        for (let i = 1; i < n; i++) {
            res.push(row.substr(0, m));
        }

    }

    return res.join('\n');
}

async function main() {

    try {

        let input = await new Promise(resolve => {

            let _input = '';
            process.stdin.resume();
            process.stdin.setEncoding('utf-8');
            process.stdin.on('data', (buf) => {
                _input += buf;
            });
            process.stdin.on('end', () => {
                resolve(_input);
            });

        });
        let output = solve(input);

        console.log(output);

    } catch (err) {
        console.error(err);
    }
}

main();

let input = require('fs').readFileSync(0, 'utf8').trim().split('\n');
const read = () => input.shift();
const readInt = () => parseInt(read());
const readInts = () => read().split(' ').map(n => parseInt(n));
const print = console.log;

const solution = () => {
  const c = readInt();
  for (let ci = 1; ci <= c; ci++) {
    const [y, x] = readInts();

    let odds = [y, x].filter(x => x % 2 === 1).length
    let fills = odds === 2 ? 2 : 1;

    let blackMod = y % 2;
    for (let i = 0; i < y; i++) {
      let str = '';
      for (let j = 0; j < x; j++) {
        if (j % 2 === blackMod) {
          str += 'B'
        } else if (fills !== 0) {
          str += 'B'
          fills--;
        } else {
          str += 'W'
        }
      }
      if (blackMod === 1) { blackMod = 0 }
      else if (blackMod === 0) { blackMod = 1 }
      print(str);
    }
  }
};

solution();

// Q: https://codeforces.com/contest/1333/problem/A

const readline = require('readline');

let input = [];

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

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

rl.on('close', () => {
	const test = parseInt(input[0]);
	for (let t=0; t < test; t++) {
        let n, m;
        [n, m] = input[t+1].split(' ').map((a) => parseInt(a));
        let output = Array(n).fill(null).map(() => Array(m).fill('B'));
        output[0][0] = 'W';
        for (let i = 0; i < n; i++) {
            console.log(output[i].join(''));
        }
	}
});

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

const MOD1 = 1000000007

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

function sort(a, inc = true) {
  if (inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while (t--) {
    const [n, m] = readInts()
    let ans = new Array(n)
    for (let i = 0; i < n; i++) {
      ans[i] = new Array(m).fill('B')
    }
    ans[n - 1][m - 1] = 'W'
    for (let i = 0; i < n; i++) {
      wr(ans[i].join(''))
    }
  }
}

let i = '';
let lines;
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
  const { EOL } = require('os');
  lines = i.split(EOL); /*your input text, split by lines*/
  main();
});

function solve(nums) {

}

function main() {
  let currentLine = 0;
  const readLine = (_) => lines[currentLine++].split(' ').map((val) => parseInt(val));

  const test = readLine()[0];
  for (let t = 1; t <= test; ++t) {
    const [n, m] = readLine();
    let secondLine = new Array(m).fill('B').join('');
    let firstLine = 'W'.concat(secondLine.slice(1));
    const result = new Array(n).fill().map((val, i) => i === 0 ? firstLine : secondLine).join('\n');
    console.log(result);
  }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const n = +lines[0];
    for (let i = 0; i < n; i++) {
        const [n, m] = lines[i + 1].split(" ").map((x) => +x);
        for (let t = 0; t < n; t++) {
            const str = Array(m).fill("B");
            if (t === 0) {
                str[0] = "W";
            }
            console.log(str.join(""));
        }
    }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let j = 0; j < n; j++) {
            const line = Array(m).fill("B");
            if(j === 0) {
                line[0] = "W";
            }
            console.log(line.join(""));
        }
    }
}

t = +readline();
while (t-->0){
    ip = readline().split(' ').map(Number);
    n = +ip[0];
    m = +ip[1];
    out = 'W';
    for (i=1;i<m;i++){
        out += 'B';
    }
    blacks = '';
    for (i=0;i<m;i++){
        blacks += 'B';
    }
    for (i=1;i<n;i++){
        out += '\n'+blacks;
    }
    print(out);
}

t = +readline();
while (t-- > 0) {
    ip = readline().split(' ').map(Number);
    n = +ip[0];
    m = +ip[1];
    out = 'W';
    for (i = 1; i < m; i++) {
        out += 'B';
    }
    blacks = '';
    for (i = 0; i < m; i++) {
        blacks += 'B';
    }
    for (i = 1; i < n; i++) {
        out += '\n' + blacks;
    }
    print(out);
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    let line;
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let j = 0; j < n; j++) {
            if(j === 0) {
                line = "W" + "B".repeat(m-1);
            } else {
                line = "B".repeat(m);
            }
            console.log(line);
        }
    }
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    var n = one[0];
    var m = one[1];
    var mass = n * m;
    var output = new Array(n);
    for(var j = 0; j < n; j++){
      output[j] = new Array(m);
    }

    for(var j = 0; j < n; j++){
      for(var k = 0; k < m; k++){
        /*if(j % 2 == mass % 2){
          if(k % 2 == 0){

          }else{
            output[j][k] = "W";
          }
        }else{
          if(k % 2 == 1){
            output[j][k] = "B";
          }else{
            output[j][k] = "W";
          }
        }*/
        output[j][k] = "B";
      }
    }
    output[0][0] = "W";
    /*if(mass % 2 == 0){
      output[n - 1][m - 1] = output[n - 2][m - 1];
    }*/
    for(var j = 0; j < n; j++){
      myout(myconv(output[j],0));
    }
  }
}

function main(n, m) {
    var output = '';
    for (i = 0; i < n; i++) {
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                output += 'W';
            } else {
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var outputB = '';

for (var z = 1; z <= +n; z++) {
    input = readline().split(' ');

    outputB += main(+input[0], +input[1]);
}

print(outputB);

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let j = 0; j < n; j++) {
            let line = "";
            for(let k = 0; k < m; k++) {
                if(j == 0 && k == 0) {
                    line += "W";
                } else {
                    line += "B";
                }
            }
            console.log(line);
        }
    }
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const [n, m] = lines[i+1].split(' ').map(x => +x)
    for (let t=0; t<n;t++) {
      const str = Array(m).fill('B')
      if (t === 0) {
        str[0] = 'W'
      }
      console.log(str.join(''))
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

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

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

const store = {};

function main() {
	let t = readLine() >> 0;

	while (t--) {
		let [n, m] = readLine()
			.split(' ')
			.map(x => x >> 0);

		let grid = Array(n).fill('B'.repeat(m));
		let white = grid[0].split('');
		white.splice(0, 1, 'W');
		grid[0] = white.join('');
		console.log(grid.join('\n'));
	}
}

function main(n, m) {
    var output = '';
    for (i = 0; i < n; i++) {
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                output += 'W';
            } else {
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var outputB = '';

for (var i = 1; i <= +n; i++) {
    input = readline().split(' ');

    outputB += main(+input[0], +input[1]);
}

print(outputB);

function main(n, m) {
    var output = '';
    for (i = 0; i < n; i++) {
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                output += 'W';
            } else {
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var output = '';

for (var i = 1; i <= +n; i++) {
    input = readline().split(' ');

    output += main(+input[0], +input[1]);
}

print(output);

function main(n, m) {
    var rows = [];
    var output = '';
    for (i = 0; i < n; i++) {
        rows[i] = [];
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                output += 'W';
            } else {
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var output = '';

for (var i = 1; i <= n; i++) {
    input = readline().split(' ');

    output += main(+input[0], +input[1]);
}

print(output);

function main(n, m) {
    var rows = [];
    var output = '';
    for (i = 0; i < n; i++) {
        rows[i] = [];
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                rows[i].push(1);
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                rows[i].push(1);
                output += 'W';
            } else {
                rows[i].push(0);
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var output = '';

for (var i = 1; i <= n; i++) {
    input = readline().split(' ');

    output += main(+input[0], +input[1]);
}

print(output);

function main(n, m) {
    var rows = [];
    var output = '';
    for (i = 0; i < n; i++) {
        rows[i] = [];
        for (k = 0; k < m; k++) {
            if(i === 0 && k < (m-1)) {
                output += 'W';
            } else if (i === 1 && n > 2 && k === (m-1)){
                output += 'W';
            } else {
                output += 'B';
            }
        }
        output += '\n';
    }
    return output;
}

var n = readline();
var input = [];
var output = '';

for (var i = 0; i <= n; i++) {
    input = readline().split(' ');

    output += main(+input[0], +input[1]);
}

print(output);

function main() {
    var t = readline();
	while(t--){
		var arr = readline().split(" ").map(num => parseInt(num));
	    var n = arr[0];
	    var m = arr[1];
	    print(n, m);
		var arr = new Array(n).fill(null);
		arr = arr.map(elem => new Array(m).fill(null));
		if(n < 3){
			arr[0] = arr[0].map(num => 'B');
			arr[1] = arr[1].map(num => 'W');
			arr[1][1] = 'B';
		}else if(m < 3){
			for(var i = 0; i < n; i++){
				arr[i][0] = 'B';
				arr[i][1] = 'W';
			}
			arr[1][1] = 'B';
		}else{
			for(var i = 0; i < n; i++){
				for(var j = 0; j < m; j++){
					arr[i][j] = 'B';
				}
			}
			arr[0][0] = 'W';
			arr[0][1] = 'W';
			arr[1][0] = 'W';
			arr[1][1] = 'W';
		}
		for(var i = 0; i < n; i++) print(arr[i].join(''));
	}
}
main();

let input = require('fs').readFileSync(0, 'utf8').trim().split('\n');
const read = () => input.shift();
const readInt = () => parseInt(read());
const readInts = () => read().split(' ').map(n => parseInt(n));
const print = console.log;

const solution = () => {
  const c = readInt();
  for (let ci = 1; ci <= c; ci++) {
    const [y, x] = readInts();

    for (let i = 0; i < y; i++) {
      let str = '';
      for (let j = 0; j < x; j++) {
        if (i === 0 && j === 1) {
          str += 'B';
        } else {
          str += i % 2 === 0
            ? j % 2 === 0 ? 'B' : 'W'
            : j % 2 === 1 ? 'B' : 'W';
        }
      }
      print(str);
    }
  }
};

solution();

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let j = 0; j < n; j++) {
            for(let k = 0; k < m; k++) {
                if(j == 0 && k == 0) {
                    rl.write("W");
                } else {
                    rl.write("B");
                }
            }
            rl.write("\n");
        }
    }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map((x) => +x);
        for (let i = 0; i < n; i++) {
            for(let j = 0; j < m; j++) {
                if(i === 0 && j === 0) {
                    rl.write("W");
                } else {
                    rl.write("B");
                }
            }
            rl.write("\n");
        }
    }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map((x) => +x);
        for (let i = 0; i < n; i++) {
            for(let j = 0; j < m; j++) {
                if(i == 0 && j == 0) {
                    rl.write("W");
                } else {
                    rl.write("B");
                }
            }
            rl.write("\n");
        }
    }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let i = 0; i < n; i++) {
            for(let j = 0; j < m; j++) {
                if(i === 0 && j === 0) {
                    rl.write("W");
                } else {
                    rl.write("B");
                }
            }
            rl.write("\n");
        }
    }
}

const readline = require("readline");

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

let arr = [];

rl.on("line", (line) => {
    arr.push(line);
}).on("close", () => {
    processData(arr);
    process.exit(0);
});

function processData(lines) {
    const t = +lines[0];
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[i + 1].split(" ").map(x => +x);
        for (let i = 0; i < n; i++) {
            for(let j = 0; j < m; j++) {
                if(i == 0 && j == 0) {
                    rl.write("W");
                } else {
                    rl.write("B");
                }
            }
            rl.write("\n");
        }
    }
}


function solve(n) {
    var a = 0;
    var b = n;

    var min = 1;
    var max = 2;
    var average = 0;

    if (n === 0) {
        print('Y 0 0');
        return;
    }

    while (max - min > 10e-13) {
        average = (min + max) / 2;
        a = n - average;
        b = average;

        if (a * b > n) {
            max = average;
        } else {
            min = average;
        }
    }

    if (Math.abs(a + b - a * b) < 10e-6 && Math.abs(a + b - n) < 10e-6) {
        print('Y ' + a + ' ' + b);
    } else {
        print('N');
    }
}

var lines = +readline();
for(var i = 0; i<lines; i++) {
    solve(+readline())
}

var T = parseInt(readline());
for(var t=1;t<=T;t++)
{
    var d=parseInt(readline());//aici da ReferenceError: readLine is not defined
    if(d*d-4*d<0)
    {
        print("N");
        continue;
    }
    var delta=Math.sqrt(d*d-4*d);
    var t1=(d-delta)/2,t2=(d+delta)/2;
    print('Y',t1,t2);
}

function doIt() {

	var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -6);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var half = num / 2;
		var diff = Math.pow(half, 2) - num;
		if(diff === 0) {
		    print('Y ' + half + ' ' + half);
		    continue;
		}else if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = ('' + ((start + finish) / 2)).split('.');
         if(val1.length > 1) {
            val1[1] = val1[1].substr(0, 9);
         }
         val1 = +(val1.join('.'));

			var val2 = num - val1;

			diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
            val2 = Math.floor(val2 * 1000000000) / 1000000000;
				print('Y ' + val2 + ' ' + val1);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

}

doIt();

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
	inputString+=inputStdin;
});
process.stdin.on('end',_=>{
	inputString=inputString.trim().split("\n").map(string=>{
		return string.trim();
	});
	main();
});
function readLine()
{
	return inputString[currentLine++];
}
function main()
{
	const t=parseInt(readLine());
	for(let k=0;k<t;++k)
	{
		const n=+(readLine());
		// const [a,b,c]=readLine().trim().split(" ").map(x=>{return +(x);});
		let lc=0,lo=0,hi=n/2,mid;
		while(lc<1000)
		{
			mid=(lo+hi)/2;
			if(((n-mid)*mid)>n)
				hi=mid;
			else
				lo=mid;
			lc++;
		}
		if(Math.abs(mid*(n-mid)-n)<=0.000001)
			console.log('Y '+(n-mid)+' '+mid);
		else
			console.log('N');
	}
	return 0;
}

var num = parseInt(readline());
for (var i = 0; i < num; i++) {
	var curNum = parseInt(readline());
	var d = curNum * curNum - 4 * curNum;
	if ( d < 0 ) {
		print('N');
    } else if ( d === 0 ) {
		print('Y ' + curNum / 2 + ' ' + curNum / 2);
    } else {
		d = Math.sqrt(d);
		print('Y ' + (curNum+d)/2 + ' ' + (curNum-d)/2);
    }
}

function solve(n) {
    var a = 0;
    var b = n;

    var min = 1;
    var max = 2;
    var average = 0;

    if (n === 0) {
        print('Y 0 0');
        return;
    }

    while (max - min > 10e-9) {
        average = (min + max) / 2;
        a = n - average;
        b = average;

        if (a * b > n) {
            max = average;
        } else {
            min = average;
        }
    }

    if (Math.abs(a + b - a * b) < 10e-6 && Math.abs(a + b - n) < 10e-6) {
        print('Y ' + a + ' ' + b);
    } else {
        print('N');
    }
}

var lines = +readline();
for(var i = 0; i<lines; i++) {
    solve(+readline())
}

function solve(n) {
    var a = 0;
    var b = n;

    var min = 1;
    var max = 2;
    var average = 0;

    if (n === 0) {
        write('Y 0 0');
        return;
    }

    while (max - min > 10e-9) {
        average = (min + max) / 2;
        a = n - average;
        b = average;

        if (a * b > n) {
            max = average;
        } else {
            min = average;
        }
    }

    if (Math.abs(a + b - a * b) < 10e-6 && Math.abs(a + b - n) < 10e-6) {
        write('Y ' + a + ' ' + b);
    } else {
        write('N');
    }
}

var lines = +readline();
for(var i = 0; i<lines; i++) {
    solve(+readline())
}

function doIt() {

	var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -7);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var half = num / 2;
		var diff = Math.pow(half, 2) - num;
		if(diff === 0) {
		    print('Y ' + half + ' ' + half);
		}else if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = ('' + ((start + finish) / 2)).split('.');
         if(val1.length > 1) {
            val1[1] = val1[1].substr(0, 9);
         }
         val1 = +(val1.join('.'));

			var val2 = num - val1;

			diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
            val2 = Math.floor(val2 * 1000000000) / 1000000000;
				print('Y ' + val2 + ' ' + val1);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

}

doIt();

var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -6);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var diff = Math.pow(num / 2, 2) - num;
		if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = (start + finish) / 2;
			var val2 = num - val1;

			var diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
				print('Y ' + val1 + ' ' + val2);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

function doIt() {

	var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -7);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var diff = Math.pow(num / 2, 2) - num;
		if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = ('' + ((start + finish) / 2)).split('.');
         if(val1.length > 1) {
            val1[1] = val1[1].substr(0, 9);
         }
         val1 = +(val1.join('.'));

			var val2 = num - val1;

			diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
            val2 = Math.floor(val2 * 1000000000) / 1000000000;
				print('Y ' + val2 + ' ' + val1);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

}

doIt();

function doIt() {

	var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -7);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var half = num / 2;
		var diff = Math.pow(half, 2) - num;
		if(diff === 0) {
		    print('Y ' + half + ' ' + half);
		    continue;
		}else if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = ('' + ((start + finish) / 2)).split('.');
         if(val1.length > 1) {
            val1[1] = val1[1].substr(0, 9);
         }
         val1 = +(val1.join('.'));

			var val2 = num - val1;

			diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
            val2 = Math.floor(val2 * 1000000000) / 1000000000;
				print('Y ' + val2 + ' ' + val1);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

}

doIt();

function doIt() {

	var cnt = +readline();
	var res = [];
	var minDiff = Math.pow(10, -6);
	var step = Math.pow(10, -9);

	for(var i = 0; i < cnt; i++) {
		var num = +readline();
		var diff = Math.pow(num / 2, 2) - num;
		if(diff < 0) {
			print('N');
			continue;
		}

		var start = 1;
		var finish = 2;

		while(start < finish) {
			var val1 = ('' + ((start + finish) / 2)).split('.');
         if(val1.length > 1) {
            val1[1] = val1[1].substr(0, 9);
         }
         val1 = +(val1.join('.'));

			var val2 = num - val1;

			diff = val1 * val2 - num;
			if(Math.abs(diff) <= minDiff) {
				print('Y ' + val1 + ' ' + val2);
				break;
			}

			if(diff < 0) {
				start = val1 + step;
			} else {
				finish = val1 - step;
			}
		}
	}

}

doIt();


'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = read(),
        b = read();
  const tr = new SegTree(n);
  const res = [];
  for (let i = 0, j = 0; i < n; i = ++j) {
    if (a[i] === '1') continue;
    while (a[j + 1] === '0') j++;
    res.push([i, j]);
    if (i) tr.update(0, i - 1, 1);
    if (j < n - 1) tr.update(j + 1, n - 1, 1);
  }
  let one = 0,
      zero = 0;
  for (let i = 0; i < n; i++) {
    const x = tr.query(i, i);
    if (x & 1) {
      if (b[i] === '0') one++;else zero++;
    } else {
      if (b[i] === '0') zero++;else one++;
    }
    if (zero && one) return 'No';
  }
  if (zero) res.push([0, n - 1]);else res.push([0, 0], [1, n - 1]);
  return `Yes\n${res.length}\n${res.map(([l, r]) => `${l + 1} ${r + 1}`).join('\n')}`;
}
class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode();
    this.update = (x, y, z) => {
      x = Math.max(x, 0);
      y = Math.min(y, n);
      this._update(this.root, 0, n, x, y, z);
    };
    this.query = (x, y) => {
      x = Math.max(x, 0);
      y = Math.min(y, n);
      return this._query(this.root, 0, n, x, y);
    };
  }
  _newNode(val = 0, left = null, right = null) {
    return {
      val,
      left,
      right,
      add: 0
    };
  }
  _down(node, l, r) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    const mid = Math.floor((l + r) / 2);
    left.add += node.add;
    left.val += node.add * (mid - l + 1);
    right.add += node.add;
    right.val += node.add * (r - mid);
    node.add = 0;
  }
  _up(node) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    node.val = left.val + right.val;
  }
  _update(node, l, r, x, y, z) {
    if (!node) return;
    if (l === x && r === y) {
      node.add += z;
      node.val += z * (r - l + 1);
      return;
    }
    const mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (y <= mid) this._update(node.left, l, mid, x, y, z);else if (x > mid) this._update(node.right, mid + 1, r, x, y, z);else this._update(node.left, l, mid, x, mid, z), this._update(node.right, mid + 1, r, mid + 1, y, z);
    this._up(node);
  }
  _query(node, l, r, x, y) {
    if (y < x) return 0;
    if (!node) return 0;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (!node.left) {
      node.left = this._newNode();
      node.right = this._newNode();
    }
    this._down(node, l, r);
    if (y <= mid) res = this._query(node.left, l, mid, x, y);else if (x > mid) res = this._query(node.right, mid + 1, r, x, y);else res = this._query(node.left, l, mid, x, mid) + this._query(node.right, mid + 1, r, mid + 1, y);
    this._up(node);
    return res;
  }
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

function solve() {
    var n = Number(read());
    var a = read();
    var b = read();
    var aOneIndexes = [];
    var equalsCount = 0;
    for (var i = 0; i < n; i++) {
        if (a[i] === b[i]) {
            equalsCount++;
        }
        if (a[i] === '1') {
            aOneIndexes.push(i);
        }
    }
    if (equalsCount !== 0 && equalsCount !== n) {
        write('NO');
        return;
    }
    write('YES');
    var operationsOdd = ((aOneIndexes.length) & 1);
    var equalityOdd = equalsCount === n ? 0 : 1;
    var needAddOperations = !!(operationsOdd ^ equalityOdd);
    write(aOneIndexes.length + (needAddOperations ? 3 : 0));
    for (i = 0; i < aOneIndexes.length; i++) {
        var index = aOneIndexes[i] + 1;
        write(index + ' ' + index);
    }
    if (needAddOperations) {
        write('1 ' + n);
        write('1 1');
        write('2 ' + n);
    }
}

function start() {
    var T = 1;
    T = Number(read());
    for (var t = 0; t < T; t++) {
        solve();
    }
    writeAns();
}

function gcd(a, b) {
    if (b === 0) {
        return a;
    }
    return gcd(b, a % b)
}

var MEMORY;
var MEMORY_INDEX = 0;
var ANS = '';

try {
    initInput(start);
} catch (e) {
    console.log(e);
}
function readArray(f) {
    return read().split(' ').map(f);
}

function sortNumbers(a, b) {
    return a - b;
}
function sortNumbersDec(a, b) {
    return b - a;
}
var ANS;
// вывод через ANS быстрее, но ест кучу памяти.
// К тому же, максимальная длина строки - 2097151.
function write(value) {
    // console.log(value);
    ANS += value + '\n';
}
function writeAns() {
    if (ANS) {
        console.log(ANS);
    }
}
function read() {
    return MEMORY[MEMORY_INDEX++];
}
function initInput(callback) {
    var fs = require('fs');
    var isLocalStart = process.argv[2] === 'lorelvate';
    if (!isLocalStart) {
        MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
        callback();
        return;
    }
    var path = require('path');
    fs.readFile(path.join(__dirname, 'input.txt'), 'utf8', (err, data) => {
        if (err) {
            write(err);
            return;
        }
        MEMORY = data.split('\r\n');
        callback();
    });
}