Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has $$$a$$$ sticks and $$$b$$$ diamonds?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^9$$$) — the number of sticks and the number of diamonds, respectively.

For each test case print one integer — the maximum number of emeralds Polycarp can earn.

NoteIn the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.In the second test case Polycarp does not have any diamonds, so he cannot craft anything.

"use strict";

//readline().split(' ').map(Number);

function sec(){
    var arr = readline().split(' ').map(Number);
    var ans = Math.min(arr[0],arr[1],parseInt((arr[0]+arr[1])/3));
    /*
    var ans = 0;
    while (arr[0]>0 && arr[1]>0){
        //print(arr[0]+' '+arr[1]);
        if(arr[0]>=arr[1]){
            ans += parseInt(arr[0]/2);
            arr[1] -= parseInt(arr[0]/2);
            arr[0] -= parseInt(arr[0]/2)*2;
        }
        else if(arr[0]<arr[1]){
            ans += parseInt(arr[1]/2);
            arr[0] -= parseInt(arr[1]/2);
            arr[1] -= parseInt(arr[1]/2)*2;
        }
    }*/
    print(ans);
}

function main(){
    var t = readline();
    while(t--){
        sec();
    }
}

main();

//↓見なくていいよ！ここから--------------------------------------------------
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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    var a = Math.min(one[0],one[1]);
    var b = Math.max(one[0],one[1]);
    if(a * 2 <= b){
      output[i] = a;
      continue;
    }
    var count = b - a;
    var tmp = b;
    b -= (tmp - a) * 2;
    a -= (tmp - a);
    //myerr({a,b});
    count += 2 * Math.floor(a / 3);
    var tmp = a;
    a -= Math.floor(tmp / 3) * 3;
    b -= Math.floor(tmp / 3) * 3;
    //myerr({a,b});
    if(a > 0 && b > 1){
      count++;
    }
    output[i] = count;
  }
  myout(myconv(output,9));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
  data = data.split('\n');
  const testCases = data[0] * 1;
  let i = 1;
  while (i <= testCases) {
    let int = data[i].split(' ');
    let s = int[0] * 1;
    let d = int[1] * 1;
    console.log(Math.min(s,d, Math.floor((s+d)/3)));
    i += 1;
  }
}

const data = [];

//const fs = require('fs');
//const inputStream = fs.createReadStream("./in.txt");
const inputStream = process.stdin;

class DoubleIter {
    constructor(iter) {
        this.iter = iter.values();
        this.current = this.iter.next();
        this.iterOfCurrent = this.current.value.values();
    }

    [Symbol.iterator]() {
        return {
            next: () => {
                let { value, done } = this.iterOfCurrent.next();
                if (!done) {
                    return {value, done}
                } else {
                    do {
                        this.current = this.iter.next();
                        if (this.current.done)
                            return { value: undefined, done: true };
                        this.iterOfCurrent = this.current.value.values();
                        ({ value, done } = this.iterOfCurrent.next());
                    } while (done);
                    return {value, done};
                }
            }
        }
    }
}

class Scanner {
    constructor(iterable) {
        this.iter = iterable[Symbol.iterator]();
    }

    getWord() {
        const res = [];
        let {value, done} = this.iter.next();
        while (!done && !this.isLetter(value))
            ({value, done} = this.iter.next());
        if (!done) {
            while (!done && this.isLetter(value)) {
                res.push(value);
                ({value, done} = this.iter.next());
            }
        }
        return String.fromCharCode(...res);
    }

    isLetter(char) {
        return (
            (48 <= char && char <= 57) || // 0-9
            (97 <= char && char <= 122) || // a-z
            (65 <= char && char <= 90) // A-Z
        );
    }
}

inputStream.on("data", (chunk) => {
    data.push(chunk);
});

inputStream.on("end", () => {
    start();
});

function start() {
    const scan = new Scanner(new DoubleIter(data));
    const t = +scan.getWord();
    for (let i = 0; i < t; i++) {
        let a = +scan.getWord();
        let b = +scan.getWord();
        //console.log(a, b);
        if (a > b) {
            const t = a;
            a = b;
            b = t;
        }
        const mid = (2*a - b) / 3;
        const x1 = Math.floor(mid);
        let res1 = ~~((x1 + b) / 2);
        const x2 = Math.ceil(mid);
        let res2 = a - x2;
        if (x1 < 0)
            res1 = 0;
        if (x2 < 0)
            res2 = a;
        const mx = Math.max(res1, res2);

        process.stdout.write(mx.toString() + '\n');
    }
    process.stdout.end()
}

function func(a, b, c) {
    a -= c;
    b -= c;
    return Math.min(c, Math.max(a, b));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
    stdinInput += input;

})

process.stdin.on('end', () => {
    main(stdinInput);
})

function main(data) {
    data = data.split("\n");
    let testCases = data[0] * 1;
    let i = 1;
    while (i <= testCases) {
        let line = data[i].split(" ");
        let stick = line[0] * 1;
        let diamonds = line[1] * 1;
        console.log(Math.min(stick, Math.min(diamonds, Math.floor((stick + diamonds) / 3))));
        i += 1;
    }
}

//↓見なくていいよ！ここから--------------------------------------------------
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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    one.sort(function(mae,ato){
    	return mae - ato;
    });
    var a = one[0];
    var b = one[1];
    if(a * 2 <= b){
      output[i] = a;
      continue;
    }
    var count = 2 * Math.floor(Math.min(a, b) / 3);
    var tmp = a;
    a -= Math.floor(tmp / 3) * 3;
    b -= Math.floor(tmp / 3) * 3;
    //myerr({a,b});
    if(a > 0 && b > 1){
      count++;
    }
    output[i] = count;
  }
  myout(myconv(output,9));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
  data = data.split('\n');
  const testCases = data[0] * 1;
  let i = 1;
  while (i <= testCases) {
    let int = data[i].split(' ');
    let s = int[0] * 1;
    let d = int[1] * 1;

    let e = 0;
    if (s === 0 || d === 0) {
      console.log(e);
    } else console.log(Math.floor((s + d) / 3));
    i += 1;
  }
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
  data = data.split('\n');
  const testCases = data[0] * 1;
  let i = 1;
  while (i <= testCases) {
    let int = data[i].split(' ');
    let s = int[0] * 1;
    let d = int[1] * 1;
    let e = 0;
    if (s === 0 || d === 0) {
      console.log(e);
    } else if (s === d) {
      while (s > 1) {
        s -= e % 2 ? 2 : 1;
        e += 1;
      }
      console.log(e);
    } else if (d > s) {
      e = Math.floor(d / 2);
      const diff = s - e;
      if (diff === 0 || diff === 1) console.log(e);
      else if (diff > 1) console.log(e + 1);
      else if (s % 2) console.log(s + 1);
      else console.log(s);
    } else {
      e = Math.floor(s / 2);
      const diff = d - e;
      if (diff === 0 || diff === 1) console.log(e);
      else if (diff > 1) console.log(e + 1);
      else if (d % 2) console.log(d + 1);
      else console.log(d);
    }
    i += 1;
  }
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
  data = data.split('\n');
  const testCases = data[0] * 1;
  let i = 1;
  while (i <= testCases) {
    let int = data[i].split(' ');
    let s = int[0] * 1;
    let d = int[1] * 1;
    let e = 0;
    if (s === 0 || d === 0) {
      console.log(e);
    } else if (s === d) {
      while (s > 1) {
        s -= e % 2 ? 2 : 1;
        e += 1;
      }
      console.log(e);
    } else if (d > s) {
      e = Math.floor(d / 2);
      const diff = s - e;
      if (diff === 0 || diff === 1) console.log(e);
      else console.log(e + 1);
    } else {
      e = Math.floor(s / 2);
      const diff = d - e;
      if (diff === 0 || diff === 1) console.log(e);
      else console.log(e + 1);
    }
    i += 1;
  }
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
  data = data.split('\n');
  const testCases = data[0] * 1;
  let i = 1;
  while (i <= testCases) {
    let int = data[i].split(' ');
    let s = int[0] * 1;
    let d = int[1] * 1;
    console.log(s,d, Math.floor((s+d)/3))
    i += 1;
  }
}

