'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() {
    const x = readline();
    var cases = parseInt(x);
    //console.log("Cases",cases);
    for(var i=1;i<=cases;i++){
         //console.log("case ",i);
         var line2 = readline();
         var dims = line2.split(" ");
         var r = parseInt(dims[0]);
         var g = parseInt(dims[1]);
         var b = parseInt(dims[2]);
         var w = parseInt(dims[3]);
         console.log(getresult(r,g,b,w));
    }

}

function getresult(r,g,b,w){
    var numOdds = 0;
    var min = Math.min(r,g,b);

    if(r%2 == 1){
        numOdds++;
    }
    if(g%2 == 1){
        numOdds++;
    }
    if(b%2 == 1){
        numOdds++;
    }
    if(numOdds == 3){
        return "Yes";
    }
    if(numOdds == 2){
        return (w%2 === 1 && min >= 1) ? "Yes" : "No";
    }
    if(numOdds == 1){
       return w%2 === 0 ? "Yes":"No";
    }
    if(numOdds === 0){
        return "Yes";
    }

    return "No"
}

const isPossiblePalindrome = (input) => {
  var oddCount = 0;

  for (var j = 0; j < 4; j++) {
    if (input[j] % 2) {
      oddCount++;
    }
  }

  return oddCount <= 1;
};

const main = () => {
  const N = Number(readline());

  for (var i = 0; i < N; i++) {
    var input = readline()
      .split(" ")
      .map((i) => Number(i));

    if (isPossiblePalindrome(input)) {
      print("Yes");
      continue;
    }

    var min = Math.min(input[0], input[1], input[2]);

    if (min === 0) {
      print("No");
      continue;
    }

    input[0]--;
    input[1]--;
    input[2]--;
    input[3] += 3;

    if (isPossiblePalindrome(input)) {
      print("Yes");
      continue;
    }

    if (min === 1) {
      print("No");
      continue;
    }

    input[0]--;
    input[1]--;
    input[2]--;
    input[3] += 3;

    if (isPossiblePalindrome(input)) {
      print("Yes");
    } else {
      print("No");
    }
  }
};

main();

var readline=require("readline");
var rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
var arr=[];
rl.on('line',function(inp){
    arr.push(inp);
    if(arr.length>1){
        var t=arr[arr.length-1].split(' ');
        for(var i=0;i<t.length;i++) t[i]=parseInt(t[i]);
        var ans=0;
        for(var i=0;i<t.length;i++) if(t[i]%2==1) ans++;
        if(ans>1){
            var flag=0;
            for(var i=0;i<t.length-1;i++){
                if(t[i]===0){
                    console.log("No");
                    flag=1;break;
                }
            }
            if(flag==0){
                t[t.length-1]+=3;ans=0;
                for(var i=0;i<t.length-1;i++) t[i]--;
                for(var i=0;i<t.length;i++) if(t[i]%2==1) ans++;
                if(ans>1) console.log("No");
                else console.log("Yes");
            }
        }
        else console.log("Yes");
    }
    if(arr.length==(parseInt(arr[0])+1)) process.exit(0);
});

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 cases = +readLine()
    for(let i = 0; i < cases; i++) {
        console.log(possiblePali(readLine().split(' ').map(Number)) ? 'Yes' : 'No')
    }
}

function possiblePali(balls) {
    for(let i = 0; i < 3; i++) {
        if(balls.filter(b => b&1).length < 2) return true
        const [r, g, b, w] = balls
        if(r > 0 && g > 0 && b > 0) balls = [r - 1, g - 1, b - 1, w + 1]
    }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [countOdd, countEven, count0] = [0, 0, 0];
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n, index) => {
        n = parseInt(n);
        if (n % 2 === 0) countEven++;
        else countOdd++;
        if (n === 0 && index !== 3) count0++;
        return n;
      });
    if (count0 > 0 && countEven < 3) {
      console.log("No");
    } else {
      if (count0 === 4 || countOdd <= 1 || countOdd >= 3) {
        console.log("Yes");
      } else console.log("No");
    }
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var tmp = nextIntArray();
    var r = tmp[0];
    var g = tmp[1];
    var b = tmp[2];
    var w = tmp[3];
    if(r > 0 && g > 0 && b > 0){

      for(var j = 0; j <= 3; j++){
        var list = [r - j, b - j, g - j, w + (j * 3)];
        var oddCount = 0;
        var isOK = false;
        var isNG = false;
        for(var k = 0; k < 4; k++){
          if(list[k] < 0){
            isNG = true;
            break;
          }
          if(list[k] % 2 == 1){
            oddCount++;
          }
        }
        if(isNG){
          break;
        }
        if(oddCount <= 1){
          output[i] = "Yes";
          isOK = true;
          break;
        }
      }
      if(output[i] == null){
        output[i] = "No";
      }
    }else{
      var odd = 0;
      odd += (r % 2 != 0) ? 1 : 0;
      odd += (g % 2 != 0) ? 1 : 0;
      odd += (b % 2 != 0) ? 1 : 0;
      odd += (w % 2 != 0) ? 1 : 0;
      if(odd > 1){
        output[i] = "No";
      }else{
        output[i] = "Yes";
      }
    }
  }
  myout(myconv(output, 9));
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  const t = Number(readLine())
  for (let i = 0; i < t; i++) {
    const counts = readLine().split(/\s/).map(Number)
    const w = counts.pop()
    const oddCount = counts.reduce((acc, curr) => acc + (curr % 2), 0)
    if (w % 2 === 0) {
      console.log(oddCount === 2 ? 'No' : 'Yes')
    } else {
      switch (oddCount) {
        case 0:
        case 3:
          console.log('Yes')
          break
        case 1:
          console.log('No')
          break
        case 2:
          console.log(counts.every(count => count !== 0) ? 'Yes' : 'No')
          break
      }
    }
  }
}

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

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

function main() {
	let n = readLine() >> 0;
	while (n--) {
		let odd = 0,
			even = 0,
			zero = 0;
		let c = readLine()
			.split(' ')
			.map((x, i) => {
				x = x >> 0;
				if (i < 3 && x === 0) zero++;
				if ((x & 1) === 1) {
					odd++;
				} else {
					even++;
				}
				return x;
			});

		if (even >= 3) {
			console.log('Yes');
		} else {
			if (zero > 0) console.log('No');
			else {
				if (odd > even) [odd, even] = [even, odd];
				if (even >= 3) {
					console.log('Yes');
				} else {
					console.log('No');
				}
			}
		}
	}
}

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

    A();
});

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

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

    return a;
}

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

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [r,g,b,w] = ti(readline().split(' '));
        if(r%2 === 0 && g%2 === 0 && b%2 === 0){
            console.log('Yes');
            continue;
        }else if(r%2 === 0 && g%2 === 0 && b%2 !== 0 || r%2 === 0 && g%2 !== 0 && b%2 === 0 || r%2 !== 0 && g%2 === 0 && b%2 === 0){
            if(w%2 === 0)
                console.log('Yes');
            else
                console.log('No');
            continue;
        }else if(r%2 !== 0 && g%2 !== 0 && b%2 === 0 && b !== 0 || r%2 !== 0 && g%2 === 0 && b%2 !== 0 && g !== 0 || r%2 === 0 && g%2 !== 0 && b%2 !== 0 && r !== 0){
            if(w%2 !== 0)
                console.log('Yes');
            else
                console.log('No');
            continue;
        }else if(r%2 !== 0 && g%2 !== 0 && b%2 !== 0){
            console.log('Yes');
            continue;
        }
        else{
            console.log('No');
        }
    }
}

const main = () => {
  const N = Number(readline());

  for (var i = 0; i < N; i++) {
    var input = readline()
      .split(" ")
      .map((i) => Number(i));

    var min = Math.min(input[0], input[1], input[2]);

    if (input[0] === min) {
      input[0] = 0;
      input[1] -= min;
      input[2] -= min;
    } else if (input[1] === min) {
      input[0] -= min;
      input[1] = 0;
      input[2] -= min;
    } else {
      input[0] -= min;
      input[1] -= min;
      input[2] = 0;
    }

    input[3] += 3 * min;

    var oddCount = 0;
    var positiveCount = 0;

    for (var j = 0; j < 4; j++) {
      if (input[j] % 2) {
        oddCount++;
      }
      if (input[j] > 0) {
        positiveCount++;
      }
    }

    if (oddCount === 1 || positiveCount <= 1) {
      print("Yes");
    } else {
      print("No");
    }
  }
};

main();

const isPossiblePalindrome = (input) => {
  var oddCount = 0;
  var positiveCount = 0;

  for (var j = 0; j < 4; j++) {
    if (input[j] % 2) {
      oddCount++;
    }
    if (input[j] > 0) {
      positiveCount++;
    }
  }

  return oddCount === 1 || positiveCount <= 1;
};

const main = () => {
  const N = Number(readline());

  for (var i = 0; i < N; i++) {
    var input = readline()
      .split(" ")
      .map((i) => Number(i));

    if (isPossiblePalindrome(input)) {
      print("Yes");
      continue;
    }

    var min = Math.min(input[0], input[1], input[2]);

    if (input[0] === min) {
      input[0] = 0;
      input[1] -= min;
      input[2] -= min;
    } else if (input[1] === min) {
      input[0] -= min;
      input[1] = 0;
      input[2] -= min;
    } else {
      input[0] -= min;
      input[1] -= min;
      input[2] = 0;
    }

    input[3] += 3 * min;

    if (isPossiblePalindrome(input)) {
      print("Yes");
    } else {
      print("No");
    }
  }
};

