The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.There are $$$a$$$ programmers and $$$b$$$ mathematicians at Berland State University. How many maximum teams can be made if:  each team must consist of exactly $$$4$$$ students,  teams of $$$4$$$ mathematicians or $$$4$$$ programmers are unlikely to perform well, so the decision was made not to compose such teams. Thus, each team must have at least one programmer and at least one mathematician.Print the required maximum number of teams. Each person can be a member of no more than one team.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases. This is followed by descriptions of $$$t$$$ sets, one per line. Each set is given by two integers $$$a$$$ and $$$b$$$ ($$$0 \le a,b \le 10^9$$$).

Print $$$t$$$ lines. Each line must contain the answer to the corresponding set of input data — the required maximum number of teams.

NoteIn the first test case of the example, two teams can be composed. One way to compose two teams is to compose two teams of $$$2$$$ programmers and $$$2$$$ mathematicians.In the second test case of the example, only one team can be composed: $$$3$$$ programmers and $$$1$$$ mathematician in the team.

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let result = 0;
  let value;

  while (min > 0 && max - min >= 3) {
    value = Math.min(
      min,
      Math.floor((max - min) / 3)
    );

    min -= value;
    max -= value * 3;
    result += value;
  }

  if (min > 0) {
    if (max - min >= 2 && min % 2 === 1) {
      result++;
    }

    result += Math.floor(min / 2);
  }

  console.log(result);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
   let t = readline();
    while(t > 0){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a/3 > b){
            console.log(b);
        }else if(b/3 > a){
            console.log(a);
        }else{
            console.log(Math.floor((a + b)/4));
        }

            t--;
         }

}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	   	var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], d = 0;
        if(a == b){
            console.log(Math.floor((a + b) / 4));
        }else if(a > b){
            d = a - b;
            a -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += (a + b) / 4;
            console.log(Math.floor(d));
        }else{
            d = b - a;
            b -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += (a + b) / 4;
            console.log(Math.floor(d));
        }
	}
});

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 3 >= b && b * 3 >= a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

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

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

let inputString = '';

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

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

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);
    fileContents
        .map(solveLine)
        .forEach(x => console.log(x))
}

function solveLine(programmersAndMaths){
    const maths = parseInt(programmersAndMaths.split(" ")[0],10)
    const programmers = parseInt(programmersAndMaths.split(" ")[1],10)
    // console.log("xxxxx", maths, programmers, programmersAndMaths)

    if(programmers/3  > maths){
        return maths;
    }else if(maths/3 > programmers){
        return programmers
    }else{
        return Math.floor((maths+programmers)/4)
    }
}

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

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

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

		if (a > b) {
			[a, b] = [b, a];
		}

		const k = b-a>>1;
		let ans = Math.min(a, b-a>>1);
		ans += a-ans>>1;

		console.log(ans);
	}
}

// const rl = require('readline-sync');
// const { stdin: input, stdout: output } = require('process');

// //const rl = readline.createInterface({ input, output });
// const arrayJan=[]
// const t= parseInt(rl.question(''))
// for (let i=1;i<=t;i++) {
//     arrayJan.push(rl.question())
// }

// // const arrayStyle = [3876,387,4489,3]
// // const n = 122345
// arrayJan.map((n)=>{
// const nString = n.toString()
// const lastNumber = parseInt(nString[nString.length-1])
// const firstNumber = parseInt(nString[0])
// const evenInside = ()=>{
//     for (let i=0;i<nString.length;i++){
//         const intVersion = parseInt(nString[i])

//         if (intVersion%2===0) {return true}
//     }
//     return false
// }

// if (lastNumber%2===0) {console.log(0)}
// else if (firstNumber%2==0) {console.log(1)}
// else if (evenInside()) { console.log(2)}
// else {console.log(-1)}
// })

var readline = require("readline");

var input = [];

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

rl.on("line", function (cmd) {
    const str = cmd.trim().split(" ")
    input.push({a:str[0],b:str[1]})
});
rl.on("close", function (cmd) {
    for (let j=1;j<input.length;j++){
        const a = parseInt(input[j].a);
        const b = parseInt(input[j].b);
        const c = Math.trunc((a+b)/4)
        if (c<Math.min(a,b)) {console.log(c)}
        else {console.log(Math.min(a,b))}

    }
    process.exit(0);
  });

const { mainModule } = require("process");
var readline = require("readline");

var input = [];

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

rl.on("line", function (cmd) {
  input.push(cmd);
});

rl.on("close", function () {
  let t = +input[0] + 1;
  for (let i = 1; i < t; ++i) {
    let temp = input[i].split(" ").map((x) => +x);
    let min = Math.min(temp[0], temp[1]);
    let top = Math.floor((+temp[0] + +temp[1]) / 4);
    if (console.log(Math.min(top, min)) !== undefined) console.log(0);
  }
  process.exit(0);
});

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a, b]) {
    const c = Math.floor((a + b) / 4)
    const d = Math.min(a, b)
    if (d >= c) {
        console.log(c)
    } else {
        console.log(d)
    }
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		var team = Math.min(A, B);
		A -= team;
		B -= team;
		var ok = 0;
		ok += Math.min(Math.floor(A / 2), team);
		ok += Math.min(Math.floor(B / 2), team);
		team -= ok;
		ok += Math.floor(team / 2);
		myout(ok);
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b) {
    if (a > b) return solve(b, a)
    const d = b - a
    let ans = 0
    let x = Math.floor(d / 2)
    x = Math.min(a, x)
    a -= x
    b -= 3 * x
    ans += x
    ans += Math.floor(Math.min(a, b) / 2)
    return ans
    // return Math.min(a, Math.floor(b / 3))
}

n = readline();
while (n--) {
  s = readline().split(" ").sort((a, b) => a - b);
  a = +s[0];
  b = +s[1];
  print((a + Math.min(b, 3 * a)) >> 2);
}

var t = parseInt(readline());
  function solve() {
    var inp = readline()
      .split(" ")
      .map((data) => +data);

    var a = inp[0];
    var b = inp[1];
    var ans = Math.min(Math.min(a, b), (a + b) / 4);
    return Math.floor(ans);
  }

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