const data = [];

class DoubleIter {
    constructor(iter) {
        this.iter = iter.values();
        this.current = this.iter.next();
        this.iterOfCurrent = this.current.value.values();
    }

    [Symbol.iterator]() {
        return {
            next: () => {
                let { value, done } = this.iterOfCurrent.next();
                if (!done) {
                    return {value, done}
                } else {
                    do {
                        this.current = this.iter.next();
                        if (this.current.done)
                            return { value: undefined, done: true };
                        this.iterOfCurrent = this.current.value.values();
                        ({ value, done } = this.iterOfCurrent.next());
                    } while (done);
                    return {value, done};
                }
            }
        }
    }
}

class Scanner {
    constructor(iterable) {
        this.iter = iterable[Symbol.iterator]();
    }

    getWord() {
        const res = [];
        let {value, done} = this.iter.next();
        while (!done && !this.isLetter(value))
            ({value, done} = this.iter.next());
        if (!done) {
            while (!done && this.isLetter(value)) {
                res.push(value);
                ({value, done} = this.iter.next());
            }
        }
        return String.fromCharCode(...res);
    }

    isLetter(char) {
        return (
            (48 <= char && char <= 57) || // 0-9
            (97 <= char && char <= 122) || // a-z
            (65 <= char && char <= 90) // A-Z
        );
    }
}

process.stdin.on("data", (chunk) => {
    data.push(chunk);
});

process.stdin.on("end", () => {
    start();
});

function start() {
    const scan = new Scanner(new DoubleIter(data));
    const t = +scan.getWord();
    for (let i = 0; i < t; i++) {
        let a = +scan.getWord();
        let b = +scan.getWord();
        //console.log(a, b);
        if (a > b) {
            const t = a;
            a = b;
            b = t;
        }
        const mid = (2*a - b) / 3;
        const x1 = Math.floor(mid);
        let res1 = ~~((x1 + b) / 2);
        const x2 = Math.ceil(mid);
        let res2 = a - x2;
        if (x1 < 0)
            res1 = 0;
        if (x2 < 0)
            res2 = 0;
        const mx = Math.max(res1, res2);

        process.stdout.write(mx.toString() + '\n');
    }
    process.stdout.end()
}

function func(a, b, c) {
    a -= c;
    b -= c;
    return Math.min(c, Math.max(a, b));
}

const data = [];

class DoubleIter {
    constructor(iter) {
        this.iter = iter.values();
        this.current = this.iter.next();
        this.iterOfCurrent = this.current.value.values();
    }

    [Symbol.iterator]() {
        return {
            next: () => {
                let { value, done } = this.iterOfCurrent.next();
                if (!done) {
                    return {value, done}
                } else {
                    do {
                        this.current = this.iter.next();
                        if (this.current.done)
                            return { value: undefined, done: true };
                        this.iterOfCurrent = this.current.value.values();
                        ({ value, done } = this.iterOfCurrent.next());
                    } while (done);
                    return {value, done};
                }
            }
        }
    }
}

class Scanner {
    constructor(iterable) {
        this.iter = iterable[Symbol.iterator]();
    }

    getWord() {
        const res = [];
        let {value, done} = this.iter.next();
        while (!done && !this.isLetter(value))
            ({value, done} = this.iter.next());
        if (!done) {
            while (!done && this.isLetter(value)) {
                res.push(value);
                ({value, done} = this.iter.next());
            }
        }
        return String.fromCharCode(...res);
    }

    isLetter(char) {
        return (
            (48 <= char && char <= 57) || // 0-9
            (97 <= char && char <= 122) || // a-z
            (65 <= char && char <= 90) // A-Z
        );
    }
}

process.stdin.on("data", (chunk) => {
    data.push(chunk);
});

process.stdin.on("end", () => {
    start();
});

function start() {
    const scan = new Scanner(new DoubleIter(data));
    const t = +scan.getWord();
    for (let i = 0; i < t; i++) {
        let a = +scan.getWord();
        let b = +scan.getWord();
        //console.log(a, b);
        if (a > b) {
            const t = a;
            a = b;
            b = t;
        }
        const mid = (2*a - b) / 3;
        const x1 = Math.floor(mid);
        let res1 = ~~((x1 + b) / 2);
        const x2 = Math.ceil(mid);
        let res2 = 2 - x2;
        if (x1 < 0)
            res1 = 0;
        if (x2 < 0)
            res2 = 0;
        const mx = Math.max(res1, res2);

        process.stdout.write(mx.toString() + '\n');
    }
    process.stdout.end()
}

function func(a, b, c) {
    a -= c;
    b -= c;
    return Math.min(c, Math.max(a, b));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
    stdinInput += input;

})

process.stdin.on('end', () => {
    main(stdinInput);
})

function main(data) {
    data = data.split("\n");
    let testCases = data[0] * 1;
    let i = 1;
    while (i <= testCases) {
        let line = data[i].split(" ");
        let stick = line[0] * 1;
        let diamonds = line[0] * 1;
         console.log(Math.min(stick,Math.min(diamonds,Math.floor( (stick + diamonds) / 3))));
         i+=1;
    }
}

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

let stdinInput = '';

process.stdin.on('data', input => {
    stdinInput += input;

})

process.stdin.on('end', () => {
    main(stdinInput);
})

function main(data) {
    data = data.split("\n");
    let testCases = data[0] * 1;
    let i = 1;
    while (testCases--) {
        let line = data[i].split("\n");
        let stick = line[0] * 1;
        let diamonds = line[0] * 1;
        let polycrap = Math.min(stick, Math.floor(diamonds / 2));

        let stickTemp = polycrap - stick;
        let diamondsTemp = polycrap - Math.floor(diamonds / 2);
        let remains = Math.min(Math.floor(stickTemp / 2), diamondsTemp);
        let polyAnswer = remains + polycrap;

        let swords = Math.min(Math.floor(stick / 2), diamonds);
        diamondsTemp = swords - diamonds;
         stickTemp = swords - Math.floor(stick / 2);
         remains = Math.min(Math.floor(diamondsTemp / 2), stickTemp);
         let swordsAnswer  = remains + polycrap;
         console.log(Math.min(swordsAnswer,polyAnswer));
         i+=1;
    }
}

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

let stdinInput = '';

process.stdin.on('data', input => {
    stdinInput += input;

})

process.stdin.on('end', () => {
    main(stdinInput);
})

function main(data) {
    data = data.split("\n");
    let testCases = data[0] * 1;
    let i = 1;
    while (i <= testCases) {
        let line = data[i].split("\n");
        let stick = line[0] * 1;
        let diamonds = line[0] * 1;
         console.log(Math.min(stick,Math.min(diamonds,Math.floor( (stick + diamonds) / 3))));
         i+=1;
    }
}


For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three numbers:  $$$n_0$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$0$$$;  $$$n_1$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$1$$$;  $$$n_2$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$2$$$. For example, for the string $$$s=$$$"1110011110", the following substrings would be written: "11", "11", "10", "00", "01", "11", "11", "11", "10". Thus, $$$n_0=1$$$, $$$n_1=3$$$, $$$n_2=5$$$.Your task is to restore any suitable binary string $$$s$$$ from the given values $$$n_0, n_1, n_2$$$. It is guaranteed that at least one of the numbers $$$n_0, n_1, n_2$$$ is greater than $$$0$$$. Also, it is guaranteed that a solution exists.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 > 0$$$). It is guaranteed that the answer for given $$$n_0, n_1, n_2$$$ exists.

Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.

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