main();

'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() {
    const x = readline();
    var cases = parseInt(x);
    //console.log("Cases",cases);
    for(var i=1;i<=cases;i++){
         //console.log("case ",i);
         var line2 = readline();
         var dims = line2.split(" ");
         var r = parseInt(dims[0]);
         var g = parseInt(dims[1]);
         var b = parseInt(dims[2]);
         var w = parseInt(dims[3]);
         console.log(getresult(r,g,b,w));
    }

}

function getresult(r,g,b,w){
    var numOdds = 0;
    var min = Math.min(r,g,b);
    if(r%2 == 1){
        numOdds++;
    }
    if(g%2 == 1){
        numOdds++;
    }
    if(b%2 == 1){
        numOdds++;
    }
    if(numOdds == 3){
        return true;
    }
    if(numOdds == 2){
        return (w%2 === 1 && min >= 1) ? "Yes" : "No";
    }
    if(numOdds == 1){
       return w%2 === 0 ? "Yes":"No";
    }
    if(numOdds === 0){
        return "Yes";
    }

    return "No"
}

function minChanges(arr){
   var pathCovered = [];

   var dp = [];

   for(var i =0; i<arr.length;i++){
       var rw = [];
       var cl = arr[0].length;
       for(var j=0;j<cl;j++){
           rw.push(0);
       }
       dp.push(rw);
   }

   dp[0][0] = 0;

   var cleng = arr[0].length;

   var rowLast = arr[arr.length-1][cleng-1];

   for(var row = 0;row<arr.length;row++){
       var colLength = arr[0].length;
       for(var col = 0; col < colLength ; col++){
           var minValFromLeft = 10000;
           var minValFromTop = 10000;
           if(row === 0 && col === 0){
              minValFromLeft = 0;
              minValFromTop = 0;
           }
           if(col>0){
               var leftElem = arr[row][col-1];
               if(leftElem == "R"){
                  minValFromLeft = dp[row][col-1];
               }
               else{
                minValFromLeft = 1+dp[row][col-1];
               }
           }
           if(row>0){
                var topElem = arr[row-1][col];
                if(topElem == "D"){
                    minValFromTop = dp[row-1][col];
                }
                else{
                    minValFromTop = 1+dp[row-1][col];
                }
           }
          dp[row][col] = Math.min(minValFromLeft,minValFromTop);
       }
   }

   return dp[arr.length-1][cleng-1];
}

var readline=require("readline");
var rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
var arr=[];
rl.on('line',function(inp){
    arr.push(inp);
    if(arr.length>1){
        var t=arr[arr.length-1].split(' ');
        for(var i=0;i<t.length;i++) t[i]=parseInt(t[i]);
        var minn=1e12,ans=0;
        for(var i=0;i<t.length-1;i++) minn=Math.min(minn,t[i]);
        for(var i=0;i<t.length;i++){
            if(i==t.length-1) t[i]+=minn;
            else t[i]-=minn;
            if(t[i]%2!=0) ans++;
        }
        if(ans>1) console.log("No");
        else console.log("Yes");
    }
    if(arr.length==(parseInt(arr[0])+1)) process.exit(0);
});

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 cases = +readLine()
    for(let i = 0; i < cases; i++) {
        console.log(possiblePali(readLine().split(' ').map(Number)) ? 'Yes' : 'No')
    }
}

function possiblePali(balls) {
    console.log(balls)

    for(let i = 0; i < 3; i++) {
        if(balls.filter(b => b&1).length < 2) return true
        const [r, g, b, w] = balls
        console.log({r, g, b, w})
        if(r > 0 && g > 0 && b > 0) balls = [r - 1, g - 1, b - 1, w + 1]
    }
}

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 cases = +readLine()
    for(let i = 0; i < cases; i++) {
        console.log(possiblePali(readLine().split(' ').map(Number)) ? 'Yes' : 'No')
    }
}

function possiblePali(balls) {
    console.log(balls)

    for(let i = 0; i < 3; i++) {
        if(balls.filter(b => b&1).length < 2) return true
        const [r, g, b, w] = balls
        if(r > 0 && g > 0 && b > 0) balls = [r - 1, g - 1, b - 1, w + 1]
    }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    if (a === 0 && b === 0 && c === 0 && d === 0) {
      console.log("Yes");
    } else {
      if (a === 0 || b === 0 || c === 0 || d === 0) {
        console.log("No");
      } else {
        const min = Math.min(a, b, c);
        a = a - min;
        b = b - min;
        c = c - min;
        d = d + 3 * min;
        let [countEven, countOdd] = [0, 0];
        if (a % 2 === 0) countEven++;
        else countOdd++;
        if (b % 2 === 0) countEven++;
        else countOdd++;
        if (c % 2 === 0) countEven++;
        else countOdd++;
        if (d % 2 === 0) countEven++;
        else countOdd++;

        if ((countOdd === 1 && countEven === 3) || countOdd === 4 || countEven === 4) console.log("Yes");
        else console.log("No");
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [countOdd, countEven, count0] = [0, 0, 0];
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n % 2 === 0) countEven++;
        else countOdd++;
        if (n === 0) count0++;
        return n;
      });
    if ((a === 0 || b === 0 || c === 0) && count0 < 3) {
      console.log("No");
    } else {
      if (count0 === 4 || countOdd <= 1 || countOdd >= 3) {
        console.log("Yes");
      } else console.log("No");
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    if (a === 0 && b === 0 && c === 0 && d === 0) {
      console.log("Yes");
    } else {
      if (a === 0 || b === 0 || c === 0 || d === 0) {
        console.log("No");
      } else {
        const min = Math.min(a, b, c);
        a = a - min;
        b = b - min;
        c = c - min;
        d = d + 3 * min;
        let [countEven, countOdd] = [0, 0];
        if (a % 2 === 0) countEven++;
        else countOdd++;
        if (b % 2 === 0) countEven++;
        else countOdd++;
        if (c % 2 === 0) countEven++;
        else countOdd++;
        if (d % 2 === 0) countEven++;
        else countOdd++;

        if (countOdd === 1 || countOdd === 4 || countEven === 4) console.log("Yes");
        else console.log("No");
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    if (a === 0 && b === 0 && c === 0 && d === 0) {
      console.log("YES");
    } else {
      if (a === 0 || b === 0 || c === 0 || d === 0) {
        console.log("NO");
      } else {
        console.log("YES");
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [countOdd, countEven, count0] = [0, 0, 0];
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n % 2 === 0) countEven++;
        else countOdd++;
        if (n === 0) count0++;
        return n;
      });
    if (count0 > 0 && count0 < 3) {
      console.log("No");
    } else {
      if (count0 === 4 || countOdd <= 1 || countOdd >= 3) {
        console.log("Yes");
      } else console.log("No");
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    if (a === 0 && b === 0 && c === 0) {
      console.log("Yes");
    } else {
      if (a === 0 || b === 0 || c === 0) {
        console.log("No");
      } else {
        const min = Math.min(a, b, c);
        a = a - min;
        b = b - min;
        c = c - min;
        d = d + 3 * min;
        let [countEven, countOdd] = [0, 0];
        if (a % 2 === 0) countEven++;
        else countOdd++;
        if (b % 2 === 0) countEven++;
        else countOdd++;
        if (c % 2 === 0) countEven++;
        else countOdd++;
        if (d % 2 === 0) countEven++;
        else countOdd++;

        if ((a === min && b === min && c === min) || countOdd === 1 || countEven === 4) console.log("Yes");
        else console.log("No");
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let [countOdd, countEven, count0] = [0, 0, 0];
    let [a, b, c, d] = readLine()
      .split(" ")
      .map((n) => {
        n = parseInt(n);
        if (n % 2 === 0) countEven++;
        else countOdd++;
        if (n === 0) count0++;
        return n;
      });
    if ((a === 0 || b === 0 || c === 0) && count0 !== 4) {
      console.log("No");
    } else {
      if (count0 === 4 || countOdd <= 1 || countOdd >= 3) {
        console.log("Yes");
      } else console.log("No");
    }
  }
}

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

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

function main() {
	let n = readLine() >> 0;
	while (n--) {
		let odd = 0,
			even = 0,
			zero = 0;
		let c = readLine()
			.split(' ')
			.map(x => {
				x = x >> 0;
				if (x === 0) zero++;
				if ((x & 1) === 1) {
					odd++;
				} else {
					even++;
				}
				return x;
			});

		let s = c.reduce((a, c) => a + c);

		if (even >= 3) {
			console.log('Yes');
		} else {
			if (zero > 0) console.log('No');
			else {
				if (odd > even) [odd, even] = [even, odd];
				if (even >= 3) {
					console.log('Yes');
				} else {
					console.log('No');
				}
			}
		}
	}
}

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

    A();
});

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

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

    return a;
}

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

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [r,g,b,w] = ti(readline().split(' '));
        if(r%2 === 0 && g%2 === 0 && b%2 === 0){
            console.log('Yes');
            continue;
        }else if(r%2 === 0 && g%2 === 0 && b%2 !== 0 || r%2 === 0 && g%2 !== 0 && b%2 === 0 || r%2 !== 0 && g%2 === 0 && b%2 === 0){
            console.log('Yes');
            continue;
        }else if(r%2 !== 0 && g%2 !== 0 && b%2 === 0 && b !== 0 || r%2 !== 0 && g%2 === 0 && b%2 !== 0 && g !== 0 || r%2 === 0 && g%2 !== 0 && b%2 !== 0 && r !== 0){
            console.log('yes');
            continue;
        }else{
            console.log('No');
            continue;
        }
    }
}