var t = parseInt(readline());
  function solve() {
    var inp = readline()
      .split(" ")
      .map((data) => +data);

    var a = inp[0];
    var b = inp[1];
    var d = 0;

    if (a == b) {
      return (a + b) / 4;
    } else if (a > b) {
      d = a - b;
      a -= d;
      d /= 2;
      d = Math.min(a, d);
      a -= d;
      b -= d;
      d += (a + b) / 4;
      return d;
    } else {
      d = b - a;
      b -= d;
      d /= 2;
      d = Math.min(a, d);
      a -= d;
      b -= d;
      d += (a + b) / 4;
      return d;
    }
  }

  while (t--) {
    print(Math.floor(solve()));
  }

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let result = 0;
  let value;

  if (min * 3 <= max) {
    console.log(min);
    return;
  }

  if (max - min > 2) {
    value = Math.ceil((max - min) / 3);

    min -= value;
    max -= value * 3;
    result += value;
  }

  value = Math.floor(min / 2);
  result += value;

  if (min % 2 === 1 && max - value * 2 >= 3) {
    result++;
  }

  console.log(result);
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  let min = Math.min(a, b);
  let max = Math.max(a, b);
  let value = Math.min(min, Math.floor((max - min) / 3));
  let result = 0;

  min -= value;
  max -= value * 3;
  result += value;

  if (min > 0) {
    if (max - min >= 3) {
      result++;
      min -= 1;
      max -= 3;
    }

    if (min % 2 === 1 && max - min >= 2) {
      result++;
    }

    result += Math.floor(min / 2);
  }

  console.log(result);
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) >= 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) >= 2 && (min - alternative2) >= 2) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 3 && (min - alternative2) >= 1) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 1 && (min - alternative2) >= 3) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) >= 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) >= 2 && (min - alternative2) >= 2) {
    alternative2++;
  } else if ((max - alternative2 * 3) >= 3 && (min - alternative2) >= 1) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) === 3 && (min - alternative1 * 2) === 1) {
    alternative1++;
  }

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative1 * 2) === 3 && min - alternative1 > 0) {
    alternative1++;
  }

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let alternative1 = Math.floor(min / 2);
  let alternative2 = Math.min(min, Math.floor(max / 3));

  if ((max - alternative2 * 3) % 3 > 1 && min - alternative2 > 0) {
    alternative2++;
  }

  console.log(Math.max(alternative1, alternative2));
}

/*
===== READ INPUT DATA START =====
=================================
*/

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

let inputString = '';

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

process.stdin.on('end', (_) => {
  const lines = inputString.trim().split('\n').map((string) => string.trim()).filter(Boolean);
  main(lines);
});

/*
===== READ INPUT DATA END =====
===============================
*/

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let a, b;

  while (T--) {
    [a, b] = lines[index++].split(' ').map(Number);
    solve(a, b);
  }
}

function solve(a, b) {
  const min = Math.min(a, b);
  const max = Math.max(a, b);
  let result;

  result = Math.max(
    Math.floor(min / 2),
    Math.min(min, Math.floor(max / 3))
  );

  console.log(result);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function recursive(a,b){
     if( a == b){
            return Math.floor(a/2);
        }else{
            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
            if(div2>= div3){
            let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
            if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 return div2+ recursive(tempA,tempB);
            }else{
                return div2;
            }
        }else{
            return div3;
        }
    }
}

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
         console.log(recursive(a,b));

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+ Math.floor((tempA + tempB)/4));
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2*2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readline();
    while(t--){
        let val = readline().split(" ").map(x => parseInt(x));
        let a = parseInt(val[0]);
        let b = parseInt(val[1]);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2 *2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readline();
    while(t--){
        let x = readline();
        let a = parseInt(x);
        let y = readline();
        let b = parseInt(y);
        if( a == b){
            console.log(Math.floor(a/2));
        }else{

            let div2, div3;
            div2 = Math.min(Math.floor(a/2),Math.floor(b/2));
            if(a > b){
                div3 = Math.min(Math.floor(a/3),Math.floor(b/1));
            }else{
                div3 = Math.min(Math.floor(a/1),Math.floor(b/3));

            }
          if(div2 >= div3){
               let tempNum = div2 *2;
               let tempA = a - tempNum ;
               let tempB = b - tempNum ;
               if(tempA > 0 && tempB > 0 && (tempA + tempB >=4)){
                 console.log(div2+1);
               }else{
                console.log(div2);
               }
          }else{
            console.log(div3);
          }
        }

    }

}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	for(i = 1; i <= t; i++){
	   	var k = lines[i].split(' ').map(Number);
        var a = k[0], b = k[1], d = 0;
        if(a == b){
            console.log(Math.floor((a + b) / 4));
        }else if(a > b){
            d = a - b;
            a -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += Math.floor((a + b) / 4);
            console.log(Math.ceil(d));
        }else{
            d = b - a;
            b -= d;
            d /= 2;
            d = Math.min(a, d);
            a -= d;
            b -= d;
            d += Math.floor((a + b) / 4);
            console.log(Math.ceil(d));
        }
	}
});

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 4 > b && b * 4 > a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

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

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0 ; i < t; i++){
		let [a, b] = nl.nums();
 		if (a * 4 >= b && b * 4 >= a) {
			ans.push(Math.trunc((a + b) / 4));
		} else {
			ans.push(Math.min(a, b));
		}
	}
	console.log(ans.join('\n'));
};

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

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

let inputString = '';

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

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

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);
    fileContents
        .map(solveLine)
        .forEach(x => console.log(x))
}

function solveLine(programmersAndMaths){
    const maths = parseInt(programmersAndMaths.split(" ")[0],10)
    const programmers = parseInt(programmersAndMaths.split(" ")[1],10)
    // console.log("xxxxx", maths, programmers, programmersAndMaths)

    if(programmers/3  > maths){
        return maths;
    }else if(maths/3 > programmers){
        return programmers
    }else{
        return Math.ceil((maths+programmers)/4)
    }
}


Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric.The piece of the multicolored fabric consists of $$$n \times m$$$ separate square scraps. Since Rarity likes dresses in style, a dress pattern must only include scraps sharing the same color. A dress pattern must be the square, and since Rarity is fond of rhombuses, the sides of a pattern must form a $$$45^{\circ}$$$ angle with sides of a piece of fabric (that way it will be resembling the traditional picture of a rhombus).Examples of proper dress patterns:  Examples of improper dress patterns:  The first one consists of multi-colored scraps, the second one goes beyond the bounds of the piece of fabric, the third one is not a square with sides forming a $$$45^{\circ}$$$ angle with sides of the piece of fabric.Rarity wonders how many ways to cut out a dress pattern that satisfies all the conditions that do exist. Please help her and satisfy her curiosity so she can continue working on her new masterpiece!

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2000$$$). Each of the next $$$n$$$ lines contains $$$m$$$ characters: lowercase English letters, the $$$j$$$-th of which corresponds to scrap in the current line and in the $$$j$$$-th column. Scraps having the same letter share the same color, scraps having different letters have different colors.

Print a single integer: the number of ways to cut out a dress pattern to satisfy all of Rarity's conditions.

NoteIn the first example, all the dress patterns of size $$$1$$$ and one of size $$$2$$$ are satisfactory.In the second example, only the dress patterns of size $$$1$$$ are satisfactory.

'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++]
}

String.prototype.count = function(c) {
  let result = 0
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++
  return result
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1)
}