let inputString = '';
let currentLine = 0;

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

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

    F();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function F(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n0, n1, n2] = ti(readline().split(' '));
        let s = '';
        if(n2 !== 0){
            for(let i = 0; i <= n2; i++){
                s += '1';
            }
        }

        if(n0 !== 0){
            s += '0';
            for(let i = 0; i < n0; i++)
                s += '0';
        }

        if(n1 !== 0){
            let p = s.length !== 0 ? s[s.length-1] : '';
            if(n2 !== 0 && n0 !== 0)
                n1 -= 1;
            if(n0 === 0 && n2 === 0)
                n1 += 1;

            for(let i = 0; i < n1; i++){
                if(p === '0'){
                    s += '1';
                    p = '1';
                }else{
                    s += '0';
                    p = '0';
                }
            }
        }

        console.log(s);
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {

    let cases = parseInt(readline(), 10);
    for (var X = 0; X < cases; X++) {
      let [n0,n1,n2] = readline().split(" ").map(e => parseInt(e));
      //console.log({n1,n2,n3})

      let zz = [];
      for (var i = 0; i < n0; i++) {
        zz.push('00');
      }

      let ee = [];
      for (var i = 0; i < n2; i++) {
        ee.push('11');
      }

      let mid = [];
      for (var i = 0; i < n1; i++) {
        if (i % 2 == 0) {
          mid.unshift('10');
        } else {
          mid.unshift('01');
        }
      }

      // console.log({
      //   zz,
      //   mid,
      //   ee,
      // })

      let res = [...ee, ...mid, ...zz];
      if (n1 % 2 == 0 && n1 >= 2) {
        mid.splice(1, 0, ...ee)
        res = [...mid, ...zz];
      }

      //console.log(res);

      let output = "";
      for (var k = 0; k < res.length; k++) {
        if (k == 0) {
          output += res[k];
        } else {
          output += res[k][1];
        }
      }

      console.log(output);

      //break;

    }

}

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

let inputString = '';
let currentLine = 0;

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

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

    F();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function F(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n0, n1, n2] = ti(readline().split(' '));
        let s = '';
        if(n2 !== 0){
            for(let i = 0; i <= n2; i++){
                s += '1';
            }
        }

        if(n0 !== 0){
            s += '0';
            for(let i = 0; i < n0; i++)
                s += '0';

            let p = s[s.length-1];
            for(let i = 0; i < n1-1; i++){
                if(p === '0'){
                    s += '1';
                    p = '1';
                }
                else{
                    s += '0';
                    p = '0';
                }
            }
        }else{
            if(n1 !== 0){
                s += '0';
                let p = '0';
                for(let i = 0; i < n1-1; i++){
                    if(p === '0'){
                        s += '1';
                        p = '1';
                    }
                    else{
                        s += '0';
                        p = '0';
                    }
                }
            }
        }

        console.log(s);
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    F();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function F(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n0, n1, n2] = ti(readline().split(' '));
        let s = '1';
        for(let i = 0; i < n2; i++){
            s += '1';
        }

        if(n0 !== 0){
            s += '0';
            for(let i = 0; i < n0; i++)
                s += '0';

            let p = s[s.length-1];
            for(let i = 0; i < n1-1; i++){
                if(p === '0'){
                    s += '1';
                    p = '1';
                }
                else{
                    s += '0';
                    p = '0';
                }
            }
        }else{
            if(n1 !== 0){
                s += '0';
                let p = '0';
                for(let i = 0; i < n1-1; i++){
                    if(p === '0'){
                        s += '1';
                        p = '1';
                    }
                    else{
                        s += '0';
                        p = '0';
                    }
                }
            }
        }

        console.log(s);
    }
}


Recently Petya walked in the forest and found a magic stick.Since Petya really likes numbers, the first thing he learned was spells for changing numbers. So far, he knows only two spells that can be applied to a positive integer:   If the chosen number $$$a$$$ is even, then the spell will turn it into $$$\frac{3a}{2}$$$;  If the chosen number $$$a$$$ is greater than one, then the spell will turn it into $$$a-1$$$. Note that if the number is even and greater than one, then Petya can choose which spell to apply.Petya now has only one number $$$x$$$. He wants to know if his favorite number $$$y$$$ can be obtained from $$$x$$$ using the spells he knows. The spells can be used any number of times in any order. It is not required to use spells, Petya can leave $$$x$$$ as it is.

The first line contains single integer $$$T$$$ ($$$1 \le T \le 10^4$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, y \le 10^9$$$) — the current number and the number that Petya wants to get.

For the $$$i$$$-th test case print the answer on it — YES if Petya can get the number $$$y$$$ from the number $$$x$$$ using known spells, and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

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

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

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

  for(let i = 0; i < t; i++) {
    const arrT = arr[i].split(' ').map(a => parseInt(a))
    const x = arrT[0]
    const y = arrT[1]

    if(x >= y) console.log('YES')

    else {
      if(x == 2 && y == 3) console.log('YES')
      else if(x > 3) console.log('YES')
      else console.log('NO')
    }
  }
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// thats all what you have to write to get input from stdin, using readLine.

// Main code runs in main();

function main() {
    const n = +readline();

    for (let i = 0; i < n; i++) {
        let res = false;
        const [x, y] = readline().split(" ").map(t => parseInt(t));
        if (x > 3) res = true;
        else if (x === 1) {
            res = y === 1 ? true : false;
        } else res = y < 4;
        console.log(res ? "YES" : "NO");
    }
}

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

function magic(a,b){
    while (a!=b){
        if(a>b){
            console.log("YES");
            return;
        }else{
            if(a%2==1){
                if(a!=(a-1)*3/2 && (a-1)*3/2!=0){
                    --a;
                }else{
                    console.log("NO");
                    return;
                }
            }else{
                a=a*3/2;
            }
        }
    }
    console.log("YES");
}

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0);
const inputString = stdinBuffer.toString();

const [count, ...data] = inputString.split('\n');

data.length = Math.min(parseInt(count, 10), data.length);

function find(dataString) {
  const [current, desired] = dataString.split(' ').map(x => { return parseInt(x, 10) });

  if (current === desired) return 'yes';
  if (current === 2 && desired <= 3) return 'yes';
  if (current === 3 && desired < 3) return 'yes';
  if (current >= 4) return 'yes';

  return 'no';
}
process.stdout.write(`${data.map(find).join('\n')}`);

var count = Number(readline());
for(var i=0; i<count; i++){
    var args = readline().split(" ");
    var x = Number(args[0]);
    var y = Number(args[1]);
    print(
        ((y==1)||(x>3)||(y<=x)||((x==2)&&(y==3)))
        ? "YES" : "NO");
}

// var num = readline().split(" ").map(x => parseInt(x)); // num will be an array [1,2,3]
// var x = num[0]; // to store values in different variables.
// var y= num[1];
// var z= num[2];

// var num2= readline(); // reads next line.

// print(num2)

// let input = document.querySelector('.input pre').textContent.split('\n')

// const readline = () => input.shift()

// const print = console.log

// begin solution

const solution = (x, y) => 3 < x || y <= x || x === 2 && y === 3

const uglySolution = (x, y) => solution(x, y) ? 'yes' : 'no'

// boilerplate

const inputCount = readline()

for (var i = 0; i < inputCount; i++) {
    print(uglySolution.apply(this, (readline().split(' ').map(Number))))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// thats all what you have to write to get input from stdin, using readLine.

// Main code runs in main();

function main() {
    const n = +readline();
    let res = false;
    for (let i = 0; i < n; i++) {
        const [x, y] = readline().split(" ").map(t => parseInt(t));
        if (x > 3) res = true;
        else if (x === 1) {
            res = y === 1 ? true : false;
        } else res = y < 4;
    }
    console.log(res ? "YES" : "NO");
}

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0);
const inputString = stdinBuffer.toString();

const [count, ...data] = inputString.split('\n');

data.length = Math.min(parseInt(count, 10), data.length);

function find(dataString) {
  const [current, desired] = dataString.split(' ').map(x => { return parseInt(x, 10) });

  if (current === desired) return 'yes';
  if (current === 2 && desired === 3) return 'yes';
  if (current === 3 && desired < 3) return 'yes';
  if (current >= 4) return 'yes';

  return 'no';
}