function solve() {
    const [n, m] = readArray(Number);
    const matr = [];
    function canDraw(x, y) {
        if (x < 0 || x >= n) {
            return false;
        }
        if (y < 0 || y >= m) {
            return false;
        }
        return matr[x][y] === '0';
    }
    for (let i = 0; i < n; i++) {
        matr.push(read());
    }
    if (matr[0][0] === '1') {
        write(-1);
        return;
    }
    const ans = [];
    for (let i = n - 1; i > 0; i--) {
        for (let j = m - 1; j >= 0; j--) {
            if (matr[i][j] === '1') {
                ans.push([i, j + 1, i + 1, j + 1]);
            }
        }
    }
    for (let j = m - 1; j > 0; j--) {
        if (matr[0][j] === '1') {
            ans.push([1, j, 1, j + 1]);
        }
    }
    write(ans.length);
    for (const draw of ans) {
        write(draw.join(' '));
    }
}

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

try {
    initInput(start);
} catch (e) {
    write(e);
}

var MEMORY;
var MEMORY_INDEX;
function readArray(f) {
    return read().split(' ').map(f);
}
function write(value) {
    console.log(value);
}
function read() {
    return MEMORY[MEMORY_INDEX++];
}
function initInput(callback) {
    var fs = require('fs');
    var isLocalStart = process.argv[2] === 'lorelvate';
    if (isLocalStart) {
        var path = require('path');
        fs.readFile(path.join(__dirname, 'input.txt'), 'utf8', (err, data) => {
            if (err) {
                write(err);
                return;
            }
            MEMORY = data.split('\r\n');
            MEMORY_INDEX = 0;
            callback();
        });
        return;
    }
    MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
    MEMORY_INDEX = 0;
    callback();
}

function solve() {
   const [n, m] = readArray(Number);
   const matr = [];
   function canDraw(x, y) {
      if (x < 0 || x >= n) {
         return false;
      }
      if (y < 0 || y >= m) {
         return false;
      }
      return matr[x][y] === '0';
   }
   for (let i = 0; i < n; i++) {
      matr.push(read());
   }
   if (matr[0][0] === '1') {
      write(-1);
      return;
   }
   const ans = [];
   for (let i = n - 1; i > 0; i--) {
      for (let j = m - 1; j >= 0; j--) {
         if (matr[i][j] === '1') {
            ans.push([i, j + 1, i + 1, j + 1]);
         }
      }
   }
   for (let j = m - 1; j > 0; j--) {
      if (matr[0][j] === '1') {
         ans.push([1, j, 1, j + 1]);
      }
   }
   write(ans.length);
   for (const draw of ans) {
      write(draw.join(' '));
   }
}

function countBeatyMul(x, d, start) {
   if (x % d !== 0) {
      return 0;
   }
   if (isBeaty(x, d)) {
      return 1;
   }
   let ans = 0;
   for (let i = start; i <= Math.floor(Math.sqrt(x)); i++) {
      if (x % i !== 0) {
         continue;
      }
      const xDivI = Math.floor(x / i);
      if (xDivI < start) {
         continue;
      }
      if (isBeaty(i, d)) {
         ans += countBeatyMul(xDivI, d, i)
      }
   }
   return ans;
}

function isBeaty(x, d) {
   return x % d === 0 && x % (d * d) !== 0;
}

function init() {
   try {
      var T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');

   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

"use strict";

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

let inputStr = "";
let currentLne = 0;

process.stdin.on('data' , inputStdin =>{

	 inputStr += inputStdin;
})

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

main();
})

function readline(){
   return inputStr[currentLne++];
}

function main(){
   let t = parseInt(readline());
   let c =0;

   while(c<t){
        let mat = readline().split(" ").map(a => parseInt(a));
        let tr = mat[0];
        let count =0;
        let arrd=[]
           while(count<tr){
              let rows = readline().split("").map(b=> parseInt(b));
              arrd.push(rows);
              count++;
           }
         let newarr = new Array();
         let co =0;
         for (var i = arrd.length-1; i>=0 ; i--) {
               for (var j = arrd[0].length-1; j >=0  ; j--) {
                if(arrd[i][j]==1){
                     co++;
                }
            }
         }

         if(arrd[0][0] ==1){
           console.log(-1);
         }else{
             console.log(co);
             for (var i = arrd.length-1; i>=0 ; i--) {
             for (var j = arrd[0].length-1; j >=0  ; j--) {
                if(arrd[i][j]==1){
                     co++;
                          if(j - 1 >= 0) {
                              console.log(i+1,j,i+1,j+1);

                          }
                          else {
                             console.log(i,j+1,i+1,j+1);

                          }
                     }
                 }
             }
         }
      c++
   }

}

//type input.txt | node code.js

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

E.s2a = (arr)=>arr.map(a=>a.split('').map(c=>c=='0' ? 0 : 1))

const calc = (arr)=>{
  arr = E.s2a(arr);
  if (arr[0][0]==1)
    return false;
  let q = [];
  let n = arr.length;
  let m = arr[0].length;
  for (let i=n-1; i>=0; i--){
    for (let j=m-1; j>=0; j--){
      if (arr[i][j]){
        if (i)
          q.push({fromI: i-1, toI: i, fromJ: j, toJ: j});
        else
          q.push({fromI: i, toI: i, fromJ: j-1, toJ: j});
      }
      else
          q.push({fromI: i, toI: i, fromJ: j, toJ: j});
    }
  }
  return q
};

function main() {
    let T = +readline();
    while (T--){
      let [n, m] = ra();
      let arr = [];
      for (let i=0;i<n;i++)
        arr.push(readline());
      let q = calc(arr);
      if (!q)
        print(-1)
      else {
        print(q.length);
        for (let p of q){
          print(p.fromI+1, p.fromJ+1, p.toI+1, p.toJ+1);
        }
      }
    }
}

E.calc = calc;

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

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

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m, s) {
  if (s[0][0] === '1') return -1;
  let res = [];
  for (let i = n - 1; i >= 0; i--) {
    for (let j = m - 1; j >= 0; j--) {
      if (s[i][j] === '1') res.push(j === 0 ? [i, j + 1, i + 1, j + 1] : [i + 1, j, i + 1, j + 1]);
    }
  }
  return res.length + '\n' + res.map(arr => arr.join(' ')).join('\n');
}

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

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

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 testCases = Number(readline());
  for (let t = 0; t < testCases; t++) {
    let [m, n] = readline().split(" ").map(Number);
    let board = [];

    let row = readline().split("").map(Number);
    board.push(row);

    if (board[0][0] === 1) {
      console.log(-1);
      for (let i = 1; i < m; i++) {
        readline();
      }
    } else {
      for (let i = 1; i < m; i++) {
        let row = readline().split("").map(Number);
        board.push(row);
      }
      console.log(m * n);
      for (let i = m - 1; i >= 0; i--) {
        for (let j = n - 1; j >= 0; j--) {
          if (board[i][j] === 1) {
            if (j === 0) {
              console.log(i - 1 + 1, j + 1, i + 1, j + 1);
            } else {
              console.log(i + 1, j - 1 + 1, i + 1, j + 1);
            }
          } else {
            console.log(i + 1, j + 1, i + 1, j + 1);
          }
        }
      }
    }
  }
}