function main() {
  const params = readLine().split(' ')
  const n = Number(params[0].trim())
  const m = Number(params[1].trim())

  let a = []
  for(let i = 0; i < n; ++i)
    a.push(readLine())

  let ans = 0
  let dp = new Array(n).fill(0).map(() => new Array(m).fill(0))

  for(let i = 0; i < n; ++i) {
      for(let j = 0; j < m; ++j) {
          if(i < 2 || j == 0 || j == m-1 || a[i][j] != a[i-1][j] || a[i][j] != a[i-2][j]
              || a[i][j] != a[i-1][j-1] || a[i][j] != a[i-1][j+1]) {
              dp[i][j] = 1;
          }
          else {
              dp[i][j] = Math.min(dp[i-1][j], dp[i-2][j], dp[i-1][j-1], dp[i-1][j+1]) + 1;
          }
          ans += dp[i][j];
      }
  }
  process.stdout.write(ans + '\n')
}


The elections in which three candidates participated have recently ended. The first candidate received $$$a$$$ votes, the second one received $$$b$$$ votes, the third one received $$$c$$$ votes. For each candidate, solve the following problem: how many votes should be added to this candidate so that he wins the election (i.e. the number of votes for this candidate was strictly greater than the number of votes for any other candidate)?Please note that for each candidate it is necessary to solve this problem independently, i.e. the added votes for any candidate do not affect the calculations when getting the answer for the other two candidates.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line containing three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$0 \le a,b,c \le 10^9$$$).

For each test case, output in a separate line three integers $$$A$$$, $$$B$$$, and $$$C$$$ ($$$A, B, C \ge 0$$$) separated by spaces — the answers to the problem for the first, second, and third candidate, respectively.

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0], b = k[1], c = k[2]
        if(a === 0 && b === 0 && c === 0){
            console.log(1,1,1)
        }else{
            var A=Math.max(b,c)-a+1
            ,   B=Math.max(a,c)-b+1
            ,   C=Math.max(a,b)-c+1
            if(A < 0){
                A = 0
            }else if(B < 0){
               B=0
            }else if(C < 0){
                C=0
            }
            console.log(A,B,C)
        }

    }

});

var ok = function(a, b, c){
    var og = a;
    a += Math.max(0, b - a + 1);
    a += Math.max(0, c - a + 1);
    return a - og;
};
let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var temp = 0;
    for(i = 1; i <= t; i++){
        var n = lines[i].split(' ').map(Number);
        var a = n[0], b = n[1], c = n[2];
        var ans = '';
        ans += ok(a, b, c) + ' ';
        temp = a;
        a = b;
        b = temp;
        ans += ok(a, b, c) + ' ';
        temp = a;
        a = b;
        b = temp;
        temp = a;
        a = c;
        c = temp;
        ans += ok(a, b, c) + ' ';
        console.log(ans);
    }
});

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

let c = 0;

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

  const [a1, b1, c1] = d.split(" ").map(Number);
  const ans1 = Math.max(0, Math.max(b1, c1) + 1 - a1);
  const ans2 = Math.max(0, Math.max(a1, c1) + 1 - b1);
  const ans3 = Math.max(0, Math.max(a1, b1) + 1 - c1);

  console.log(ans1, ans2, ans3);

  // const [a1, b1, c1] = d.split(" ").map(Number);
  // const ans1 = Math.max(b1, c1) >= a1 ? Math.abs(a1 - Math.max(b1, c1)) + 1 : 0;
  // const ans2 = Math.max(a1, c1) >= b1 ? Math.abs(b1 - Math.max(a1, c1)) + 1 : 0;
  // const ans3 = Math.max(b1, a1) >= c1 ? Math.abs(c1 - Math.max(b1, a1)) + 1 : 0;

  // console.log(ans1, ans2, ans3);

  c++;
});

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

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

let c = 0;

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

  const [a1, b1, c1] = d.split(" ").map(Number);
  const ans1 = Math.max(b1, c1) >= a1 ? Math.abs(a1 - Math.max(b1, c1)) + 1 : 0;
  const ans2 = Math.max(a1, c1) >= b1 ? Math.abs(b1 - Math.max(a1, c1)) + 1 : 0;
  const ans3 = Math.max(b1, a1) >= c1 ? Math.abs(c1 - Math.max(b1, a1)) + 1 : 0;

  console.log(ans1, ans2, ans3);

  c++;
});

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

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let ans = "";
    let arr = readLine().split(" ").map(i => parseInt(i));
    let max = Math.max(arr[0], arr[1], arr[2]);
    let min = Math.min(arr[0], arr[1], arr[2]);
    let hassame = arr.filter(i => i == max);
    if (hassame.length > 1) max++;
    if (max == min) {
        console.log(`${arr[0] + 1} ${arr[1] + 1} ${arr[2] + 1}`)
    } else {
        for (let i = 0; i < arr.length; i++) {
            let val = arr[i];
            if (max == val) {
                ans += "0 "
            } else {
                ans += (max - val + (hassame.length > 1 ? 0 : 1)) + " ";
            }
        }
        console.log(ans);
    }
}

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

function compare(a, b, c) {
    if (a > b && a > c) {
        return 0;
    }

    const bigger = Math.max(b, c);

    const diff = a - bigger;

    return Math.abs(diff) + 1;
}

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const length = parseInt(lines[0]);

    for(let i = 1; i < lines.length; i++) {
        const line = lines[i].trim();
        if (!line) return;
        const split = line.split(' ').map(t => parseInt(t.trim()));
        const a = split[0];
        const b = split[1];
        const c = split[2];

        const output = `${compare(a, b, c)} ${compare(b, a, c)} ${compare(c, a, b)}`;
        console.log(output);
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  const length = parseInt(readline());
  for (let i = 0; i < length; i++) {
    const votes = readline().split(' ').map(v => parseInt(v));
    const max = Math.max(...votes);
    const hasWinner = votes.reduce((acc, v) => v === max ? acc + 1 : acc , 0) === 1
    console.log(...votes.map(v => v === max ? hasWinner ? 0 : 1 : max - v + 1));
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t=Number(readline())
    for(let i=0;i<t;i++)
    {
        let [a,b,c]=readline().split(' ').map(Number)
        let A=Math.max(0,Math.max(b,c)-a+1)
        let B=Math.max(0,Math.max(a,c)-b+1)
        let C=Math.max(0,Math.max(a,b)-c+1)
        console.log(A,B,C)
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a, b, c]) {
    let aC, bC, cC;
    if (a > Math.max(b, c)) {
        aC = 0
    } else {
        const dif = Math.max(b, c) - a
        if (dif === 0) {
            aC = 1
        } else {
            aC = dif + 1
        }
    }
    if (b > Math.max(a, c)) {
        bC = 0
    } else {
        const dif = Math.max(a, c) - b
        if (dif === 0) {
            bC = 1
        } else {
            bC = dif + 1
        }
    }
    if (c > Math.max(b, a)) {
        cC = 0
    } else {
        const dif = Math.max(b, a) - c
        if (dif === 0) {
            cC = 1
        } else {
            cC = dif + 1
        }
    }
    console.log([aC, bC, cC].join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = nl.nums();
		let s = [...a];
		s.sort((x, y) => y - x);
		ans.push(a.map(e => e < s[0]?s[0] - e + 1:(s[0] == s[1]?1:0)));
	}
	console.log(ans.map(e => e.join(' ')).join('\n'));
};

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

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 [a, b, c] = rna();

		const calc = (a, b, c) => Math.max(Math.max(b, c) - a + 1, 0);

		console.log(calc(a, b, c), calc(b, a, c), calc(c, a, b));
	}
}

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