process.stdout.write(`${data.map(find).join('\n')}`);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0);
const inputString = stdinBuffer.toString();

const [count, ...data] = inputString.split('\n');

data.length = parseInt(count, 10);

function find(dataString) {
  const [current, desired] = dataString.split(' ').map(x => { return parseInt(x, 10) });

  if (current === desired) return 'yes';
  if (current === 2 && desired === 3) return 'yes';
  if (current === 3 && desired < 3) return 'yes';
  if (current >= 4) return 'yes';

  return 'no';
}

process.stdout.write(`${data.map(find).join('\n')}`);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0);
const inputString = stdinBuffer.toString();

const [count, ...data] = inputString.split('\n');

data.length = parseInt(count, 10);

function find(dataString) {
  const [current, desired] = dataString.split(' ').map(x => { return parseInt(x, 10) });

  if (current === desired) return 'yes';

  if (current > desired && current > 1) return 'yes';

  if (desired > current && current % 2 === 0) return 'yes';

  return 'no';
}

process.stdout.write(`${data.map(find).join('\n')}`);

n=readline();
while(n--) {
    var x= readline().split(' ')
    if (x[0]==x[1]) {
        print('YES');
        continue;
    }
    if ((x[0]==2||x[0]==3) && x[1]>3) print('NO');
    else print('YES');
}

// var num = readline().split(" ").map(x => parseInt(x)); // num will be an array [1,2,3]
// var x = num[0]; // to store values in different variables.
// var y= num[1];
// var z= num[2];

// var num2= readline(); // reads next line.

// print(num2)

// let input = document.querySelector('.input pre').textContent.split('\n')

// const readline = () => input.shift()

// const print = console.log

// begin solution

const solution = (x, y) => 3 < x || y <= x || x === 2 && y === 3

const uglySolution = (x, y) => solution(x, y) ? 'yes' : 'no'

// boilerplate

// const inputCount = readline()

// for (let i = 0; i < inputCount; i++) {
//     print(uglySolution.apply(this, (readline().split(' ').map(Number))))
// }

const num = readline().split(" ").map(x => parseInt(x)); // num will be an array [1,2,3]
var x = num[0]; // to store values in different variables.
var y= num[1];
var z= num[2];

var num2= readline(); // reads next line.

print(num2)

// const solution = (x, y) => 3 < x || y <= x || x === 2 && y === 3

// const uglySolution = (x, y) => solution(x, y) ? 'yes' : 'no'

// // boilerplate

// const inputCount = readline()

// for (let i = 0; i < inputCount; i++) {
//     print(solution(...(readline().split(' ').map(Number))))
// }

// var num = readline().split(" ").map(x => parseInt(x)); // num will be an array [1,2,3]
// var x = num[0]; // to store values in different variables.
// var y= num[1];
// var z= num[2];

// var num2= readline(); // reads next line.

// print(num2)

// let input = document.querySelector('.input pre').textContent.split('\n')

// const readline = () => input.shift()

// const print = console.log

// begin solution

const solution = (x, y) => 3 < x || y <= x || x === 2 && y === 3

const uglySolution = (x, y) => solution(x, y) ? 'yes' : 'no'

// boilerplate

const inputCount = readline()

// for (let i = 0; i < inputCount; i++) {
//     print(uglySolution.apply(this, (readline().split(' ').map(Number))))
// }

var num = readline().split(" ").map(x => parseInt(x)); // num will be an array [1,2,3]
var x = num[0]; // to store values in different variables.
var y= num[1];
var z= num[2];

var num2= readline(); // reads next line.

print(num2)

// const solution = (x, y) => 3 < x || y <= x || x === 2 && y === 3

// const uglySolution = (x, y) => solution(x, y) ? 'yes' : 'no'

// // boilerplate

// const inputCount = readline()

// for (let i = 0; i < inputCount; i++) {
//     print(solution(...(readline().split(' ').map(Number))))
// }


InteractionThis is an interactive problem. You need to read participants' queries from standard input and print your responses to standard output. You don't know the number of queries upfront, so you'll need to process them as you get them; you'll know you're done once you reach the end of the file.In each query, you will be asked the question, written in one line. You have to answer it correctly, patiently and without any display of emotions. Your response is case-insensitive.Please make sure to use the stream flushing operation after each response in order not to leave part of your output in some buffer.ExampleInput
Is it rated?
Is it rated?
Is it rated?
Output
NO
NO
NO

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

process.stdin.on('data', (inputStdin) => {
  console.log('NO')
})

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 747:
/***/ ((module) => {

module.exports = require("fs");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {

// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(747);
;// CONCATENATED MODULE: external "readline"
const external_readline_namespaceObject = require("readline");;
var external_readline_default = /*#__PURE__*/__webpack_require__.n(external_readline_namespaceObject);
;// CONCATENATED MODULE: ./src/lib/io.ts

class InteractiveIO {
  constructor() {
    this.rl = void 0;
    this.lines = [];
    this.rl = external_readline_default().createInterface({
      input: process.stdin,
      output: process.stdout
    });
    this.rl.on('line', line => {
      this.lines.push(line);
    });
  }

  nextLine() {
    return new Promise(resolve => {
      if (this.lines.length) {
        resolve(this.lines.shift());
        return;
      }

      let waitId = null;
      let timeoutId = null;
      waitId = setInterval(() => {
        if (this.lines.length) {
          resolve(this.lines.shift());
          clearTimeout(timeoutId);
          clearInterval(waitId);
          return;
        }
      }, 1);
      timeoutId = setTimeout(() => {
        clearInterval(waitId);
        resolve(null);
      }, 500);
    });
  }

  close() {
    this.rl.close();
  }

}
class IO {
  constructor() {
    this.i = 0;
    this.text = '';
    this.out = '';
    this.readInput();
  }

  readInput() {
    this.text = __webpack_require__(747).readFileSync(0, 'utf8');
  }

  nextToken() {
    let ret = '';

    while (this.text[this.i].charCodeAt(0) <= 32) {
      this.i++;
    }

    while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
      ret += this.text[this.i];
      this.i++;
    }

    return ret;
  }

  nextNum() {
    return Number(this.nextToken());
  }

  nextBigInt() {
    return BigInt(this.nextToken());
  }

  nextNumArray(n) {
    let ret = [];

    while (n--) {
      ret.push(this.nextNum());
    }

    return ret;
  }

  _write(x) {
    this.out += x;
  }

  write(x) {
    this._write(x + ' ');
  }

  writeLine(x) {
    this._write(x + '\n');
  }

  flush() {
    fs.writeFileSync(1, this.out);
    this.out = '';
  }

}
;// CONCATENATED MODULE: ./src/cf-1505/1505-a.ts

const io = new InteractiveIO();

async function solve() {
  while (true) {
    let str = await io.nextLine();

    if (!str) {
      return;
    }

    console.log('NO');
  }
}

async function main() {
  try {
    await solve();
  } catch (e) {
    console.log(e.stack);
  }

  io.close();
}

main();

})();

/******/ })()
;

let inputs = '';
process.stdin.on('data', c => process.stdout.write("NO\n"));

const readline = require('readline');

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

const g = main();
g.next()
rl.on('line', (input) => {
    // console.log('read', input)
    input.split('\n').forEach(s => s.trim() && g.next(s))
});

function* main() {
    let input

    // input = yield 1
    const t = 1//+input
    for (let i = 0; i < t;) {
        input = yield 1
        console.log('NO')
    }
    // process.exit(0)
}

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

readline.on('line', line => {
    if (line == 'Is it rated?') {
        console.log("NO")
    }
});

    console.log('NO')
    console.log('NO')
    console.log('NO')