var tests = parseInt(readline());
    var n,m;
    var mat;
    for (var ti=0; ti < tests; ti++) {
        var nm = readline().split(' ').map(x=>parseInt(x));
        n = nm[0];
        m = nm[1];
        mat = [];
        for (var i = 0; i < n; i++) {
            var row = readline().split('').map(x=>parseInt(x));
            mat.push(row);
        }
        if (mat[0][0]) {
            print('-1');
            continue;
        }

        var ans = [];
        for (var r = n-1; r >= 0; r--) {
            for (var c = m-1; c >= 1; c--) {
                if (mat[r][c]) {
                    ans.push([r+1, c, r+1, c+1]);
                }
            }
        }

        for (var r = n-1; r > 0; r--) {
            if (mat[r][0]) {
                ans.push([r, 1, r+1, 1]);
            }
        }

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

function solve() {
    const [n, m] = readArray(Number);
    const matr = [];
    function canDraw(x, y) {
        if (x < 0 || x >= n) {
            return false;
        }
        if (y < 0 || y >= m) {
            return false;
        }
        return matr[x][y] === '0';
    }
    for (let i = 0; i < n; i++) {
        matr.push(read());
    }
    if (matr[0][0] === '1') {
        write(-1);
        return;
    }
    const ans = [];
    for (let i = n - 1; i > 0; i--) {
        for (let j = m - 1; j >= 0; j--) {
            if (matr[i][j] === '1') {
                ans.push([i, j + 1, i + 1, j + 1]);
            }
        }
    }
    for (let j = m - 1; j > 0; j--) {
        if (matr[0][j] === '1') {
            ans.push([1, j, 1, j + 1]);
        }
    }
    write(ans.length);
    for (const draw of ans) {
        write(draw.join(' '));
    }
}

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

try {
    initInput(start);
} catch (e) {
    write(e);
}

var MEMORY;
var MEMORY_INDEX;
function readArray(f) {
    return read().split(' ').map(f);
}
var ANS;
function write(value) {
    ANS += value + '\n';
}
function writeAns() {
    console.log(ANS);
}
function read() {
    return MEMORY[MEMORY_INDEX++];
}
function initInput(callback) {
    var fs = require('fs');
    var isLocalStart = process.argv[2] === 'lorelvate';
    if (isLocalStart) {
        var path = require('path');
        fs.readFile(path.join(__dirname, 'input.txt'), 'utf8', (err, data) => {
            if (err) {
                write(err);
                return;
            }
            MEMORY = data.split('\r\n');
            ANS = '';
            MEMORY_INDEX = 0;
            callback();
        });
        return;
    }
    MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
    ANS = '';
    MEMORY_INDEX = 0;
    callback();
}

"use strict";

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

let inputStr = "";
let currentLne = 0;

process.stdin.on('data' , inputStdin =>{

	 inputStr += inputStdin;
})

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

main();
})

function readline(){
   return inputStr[currentLne++];
}

function main(){
   let t = parseInt(readline());
   let c =0;

   while(c<t){
        let mat = readline().split(" ").map(a => parseInt(a));
        let tr = mat[0];
        let count =0;
        let arrd=[]
           while(count<tr){
              let rows = readline().split("").map(b=> parseInt(b));
              arrd.push(rows);
              count++;
           }

let newarr = new Array();
// let x =[]
// for (var o = 0; o < newarr.length; o++) {
//     newarr[o] = new Array(5).fill(0);
// }

// let m =0;
// let n =0;
// let co =0;
let co =0;

for (var i = arrd.length-1; i>=0 ; i--) {
      for (var j = arrd[0].length-1; j >=0  ; j--) {
       if(arrd[i][j]==1){
            co++;
       }
   }
}
console.log(co);
if(arrd[0][0] ==1){
  console.log(-1);
}else{
    for (var i = arrd.length-1; i>=0 ; i--) {
    for (var j = arrd[0].length-1; j >=0  ; j--) {
       if(arrd[i][j]==1){
            co++;
                 if(j - 1 >= 0) {
                     console.log(i+1,j,i+1,j+1);
                     // cout << i + 1 << " " << j << " ";
                     // cout << i + 1 << " " << j + 1 << endl;
                 }
                 else {
                    console.log(i,j+1,i+1,j+1)
                      // cout << i << " " << j + 1 << " " ;
                      // cout << i + 1 << " " << j + 1 << endl;
                 }
      }
     }
    }
}
// console.log(newarr);

      c++
   }

}

//type input.txt | node code.js

"use strict";

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

let inputStr = "";
let currentLne = 0;

process.stdin.on('data' , inputStdin =>{

	 inputStr += inputStdin;
})

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

main();
})

function readline(){
   return inputStr[currentLne++];
}

function main(){
   let t = parseInt(readline());
   let c =0;

   while(c<t){
        let mat = readline().split(" ").map(a => parseInt(a));
        let tr = mat[0];
        let count =0;
        let arrd=[]
           while(count<tr){
              let rows = readline().split("").map(b=> parseInt(b));
              arrd.push(rows);
              count++;
           }

let newarr = new Array();
// let x =[]
// for (var o = 0; o < newarr.length; o++) {
//     newarr[o] = new Array(5).fill(0);
// }

// let m =0;
// let n =0;
// let co =0;
let co =0;

for (var i = arrd.length-1; i>=0 ; i--) {
      for (var j = arrd[0].length-1; j >=0  ; j--) {
       if(arrd[i][j]==1){
            co++;
       }
   }
}
console.log(co);
if(arrd[0][0] ==1){
  console.log(-1);
}else{
    for (var i = arrd.length-1; i>=0 ; i--) {
    for (var j = arrd[0].length-1; j >=0  ; j--) {
       if(arrd[i][j]==1){
            co++;
                 if(j - 1 >= 0) {
                     console.log(i+1," ",j," ",i+1," ",j+1);
                     // cout << i + 1 << " " << j << " ";
                     // cout << i + 1 << " " << j + 1 << endl;
                 }
                 else {
                    console.log(i," ",j+1," ",i+1," ",j+1)
                      // cout << i << " " << j + 1 << " " ;
                      // cout << i + 1 << " " << j + 1 << endl;
                 }
      }
     }
    }
}
// console.log(newarr);

      c++
   }

}

//type input.txt | node code.js

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

E.s2a = (arr)=>arr.map(a=>a.split('').map(c=>c=='0' ? 0 : 1))

const calc = (arr)=>{
  arr = E.s2a(arr);
  if (arr[0][0]==1)
    return false;
  let q = [];
  let n = arr.length;
  let m = arr[0].length;
  for (let i=n-1; i>=0; i--){
    for (let j=m-1; j>=0; j--){
      if (arr[i][j]){
        if (i)
          q.push({fromI: i-1, toI: i, fromJ: j, toJ: j});
        else
          q.push({fromI: i, toI: i, fromJ: j-1, toJ: j});
      }
      else
          q.push({fromI: i, toI: i, fromJ: j, toJ: j});
    }
  }
  return q
};

function main() {
    let T = +readline();
    while (T--){
      let [n, m] = ra();
      let arr = [];
      for (let i=0;i<n;i++)
        arr.push(readline());
      let q = calc(arr);
      if (!q)
        print(-1)
      else {
        print(q.length);
        for (let p of q){
          print(p.fromI, p.fromJ, p.toI, p.toJ);
        }
      }
    }
}

E.calc = calc;


let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    let z=0;
    let gcd=(a,b)=>{
        if(!b) return a;
        return gcd(b,a%b);
    }
    for(let _=1;_<=t;_++)
    {
        let [a,b,c,d]=line[_].split(' ').map(x=>{return parseInt(x)});
        let x=a*b;
        let ansx=-1,ansy=-1;
        for(let i=a+1;i<=c;i++)
        {
            let z=gcd(i,x);
            let num=x/z;
            let k=Math.floor((b+1)/num);
            if(k*num<b+1) k++;
            if(k*num<=d)
            {
                ansx=i,ansy=k*num;
            }
        }
        console.log(ansx,ansy);
    }
})

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [a, b, c, d] = rns();
  const cnt = new Map();
  const calc = n => {
    var _cnt$get2;
    for (let i = 2; i <= n / i; i++) {
      if (n % i === 0) {
        while (n % i === 0) {
          var _cnt$get;
          cnt.set(i, ((_cnt$get = cnt.get(i)) !== null && _cnt$get !== void 0 ? _cnt$get : 0) + 1);
          n /= i;
        }
      }
    }
    if (n > 1) cnt.set(n, ((_cnt$get2 = cnt.get(n)) !== null && _cnt$get2 !== void 0 ? _cnt$get2 : 0) + 1);
  };
  calc(a);
  calc(b);
  const p = [...cnt.entries()];
  const [A, B, C, D] = [a, b, c, d].map(BigInt);
  const t = A * B;
  const check = (a, b, c) => {
    if (c > a && c <= b) return c;
    let x = a / c;
    if (x * c <= a) x++;
    if (x * c <= b) return x * c;
    return -1n;
  };
  let res = [-1n, -1n];
  const dfs = (i, num) => {
    if (i === p.length) {
      let a = check(A, C, num),
          b = check(B, D, t / num);
      if (a !== -1n && b !== -1n) {
        res = [a, b];
        return true;
      }
      return false;
    }
    const [x, y] = p[i];
    for (let j = 0; j <= y; j++) {
      if (dfs(i + 1, num * BigInt(x ** j))) return true;
    }
  };
  dfs(0, 1n);
  return res.join(' ');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

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