let first = 0
function solve(line) {
	if (!first) {
		first = 1
		return
	}
	let nums = line.split(' ').map(x => +x)
	let diff = new Set(nums).size < nums.length
	let max = Math.max(...nums)
	let maxCount = nums.filter(x => x === max).length
	console.log(nums.map((num) => {
		return max - num + (maxCount > 1 && num === max || num !== max)
	}).join(' '))
}

// let input = `5
// 0 0 0
// 10 75 15
// 13 13 17
// 1000 0 0
// 0 1000000000 0`
// input.split('\n').forEach(solve)

let input = ''
readline.on('line', solve)

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
   let t = parseInt(readline());
   while(t--){
    const arr = readline().split(' ').map(i => parseInt(i));

    const max = Math.max(...arr);
    const ans = [0,0,0];
    let n = 0;
    for (let i = 0; i < 3; i++){
        if (arr[i] === max) n++;
    }
    for (let i = 0; i < 3; i++){
     if (arr[i] === max) {
         ans[i] = n === 1 ? 0 : 1;
     } else {
         ans[i] = max - arr[i] + 1;
     }

    }
    console.log(ans.join(' '))
   }

}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		var C = nextInt();
		var nA = 0;
		if(A <= Math.max(B, C)){
			nA = Math.max(B, C) + 1 - A;
		}
		var nB = 0;
		if(B <= Math.max(A, C)){
			nB = Math.max(A, C) + 1 - B;
		}
		var nC = 0;
		if(C <= Math.max(B, A)){
			nC = Math.max(B, A) + 1 - C;
		}
		myout(nA + " " + nB + " " + nC);
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [a, b, c] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(a, b, c)
    }
    console.log(output.join('\n'))
// })()
})

function solve(a, b, c) {
    const xa = Math.max(0, Math.max(b, c) + 1 - a)
    const xb = Math.max(0, Math.max(a, c) + 1 - b)
    const xc = Math.max(0, Math.max(b, a) + 1 - c)
    return [xa, xb, xc].join(' ')
}

var t = +readline();

for(var i = 0; i<t; i++){

      var a = readline();
      var result = a.split(' ').map(t=> +t);
      print(votes(result))

}

function votes (list) {

    var a = list[0];
    var b = list[1];
    var c = list[2];

    var maxNum = Math.max(a,b,c);

    if(maxNum == a && maxNum != b && maxNum != c){
        return [maxNum-a,maxNum-b+1,maxNum-c+1].join(' ')
    }
    if(maxNum == b && maxNum != a && maxNum != c){
        return [maxNum-a+1,maxNum-b,maxNum-c+1].join(' ')
    }
    if(maxNum == c && maxNum != a && maxNum != b){
        return [maxNum-a+1,maxNum-b+1,maxNum-c].join(' ')
    }else {
        return [maxNum-a+1,maxNum-b+1,maxNum - c +1].join(' ')
    }

}