// JavaScript V8 4.8.0
while (readline()) {
  print('NO')
}

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 747:
/***/ ((module) => {

module.exports = require("fs");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {

// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(747);
;// CONCATENATED MODULE: external "readline"
const external_readline_namespaceObject = require("readline");;
var external_readline_default = /*#__PURE__*/__webpack_require__.n(external_readline_namespaceObject);
;// CONCATENATED MODULE: ./src/lib/io.ts

class InteractiveIO {
  constructor() {
    this.rl = void 0;
    this.lines = [];
    this.rl = external_readline_default().createInterface({
      input: process.stdin,
      output: process.stdout
    });
    this.rl.on('line', line => {
      this.lines.push(line);
    });
  }

  nextLine() {
    return new Promise(resolve => {
      if (this.lines.length) {
        resolve(this.lines.shift());
        return;
      }

      let waitId = null;
      let timeoutId = null;
      waitId = setInterval(() => {
        if (this.lines.length) {
          resolve(this.lines.shift());
          clearTimeout(timeoutId);
          clearInterval(waitId);
          return;
        }
      }, 1);
      timeoutId = setTimeout(() => {
        clearInterval(waitId);
        resolve(null);
      }, 500);
    });
  }

  close() {
    this.rl.close();
  }

}
class IO {
  constructor() {
    this.i = 0;
    this.text = '';
    this.out = '';
    this.readInput();
  }

  readInput() {
    this.text = __webpack_require__(747).readFileSync(0, 'utf8');
  }

  nextToken() {
    let ret = '';

    while (this.text[this.i].charCodeAt(0) <= 32) {
      this.i++;
    }

    while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
      ret += this.text[this.i];
      this.i++;
    }

    return ret;
  }

  nextNum() {
    return Number(this.nextToken());
  }

  nextBigInt() {
    return BigInt(this.nextToken());
  }

  nextNumArray(n) {
    let ret = [];

    while (n--) {
      ret.push(this.nextNum());
    }

    return ret;
  }

  _write(x) {
    this.out += x;
  }

  write(x) {
    this._write(x + ' ');
  }

  writeLine(x) {
    this._write(x + '\n');
  }

  flush() {
    fs.writeFileSync(1, this.out);
    this.out = '';
  }

}
;// CONCATENATED MODULE: ./src/cf-1505/1505-a.ts

const io = new InteractiveIO();

async function solve() {
  while (true) {
    let str = await io.nextLine();

    if (!str) {
      return;
    }

    console.log('NO');
  }
}

async function main() {
  try {
    solve();
  } catch (e) {
    console.log(e.stack);
  }

  io.close();
}

main();

})();

/******/ })()
;

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 747:
/***/ ((module) => {

module.exports = require("fs");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {

// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(747);
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
;// CONCATENATED MODULE: ./src/lib/io.ts

class IO {
  constructor() {
    this.i = 0;
    this.text = '';
    this.out = '';
    this.readInput();
  }

  readInput() {
    this.text = __webpack_require__(747).readFileSync(0, 'utf8');
  }

  nextToken() {
    let ret = '';

    while (this.text[this.i].charCodeAt(0) <= 32) {
      this.i++;
    }

    while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
      ret += this.text[this.i];
      this.i++;
    }

    return ret;
  }

  nextNum() {
    return Number(this.nextToken());
  }

  nextBigInt() {
    return BigInt(this.nextToken());
  }

  nextNumArray(n) {
    let ret = [];

    while (n--) {
      ret.push(this.nextNum());
    }

    return ret;
  }

  _write(x) {
    this.out += x;
  }

  write(x) {
    this._write(x + ' ');
  }

  writeLine(x) {
    this._write(x + '\n');
  }

  flush() {
    external_fs_default().writeFileSync(1, this.out);
    this.out = '';
  }

}
;// CONCATENATED MODULE: ./src/cf-1505/1505-a.ts

const io = new IO();

function solve() {
  while (true) {
    let str = io.nextToken();

    if (!str) {
      return;
    }

    io.writeLine('NO');
    io.flush();
  }
}

function main() {
  try {
    solve();
    io.flush();
  } catch (e) {
    console.log(e.stack);
  }
}

main();

})();

/******/ })()
;


You like the card board game "Set". Each card contains $$$k$$$ features, each of which is equal to a value from the set $$$\{0, 1, 2\}$$$. The deck contains all possible variants of cards, that is, there are $$$3^k$$$ different cards in total.A feature for three cards is called good if it is the same for these cards or pairwise distinct. Three cards are called a set if all $$$k$$$ features are good for them.For example, the cards $$$(0, 0, 0)$$$, $$$(0, 2, 1)$$$, and $$$(0, 1, 2)$$$ form a set, but the cards $$$(0, 2, 2)$$$, $$$(2, 1, 2)$$$, and $$$(1, 2, 0)$$$ do not, as, for example, the last feature is not good.A group of five cards is called a meta-set, if there is strictly more than one set among them. How many meta-sets there are among given $$$n$$$ distinct cards?

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^3$$$, $$$1 \le k \le 20$$$) — the number of cards on a table and the number of card features. The description of the cards follows in the next $$$n$$$ lines. Each line describing a card contains $$$k$$$ integers $$$c_{i, 1}, c_{i, 2}, \ldots, c_{i, k}$$$ ($$$0 \le c_{i, j} \le 2$$$) — card features. It is guaranteed that all cards are distinct.

Output one integer — the number of meta-sets.

NoteLet's draw the cards indicating the first four features. The first feature will indicate the number of objects on a card: $$$1$$$, $$$2$$$, $$$3$$$. The second one is the color: red, green, purple. The third is the shape: oval, diamond, squiggle. The fourth is filling: open, striped, solid.You can see the first three tests below. For the first two tests, the meta-sets are highlighted.In the first test, the only meta-set is the five cards $$$(0000,\ 0001,\ 0002,\ 0010,\ 0020)$$$. The sets in it are the triples $$$(0000,\ 0001,\ 0002)$$$ and $$$(0000,\ 0010,\ 0020)$$$. Also, a set is the triple $$$(0100,\ 1000,\ 2200)$$$ which does not belong to any meta-set.   In the second test, the following groups of five cards are meta-sets: $$$(0000,\ 0001,\ 0002,\ 0010,\ 0020)$$$, $$$(0000,\ 0001,\ 0002,\ 0100,\ 0200)$$$, $$$(0000,\ 0010,\ 0020,\ 0100,\ 0200)$$$.   In there third test, there are $$$54$$$ meta-sets.

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        m = rn(),
        a = Array.from({
    length: n
  }, () => new Array(m)),
        b = new Array(n).fill(0),
        cnt = new Map();
  for (let i = 0; i < n; i++) {
    var _cnt$get;
    for (let j = 0; j < m; j++) {
      a[i][j] = rn();
      b[i] = b[i] * 3 + a[i][j];
    }
    cnt.set(b[i], ((_cnt$get = cnt.get(b[i])) !== null && _cnt$get !== void 0 ? _cnt$get : 0) + 1);
  }
  let res = 0;
  for (let i = 0; i < n; i++) {
    let ans = 0;
    for (let j = 0; j < n; j++) {
      var _cnt$get2;
      if (i === j) continue;
      let num = 0;
      for (let k = 0; k < m; k++) {
        if (a[i][k] === a[j][k]) {
          num = num * 3 + a[i][k];
        } else {
          num = num * 3 + (3 - a[i][k] - a[j][k]);
        }
      }
      let tmp = (_cnt$get2 = cnt.get(num)) !== null && _cnt$get2 !== void 0 ? _cnt$get2 : 0;
      if (num === b[i]) tmp--;
      if (num === b[j]) tmp--;
      ans += tmp;
    }
    ans /= 2;
    res += ans * (ans - 1) / 2;
  }
  return res;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    let limit = 100;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      }
    }
    if (t >= limit) ; else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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


In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's birthday, and her mother decided to spend no more than m bourles on the gift to the daughter. Tanya will choose several different types of toys from the new collection as a gift. Of course, she does not want to get a type of toy which she already has.Tanya wants to have as many distinct types of toys in her collection as possible as the result. The new collection is too diverse, and Tanya is too little, so she asks you to help her in this.