function solve(a, b, c, d) {
    // const af = factors(a)
    // const bf = factors(b)
// console.log(af, bf)
    const prod = a * b
    const pf = factors(prod)
// console.log(pf)
    for (let i = 0; i < pf.length; i++) {
        const k1 = pf[i]
        const k2 = prod / pf[i]
//     for (let i = 0; i < af.length; i++) {
//         for (let j = 0; j < bf.length; j++) {
//             const k1 = af[i] * bf[j]
//             const k2 = prod / k1
            const r1 = has(k1, a, c)
            const r2 = has(k2, b, d)
// console.log(k1, k2, r1, r2)
            if (r1 < 0 || r2 < 0) continue
            return [r1, r2]
//         }
    }
    return [-1, -1]
}
function has(k, a, b) {
    // (a, b]
    let r = Math.ceil(a / k) * k
    if (r === a) r += k
    return r <= b ? r : -1
}
function factors(n) {
    const limit = Math.ceil(Math.sqrt(n))
    const r = []
    for (let i = 1; i < limit; i++) {
        if (!(n % i)) {
            r.push(i, n / i)
        }
    }
    if (!(n % limit)) r.push(limit)
    return r
}

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [a, b, c, d] = rns();
  const cnt = new Map();
  const calc = n => {
    var _cnt$get2;
    for (let i = 2; i <= n / i; i++) {
      if (n % i === 0) {
        while (n % i === 0) {
          var _cnt$get;
          cnt.set(i, ((_cnt$get = cnt.get(i)) !== null && _cnt$get !== void 0 ? _cnt$get : 0) + 1);
          n /= i;
        }
      }
    }
    if (n > 1) cnt.set(n, ((_cnt$get2 = cnt.get(n)) !== null && _cnt$get2 !== void 0 ? _cnt$get2 : 0) + 1);
  };
  calc(a);
  calc(b);
  const p = [...cnt.entries()];
  const [A, B, C, D] = [a, b, c, d].map(BigInt);
  const t = A * B;
  const check = (a, b, c) => {
    if (c > a && c <= b) return c;
    let x = a / c;
    if (x * c <= a) x++;
    if (x * c <= b) return x * c;
    return -1n;
  };
  let res = [-1n, -1n];
  const dfs = (i, num) => {
    if (i === p.length) {
      if (num > t) return false;
      let a = check(A, C, num),
          b = check(B, D, t / num);
      if (a !== -1n && b !== -1n) {
        res = [a, b];
        return true;
      }
      return false;
    }
    const [x, y] = p[i];
    for (let j = 0; j <= y; j++) {
      if (dfs(i + 1, num * BigInt(x ** j))) return true;
    }
  };
  dfs(0, 1n);
  return res.join(' ');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

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

function solve(a, b, c, d) {
    const af = factors(a)
    const bf = factors(b)
    const prod = a * b
    for (let i = 0; i < af.length; i++) {
        for (let j = 0; j < bf.length; j++) {
            const k1 = af[i] * bf[j]
            const k2 = prod / k1
            const r1 = has(k1, a, c)
            const r2 = has(k2, b, d)
            if (r1 < 0 || r2 < 0) continue
            return [r1, r2]
        }
    }
    return [-1, -1]
}
function has(k, a, b) {
    // (a, b]
    let r = Math.ceil(a / k) * k
    if (r === a) r += k
    return r <= b ? r : -1
}
function factors(n) {
    const limit = Math.floor(Math.sqrt(n))
    const r = []
    for (let i = 1; i < limit; i++) {
        if (!(n % i)) {
            r.push(i, n / i)
        }
    }
    if (!(n % limit)) r.push(limit)
    return r
}


var $ = "abcdefghijklmnopqrstuvwxyz";
var a = [];
var n = parseInt(readline());
for(var i=0;i<26;i++) a[i] = 0;
var c = []
for(var i=0;i<26;i++) {
    var ddd = [];
    for(var j=0;j<26;j++) ddd[j] = 0;
    c[i] = ddd;
}
for(var i=0;i<n;i++) {
    var s = readline();
    var m = s.length;
    var b = [];
    for(var j=0;j<26;j++) b[j] = false;
    var tmp = 0;
    for(var j=0;j<m;j++) {
        for(var k=0;k<26;k++) {
            if(s[j] == $[k]) {
                if(b[k] == false) tmp++;
                b[k] = true;
                break;
            }
        }
    }
    if(tmp ==1) {
        for(var j=0;j<26;j++) if(b[j] == true) a[j] += m;
    }
    else if(tmp == 2) {
        var id = [];
        id[0] = 'A';
        id[1] = 'A';
        for(var j=0;j<26;j++) if(b[j] == true) {
            if(id[0] == 'A') id[0] = j;
            else {
                id[1] = j;
                break;
            }
        }
        c[ id[0] ][ id[1] ] += m;
    }
}
var ans = 0;
for(var i=0;i<26;i++) {
    if(a[i] > ans) ans = a[i];
    for(var j=i+1;j<26;j++) {
        var tmp = a[i] + a[j] + c[i][j];
        if(tmp > ans) ans = tmp;
    }
}
print(ans);
// var ss = "";
// for(var i=0;i<26;i++) ss += " " + a[i];
// print(ss);
// for(var i=0;i<26;i++) {
//     ss = "";
//     for(var j=0;j<26;j++) {
//         ss += " " + c[i][j];
//     }
//     print(ss);
// }

var n = parseInt(readline()),
    lettersUsed = [],
    pairs = [],
    words = [],
    res = 0,
    currRes = 0;

for (var i = 0; i < n; i++) {
    var word = readline();
    var isGood = true,
        let1 = word.charAt(0),
        let2 = '';
    for (var j = 1; j < word.length; j++) {
        if (word.charAt(j) != let1) {
            if (let2 == '') let2 = word.charAt(j);
            else if (word.charAt(j) != let2) {
                isGood = false;
                break;
            }
        }
    }
    if (isGood) {
        words.push(word);
        if ( lettersUsed.indexOf(let1) == -1 ) lettersUsed.push(let1);
        if ( lettersUsed.indexOf(let2) == -1 && let2 != '' ) lettersUsed.push(let2);
    }
}

if (lettersUsed.length > 1) {
	for (var i = 0; i < lettersUsed.length - 1; i++) {
	    for (var j = i+1; j < lettersUsed.length; j++) {
	        pairs.push( [lettersUsed[i], lettersUsed[j]] );
	    }
	}
} else {
	pairs.push( [lettersUsed[0], lettersUsed[0]] );
}

for (var i = 0; i < pairs.length; i++) {
    currRes = 0;
    for (var j = 0; j < words.length; j++) {
        var good = true;
        for (var k = 0; k < words[j].length; k++) {
            if (words[j].charAt(k) != pairs[i][0] && words[j].charAt(k) != pairs[i][1]) {
                good = false;
                break;
            }
        }
        if (good) currRes += words[j].length;
    }
    if (currRes > res) res = currRes;
}

print(res);

var n = parseInt(readline()),
    lettersUsed = [],
    pairs = [],
    words = [],
    res = 0,
    currRes = 0;

for (var i = 0; i < n; i++) {
    var word = readline();
    var isGood = true,
        let1 = word.charAt(0),
        let2 = '';
    for (var j = 1; j < word.length; j++) {
        if (word.charAt(j) != let1) {
            if (let2 == '') let2 = word.charAt(j);
            else if (word.charAt(j) != let2) {
                isGood = false;
                break;
            }
        }
    }
    if (isGood) {
        words.push(word);
        if ( lettersUsed.indexOf(let1) == -1 ) lettersUsed.push(let1);
        if ( lettersUsed.indexOf(let2) == -1 && let2 != '' ) lettersUsed.push(let2);
    }
}

for (var i = 0; i < lettersUsed.length - 1; i++) {
    for (var j = i+1; j < lettersUsed.length; j++) {
        pairs.push( [lettersUsed[i], lettersUsed[j]] );
    }
}

for (var i = 0; i < pairs.length; i++) {
    currRes = 0;
    for (var j = 0; j < words.length; j++) {
        var good = true;
        for (var k = 0; k < words[j].length; k++) {
            if (words[j].charAt(k) != pairs[i][0] && words[j].charAt(k) != pairs[i][1]) {
                good = false;
                break;
            }
        }
        if (good) currRes += words[j].length;
    }
    if (currRes > res) res = currRes;
}

print(res);

var n = parseInt(readline()),
	lettersUsed = [],
	pairs = [],
	words = [],
	res = 0,
	currRes = 0;

for (var i = 0; i < n; i++) {
	var word = readline();
	var isGood = true,
		let1 = word.charAt(0),
		let2 = '';
	for (var j = 1; j < word.length; j++) {
		if (word.charAt(i) != let1) {
			if (let2 == '') let2 = word.charAt(i);
			else if (word.charAt(i) != let2) {
				isGood = false;
				break;
			}
		}
	}
	if (isGood) {
		words.push(word);
		if ( lettersUsed.indexOf(let1) == -1 ) lettersUsed.push(let1);
		if ( lettersUsed.indexOf(let2) == -1 && let2 != '' ) lettersUsed.push(let2);
	}
}

for (var i = 0; i < lettersUsed.length - 1; i++) {
	for (var j = i+1; j < lettersUsed.length; j++) {
		pairs.push( [lettersUsed[i], lettersUsed[j]] );
	}
}

for (var i = 0; i < pairs.length; i++) {
	currRes = 0;
	for (var j = 0; j < words.length; j++) {
		var good = true;
		for (var k = 0; k < words[j].length; k++) {
			if (words[j].charAt(k) != pairs[i][0] && words[j].charAt(k) != pairs[i][1]) {
				good = false;
				break;
			}
		}
		if (good) currRes += words[j].length;
	}
	if (currRes > res) res = currRes;
}

print(res);


const coords = {};
const nbrs = {};
const points = require("fs").readFileSync(0, "utf8").split("\n").slice(1).filter(Boolean).map(point => {
    let [x,y] = point.split(" ").map(n => parseInt(n, 10));
    const str = `${x} ${y}`;
    coords[str] = [x,y];
    nbrs[str] = [
        `${x+1} ${y}`,`${x-1} ${y}`,`${x} ${y-1}`,`${x} ${y+1}`
    ];
    return str;
});