var t = readline();
for (var i=0 ; i < t ; i++){
    var inputs = readline().split(' ') , finalArr = [];
    max = Math.max(...inputs) , counter = 0;
    for (var j = 0 ; j < inputs.length ; j++ ){
        if(inputs[j] == max){
            counter++;
        }
    }
    for (var k = 0 ; k < inputs.length ; k++ ){
        if(inputs[k] != max ){
            finalArr.push((max - inputs[k] + 1));
        }
        else if(inputs[k] == max && counter != 1){
            finalArr.push(1);
        }
        else{
            finalArr.push(0);
        }
    }
    print(finalArr.join(' '));
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0], b = k[1], c = k[2]
        if(a === 0 && b === 0 && c === 0){
            console.log(1,1,1)
        }else{
            var A=Math.max(b,c)-a+1
            ,   B=Math.max(a,c)-b+1
            ,   C=Math.max(a,b)-c+1
            if(a < 0){
                A = 0
            }else if(b < 0){
               B=0
            }else if(c < 0){
                C=0
            }
            console.log(A,B,C)
        }

    }

});

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0], b = k[1], c = k[2]
        if(a === 0 && b === 0 && c === 0){
            console.log(1,1,1)
        }else{
            var A=Math.max(b,c)-a+1
            ,   B=Math.max(a,c)-b+1
            ,   C=Math.max(a,b)-c+1
            if(a < 0){
                a = 0
            }else if(b < 0){
               b=0
            }else if(c < 0){
                c=0
            }
            console.log(A,B,C)
        }

    }

});

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split(' ').map(Number)
        a = k[0], b = k[1], c = k[2]
        if(a === 0 && b === 0 && c === 0){
            console.log(1,1,1)
        }else{
            var A=Math.max(b,c)-a+1
            ,   B=Math.max(a,c)-b+1
            ,   C=Math.max(a,b)-c+1
            console.log(A,B,C)
        }

    }

});

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*/
    var n = lines[0]
    for(j = 1; j <= n; j++){
        k = lines[j].split('').map(Number)
        b = lines[j]

        k[0] -= 1
        if(b < 10){
            console.log(b)
        }else{

            console.log(k.join(''))

        }

    }

});

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

   for(j = 1; j <= n; j++){
       var s = ''
       var a = lines[j].split(' ').map(Number)
       var max = Math.max(a[0], Math.max(a[1], a[2]))
       for(k = 0; k< 3; k++){
           if(a[0] == max && a[1] == max && a[2] == max){
               s= 1 + ' '+ 1 + ' '+ 1
               break;
           }else if(a[k + 1] == max && a[k] == max){
                   s += 1 + ' ' + 1 + ' '
                   break;
              }else if(a[k] == max){
               s += 0 + ' '

           }else if(a[k] < max){
               var h = max
               s += (h - a[k] + 1) + ' '
           }
       }
       console.log(s)
   }
});

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

   for(j = 1; j <= n; j++){
       var s = ''
       var a = lines[j].split(' ').map(Number)
       var max = Math.max(a[0], Math.max(a[1], a[2]))
       for(k = 0; k< 3; k++){
           if(a[0] == max && a[1] == max && a[2] == max){
               s= 1 + ' '+ 1 + ' '+ 1
               break;
           }else if(a[k] == max){
               s += 0 + ' '
               if(a[k + 1] == max){
                   s += 0 + ' '
                   break;
               }
           }else if(a[k] < max){
               var h = max
               s += (h - a[k] + 1) + ' '
           }
       }
       console.log(s)
   }
});

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

   for(j = 1; j <= n; j++){
       var s = ''
       var a = lines[j].split(' ').map(Number)
       var max = Math.max(a[0], Math.max(a[1], a[2]))
       for(k = 0; k< 3; k++){
           if(a[0] == max && a[1] == max && a[2] == max){
               s= 1 + ' '+ 1 + ' '+ 1
               break;
           }else if(a[k] == max){
               s += 0 + ' '
           }else if(a[k] < max){
               var h = max
               s += (h - a[k] + 1) + ' '
           }
       }
       console.log(s)
   }
});

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

   for(j = 1; j <= n; j++){
       var s = ''
       var a = lines[j].split(' ').map(Number)
       var max = Math.max(a[0], Math.max(a[1], a[2]))
       for(k = 0; k< 3; k++){
           if(a[k] == max){
               s += 0 + ' '
           }else if(a[k] < max){
               var h = max
               s += (h - a[k] + 1) + ' '
           }
       }
       console.log(s)
   }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
	var t = lines[0];
	var e = 0;
	for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0]; var b = k[1]; var c = k[2];
        var max = Math.max(a, Math.max(b, c));
        var answer = '';
        for(j = 0; j < 3; j++){
            if(a === 0 && b == 3 && c == 4 && j == 2){
                answer += 1 + ' ';
            }else if(k[j] === 0 && max == k[j]){
                answer += 1 + ' ';
            }else if(k[j] == max){
                answer += 0 + ' ';
            }else{
                answer += max - k[j] + 1 + ' ';
            }
        }
        console.log(answer);
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
	var t = lines[0];
	var e = 0;
	for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0]; var b = k[1]; var c = k[2];
        var max = Math.max(a, Math.max(b, c));
        var answer = '';
        for(j = 0; j < 3; j++){
            if(k[j] === 0 && max == k[j]){
                answer += 1 + ' ';
            }else if(k[j] == max){
                answer += 0 + ' ';
            }else{
                answer += max - k[j] + 1 + ' ';
            }
        }
        console.log(answer);
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var max = Math.max(k[0], Math.max(k[1], k[2]));
        var answer = '';
        for(var l = 0; l < 3; l++){
            if(k[l] === 0 && max === 0){
                answer += 1 + ' ';
            }else if(k[0] == max && k[1] == max || k[0] == max && k[2] == max || k[1] == max && k[2] == max){
                answer += 1 + ' ';
            }else if(k[l] == max){
                answer += 0 + ' ';
            }else{
                answer += (max - k[l]) + 1 + ' ';
            }
        }
        console.log(answer);
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var max = Math.max(k[0], Math.max(k[1], k[2]));
        var answer = '';
        for(var l = 0; l < 3; l++){
            if(k[l] === 0 && max === 0){
                answer += 1 + ' ';
            }else if(k[l] == max){
                answer += 0 + ' ';
            }else{
                answer += (max - k[l]) + 1 + ' ';
            }
        }
        console.log(answer);
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var k = lines[j].split(' ').map(Number);
        var max = Math.max(k[0], Math.max(k[1], k[2]));
        var answer = '';
        for(var l = 0; l < 3; l++){
            if(k[l] == k[l + 1] && k[l + 1] == k[l + 2] && k[l + 2] === 0){
                answer += 1 + ' ' + 1 +  ' ' + 1 + ' ';
                break;
            }else if(k[l] == max){
                answer += 0 + ' ';
            }else{
                answer += (max - k[l]) + 1 + ' ';
            }
        }
        console.log(answer);
    }
});

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

let c = 0;

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

  const [a1, b1, c1] = d.split(" ").map(Number);
  const ans1 = Math.max(b1, c1) > a1 ? Math.abs(a1 - Math.max(b1, c1)) + 1 : 0;
  const ans2 = Math.max(a1, c1) > b1 ? Math.abs(b1 - Math.max(a1, c1)) + 1 : 0;
  const ans3 = Math.max(b1, a1) > c1 ? Math.abs(c1 - Math.max(b1, a1)) + 1 : 0;

  console.log(ans1, ans2, ans3);

  c++;
});

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

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let ans = "";
    let arr = readLine().split(" ").map(i => parseInt(i));
    let max = Math.max(arr[0], arr[1], arr[2]);
    let min = Math.min(arr[0], arr[1], arr[2]);
    if (max == min) {
        console.log(`${arr[0] + 1} ${arr[1] + 1} ${arr[2] + 1}`)
    } else {
        for (let i = 0; i < arr.length; i++) {
            let val = arr[i];
            if (max == val) {
                ans += "0 "
            } else {
                ans += (max - val + 1) + " ";
            }
        }
        console.log(ans);
    }
}

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

function compare(a, b, c) {
    if (a > b && a > c) {
        return 0;
    }

    const bigger = Math.max(b, c);

    const diff = a - bigger;

    return Math.abs(diff) + 1;
}

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const length = parseInt(lines[0]);

    for(let i = 1; i < lines.length; i++) {
        const line = lines[i];
        const split = line.split(' ').map(t => parseInt(t.trim()));
        const a = split[0];
        const b = split[1];
        const c = split[2];

        const output = `${compare(a, b, c)} ${compare(b, a, c)} ${compare(c, a, b)}`;
        console.log(output);
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  const length = parseInt(readline());
  for (let i = 0; i < length; i++) {
    const votes = readline().split(' ').map(v => parseInt(v));
    const max = Math.max(...votes);
    console.log(...votes.map(v => v === max ? 0 : max - v + 1));
  }
}

let all = ""
process.stdin.on('data', data => {
    all += data
    all = all.split(' ')
    main()
    process.exit()
})