The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys. The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya already has.

In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m. In the second line print k distinct space-separated integers t1, t2, ..., tk (1 ≤ ti ≤ 109) — the types of toys that Tanya should choose. If there are multiple answers, you may print any of them. Values of ti can be printed in any order.

NoteIn the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.

function sortNumber(a,b) {
    return a - b;
}

var input = readline().split(' ')
  , n = +input[0]
  , m = +input[1]
  , types = readline().split(' ').map( Number ).sort(sortNumber);
  // 4 14
  // 4 6 12 8
// console.log(types);
// console.log(Math.pow(10, 9));
for (var i = 1, sum = 0, curr = types.shift(), result = []; i < Math.pow(10, 9); i++) {
  if ((sum + i) > m) {
      break;
  };
  if (i === curr) {
    curr = types.shift();
    continue;
  } else {
    //console.log(i);
    result.push(i);
    sum += i;
  }
}
print(result.length);
print(result.join(' '));
//console.log(result);
//console.log(i);
//alert('asdas');

var arr = readline().split(" ", 2).map(Number);
var n = arr[0], m = arr[1];

function getSum(x) {
    return (x + 1) * x / 2;
}
var beg = 1, end = 5e4, mid;
while(true) {
    if (getSum(end) <= m) {
        break;
    }
    mid = Math.ceil((beg + end) / 2);
    if (getSum(mid) <= m) {
        beg = mid;
    } else {
        end = mid - 1;
    }
}
var buy = end, money = m - getSum(buy), over = 0;

var array = readline().split(" ", n).map(Number);
array.sort(function(a, b) {return a - b;});
for (var i = 0; i < n; ++i) {
    if (array[i] <= buy) {
        ++over;
        money += array[i];
        if (money >= buy + 1) {
            ++buy;
            money -= buy;
        }
    } else {
        break;
    }
}

function range(array, num) {
    var result = "", beg, end;
    if (num === 0) {
        beg = 1;
    } else {
        beg = array[num - 1] + 1;
    }
    end = array[num];
    for (var i = beg; i < end; ++i) {
        result += i + " ";
    }
    return result;
}
var answer = "";
print(buy - over);
for (var i = 0; i < over; ++i) {
    answer += range(array, i);
}
for (var i = (over === 0 ? 1 : array[over - 1] + 1); i <= buy; ++i) {
    answer += i  + " ";
}
print(answer);

var arr = readline().split(" ", 2).map(Number);
var n = arr[0], m = arr[1];

function getSum(x) {
    return (x + 1) * x / 2;
}
var beg = 1, end = 5e4, mid;
while(true) {
    if (getSum(end) <= m) {
        break;
    }
    mid = Math.ceil((beg + end) / 2);
    if (getSum(mid) <= m) {
        beg = mid;
    } else {
        end = mid - 1;
    }
}
var buy = end, money = m - getSum(buy), over = 0;

var array = readline().split(" ", n).map(Number);
array.sort(function(a, b) {return a - b;});
for (var i = 0; i < n; ++i) {
    if (array[i] <= buy) {
        ++over;
        money += array[i];
        if (money >= buy + 1) {
            ++buy;
            money -= buy;
        }
    } else {
        break;
    }
}

function range(array, num) {
    var result = "", beg, end;
    if (num === 0) {
        beg = 1;
    } else {
        beg = array[num - 1] + 1;
    }
    end = array[num];
    for (var i = beg; i < end; ++i) {
        result += i + " ";
    }
    return result;
}
var answer = "";
print(buy - over);
for (var i = 0; i < over; ++i) {
    answer += range(array, i);
}
for (var i = array[over - 1] + 1; i <= buy; ++i) {
    answer += i  + " ";
}
print(answer);


Paprika loves permutations. She has an array $$$a_1, a_2, \dots, a_n$$$. She wants to make the array a permutation of integers $$$1$$$ to $$$n$$$.In order to achieve this goal, she can perform operations on the array. In each operation she can choose two integers $$$i$$$ ($$$1 \le i \le n$$$) and $$$x$$$ ($$$x > 0$$$), then perform $$$a_i := a_i \bmod x$$$ (that is, replace $$$a_i$$$ by the remainder of $$$a_i$$$ divided by $$$x$$$). In different operations, the chosen $$$i$$$ and $$$x$$$ can be different.Determine the minimum number of operations needed to make the array a permutation of integers $$$1$$$ to $$$n$$$. If it is impossible, output $$$-1$$$.A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. ($$$1 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output the minimum number of operations needed to make the array a permutation of integers $$$1$$$ to $$$n$$$, or $$$-1$$$ if it is impossible.

NoteFor the first test, the only possible sequence of operations which minimizes the number of operations is:   Choose $$$i=2$$$, $$$x=5$$$. Perform $$$a_2 := a_2 \bmod 5 = 2$$$. For the second test, it is impossible to obtain a permutation of integers from $$$1$$$ to $$$n$$$.

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

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

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

		const rem = [];
		const seq = new Set();
		for (let i = 1; i <= n; i++) seq.add(i);

		for (let i = 0; i < n; i++) {
			if (seq.has(a[i]))
				seq.delete(a[i]);
			else
				rem.push(a[i]);
		}

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

		let ok = true, it = seq.values();
		for (let i = 0; ok && i < rem.length; i++) {
			ok = rem[i] > 2*it.next().value;
		}

		console.log(ok ? rem.length : -1);
	}
}

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

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

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

		let avl = new Set(a);
		let used = new Set();

		let rem = [];
		let seq = [];

		for (let x = 1; x <= n; x++) {
			if (avl.has(x)) {
				used.add(x);
			} else {
				seq.push(x);
			}
		}

		for (let i = 0; i < n; i++) {
			if (used.has(a[i])) {
				used.delete(a[i]);
			} else {
				rem.push(a[i]);
			}
		}

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

		let ok = true;
		for (let i = 0; ok && i < rem.length; i++) {
			ok = rem[i] > 2*seq[i];
		}

		console.log(ok ? rem.length : -1);
	}
}

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

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

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

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

		let ans = n;
		const done = Array(n+1);
		const used = Array(n+1);
		for (let i = 0; i < n; i++) {
			if (a[i] <= n && !done[a[i]]) {
				done[a[i]] = true;
				used[i] = true;
				ans--;
			}
		}

		let ok = true;
		for (let i = 0, x = 1; ok && i < n; i++) {
			while (x <= n && done[x]) x++;
			if (!used[i]) {
				if (a[i] > 2*x) {
					x++;
				} else {
					ok = false;
				}
			}
		}

		console.log(ok ? ans : -1);
	}
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let narr = [],
      obj = {};
    for (let i = 0; i < n; i++) {
      if (arr[i] > n) narr.push(arr[i]);
      else if (obj[arr[i]] === undefined) obj[arr[i]] = 1;
      else narr.push(arr[i]);
    }
    narr.sort((a, b) => a - b);
    const helper = (arr) => {
      let ans = 0,
        k = 0;
      for (let i = 0; i < n; i++) {
        if (obj[i + 1] === 1) continue;
        else {
          if (arr[k++] > 2 * (i + 1)) ans++;
          else return -1;
        }
      }
      return ans;
    };
    console.log(helper(narr));
  }
};
solve();

/* Common Template Starts */
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/* Common Template Ends */