const map = {};
for(let point of points) {
    map[ point ] = [];
    for(ne of nbrs[point]) {
        if(map[ne]) {
            map[ne].push(point);
            map[point].push(ne);
        }
    }
}

let best = {}, wset = [];
for(let point of points) {
    if(map[point].length < 4) {
        wset.push(point);
        best[point] = nbrs[point].find(pt => !map[point].includes(pt));
    }
}

while(wset.length) {
    wset = wset.map(point => nbrs[point].filter(ne => {
        if(map[ne] && !best[ne]) {
            best[ne] = best[point];
            return true;
        }
    })).flat(1);
}

for(let point of points) {
    console.log(best[point]);
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const getDist = (p1, p2)=>Math.abs(p1[0]-p2[0])+Math.abs(p1[1]-p2[1])

class GDB {
  constructor(points){
    let XA = this.XA = {};
    let YA = this.YA = {};
    for (let p of points){
      let [x, y] = p;
      if (!XA[x]) XA[x] = new Set();
      XA[x].add(y);
      if (!YA[y]) YA[y] = new Set();
      YA[y].add(x);
    }
    //console.log('XA', XA)
    //console.log('YA', YA)
    /**
    for (let x in XA){
      XA[x].sort((a, b)=>a-b);
    }
    for (let y in YA){
      YA[y].sort((a, b)=>a-b);
    }*/
  }
  getExcluded(point){
    this.cache = new Map();
    let [x, y] = point;
    let bestPoint = [1e6, 1e6];
    let bestDist = getDist(point, bestPoint)
    for (let d=0; d<bestDist; d++){ // potentially binary search
      let closestPoint = this.findClosest(point, d, bestDist-d);
      //console.log('GG', {point, closestPoint, bestDist, d})
      if (!closestPoint)
        continue;
      let dist = getDist(point, closestPoint);
      if (dist < bestDist){
        bestDist = dist;
        bestPoint = closestPoint;
      }
    }
    return bestPoint;
  }
  findClosest(point, dist, maxShift){
    let [x, y] = point;
    let bestPoint = null;
    let bestDist = Infinity;
    let updAns = p=>{
      let d = getDist(point, p);
      if (d<bestDist){
        bestDist = d;
        bestPoint = p;
      }
    };
    let gapY = this.findGap('XA', x+dist, y, maxShift);
    //console.log('AAA', gapY)
    if (gapY!==null)
      updAns([x+dist, gapY])
    gapY = this.findGap('XA', x-dist, y, maxShift);
    if (gapY!==null)
      updAns([x-dist, gapY])
    let gapX = this.findGap('YA', y+dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y+dist]);
    gapX = this.findGap('YA', y-dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y-dist]);
    // update maxShift?
    return bestPoint;
  }
  findGap(name, s, startPos, maxShift){
    let set = this[name][s];
    if (!set)
      return startPos;
    let K = [name, s, startPos, maxShift].join(';');
    if (0)
    if (this.cache.has(K))
      return this.cache.get(K);
    for (let shift=0; shift<=maxShift; shift++){ // binary search?
      if (!set.has(startPos+shift)){
        this.cache.set(K, startPos+shift)
        return startPos+shift;
      }
      if (shift && !set.has(startPos-shift)){
        this.cache.set(K, startPos-shift)
        return startPos-shift;
      }
    }
    this.cache.set(K, null)
    return null;
  }
}

let dx = [0, 0, 1, -1]
let dy = [-1, 1, 0, 0]
let p2s = p=>p[0]+';'+p[1];
const calc = (points)=>{
  let ansMap = new Map();
  for (let point of points){
    ansMap.set(p2s(point), null);
  }
  let queue = [], qi = 0;
  for (let point of points){
    let [x, y] = point;
    for (let di=0; di<4; di++){
      let dPoint = [x+dx[di], y+dy[di]];
      if (!ansMap.has(p2s(dPoint))){
        ansMap.set(p2s(point), dPoint);
        queue.push(point);
      }
    }
  }
  while (qi<queue.length){
    let point = queue[qi++];
    let [x, y] = point;
    let pointAns = ansMap.get(p2s(point));
    for (let di=0; di<4; di++){
      let dPoint = [x+dx[di], y+dy[di]];
      if (ansMap.has(p2s(dPoint)) && ansMap.get(p2s(dPoint))==null){
        ansMap.set(p2s(dPoint), pointAns);
        queue.push(dPoint);
      }
    }
  }
  return points.map(p=>ansMap.get(p2s(p)))
};

function main() {
    let T = 1 || +readline() /// DISABLE T
    while (T--){
      let n = +readline();
      let arr = []; // [x, y]
      for (let i=0; i<n; i++)
        arr.push(ra());
      print(calc(arr).map(p=>p.join(' ')).join('\n'));
    }
}

E.calc = calc;

const coords = [];
const points = require("fs").readFileSync(0, "utf8").split("\n").slice(1).filter(Boolean).map(point => {
    let [x,y] = point.split(" ").map(n => parseInt(n, 10));
    const str = `${x},${y}`;
    coords[str] = [x,y];
    return str;
});

const nbrs = (pt) => {
    let [x,y] = coords[pt];
    return [`${x+1}${y}`,`${x-1}${y}`,`${x}${y-1}`,`${x}${y+1}`];
}

const map = {};
for(let point of points) {
    map[ point ] = [];
    for(ne of nbrs(point)) {
        if(map[ne]) {
            map[ne].push(point);
            map[point].push(ne);
        }
    }
}

let best = {}, wset = [];
for(let point of points) {
    if(map[point].length < 4) {
        wset.push(point);
        best[point] = nbrs(point).find(pt => !map[point].includes(pt));
    }
}

while(wset.length) {
    wset = wset.map(point => nbrs(point).filter(ne => {
        if(map[ne] && !best[ne]) {
            best[ne] = best[point];
            return true;
        }
    })).flat(1);
}

for(let point of points) {
    console.log(coords[point][0], coords[point][1]);
}

const points = require("fs").readFileSync(0, "utf8").split("\n").slice(1).filter(Boolean).map(point => {
    let [x,y] = point.split(" ").map(n => parseInt(n, 10));
    return x + (y << 18);
});

const map = {};
for(let point of points) {
    map[ point ] = [];
    for(ne of [point-1, point+1, point - (1<<18), point + (1<<18)]) {
        if(map[ne]) {
            map[ne].push(point);
            map[point].push(ne);
        }
    }
}

let best = {}, wset = [];
for(let point of points) {
    if(map[point].length < 4) {
        wset.push(point);
        best[point] = [point-1,point+1,point-(1<<18),point+(1<<18)].find(pt => !map[point].includes(pt));
    }
}

while(wset.length) {
    wset = wset.map(point => [point-1,point+1,point-(1<<18),point+(1<<18)].filter(ne => {
        if(map[ne] && !best[ne]) {
            best[ne] = best[point];
            return true;
        }
    })).flat(1);
}

for(let point of points) {
    console.log(best[point] & ((1<<18) - 1), best[point] >> 18);
}

const points = require("fs").readFileSync(0, "utf8").split("\n").slice(1).filter(Boolean).map(point => {
    let [x,y] = point.split(" ").map(n => parseInt(n, 10));
    return x + (y << 16);
});

const map = {};
for(let point of points) {
    map[ point ] = [];
    for(ne of [point-1, point+1, point - (1<<16), point + (1<<16)]) {
        if(map[ne]) {
            map[ne].push(point);
            map[point].push(ne);
        }
    }
}

let best = {}, wset = [];
for(let point of points) {
    if(map[point].length < 4) {
        wset.push(point);
        best[point] = [point-1,point+1,point-(1<<16),point+(1<<16)].find(pt => !map[point].includes(pt));
    }
}

while(wset.length) {
    wset = wset.map(point => [point-1,point+1,point-(1<<16),point+(1<<16)].filter(ne => {
        if(map[ne] && !best[ne]) {
            best[ne] = best[point];
            return true;
        }
    })).flat(1);
}

for(let point of points) {
    console.log(best[point] & ((1<<16) - 1), best[point] >> 16);
}

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const getDist = (p1, p2)=>Math.abs(p1[0]-p2[0])+Math.abs(p1[1]-p2[1])