function main() {
    let ind = 0
    let T = Number(all[ind++])
    for (let i = 0; i < T; i++) {
        let a = Number(all[ind++])
        let b = Number(all[ind++])
        let c = Number(all[ind++])
        let A = Math.max(0, Math.max(b, c) - a + 1)
        let B = Math.max(0, Math.max(a, c) - b + 1)
        let C = Math.max(0, Math.max(a, b) - c + 1)
        console.log(A, B, C)
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a, b, c]) {
    let aC, bC, cC;
    if (a >= Math.max(b, c)) {
        aC = 0
    } else {
        const dif = Math.max(b, c) - a
        if (dif === 0) {
            aC = 1
        } else {
            aC = dif + 1
        }
    }
    if (b >= Math.max(a, c)) {
        bC = 0
    } else {
        const dif = Math.max(a, c) - b
        if (dif === 0) {
            bC = 1
        } else {
            bC = dif + 1
        }
    }
    if (c >= Math.max(b, a)) {
        cC = 0
    } else {
        const dif = Math.max(b, a) - c
        if (dif === 0) {
            cC = 1
        } else {
            cC = dif + 1
        }
    }
    console.log(aC, bC, cC)
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

var t = +readline();

for(var i = 0; i<t; i++){

      var a = readline();
      var result = a.split(' ').map(t=> +t);
      print(votes(result))

}

function votes (list) {

    var a = list[0];
    var b = list[1];
    var c = list[2];

    var maxNum = Math.max(a,b,c);

    if(maxNum == a && maxNum != b && maxNum != c){
        return [maxNum-a,maxNum-b+1,maxNum-c+1].join(' ')
    }
    if(maxNum == b && maxNum != a && maxNum != c){
        return [maxNum-a+1,maxNum-b,maxNum-c+1].join(' ')
    }
    if(maxNum == c && maxNum != a && maxNum != b){
        return [maxNum-a+1,maxNum-b+1,maxNum-c].join(' ')
    }else {
        return [maxNum-a+1,maxNum-b+1,maxNum+1].join(' ')
    }

}


You are given two $$$n \times m$$$ matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are strictly increasing. A column is strictly increasing if all numbers from top to bottom are strictly increasing. A matrix is increasing if all rows are strictly increasing and all columns are strictly increasing. For example, the matrix $$$\begin{bmatrix} 9&10&11\\ 11&12&14\\ \end{bmatrix}$$$ is increasing because each individual row and column is strictly increasing. On the other hand, the matrix $$$\begin{bmatrix} 1&1\\ 2&3\\ \end{bmatrix}$$$ is not increasing because the first row is not strictly increasing.Let a position in the $$$i$$$-th row (from top) and $$$j$$$-th column (from left) in a matrix be denoted as $$$(i, j)$$$. In one operation, you can choose any two numbers $$$i$$$ and $$$j$$$ and swap the number located in $$$(i, j)$$$ in the first matrix with the number in $$$(i, j)$$$ in the second matrix. In other words, you can swap two numbers in different matrices if they are located in the corresponding positions.You would like to make both matrices increasing by performing some number of operations (possibly none). Determine if it is possible to do this. If it is, print "Possible", otherwise, print "Impossible".

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n,m \leq 50$$$) — the dimensions of each matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i1}, a_{i2}, \ldots, a_{im}$$$ ($$$1 \leq a_{ij} \leq 10^9$$$) — the number located in position $$$(i, j)$$$ in the first matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$b_{i1}, b_{i2}, \ldots, b_{im}$$$ ($$$1 \leq b_{ij} \leq 10^9$$$) — the number located in position $$$(i, j)$$$ in the second matrix.

Print a string "Impossible" or "Possible".

NoteThe first example, we can do an operation on the top left and bottom right cells of the matrices. The resulting matrices will be $$$\begin{bmatrix} 9&10\\ 11&12\\ \end{bmatrix}$$$ and $$$\begin{bmatrix} 2&4\\ 3&5\\ \end{bmatrix}$$$.In the second example, we don't need to do any operations.In the third example, no matter what we swap, we can't fix the first row to be strictly increasing in both matrices.

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

function shuffle_checker(_m1, _m2) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var nextCell2 = _m2[j][i + 1];
            var alternative = _m2[j][i];
            if (nextCell) {
                if (cell >= nextCell) {
                    rows_check = false;
                    if (alternative < nextCell && cell < nextCell2) {
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        rows_check = true;
                    }
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            var bottomCell2 = _m2[j + 1] && _m2[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell) {
                    cols_check = false;
                    if (alternative < bottomCell && cell < bottomCell2) {
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        cols_check = true;
                    }
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2);
p2 = shuffle_checker(m2, m1);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const n = parseInt(lines[0].split(' ')[0], 10);
  let index = 1;
  const m1 = [];
  for (let i = 0; i < n; i++) {
    let r = lines[index].split(' ');
    r = r.map(data => parseInt(data));
    m1.push([...r]);
    index++;
  }
  const m2 = [];
  for (let i = 0; i < n; i++) {
    let r = lines[index].split(' ');
    r = r.map(data => parseInt(data));
    m2.push([...r]);
    index++;
  }
  isPossible(m1, m2);
});

function isPossible(m1, m2) {
  for (let i = 0; i < m1.length; i++) {
    for (let j = 0; j < m1[i].length; j++) {
      if (m2[i][j] < m1[i][j]) {
        swap(m1, m2, i, j);
      }
    }
  }

  for (let i = 0; i < m1.length; i++) {
    for (let j = 0; j < m1[i].length; j++) {
      if (!isIncreasing(m1, i, j, m1[i][j]) || !isIncreasing(m2, i, j, m2[i][j])) {
        console.log('Impossible');
        return false;
      }
    }
  }

  console.log('Possible');
}

function swap(m1, m2, i, j) {
  const temp = m1[i][j];
  m1[i][j] = m2[i][j];
  m2[i][j] = temp;
}