minOperationToConvertToPermutation = (nums, n)=>{

    nums.sort((a,b)=>a-b);

    let set = new Set();
    let j = 1;
    let count = 0;
    for(let i =0; i < n; ++i){
        if(nums[i] <= n){
            if(!set.has(nums[i])){
                set.add(nums[i])
                continue;
            }
        }

        while(set.has(j)){
            j++;
        }
        if(nums[i] % (nums[i]-j) === j){
            set.add(j);
            count++;

        }
        else{
            console.log(-1);
            // console.log(set, nums[i], j)
            return;
        }

    }
    console.log(count);
}
function main() {
    //take input according to the format;
    const t = +(readline());
    for(let i =0; i<t; ++i){
        const n = +(readline());
        const nums = readline().split(' ').map(el=>parseInt(el));
        minOperationToConvertToPermutation(nums, n);
    }
}

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

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

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

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

		let ans = n;
		const done = Array(n+1);
		const used = Array(n+1);
		for (let i = 0; i < n; i++) {
			if (a[i] <= n && !done[a[i]]) {
				done[a[i]] = true;
				used[i] = true;
				ans--;
			}
		}

		let ok = true;
		for (let i = 0, x = 1; ok && i < n; i++) {
			while (x <= n && !done[x]) x++;
			if (!used[i]) {
				if (a[i] > 2*x) {
					x++;
				} else {
					ok = false;
				}
			}
		}

		console.log(ok ? ans : -1);
	}
}

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

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

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

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

		let ans = n;
		const b = new Set(a);
		for (let i = 1; i <= n; i++) {
			if (b.has(i)) ans--;
		}

		let ok = true;
		for (let i = 0; ok && i < n; i++) {
			if (a[i] == i+1 || a[i] > 2*(i+1))
				;
			else
				ok = false;
		}

		console.log(ok ? ans : -1);
	}
}

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

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

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

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

		let ans = 0, ok = true;
		for (let i = 0; ok && i < n; i++) {
			if (a[i] == i+1 || i+1 <= a[i] - Math.ceil((a[i]+1)/2))
				;
			else
				ok = false;
			ans += a[i] != i + 1;
		}

		console.log(ok ? ans : -1);
	}
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    arr.sort((a, b) => a - b);
    const helper = () => {
      let ans = 0;
      for (let i = 0; i < n; i++) {
        if (arr[i] === i + 1) continue;
        else if (arr[i] > 2 * (i + 1)) ans++;
        else return -1;
      }
      return ans;
    };
    console.log(helper());
  }
};
solve();


For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $$$n$$$ days of summer. On the $$$i$$$-th day, $$$a_i$$$ millimeters of rain will fall. All values $$$a_i$$$ are distinct.The mayor knows that citizens will watch the weather $$$x$$$ days before the celebration and $$$y$$$ days after. Because of that, he says that a day $$$d$$$ is not-so-rainy if $$$a_d$$$ is smaller than rain amounts at each of $$$x$$$ days before day $$$d$$$ and and each of $$$y$$$ days after day $$$d$$$. In other words, $$$a_d < a_j$$$ should hold for all $$$d - x \le j < d$$$ and $$$d < j \le d + y$$$. Citizens only watch the weather during summer, so we only consider such $$$j$$$ that $$$1 \le j \le n$$$.Help mayor find the earliest not-so-rainy day of summer.

The first line contains three integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 100\,000$$$, $$$0 \le x, y \le 7$$$) — the number of days in summer, the number of days citizens watch the weather before the celebration and the number of days they do that after. The second line contains $$$n$$$ distinct integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ denotes the rain amount on the $$$i$$$-th day.

Print a single integer — the index of the earliest not-so-rainy day of summer. We can show that the answer always exists.

NoteIn the first example days $$$3$$$ and $$$8$$$ are not-so-rainy. The $$$3$$$-rd day is earlier.In the second example day $$$3$$$ is not not-so-rainy, because $$$3 + y = 6$$$ and $$$a_3 > a_6$$$. Thus, day $$$8$$$ is the answer. Note that $$$8 + y = 11$$$, but we don't consider day $$$11$$$, because it is not summer.

const processData = (lines) => {
  const [conditions, data] = lines
  const [n, x, y] = conditions.split(' ').map(x => +x)
  const realData = data.split(' ').map(x => +x)
  const max = Math.pow(10, 10)
  for (let i=0; i<realData.length; i++) {
    const leftMin = realData.slice(i-x > 0 ? i-x: 0, i).reduce((r,x) => r < x ? r : x, max)
    const rightMin = realData.slice(i+1, i+1+y).reduce((r,x) => r < x ? r : x, max)
    if (realData[i] < leftMin && realData[i] < rightMin)
      return void console.log(i+1)
  }
}

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 lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main()
})

function main() {
  const [ n, x, y ] = lines[0].split(/\s/).map(Number)
  const a = lines[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const leftMin = Math.min.apply(null, a.slice(i - x > 0 ? i - x : 0, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, i + y + 1))

    if(ai < leftMin && ai < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

const processData = () => {
  const [ n, x, y ] = lines[0].split(/\s/).map(Number)
  const a = lines[1].split(/\s/).map(Number)
  const max = Math.pow(10, 10)
  let result = 0

  a.some((ai, i) => {
    const leftMin = Math.min.apply(null, a.slice(i - x > 0 ? i - x : 0, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, i + 1 + y))

    if(a[i] < leftMin && a[i] < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  processData()
})

var numbers = readline().split(" ").map(function (x){return parseInt(x)});
var days = readline().split(" ").map(function (el){return parseInt(el)});
var x = numbers[1];
var y = numbers[2];
var n = numbers[0];
var min = Number.MAX_VALUE;
var streak=0;
function look(k, val){
  for (var j = k+1; j <= k+y ; j++) {
    if (val>days[j]) {
      return false
    }
  }
  return true
}
for (var i = 0; i < days.length; i++) {
  if (days[i]<min){
    min = days[i];
  }
    if  (look(i, days[i])){
        write(i+1)
        break;
    }

}

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

if(nxy[0] > 1) {
  for(var i = 0; i < nxy[0]; i++) {
    var first = i - nxy[1];
    var last = i + nxy[2] + 1;
    var ans = Math.min(...arr.slice(first > 0 ? first : 0, last));
    if(ans === arr[i]) {
      print(i + 1);
      break;
    }
  }
} else {
  print(1);
}

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

var main = function() {"use strict";
    // TODO
    var input = rdArN();
    var n = input[0];
    var x = input[1];
    var y = input[2];
    var A = [null].concat(rdArN());

    for (var d = 1; d <= n; ++d) {
        var minL = +Infinity;
        for (var l = d-x; l <= d - 1; ++l) {
            minL = Math.min(minL, A[l] || +Infinity);
        }
        var minR = +Infinity;
        for (var r = d + 1; r <= d + y; ++r) {
            minR = Math.min(minR, A[r] || +Infinity);
        }
        var cur = A[d];
        if (cur < minL && cur < minR) {
            wr(d);
            break;
        }
    }

    /*var SL = new Set();
    var j = x + 1;
    for (var i = 1; i < j; ++i) {
        SL.add(A[i]);
    }
    var SR = new Set();
    for (var i = j + 1; i <= j + y; ++i) {
        SR.add(A[i]);
    }
    //pr(SL.size, SR.size);
    var d = j;
    for (var l1 = 1, l2 = d - 1, r1 = d + 1, r2 = d + y; r2 <= n;
    ++l1, ++l2, ++d, ++r1, ++r2
    ) {
        var minL = SL.values().next().value;
        var minR = SR.values().next().value;
        var cur = A[d];
        if (cur < minL && cur < minR) {
            wr(d);
            break;
        }
        SL.delete(A[l1]);
        SL.add(A[l2+1]);
        SR.delete(A[r1]);
        SR.add(A[r2+1]);
    }*/
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true);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;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{configurable:true,enumerable:false,value:v});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});
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;
})();

const processData = (lines) => {
  const [conditions, data] = lines
  const [n, x, y] = conditions.split(' ')
  const realData = data.split(' ').map(x => +x)
  const max = Math.pow(10, 10)
  for (let i=0; i<realData.length; i++) {
    const leftMin = realData.slice(i-x > 0 ? i-x: 0, i).reduce((r,x) => r < x ? r : x, max)
    const rightMin = realData.slice(i+1, i+y).reduce((r,x) => r < x ? r : x, max)
    if (realData[i] < leftMin && realData[i] < rightMin)
      return void console.log(i+1)
  }
}

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