class GDB {
  constructor(points){
    let XA = this.XA = {};
    let YA = this.YA = {};
    for (let p of points){
      let [x, y] = p;
      if (!XA[x]) XA[x] = new Set();
      XA[x].add(y);
      if (!YA[y]) YA[y] = new Set();
      YA[y].add(x);
    }
    //console.log('XA', XA)
    //console.log('YA', YA)
    /**
    for (let x in XA){
      XA[x].sort((a, b)=>a-b);
    }
    for (let y in YA){
      YA[y].sort((a, b)=>a-b);
    }*/
  }
  getExcluded(point){
    this.cache = new Map();
    let [x, y] = point;
    let bestPoint = [1e6, 1e6];
    let bestDist = getDist(point, bestPoint)
    for (let d=0; d<bestDist; d++){ // potentially binary search
      let closestPoint = this.findClosest(point, d, bestDist-d);
      //console.log('GG', {point, closestPoint, bestDist, d})
      if (!closestPoint)
        continue;
      let dist = getDist(point, closestPoint);
      if (dist < bestDist){
        bestDist = dist;
        bestPoint = closestPoint;
      }
    }
    return bestPoint;
  }
  findClosest(point, dist, maxShift){
    let [x, y] = point;
    let bestPoint = null;
    let bestDist = Infinity;
    let updAns = p=>{
      let d = getDist(point, p);
      if (d<bestDist){
        bestDist = d;
        bestPoint = p;
      }
    };
    let gapY = this.findGap('XA', x+dist, y, maxShift);
    //console.log('AAA', gapY)
    if (gapY!==null)
      updAns([x+dist, gapY])
    gapY = this.findGap('XA', x-dist, y, maxShift);
    if (gapY!==null)
      updAns([x-dist, gapY])
    let gapX = this.findGap('YA', y+dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y+dist]);
    gapX = this.findGap('YA', y-dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y-dist]);
    // update maxShift?
    return bestPoint;
  }
  findGap(name, s, startPos, maxShift){
    let set = this[name][s];
    //console.log('findGap', {set, startPos, maxShift})
    if (!set)
      return startPos;
    let K = [name, s, startPos, maxShift].join(';');
    if (this.cache.has(K))
      return this.cache.get(K);
    for (let shift=0; shift<=maxShift; shift++){ // binary search?
      if (!set.has(startPos+shift)){
        this.cache.set(K, startPos+shift)
        return startPos+shift;
      }
      if (shift && !set.has(startPos-shift))
        this.cache.set(K, startPos-shift)
        return startPos-shift;
    }
    this.cache.set(K, null)
    return null;
  }
}

const calc = (points)=>{
  let gdb = new GDB(points);
  let ans = [];
  for (let point of points){
    ans.push(gdb.getExcluded(point))
  }
  return ans;
};

function main() {
    let T = 1 || +readline() /// DISABLE T
    while (T--){
      let n = +readline();
      let arr = []; // [x, y]
      for (let i=0; i<n; i++)
        arr.push(ra());
      print(calc(arr).map(p=>p.join(' ')).join('\n'));
    }
}

E.calc = calc;

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

const getDist = (p1, p2)=>Math.abs(p1[0]-p2[0])+Math.abs(p1[1]-p2[1])

class GDB {
  constructor(points){
    let XA = this.XA = {};
    this.cache = new Map();
    let YA = this.YA = {};
    for (let p of points){
      let [x, y] = p;
      if (!XA[x]) XA[x] = new Set();
      XA[x].add(y);
      if (!YA[y]) YA[y] = new Set();
      YA[y].add(x);
    }
    //console.log('XA', XA)
    //console.log('YA', YA)
    /**
    for (let x in XA){
      XA[x].sort((a, b)=>a-b);
    }
    for (let y in YA){
      YA[y].sort((a, b)=>a-b);
    }*/
  }
  getExcluded(point){
    let [x, y] = point;
    let bestPoint = [1e6, 1e6];
    let bestDist = getDist(point, bestPoint)
    for (let d=0; d<bestDist; d++){ // potentially binary search
      let closestPoint = this.findClosest(point, d, bestDist-d);
      //console.log('GG', {point, closestPoint, bestDist, d})
      if (!closestPoint)
        continue;
      let dist = getDist(point, closestPoint);
      if (dist < bestDist){
        bestDist = dist;
        bestPoint = closestPoint;
      }
    }
    return bestPoint;
  }
  findClosest(point, dist, maxShift){
    let [x, y] = point;
    let bestPoint = null;
    let bestDist = Infinity;
    let updAns = p=>{
      let d = getDist(point, p);
      if (d<bestDist){
        bestDist = d;
        bestPoint = p;
      }
    };
    let gapY = this.findGap('XA', x+dist, y, maxShift);
    //console.log('AAA', gapY)
    if (gapY!==null)
      updAns([x+dist, gapY])
    gapY = this.findGap('XA', x-dist, y, maxShift);
    if (gapY!==null)
      updAns([x-dist, gapY])
    let gapX = this.findGap('YA', y+dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y+dist]);
    gapX = this.findGap('YA', y-dist, x, maxShift);
    if (gapX!==null)
      updAns([gapX, y-dist]);
    // update maxShift?
    return bestPoint;
  }
  findGap(name, s, startPos, maxShift){
    let set = this[name][s];
    //console.log('findGap', {set, startPos, maxShift})
    if (!set)
      return startPos;
    let K = [name, s, startPos, maxShift].join(';');
    if (this.cache.has(K))
      return this.cache.get(K);
    for (let shift=0; shift<=maxShift; shift++){ // binary search?
      if (!set.has(startPos+shift)){
        this.cache.set(K, startPos+shift)
        return startPos+shift;
      }
      if (shift && !set.has(startPos-shift))
        this.cache.set(K, startPos-shift)
        return startPos-shift;
    }
    this.cache.set(K, null)
    return null;
  }
}

const calc = (points)=>{
  let gdb = new GDB(points);
  let ans = [];
  for (let point of points){
    ans.push(gdb.getExcluded(point))
  }
  return ans;
};

function main() {
    let T = 1 || +readline() /// DISABLE T
    while (T--){
      let n = +readline();
      let arr = []; // [x, y]
      for (let i=0; i<n; i++)
        arr.push(ra());
      print(calc(arr).map(p=>p.join(' ')).join('\n'));
    }
}

E.calc = calc;


"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split("").map(cur=>parseInt(cur));
          arr.unshift(0);
          let cost = 0;
          for(let i=1;i<=n;i++){
               if(arr[i]===1) continue;
               for(let j=i;j<=n;j+=i){
                    if(arr[j]==-1) continue;
                    if(arr[j]!==1){
                         cost+=i;
                         arr[j] = -1;
                    }
                    else break;
               }
          }
          console.log(cost);
     }
};
solve();

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let bin = readline().split('').map(Number);
        let R = bin.map(x => x === 1 ? 0 : 1);
        let T = bin;
        let toRemove = R.filter(x => x === 1).length;
        let cost = 0;

        let curr = 1;
        let p = 1;
        let removed = 0;

        while (removed < toRemove) {
            if (R[p-1] === 1) {
                R[p-1] = 0;
                removed++;
                cost += curr;
            } else if (T[p-1] === 1) {
                curr += 1;
                p = curr;
            } else {
                p += curr;
                if (p > n) {
                    curr += 1;
                    p = curr;
                }
            }
        }

        output(cost);

    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split("").map(cur=>parseInt(cur));
          arr.unshift(0);
          let cost = 0;
          for(let i=1;i<=n;i++){
               if(arr[i]===0){
                    for(let j=i;j<=n;j=j+i){
                         if(arr[j]===0){
                              cost+=i;
                              arr[j] = 1;
                         }
                         else break;
                    }
               }
          }
          console.log(cost);
     }
};
solve();


function main() {

    var n = Number(readline());
    var arr1 = readline().split(' ').map(Number);
    var arr2=[];
    for(var k=0;k<n;k++){
        arr2.push(readline().split(' ').map(Number));
    }

    var res = 1000000;
    for (var i = 0; i < n; i++) {
        var temp = 0;
        for (var j = 0; j < arr1[i]; j++) {
            temp += arr2[i][j] * 5 + 15;
        }
        if (temp < res) {
            res = temp;
        }
    }

    print(res);
}

main();

let data = '';
process.stdin.on('data', c => data += c);
function* nextLine() {
	for(let l of data.trim().split(/\n/g)){
		yield l;
	}
}