function isIncreasing(m, i, j, curr) {
  // check above
  if (m[i - 1]) {
    if (m[i - 1][j] >= curr) return false;
  }

  // check below
  if (m[i + 1]) {
    if (m[i + 1][j] <= curr) return false;
  }

  // check left
  if (m[i][j - 1]) {
    if (m[i][j - 1] >= curr) return false;
  }

  // check right
  if (m[i][j + 1]) {
    if (m[i][j + 1] <= curr) return false;
  }
  return true;
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

var isPossiableM1 = false;
var isPossiableM2 = false;

function shuffle_checker(_m1, _m2, can_shuffle) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i + 1];
            if (nextCell) {
                if (cell >= nextCell && (!can_shuffle || (can_shuffle && alternative >= nextCell))) {
                    rows_check = false;
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            var alternative2 = _m2[j + 1] && _m2[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell && (!can_shuffle || (can_shuffle && alternative2 >= bottomCell))) {
                    cols_check = false;
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2, true);
p2 = shuffle_checker(m2, m1, false);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];
var shuffle_map = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                     shuffle_map[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
               shuffle_map[_j - lj][i] = false;
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

function shuffle_checker(_m1, _m2) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i];
            if (nextCell) {
                if (cell >= nextCell) {
                    rows_check = false;
                    if (alternative < nextCell && !shuffle_map[j][i]) {
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        rows_check = true;
                    }
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell) {
                    cols_check = false;
                    if (alternative < bottomCell && !shuffle_map[j][i]) {
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        cols_check = true;
                    }
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2);
p2 = shuffle_checker(m2, m1);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

var isPossiableM1 = false;
var isPossiableM2 = false;

function shuffle_checker(_m1, _m2, can_shuffle) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i + 1];
            if (nextCell) {
                if (cell >= nextCell && (!can_shuffle || (can_shuffle && alternative >= nextCell))) {
                    rows_check = false;
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            var alternative2 = _m2[j + 1] && _m2[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell && (!can_shuffle || (can_shuffle && alternative2 >= bottomCell))) {
                    cols_check = false;
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2, true);
p2 = shuffle_checker(m2, m1, true);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

var isPossiableM1 = false;
var isPossiableM2 = false;

function shuffle_checker(_m1, _m2, can_shuffle) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i];
            if (nextCell) {
                if (cell >= nextCell && (!can_shuffle || (can_shuffle && alternative >= nextCell))) {
                    rows_check = false;
                    print(alternative);
                    print(i, j);
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell && (!can_shuffle || (can_shuffle && alternative >= bottomCell))) {
                    cols_check = false;
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2, true);
p2 = shuffle_checker(m2, m1, true);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];
var shuffle_map = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                     shuffle_map[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
               shuffle_map[_j - lj][i] = false;
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

function shuffle_checker(_m1, _m2) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i];
            if (nextCell) {
                if (cell >= nextCell) {
                    rows_check = false;
                    if (alternative < nextCell && !shuffle_map[j][i]) {
                        shuffle_map[j][i] = true;
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        rows_check = true;
                    }
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell) {
                    cols_check = false;
                    if (alternative < bottomCell && !shuffle_map[j][i]) {
                        shuffle_map[j][i] = true;
                        _m2[j][i] = cell;
                        _m1[j][i] = alternative;
                        cols_check = true;
                    }
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2);
p2 = shuffle_checker(m2, m1);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

var m, n;

readline().split(' ').forEach(function(c, i) {
    if (i === 0) {
        m = parseInt(c);
        return;
    } else if  (i === 1) {
        n = parseInt(c);
    }
});

var m1 = [];
var m2 = [];

function fill_matrix(_m, _j, _i) {
    var lj = _j;
    var li = _i;
    while (lj > 0) {
        readline().split(' ').forEach(function(c, i) {
            if (i < li) {
                if (!_m[_j - lj]) {
                     _m[_j - lj] = [];
                }
               _m[_j - lj][i] = parseInt(c);
            }
        });
        lj --;
    }
}

fill_matrix(m1, m, n);
fill_matrix(m2, m, n);

var isPossiableM1 = false;
var isPossiableM2 = false;

function shuffle_checker(_m1, _m2, can_shuffle) {
    var rows_check = true;
    var cols_check = true;
    _m1.forEach(function(row, j) {
        row.forEach(function(cell, i) {
            if (!rows_check || !cols_check) {
                return;
            }
            var nextCell = _m1[j][i + 1];
            var alternative = _m2[j][i];
            if (nextCell) {
                if (cell >= nextCell && (!can_shuffle || (can_shuffle && alternative >= nextCell))) {
                    rows_check = false;
                }
            }
            var bottomCell = _m1[j + 1] && _m1[j + 1][i];
            if (bottomCell) {
                if (cell >= bottomCell && (!can_shuffle || (can_shuffle && alternative >= bottomCell))) {
                    cols_check = false;
                }
            }
        });
    });
    return rows_check && cols_check;
}

var p1 = false;
var p2 = false;

p1 = shuffle_checker(m1, m2, true);
p2 = shuffle_checker(m2, m1, true);

if (p1 && p2) {
    print('Possible');
} else {
    print('Impossible');
}

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const n = parseInt(lines[0].split(' ')[0], 10);
  let index = 1;
  const m1 = [];
  for (let i = 0; i < n; i++) {
    let r = lines[index].split(' ');
    r = r.map(data => parseInt(data));
    m1.push([...r]);
    index++;
  }
  const m2 = [];
  for (let i = 0; i < n; i++) {
    let r = lines[index].split(' ');
    r = r.map(data => parseInt(data));
    m2.push([...r]);
    index++;
  }
  isPossible(m1, m2);
});

function isPossible(m1, m2) {
  for (let i = 0; i < m1.length; i++) {
    for (let j = 0; j < m1[i].length; j++) {
      if (!isIncreasing(m1, i, j, m1[i][j]) || !isIncreasing(m2, i, j, m2[i][j])) {
        if (canSwap(m1, m2, i, j)) {
          swap(m1, m2, i, j);
        } else {
          console.log('Impossible');
          return;
        }
      }
    }
  }
  console.log('Possible');
}

function canSwap(m1, m2, i, j) {
  return isIncreasing(m1, i, j, m2[i][j]) && isIncreasing(m2, i, j, m1[i][j]);
}

function swap(m1, m2, i, j) {
  const temp = m1[i][j];
  m1[i][j] = m2[i][j];
  m2[i][j] = temp;
}

function isIncreasing(m, i, j, curr) {
  // check above
  if (m[i - 1]) {
    if (m[i - 1][j] >= curr) return false;
  }

  // check below
  if (m[i + 1]) {
    if (m[i + 1][j] <= curr) return false;
  }

  // check left
  if (m[i][j - 1]) {
    if (m[i][j - 1] >= curr) return false;
  }

  // check right
  if (m[i][j + 1]) {
    if (m[i][j + 1] <= curr) return false;
  }
  return true;
}


You still have partial information about the score during the historic football match. You are given a set of pairs $$$(a_i, b_i)$$$, indicating that at some point during the match the score was "$$$a_i$$$: $$$b_i$$$". It is known that if the current score is «$$$x$$$:$$$y$$$», then after the goal it will change to "$$$x+1$$$:$$$y$$$" or "$$$x$$$:$$$y+1$$$". What is the largest number of times a draw could appear on the scoreboard?The pairs "$$$a_i$$$:$$$b_i$$$" are given in chronological order (time increases), but you are given score only for some moments of time. The last pair corresponds to the end of the match.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10000$$$) — the number of known moments in the match. Each of the next $$$n$$$ lines contains integers $$$a_i$$$ and $$$b_i$$$ ($$$0 \le a_i, b_i \le 10^9$$$), denoting the score of the match at that moment (that is, the number of goals by the first team and the number of goals by the second team). All moments are given in chronological order, that is, sequences $$$x_i$$$ and $$$y_j$$$ are non-decreasing. The last score denotes the final result of the match.

Print the maximum number of moments of time, during which the score was a draw. The starting moment of the match (with a score 0:0) is also counted.

NoteIn the example one of the possible score sequences leading to the maximum number of draws is as follows: 0:0, 1:0, 2:0, 2:1, 3:1, 3:2, 3:3, 3:4.