const processData = (lines) => {
  const [conditions, data] = lines
  const [n, x, y] = conditions.split(' ').map(x => +x)
  const realData = data.split(' ').map(x => +x)
  const max = Math.pow(10, 10)
  for (let i=0; i<realData.length; i++) {
    const leftMin = realData.slice(i-x > 0 ? i-x: 0, i).reduce((r,x) => r < x ? r : x, max)
    const rightMin = realData.slice(i+1, i+y).reduce((r,x) => r < x ? r : x, max)
    if (realData[i] < leftMin && realData[i] < rightMin)
      return void console.log(i+1)
  }
}

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 line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)
})

function checkMin(arr, ai, start, end, i) {
  start < 0 ? start = 0 : void 0
  end > arr.length - 1 ? end = arr.length - 1 : void 0

  const leftMin = Math.min.apply(null, arr.slice(start, i))
  const rightMin = Math.min.apply(null, arr.slice(i + 1, end + 1))

  return ai < leftMin && ai < rightMin
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    if(checkMin(a, ai, i - x, i + y, i)) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

// ad < aj should hold for all d−x ≤ j < d and d < j ≤ d+y

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)

  process.exit(0)
})

function findMinIndex(arr, start, end) {
  let min = arr[0]
  let minIdx = null

  arr.forEach((v, i) => {
    if(i >= start && i < end) {
      if(v < min) {
        min = v
        minIdx = i
      }
    }
  })

  return { min, idx: minIdx }
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const { min, idx } = findMinIndex(a, i - x, i + y + 1)

    if(min === ai && i === idx) {
      result = idx
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main()
})

function main() {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const start = i - x > 0 ? i - x : (0, i)
    const end = i + y
    const leftMin = Math.min.apply(null, a.slice(start, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, end + 1))

    if(ai < leftMin && ai < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  lines = lines.split(/\n/)

  main()
})

function main() {
  const [ n, x, y ] = lines[0].split(/\s/).map(Number)
  const a = lines[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const leftMin = Math.min.apply(null, a.slice(i - x > 0 ? i - x : 0, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, i + y + 1))

    if(ai < leftMin && ai < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main()
})

function main() {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const start = i - x < 0 ? 0 : i - x
    const end = i + y > n - 1 ? n - 1 : i + y
    const leftMin = Math.min.apply(null, a.slice(start, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, end + 1))

    if(ai < leftMin && ai < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)

  process.exit(0)
})

function findMinIndex(arr, start, end) {
  let min = arr[0]
  let minIdx = null

  arr.forEach((v, i) => {
    if(i >= start && i < end) {
      if(v < min) {
        min = v
        minIdx = i
      }
    }
  })

  return { min, idx: minIdx }
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result

  a.some((ai, i) => {
    const { min, idx } = findMinIndex(a, i - x, i + y + 1)

    if(min === ai && i === idx) {
      result = idx
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)
})

function checkMin(arr, ai, start, end, i) {
  start < 0 ? start = 0 : void 0
  end > arr.length - 1 ? end = arr.length - 1 : void 0

  const leftMin = Math.min.apply(null, arr.slice(start, i + 1))
  const rightMin = Math.min.apply(null, arr.slice(i, end + 1))

  return ai <= leftMin && ai <= rightMin
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    if(checkMin(a, ai, i - x, i + y, i)) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main()
})

function main() {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const start = i - x < 0 ? i : i - x
    const end = i + y
    const leftMin = Math.min.apply(null, a.slice(start, i))
    const rightMin = Math.min.apply(null, a.slice(i + 1, end + 1))

    if(ai < leftMin && ai < rightMin) {
      result = i
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)
})

function findMinIndex(arr, start, end, i) {
  start < 0 ? start = 0 : void 0

  let idx = start
  let min = arr[idx]

  arr.slice(start, end).forEach((v, i) => {
    if(v < min) {
      min = v
      idx = start + i
    }
  })

  return { min, idx }
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/).map(Number)
  let result = 0

  a.some((ai, i) => {
    const { min, idx } = findMinIndex(a, i - x, i + y + 1, i)

    if(min === ai && i === idx) {
      result = idx
      return true
    }

    return false
  })

  console.log(result + 1)
}

let line = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', function (input) {
  line += (input.trim() + '\n')
})

process.stdin.on('end', function () {
  main(line)
})

function findMin(arr, start, end) {
  start < 0 ? start = 0 : void 0

  let idx = start
  let min = Number(arr[idx])

  for(let i = start; i <= end; i++) {
    const v = Number(arr[i])

    if(v < min) {
      min = v
      idx = i
    }
  }

  return { min, idx }
}

function main(line) {
  line = line.split(/\n/).map(l => l.replace(/\r/, ''))

  const [ n, x, y ] = line[0].split(/\s/).map(Number)
  const a = line[1].split(/\s/)
  let result = 0

  a.some((ai, i) => {
    const { min, idx } = findMin(a, i - x, i + y)

    if(min === Number(ai) && i === idx) {
      result = idx
      return true
    }

    return false
  })

  console.log(result + 1)
}

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

if(nxy[0] > 1) {
  var pr = true;

  if(arr[0] < arr[1]) {
    var ans = Math.min(...arr.slice(0, nxy[2]));
    if(ans === arr[0]) {
      print(1);
      pr = false;
    }
  }

  if (pr) {
    for(var i = 1; i < arr.length - 1; i++) {
      var start = i - nxy[1];
      var end = i + nxy[2] + 1;
      var ans = Math.min(...arr.slice(start < 0 ? start : 0, end));
      if(ans === arr[i]) {
        print(i + 1);
        pr = false;
        break;
      }
    }
  }

  if(pr) {
    print(arr.length);
  }
} else {
  print(1);
}


Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the maximum value of his brother's array b. Now you have to help Devu in achieving this condition. You can perform multiple operations on the arrays. In a single operation, you are allowed to decrease or increase any element of any of the arrays by 1. Note that you are allowed to apply the operation on any index of the array multiple times.You need to find minimum number of operations required to satisfy Devu's condition so that the brothers can play peacefully without fighting.

The first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105). The second line will contain n space-separated integers representing content of the array a (1 ≤ ai ≤ 109). The third line will contain m space-separated integers representing content of the array b (1 ≤ bi ≤ 109).

You need to output a single integer representing the minimum number of operations needed to satisfy Devu's condition.

NoteIn example 1, you can increase a1 by 1 and decrease b2 by 1 and then again decrease b2 by 1. Now array a will be [3; 3] and array b will also be [3; 3]. Here minimum element of a is at least as large as maximum element of b. So minimum number of operations needed to satisfy Devu's condition are 3.In example 3, you don't need to do any operation, Devu's condition is already satisfied.

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		aLen = data[0], bLen = data[1],
		a = tokenizeIntegers(readline()),
		b = tokenizeIntegers(readline());
	function compare(a, b) {
		return a - b;
	}
	a.sort(compare);
	b.sort(compare);
	var low = a[0], high = b[b.length-1];
	if (low >= high) {
		print(0);
		return;
	}
	//print('b: '+b.join(' '));
	//print('a: '+a.join(' '));
	function compute(hinge) {
		var cost = 0;
		for (var i = 0; i < b.length; ++i) {
			//print(b[i]+' '+hinge+' '+(b[i] < hinge));
			if (b[i] > hinge) {
				cost += b[i]-hinge;
			}
		}
		for (var i = 0; i < a.length; ++i) {
			if (hinge > a[i]) {
				cost += hinge-a[i];
			}
		}
		//print('hinge = '+hinge+', cost = '+cost);
		return cost;
	}
	while (true) {
		var mid = Math.floor((low+high)/2),
			left = compute(mid-1),
			cost = compute(mid),
			right = compute(mid+1);
		if (left < cost) {
			high = mid-1;
		} else if (right < cost) {
			low = mid+1;
		} else {
			print(cost);
			return;
		}
	}
}

main();