Two players decided to play one interesting card game.There is a deck of $$$n$$$ cards, with values from $$$1$$$ to $$$n$$$. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between players such that each player has at least one card. The game goes as follows: on each turn, each player chooses one of their cards (whichever they want) and puts on the table, so that the other player doesn't see which card they chose. After that, both cards are revealed, and the player, value of whose card was larger, takes both cards in his hand. Note that as all cards have different values, one of the cards will be strictly larger than the other one. Every card may be played any amount of times. The player loses if he doesn't have any cards.For example, suppose that $$$n = 5$$$, the first player has cards with values $$$2$$$ and $$$3$$$, and the second player has cards with values $$$1$$$, $$$4$$$, $$$5$$$. Then one possible flow of the game is:The first player chooses the card $$$3$$$. The second player chooses the card $$$1$$$. As $$$3>1$$$, the first player gets both cards. Now the first player has cards $$$1$$$, $$$2$$$, $$$3$$$, the second player has cards $$$4$$$, $$$5$$$.The first player chooses the card $$$3$$$. The second player chooses the card $$$4$$$. As $$$3<4$$$, the second player gets both cards. Now the first player has cards $$$1$$$, $$$2$$$. The second player has cards $$$3$$$, $$$4$$$, $$$5$$$.The first player chooses the card $$$1$$$. The second player chooses the card $$$3$$$. As $$$1<3$$$, the second player gets both cards. Now the first player has only the card $$$2$$$. The second player has cards $$$1$$$, $$$3$$$, $$$4$$$, $$$5$$$.The first player chooses the card $$$2$$$. The second player chooses the card $$$4$$$. As $$$2<4$$$, the second player gets both cards. Now the first player is out of cards and loses. Therefore, the second player wins.Who will win if both players are playing optimally? It can be shown that one of the players has a winning strategy.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows. The first line of each test case contains three integers $$$n$$$, $$$k_1$$$, $$$k_2$$$ ($$$2 \le n \le 100, 1 \le k_1 \le n - 1, 1 \le k_2 \le n - 1, k_1 + k_2 = n$$$) — the number of cards, number of cards owned by the first player and second player correspondingly. The second line of each test case contains $$$k_1$$$ integers $$$a_1, \dots, a_{k_1}$$$ ($$$1 \le a_i \le n$$$) — the values of cards of the first player. The third line of each test case contains $$$k_2$$$ integers $$$b_1, \dots, b_{k_2}$$$ ($$$1 \le b_i \le n$$$) — the values of cards of the second player. It is guaranteed that the values of all cards are different.

For each test case, output "YES" in a separate line, if the first player wins. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

NoteIn the first test case of the example, there is only one possible move for every player: the first player will put $$$2$$$, the second player will put $$$1$$$. $$$2>1$$$, so the first player will get both cards and will win.In the second test case of the example, it can be shown that it is the second player who has a winning strategy. One possible flow of the game is illustrated in the statement.

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

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");

    }

}

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

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

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


One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n days. According to Martian laws, one can buy only an integer number of dollars. Which maximal sum of money in bourles can Vasya get by the end of day n?

The first line contains two integers n and b (1 ≤ n, b ≤ 2000) — the number of days and the initial number of money in bourles. The next line contains n integers ai (1 ≤ ai ≤ 2000) — the prices of Martian dollars.

Print the single number — which maximal sum of money in bourles can Vasya get by the end of day n.

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)


You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. You want to split it into exactly $$$k$$$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuffle) the elements of a given array. Each of the $$$n$$$ elements of the array $$$a$$$ must belong to exactly one of the $$$k$$$ subsegments.Let's see some examples of dividing the array of length $$$5$$$ into $$$3$$$ subsegments (not necessarily with odd sums): $$$[1, 2, 3, 4, 5]$$$ is the initial array, then all possible ways to divide it into $$$3$$$ non-empty non-intersecting subsegments are described below:  $$$[1], [2], [3, 4, 5]$$$;  $$$[1], [2, 3], [4, 5]$$$;  $$$[1], [2, 3, 4], [5]$$$;  $$$[1, 2], [3], [4, 5]$$$;  $$$[1, 2], [3, 4], [5]$$$;  $$$[1, 2, 3], [4], [5]$$$. Of course, it can be impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements. In this case print "NO". Otherwise, print "YES" and any possible division of the array. See the output format for the detailed explanation.You have to answer $$$q$$$ independent queries.

The first line contains one integer $$$q$$$ ($$$1 \le q \le 2 \cdot 10^5$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of subsegments, respectively. The second line of the query contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all queries does not exceed $$$2 \cdot 10^5$$$ ($$$\sum n \le 2 \cdot 10^5$$$).

For each query, print the answer to it. If it is impossible to divide the initial array into exactly $$$k$$$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The division can be represented as $$$k$$$ integers $$$r_1$$$, $$$r_2$$$, ..., $$$r_k$$$ such that $$$1 \le r_1 < r_2 < \dots < r_k = n$$$, where $$$r_j$$$ is the right border of the $$$j$$$-th segment (the index of the last element that belongs to the $$$j$$$-th segment), so the array is divided into subsegments $$$[1; r_1], [r_1 + 1; r_2], [r_2 + 1, r_3], \dots, [r_{k - 1} + 1, n]$$$. Note that $$$r_k$$$ is always $$$n$$$ but you should print it anyway.

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

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

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

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

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


Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.

The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively. The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.

Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.

NoteIn the first and the second samples, Arya will beat all present opponents each of the d days.In the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.

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


You are given two positive integers $$$a$$$ and $$$b$$$. In one move you can increase $$$a$$$ by $$$1$$$ (replace $$$a$$$ with $$$a+1$$$). Your task is to find the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$. It is possible, that you have to make $$$0$$$ moves, as $$$a$$$ is already divisible by $$$b$$$. You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).

For each test case print the answer — the minimum number of moves you need to do in order to make $$$a$$$ divisible by $$$b$$$.

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

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

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

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

'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);

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

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 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')
    }
}

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

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

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


Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.Artem wants to paint an $$$n \times m$$$ board. Each cell of the board should be colored in white or black. Lets $$$B$$$ be the number of black cells that have at least one white neighbor adjacent by the side. Let $$$W$$$ be the number of white cells that have at least one black neighbor adjacent by the side. A coloring is called good if $$$B = W + 1$$$. The first coloring shown below has $$$B=5$$$ and $$$W=4$$$ (all cells have at least one neighbor with the opposite color). However, the second coloring is not good as it has $$$B=4$$$, $$$W=4$$$ (only the bottom right cell doesn't have a neighbor with the opposite color).  Please, help Medina to find any good coloring. It's guaranteed that under given constraints the solution always exists. If there are several solutions, output any of them.

Each test contains multiple test cases.  The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 20$$$). Each of the next $$$t$$$ lines contains two integers $$$n, m$$$ ($$$2 \le n,m \le 100$$$) — the number of rows and the number of columns in the grid.

For each test case print $$$n$$$ lines, each of length $$$m$$$, where $$$i$$$-th line is the $$$i$$$-th row of your colored matrix (cell labeled with 'B' means that the cell is black, and 'W' means white). Do not use quotes. It's guaranteed that under given constraints the solution always exists.

NoteIn the first testcase, $$$B=3$$$, $$$W=2$$$.In the second testcase, $$$B=5$$$, $$$W=4$$$. You can see the coloring in the statement.

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

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

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

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

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