var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var n = nums[0];
var x = 0, y = 0;
var ans = 0;
var last_cnt = -1;
for (var i=0; i<n; i++) {
	var a,b;
	nums = readline().split(" ").map(function(x) { return parseInt(x); });
	a = nums[0], b = nums[1];
	//if (a === x && b === y) continue;
	var xx, yy;
	xx = Math.max(x,y);
	yy = Math.min(a,b);
	if (xx <= yy) {
		if (xx === last_cnt) xx++;
		ans += (yy-xx+1);
		last_cnt = yy;
	}
	x = a; y = b;
}
//if (x === 0 && y === 0) ans++;
write(ans);

var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var n = nums[0];
var x = 0, y = 0;
var ans = 0;
for (var i=0; i<n; i++) {
	var a,b;
	nums = readline().split(" ").map(function(x) { return parseInt(x); });
	a = nums[0], b = nums[1];
	if (a === x && b === y) continue;
	var xx, yy;
	xx = Math.max(x,y);
	yy = Math.min(a,b);
	if (xx <= yy) ans += (yy-xx+1);
	x = a; y = b;
}
if (x === 0 && y === 0) ans++;
write(ans);


You are given a system of pipes. It consists of two rows, each row consists of $$$n$$$ pipes. The top left pipe has the coordinates $$$(1, 1)$$$ and the bottom right — $$$(2, n)$$$.There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types:  Types of pipes You can turn each of the given pipes $$$90$$$ degrees clockwise or counterclockwise arbitrary (possibly, zero) number of times (so the types $$$1$$$ and $$$2$$$ can become each other and types $$$3, 4, 5, 6$$$ can become each other).You want to turn some pipes in a way that the water flow can start at $$$(1, 0)$$$ (to the left of the top left pipe), move to the pipe at $$$(1, 1)$$$, flow somehow by connected pipes to the pipe at $$$(2, n)$$$ and flow right to $$$(2, n + 1)$$$.Pipes are connected if they are adjacent in the system and their ends are connected. Here are examples of connected pipes:  Examples of connected pipes Let's describe the problem using some example:  The first example input And its solution is below:   The first example answer As you can see, the water flow is the poorly drawn blue line. To obtain the answer, we need to turn the pipe at $$$(1, 2)$$$ $$$90$$$ degrees clockwise, the pipe at $$$(2, 3)$$$ $$$90$$$ degrees, the pipe at $$$(1, 6)$$$ $$$90$$$ degrees, the pipe at $$$(1, 7)$$$ $$$180$$$ degrees and the pipe at $$$(2, 7)$$$ $$$180$$$ degrees. Then the flow of water can reach $$$(2, n + 1)$$$ from $$$(1, 0)$$$.You have to answer $$$q$$$ independent queries.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of queries. Then $$$q$$$ queries follow. Each query consists of exactly three lines. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of pipes in each row. The next two lines contain a description of the first and the second rows correspondingly. Each row description consists of $$$n$$$ digits from $$$1$$$ to $$$6$$$ without any whitespaces between them, each digit corresponds to the type of pipe in the corresponding cell. See the problem statement to understand which digits correspond to which types of pipes. It is guaranteed that the sum of $$$n$$$ over all queries does not exceed $$$2 \cdot 10^5$$$.

For the $$$i$$$-th query print the answer for it — "YES" (without quotes) if it is possible to turn some pipes in a way that the water flow can reach $$$(2, n + 1)$$$ from $$$(1, 0)$$$, and "NO" otherwise.

NoteThe first query from the example is described in the problem statement.

'use strict'

const tube = (n, l) => {
    let from = 'left';
    let x = 0;
    let y = 0;
    while (x < n) {
        if (l[y][x]) { if (from === 'left') x++; else return 'NO'; }
        else {
            if (from === 'left') {
                if (y) { y = 0; from = 'bottom';}
                else { y = 1; from = 'top'; }
            }
            else { x++; from = 'left'; }
        }
    }

    return y ? 'YES' : 'NO';
}
const q = parseInt(readline());

for (let i = 0; i < q; i++) {
    write(tube(parseInt(readline()), [ readline().split('').map(i => parseInt(i) < 3), readline().split('').map(i => parseInt(i) < 3) ]) + '\n');
}

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')
  const q = parseInt(arr.shift())

  let lineCount = 0
  for(let i = 0; i < q; i++) {
    const n = parseInt(arr[lineCount ++])
    const a1 = arr[lineCount ++]
    const a2 = arr[lineCount ++ ]

    let i = 0, j = -1, currentRow = 1
    let shift = false
    while(j < n && i < n){
      // console.log(i, j, currentRow)
      if(currentRow == 1) {
        if(a1[i] <= 2 && !shift) i++
        else if(a1[i] <= 2 && shift) break
        else if(a1[i] >= 3 && shift) {
          shift = false
          i ++
        }
        else{
          currentRow = 2
          shift = true
          j = i
        }
      }
      else {
        // if(j == 6) console.log(a2[j])
        if(a2[j] <= 2 && !shift) j++
        else if(a2[j] <= 2 && shift) break
        else if(a2[j] >= 3 && shift) {
          // console.log('kl')
          shift = false
          j ++
        }
        else{
          currentRow = 1
          shift = true
          i = j
        }
      }
    }
    if(j == n) console.log('YES')
    else console.log('NO')

    // console.log()
    // console.log()
    // console.log()
  }
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const q = readline();
    for(let i = 0;i<q;i++){
        const length = readline();
        const matrix = [];
        const firstRow = readline().split('').map((value,index,array)=>{return parseInt(value)});
        const secondRow = readline().split('').map((value,index,array)=>{return parseInt(value)});
        matrix[0] = firstRow;
        matrix[1] = secondRow;
        calcQuery(length,matrix);
    }
}

function calcQuery(length,matrix){
    let y = 0;
    for(let x = 0; x < length;x++){
        if(matrix[y][x] > 2 && matrix[(y+1)%2][x] < 3){
            console.log("NO");
            return;
        }
        if(matrix[y][x] > 2 && matrix[(y+1)%2][x] > 2){
            y = (y+1) % 2;
        }
    }
    if(y != 1){
        console.log("NO");
        return;
    }
    console.log("YES");
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const q = readline();
    for(let i = 0;i<q;i++){
        const length = readline();
        const matrix = [];
        const firstRow = readline().split('').map((value,index,array)=>{return parseInt(value)});
        const secondRow = readline().split('').map((value,index,array)=>{return parseInt(value)});
        matrix[0] = firstRow;
        matrix[1] = secondRow;
        calcQuery(length,matrix);
    }
}

function calcQuery(length,matrix){
    let counter = 0;
    for(let i = 0; i < length;i++){
        if(matrix[0][i] < 3 && matrix[1][i] > 2){
            console.log("NO");
            return;
        }
        if(matrix[0][i] > 2 && matrix[1][i] < 3){
            console.log("NO");
            return;
        }
        if(matrix[0][i] < 3 && matrix[1][i] < 3){
            counter ++;
        }
    }
    if((length - counter) % 2 == 0){
        console.log("NO");
        return;
    }
    console.log("YES");
}