const sol = () => {
	let nl = nextLine();
	let n = Number(nl.next().value);
	nl.next();
	let res = [];
	for(let i = 0; i < n; i++){
		let p = nl.next().value.trim().split(/\s/g).map(Number);

		let t = p.reduce((a, b) => a + b * 5 + 15,0);
		res.push(t);
	}
	console.log(Math.min(...res));;

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

print(function(n, k){
	var min=Infinity;
	for(var i=0;i<n;i++)
		min = Math.min(min, 15*k[i] + 5*readline().split(' ').map(Number).reduce(function(a, b){
			return a+b;
		}) );
	return min;
}(+readline(), readline().split(' ').map(Number)));

;(function () {
	print(function (n) {
		var m = null, w = readline().split(' ').map(Number);
		while (n--) {
			var q = readline().split(' ').reduce(function (p, e) { return p + (+e)*5; }, w[w.length - n - 1] * 15);
			if (m === null || q < m) {
				m = q;
			}
		}

		return m;
	}(+readline()));
}.call(this));

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

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

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

function main() {
	var lineNum = parseInt(readline()),
		lines = tokenizeIntegers(readline());
	var best;
	for (var i = 0; i < lineNum; ++i) {
		var wait = 0,
			items = tokenizeIntegers(readline());
		for (var j = 0; j < items.length; ++j) {
			wait += items[j]*5 + 15;
		}
		if (best === undefined || wait < best) {
			best = wait;
		}
	}
	print(best);
}

main();

var tokenizer;
var index = 0;

function next(){
    while(tokenizer == null || index == tokenizer.length){
        tokenizer = readline().split(" ");
        index = 0;
    }
    var res = tokenizer[index++];
    return res;
}

function nextInt(){
    return parseInt(next());
}

function nextFloat(){
    return parseFloat(next());
}

function solve(){
    var n = nextInt();
    var k =[];
    for(var i = 0; i < n; ++i){
        k[i] = nextInt();
    }
    var min = Number.MAX_VALUE;
    for(var i = 0; i < n; ++i){
        var cur = 0;
        for(var j = 0; j < k[i]; ++j){
            var m = nextInt();
            cur += 5*m + 15;
        }
        if(cur < min){
            min = cur;
        }
    }
    print(min);
}
solve();

/**
 * Created by artyom.
 */

readline();
readline().split(' ').map(function (q) {
    var time = q * 15 + readline().split(' ').reduce(function (s, v) {
        return s + 5 * v;
    }, 0);
    if (typeof min === 'undefined' || time < min) {
        min = time;
    }
});

print(min);

let data = '';
process.stdin.on('data', c => data += c);
function* nextLine() {
	for(let l of data.trim().split(/\n/g)){
		console.log(l);
		yield l;
	}
}

const sol = () => {
	let nl = nextLine();
	let n = Number(nl.next().value);
	nl.next();
	let res = [];
	for(let i = 0; i < n; i++){
		let p = nl.next().value.split(/\s/g).map(Number);

		let t = p.reduce((a, b) => a + b * 5 + 15,0);
		res.push(t);
	}
	console.log(Math.min(...res));;

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

let data = '';
process.stdin.on('data', c => data += c);
function* nextLine() {
	for(let l of data.trim().split(/\n/g)){
		yield l;
	}
}

const sol = () => {
	let nl = nextLine();
	let n = Number(nl.next().value);
	nl.next();
	let res = [];
	for(let i = 0; i < n; i++){
		let p = nl.next().value.split(/\s/g).map(Number);

		let t = p.reduce((a, b) => a + b * 5 + 15,0);
		res.push(t);
	}
	console.log(Math.min(...res));;

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


'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(s) {
  const n = s.length;
  const chars = new Set(s);
  for (let char of chars) {
    let count = new Map();
    for (let i = -1, j = 0; j < n; j++) {
      var _count$get2;
      if (s[j] === char) {
        if (i !== -1) {
          for (let key of chars) {
            if (key === char) continue;
            if (!count.has(key) || count.get(key) > 3) {
              console.log('NO');
              return;
            }
          }
        } else {
          for (let key of chars) {
            var _count$get;
            if (key === char) continue;
            if (((_count$get = count.get(key)) !== null && _count$get !== void 0 ? _count$get : 0) > 2) {
              console.log('NO');
              return;
            }
          }
        }
        i = j;
        count = new Map();
      }
      count.set(s[j], ((_count$get2 = count.get(s[j])) !== null && _count$get2 !== void 0 ? _count$get2 : 0) + 1);
    }
  }
  console.log('YES');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const s1 = await read();
    solve(s1);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function main () {
	let T = rn();
	while (T--) {
		const s = rl();
		const n = s.length;

		let p = '', ok = 1;
		for (let i = 0, seen = []; i < n && ok; i++) {
			if (i && s[i] == s[0]) break;
			p += s[i];
			if (seen[s[i]]) ok = 0; seen[s[i]] = 1;
		}

		for (let i = 0; i < n && ok; i++) {
			ok &= s[i] == p[i%p.length];
		}

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

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
        const string = nextCharArray().join("");

		const map = new Map();

		for (let i = 0; i < string.length; i++) {
			if (!map.has(string[i])) {
				map.set(string[i], i)
			} else {
				break;
			}
		}

		let mapSize = map.size;
		let stop = false;

		for (const [key, value] of map) {
			let index = value;
			let i = 0;
			while (index + i * mapSize < string.length) {
				if (string[index] !== string[index + i * mapSize]) {
					stop = true;
				};
				i++
			}
			if (stop) break;
		}
		if (stop) {
			myout("NO");
			continue
		}

		myout("YES");

	}
}

const readline = require('readline')

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

function solve(str) {
    const chs = {}
    for (let i = 0; i < str.length; i++) {
        chs[str[i]] = 1
    }
    //
    const prev = {}
    const count = Array(str.length)
    const arr = Array(26).fill(0)
    for (let i = 0; i < str.length; i++) {
        const x = str[i]
        const idx = str.charCodeAt(i) - 'a'.charCodeAt(0)
        arr[idx]++
        count[i] = arr.slice()
        if (x in prev) {
            const p = prev[x]
            for (let ch in chs) {
                const j = ch.charCodeAt(0) - 'a'.charCodeAt(0)
                const y = count[i][j] - (count[p][j] || 0)
                if (!y) return false
            }
        }
        //
        prev[x] = i
    }
    return true
}


var firstLine = readline().split(" ");
var n = parseInt(firstLine[0]);

function Pair(x, y) {
	this.x = x;
	this.y = y;
}

var z0 = new Pair(parseInt(firstLine[1]), parseInt(firstLine[2]));
var p = new Array(n),
	isDead = new Array(n);

for (var i = 0; i < n; i++) {
	var line = readline().split(" ");
	p[i] = new Pair(parseInt(line[0]), parseInt(line[1]));
	isDead[i] = false;
}

function isSameLine(a, b, c) {
	if (c.x == b.x && c.y == b.y) {
		return true;
	}
	var z0 = new Pair(b.x - a.x, b.y - a.y);
	var z1 = new Pair(c.x - a.x, c.y - a.y);

	return z0.x * z1.y == z0.y * z1.x;
}

var ans = 0;
for (var i = 0; i < n; i++) {
	if (isDead[i]) {
		continue;
	}
	ans++;
	isDead[i] = true;
	for (var j = i + 1; j < n; j++) {
		if (isSameLine(z0, p[i], p[j])) {
			isDead[j] = true;
		}
	}
}

print(ans);

function resolve(x, y, arr) {
  var memo = {};
  for (var i = 0; i < arr.length; i++) {
    var d = (arr[i][1] - y) / (arr[i][0] - x);
    if (d === -Infinity) {
      d = Infinity;
    }
    if (memo[d] === undefined) {
      memo[d] = [];
    }
    memo[d].push(i);
  }
  return Object.keys(memo).length;
}

const p = readline().split(' ');
var arr = [];
for (var i = 0; i < parseInt(p[0], 10); i++) {
  var st = readline().split(' ');
  arr.push(
    st.map(el => {
      return parseInt(el, 10);
    })
  );
}
print(resolve(parseInt(p[1], 10), parseInt(p[2], 10), arr));

function Point(x,y){
	this.x = x;
	this.y = y;
}

function vp(a,b,c){
	return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}

var s = readline().split(' ');
var n = +s[0];
var p0 = new Point(+s[1],+s[2]);

var u = [], p = [];
for(var i=0; i<n; i++){
	u.push(false);
	s = readline().split(' ');
	p.push(new Point(+s[0],+s[1]));
}

var ans = 0;
for(var i=0; i<n; i++){
	if(u[i]) continue;
	for(var j=i+1; j<n; j++){
		if(vp(p0,p[i],p[j])==0) u[j]=true;
	}
	ans++;
}

print(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var inp = rda(), n = inp[0], x1 = inp[1], y1 = inp[2];
var t = [];
for(var i = 0; i < n; i++) t[i] = rda();

var ans = 0;
for(var i = 0; i < n; i++){
    if(t[i] == undefined) continue;
    var x2 = t[i][0], y2 = t[i][1];
    var a = y1-y2, b = x2-x1, c = x1*y2-x2*y1;
    ans++;

    for(var j = 0; j < n; j++){
        if(t[j] == undefined) continue;
        if((a*t[j][0] + b*t[j][1] + c) == 0) delete t[j];
    }
}

write(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var inp = rda(), n = inp[0], x1 = inp[1], y1 = inp[2];
var t = [];
for(var i = 0; i < n; i++) t[i] = rda();

var ans = 0;
for(var i = 0; i < n; i++){
    if(t[i] == undefined) continue;
    var x2 = t[i][0], y2 = t[i][1];
    var a = y1-y2, b = x2-x1, c = x1*y2-x2*y1;
    ans++;

    for(var j = 0; j < n; j++){
        if(t[j] == undefined) continue;
        if((a*t[j][0] + b*t[j][1] + c) == 0) delete t[j];
    }
    print(a, b, c, i);
}

write(ans);

function resolve(x, y, arr) {
  var memo = {};
  for (var i = 0; i < arr.length; i++) {
    var d = (arr[i][1] - y) / (arr[i][0] - x);
    if (memo[d] === undefined) {
      memo[d] = [];
    }
    memo[d].push(i);
  }
  return Object.keys(memo).length;
}

const p = readline().split(' ');
var arr = [];
for (var i = 0; i < parseInt(p[0], 10); i++) {
  var st = readline().split(' ');
  arr.push(
    st.map(el => {
      return parseInt(el, 10);
    })
  );
}
print(resolve(parseInt(p[1], 10), parseInt(p[2], 10), arr));

function Point(x,y){
	this.x = x;
	this.y = y;
}

var s = readline().split(' ');
var n = +s[0];
var p0 = new Point(+s[1],+s[2]);

var p = [];
for(var i=0; i<n; i++){
	s = readline().split(' ');
	p.push(new Point(+s[0],+s[1]));
}

var map = {};
for(var i=0; i<n; i++){
	map[(p[i].y-p0.y)/(p[i].x-p0.x)]=1;
}

var ans=0;
for( var x in map){
	ans++;
}

print(ans);