"use strict";
let input = [];
const readline=require('readline');
const RL=readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
RL.on('line', (line)=>{
  input.push(line.trim());
});
RL.on('close', ()=>{
  const n=parseInt(input[0]);
  let answer=0;
  for(let i=1; i<=n; ++i){
    let cnt=0;
    const arr=input[i].split(' ');
    arr.map((ch)=>{
      let digit=parseInt(ch);
      if(digit===1){
        cnt++;
      }
    });
    if(cnt>=2){
      answer++;
    }
  }

  console.log(answer);
});

var count = parseInt(readline()),
current = [], currentMas, sum = 0, answer = 0;

for(var i = 0; i < count; i++) {
    current[i] = readline().split(" ");
}

for(var i = 0; i < count; i++) {
    currentMas = current[i];
    sum = 0;

    for(var j = 0; j < 3; j++) {
        sum+=parseInt(currentMas[j]);
    }

    if(sum >= 2) {
        answer+=1;
    }
}

write(answer);

const rows = parseToInt(readline())

var arr = [];

for(var i=0;i<rows;i++) {
  arr.push(parseToIntArray(readline()))
}

compute(arr)

function parseToInt(str) {
  return Number.parseInt(str);
}

function parseToIntArray(str) {
  return str.split(" ").map(x=>Number.parseInt(x))
}

function compute(arr) {

  var sum = 0;
  for(var i=0;i<arr.length;i++) {
    var a = arr[i][0];
    var b = arr[i][1];
    var c = arr[i][2];

    if(a+b+c > 1) {
      sum++;
    }

  }

  print(sum)

}

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

  var result = 0;

  for (var i = 0; i < N; i++) {
    var confidenceLevel = 0;

    readline()
      .split(" ")
      .forEach((opinion) => {
        if (opinion === "1") {
          confidenceLevel++;
        }
      });

    if (confidenceLevel >= 2) {
      result++;
    }
  }

  print(result);
};

main();

var input;
var count ;
var problem = 0;
var n = parseInt(readline());

for(var i=0 ; i<n ; i++){
   input = readline().split(' ').map(x=>parseInt(x));
   count = 0;
   for(var j=0 ; j<5 ; j++){
       if(input[j]=='1'){
           count++;
       }
   }
   if(count>1)
        problem++;
}
print(problem);

var input;
var count ;
var problem = 0;
var n = parseInt(readline());

for(var i=0 ; i<n ; i++){
   input = readline();
   count = 0;
   for(var j=0 ; j<5 ; j++){
       if(input.charAt(j)=='1'){
           count++;
       }
   }
   if(count>1)
        problem++;
}
print(problem);

var lines = Number(readline());
var outp = 0;
for (var i = 0; i < lines; i++) {
    var str = readline();
    var count = Number(str.charAt(0)) + Number(str.charAt(2)) + Number(str.charAt(4));
    if (count > 1) outp ++;
}
print(outp);

n = readline();
var tedad = 0;
while(n--)
{
 	s=readline().replace(new RegExp('0' , 'g'), '')

	if(s.length > 3){tedad++}

}
print(tedad)

y = readline().split(" ").map(each=>Number(each))

counter = 0
n = 0

while (counter < y) {
    x = readline()
    if (
    x == '1 1 0'||
    x == '1 1 1'||
    x == '0 1 1'||
    x == '1 0 1'
    )
    { n = n + 1 }
  counter = counter + 1 }

print ( n )

var n = readline()
var out = 0
for (var i = 0; i < n; i++) {if (readline().split(' ').map(x => Number(x)).reduce((a, b) => a + b) >=2) out++}
print(out)

const readline = require("readline");

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

function enterNumberOfTasks() {
  rl.question("", (num) => {
    const numberOfTasks = parseInt(num);
    enterLine(numberOfTasks);
  });
}

/**
 *
 * @param {number} numberOfTasks
 */
function enterLine(numberOfTasks) {
  const lines = [];
  rl.on("line", (line) => {
    lines.push(line);

    if (lines.length === numberOfTasks) {
      getAnswer(lines);
      rl.close();
      return;
    }
  });
}

/**
 *
 * @param {string[]} lines
 */
function getAnswer(lines) {
  let numberOfTasks = 0;
  lines.forEach((line) => {
    const numbers = line.split(" ").map((numStr) => parseInt(numStr));
    const sum = numbers.reduce((acc, cur) => acc + cur, 0);

    if (sum > 1) {
      numberOfTasks++;
    }
  });

  console.log(numberOfTasks);
}

enterNumberOfTasks();

var readline = require ("readline");
rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var expect = 'n';
var s= 0;
rl.on("line", function(line){
    if (expect =="n"){
        n = parseInt(line);
        case_counter = 1;
        expect = 'solution';
    } else if (expect=="solution"){
        solutions = line.split(" ");
        var r = 0;

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

            if(solutions[i] == '1'){
                r++;
            }
        }
        if (r > 1){
            s++;
        }
        ++case_counter === n +1 ? rl.close() : 0;
        expect="solution";
    }
}).on('close', function(){
    console.log(s);
    process.exit(0);

});

;(function () {
    var n = readline(), r = 0;
    for (var i = 0; i < n; i++)
        r += readline().split(' ').filter(function(v){ return v == 1;}).length > 1;
    print(r);

}).call(this);

'use strict';

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

let n = Number(readline()), count = 0;
for (var i = 0; i < n; i++) {
  if (readline().split(' ').map(Number).reduce((a,b)=>a+b) >= 2) {
    count++
  }
}
print(count);

var quantity = parseInt(readline()),
    arr = [],
    count = 0;

for (var i = 0; i < quantity; i++) {
    var s = 0;
    arr[i] = readline().split(' ').map(x => parseInt(x) && s++);
    s > 1 && count++;
}

print(count);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
var a, b, c, n, r, g;
r = 0;
g = 0;
n = readline();
while ((n-- > 0)) {
  var vavl = readline().split(" ").map(x => parseInt(x));
  a = vavl[0];
  b = vavl[1];
  c = vavl[2];
  r = (a + b + c);
  if(r >= 2)
    g += 1;
}
console.log(g);
}

// Generated by CoffeeScript 2.5.1
var lines, mainAux, nprobs, print, readline, rl, rli, sum, write;

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

print = console.log;

write = function(...args) {
  return process.stdout.write(args.join(' '));
};

lines = [];

rl.on('line', function(line) {
  return lines.push(line);
});

rl.on('close', main);

rli = 0;

readline = function() {
  return lines[rli++];
};

sum = function(items) {
  return items.reduce((function(a, b) {
    return a + b;
  }), 0);
};

nprobs = function(n, ps) {
  return ps.filter(function(p) {
    return sum(p) > 1;
  }).length;
};

mainAux = function() {
  var count, i, items, j, ref;
  count = parseInt(readline());
  items = [];
  for (i = j = 0, ref = count; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) {
    items.push(readline().split(' ').map(function(i) {
      return parseInt(i);
    }));
  }
  return print(nprobs(count, items));
};

  function main() {
    return mainAux();
  }
;

//# sourceMappingURL=testsums.js.map

//231A
const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let i = 0
let problems;
let numberOfProblems = 0;
rl.on('line', (input) => {
i++
    if(i==1) {
        problems = parseInt(input)
    } else if (i - 1 <= problems) {

        let thingyarray = input.split(" ")
        let formatarray = [];
        thingyarray.forEach(function(number) {
            let dieh = parseInt(number)
            formatarray.push(dieh)
        })

        let answer = formatarray[0] + formatarray[1] + formatarray[2]

        if (answer > 1) {
            numberOfProblems++
        }
        if (i > problems) {

            rl.close()
            console.log(numberOfProblems)
        }

    }

});

function getSum(nums){
	var total = 0;
	for(var i = 0; i < nums.length; i++)
		total += Number(nums[i]);
	return total;
}

var n = Number(readline());

var ans = 0;
for(var i = 0; i < n; i++){
	var votes = readline().split(" ");
	var sumOfVotes = getSum(votes);
	if(sumOfVotes > 1) ans++;
}

print(ans);

function getSum(nums){
	var total = 0;
	for(var i = 0; i < nums.length; i++)
		total += parseInt(nums[i]);
	return total;
}

var n = readline();

var ans = 0;
for(var i = 0; i < n; i++){
	var votes = readline().split(" ");
	var sumOfVotes = getSum(votes);
	if(sumOfVotes > 1) ans++;
}

print(ans);

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();
  let result = 0;
  while (t--) {
    let count = 0;
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    a === 1 && count++;
    b === 1 && count++;
    c === 1 && count++;
    count >= 2 && result++;
  }
  console.log(result);
}

function getSum(nums){
	var total = 0;
	for(var i = 0; i < nums.length; i++)
		total += parseInt(nums[i]);
	return total;
}

var n = readline().split(" ");

var ans = 0;
for(var i = 0; i < n; i++){
	var votes = readline().split(" ");
	var sumOfVotes = getSum(votes);
	if(sumOfVotes > 1) ans++;
}

print(ans);

var problems = readline();

function resolve(prb) {
    var problSolv=0;
    for (var i=0; i<prb; i++) {
        var persons = readline().split(" ");
        var total = parseInt(persons[0])+parseInt(persons[1])+parseInt(persons[2]);
        if (total>=2) {
            problSolv++;
        }
    }
    return problSolv;
}
print (resolve(parseInt(problems)));

//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 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 N = nextInt();
  var output = 0;
  for(var i = 0; i < N; i++){
    var list = nextIntArray();
    var count = 0;
    for(var j = 0; j < list.length; j++){
      count += list[j];
    }
    if(count >= 2){
      output++;
    }
  }
  myout(output);
}

var n = Number(readline());
var count = 0;
for (var i = 0; i < n; i++) {
	if (readline().split(" ").map(x => Number(x)).reduce((a, b) => a + b) > 1) count++;
}
print(count);

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

let input = [];
rl.on('line', function(line) {
	input.push(line);
	if (input.length === input[0] * 1 + 1) {
		//n m a
		input.shift();
		team(input);
		rl.close();
	}
});

let team = (array) => {
	const reducer = (accumulator, currentValue) => 1 * accumulator + 1 * currentValue;
	let result = array
		.map((el) => {
			return el.split(' ').reduce(reducer);
		})
		.filter((el) => {
			return el >= 2;
		});
	console.log(result.length);
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const n = readline().split(' ').map(x => parseInt(x));
  let result = 0;
  for (let i = 0; i < n; i++) {
    const vote = readline().split(' ').map(x => parseInt(x))
      .reduce((a, b) => a + b, 0);
    if (vote > 1) {
      result++;
    }
  }

  // output
  print(result);
}

var numberOfProblems = readline();
var result = 0;

for(var i = 0; i < numberOfProblems; i++){
    var decisions = readline().split(' ');
    var numberOfCanSolve = 0;

    for(var j = 0; j < decisions.length; j++){
        if(parseInt(decisions[j]) === 1){
            numberOfCanSolve++;
        }

    }
    if(numberOfCanSolve > 1){
            result++;
        }

}

print(result);

//Team

const {EOL} = require('os');

let inp = '';

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

process.stdin.on('end', () => {
    let lines = inp.split(EOL);

    let c = 0;
    for(let i = 1; i <= +lines[0]; i++)  {
    	c += Math.floor(lines[i].split(' ').reduce((a, b) => (+a) + (+b)) / 2);
    }

    process.stdout.write(c + "");

    return;
});

var problemas = readline();
var datos = new Array();
var contador = 0;
var linea = 0;

for (var x = 0; x < problemas; x++){
	linea = readline().split(' ').map(Number);
	if (linea[0]+linea[1]+linea[2] >= 2){
		contador++;
	}
}

print(contador);

'use strict';

const count = readline();
let answer = 0;

for (let i=0; i<count; i++){
    const regex = /\s+/;
    const input = readline();
    const splitted = input.split(regex);

    let sureCnt = 0;

    for(let i=0; i<splitted.length; i++){
        if (splitted[i] == 1){
            sureCnt += 1;
        }
    }

    if(sureCnt >= 2){
        answer += 1;
    }
}

print(answer);

readline();
var ans = 0;
for (var s; s = readline(); ) {
    var count = s.split( ' ' ).reduce( function(last, it) {
        return (it - '') + last;
    }, 0 );
    count > 1 && ans++;
}

print( ans );

'use strict'
const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin
});
var inp, nb, sum = 0, tt = 0, count = 0, sum = 0;
rl.question('', (nb) => {
  rl.on('line', (inp) => {
    sum = Number(inp[0]) + Number(inp[2]) + Number(inp[4]);
    if (sum >= 2){
      tt++;
    }
    count++;
    if (count == nb) {
      console.log(tt);
      rl.close();
    }
  });
});

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

function processData(data) {
     const input =  data.trim().split('\n').map(string => {
        return string.trim();
    });

        let res = 0

for (let i=1;i<=parseInt(input[0]);i++) {
    if ((input[i].split("1").length-1) > 1) {
        res++;
      }
  }
       console.log(res);

}

const readline = require('readline');

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

var count = 0;
var tasksCount;
var linesToSolve = [];

rl.on('line', line => {
    if (count === 0) {
        tasksCount = parseInt(line);
        count++;
        return;
    }

    linesToSolve.push(line);
    count++;

    if (count === tasksCount + 1) {
        rl.close();
        return;
    }
});

rl.on('close', () => {
    var result = 0;

    linesToSolve.forEach(item => {
        result += solveLine(item);
    });

    console.log(result);
    rl.close();
});

function solveLine(line) {
    return (line.match(/1/g) || []).length >= 2 ? 1 : 0;
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let problems= readline();
    let count =0;
    for (let i=0;i<problems;i++){
        let [A,B,C]= readline().split(" ");
        if(parseInt(A) + parseInt(B) + parseInt(C) >= 2){
            count++
        }
    }
    console.log(count);

    return ;
}

const readline = require('readline');

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

let data = [];
rl.on('line', (input) => {
   data.push(input);
});

rl.on('close', () => {
   solve(data);
});

function solve(data) {

   const reducer = (acc, curr) => {
      if (curr == "1") {
         return acc + 1;
      } else {
         return acc;
      };
   }

   total = 0;
   for (let i = 1; i < data.length; i++) {
      n = data[i].split(" ").reduce(reducer, 0);
      if (n >= 2) total++;
   }
   console.log(total);

}

var r = readline()

var count = 0

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

    count += readline().split(" ").map((x) => Number(x)).reduce((a,b) => a+b) >= 2 ? 1 : 0;

}

print(count)

var n = readline(), ans = 0;
while(n--){
    var temp=readline();
    if((temp.split(" ").toString().match(/1/g) !=null) &&(temp.split(" ").toString().match(/1/g).length>=2)){
        ans+=1;
    }
}
print(ans);

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

let inp = 0
process.stdin.on("data",input=>{
    inp = input
})
process.stdin.on("end",input=>{
    inp = inp.replace(/\s*$/, '').split("\n").map(str => str.replace(/\s*$/, ''));

    main();

})

function main(){
    let sure = 0;
    for (let i=1;i<=inp[0];i++){
        if(inp[i].split(" ").filter(item=>{return item>0}).length>1){sure += 1}
    }
    console.log(sure)
}

var n = parseInt(readline());
var output = 0;

for(var i = 0; i < n; i++)
{
	var sures = readline();
	if(sures.indexOf('1') != sures.lastIndexOf('1')) output++;
}

print(output);

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let t = parseInt(readLine())
	let solCount=0
	while(t--){
		let [petya,vasya,tonya] = readLine().split(" ").map(n=>+n)
		if(petya && vasya || vasya && tonya || petya && tonya)
			solCount++
	}
	console.log(solCount)
}

var numberOfProblems = parseInt(readline());
var arrOfAnswers = [];
for(var i = 0; i < numberOfProblems; ++i) {
    arrOfAnswers[i] = readline().split(" ").map(function(val){
        return parseInt(val);
    });
}
var friendsNum = 3;
var sureOfSolutions = 0
var countOfWhoSure = 0;

for(i = 0; i < parseInt(numberOfProblems); ++i) {
    countOfWhoSure = 0;
    for(var j = 0; j < friendsNum; ++j) {
        if(arrOfAnswers[i][j] == 1) {
            ++countOfWhoSure;
            if(countOfWhoSure == 2) {
                ++sureOfSolutions;
                break;
            }

        }
    }
}

print(sureOfSolutions);

if (process.argv[2] === "test") {
  lines = ["3", "1 0 0", "1 1 0", "0 1 1"];
  solve(lines);
} else {
  let i = "";
  process.stdin.on("data", (c) => (i += c));
  process.stdin.on("end", () => {
    const { EOL } = require("os");
    const lines = i.split(EOL);

    solve(lines);
  });
}

function solve(lines) {
  const problemCount = lines[0];
  let answerCount = 0;
  for (let x = 0; x < problemCount; ++x) {
    const answers = lines[x + 1].split(" ");
    const score = answers.filter((x) => x === "1").length;
    if (score >= 2) {
      ++answerCount;
    }
  }
  console.log(answerCount);
}

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

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let ty = parseInt(readLine())
	let solCount=0
	while(ty--){
		let [petya,vasya,tonya] = readLine().split(" ").map(n=>+n)
		if(petya && vasya || vasya && tonya || petya && tonya)
			solCount++
	}
	console.log(solCount)
}

numOfLines = readline();
        num = parseInt(numOfLines);
        output = 0;
        outputInOneLine = 0;
        for (i = 0; i < num; i++) {
            line = readline();
            val = line.split(" ");
            val.map(el => {
                if (el == 1) {
                    outputInOneLine++;
                }
            })
            if (outputInOneLine > 1) {
                output++;
            }
            outputInOneLine = 0;
        }
        print(output);

var count = readline();

var ans = 0;
for(var i = 0; i< count; i++){
    var nums = readline();
    nums = nums.split(' ');
    var sum = 0;
    nums.map(a => {
        a = parseInt(a,10);
        if(a>0){
            sum++;
        }
    });
    if(sum>1){
        ans++;
    }
    sum=0;
}

print(ans);

var a  =  readline();
var jami = 0;
for(i = 1; i <= a; i ++ ) {
	var cin = readline().split(" ").sort(function(a,b){return a-b});
	if(cin[1] == 1) {
		jami += 1;
	}

}

print(jami);

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

var idx = 0;
var out = 0;
rl.on("line", (theLine) => {
    if (idx === 0) {
        lines = parseInt(theLine);
    }
    else {
        var scores =  theLine.split(" ");
        var currentCount = 0;
        scores.forEach(element => {
            if (element === "1")
                currentCount++
        });
        if (currentCount>1)
            out++;
    }
    idx++;
    if (idx > lines)
    {
        rl.close();
          console.log(out.toString());
    }

})

let fs = require('fs')

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

for (let index = 0; index < txt.length; index++) {
    if (!isNaN(txt[index]*1)) {
        let tab = []
        for (let i = 1; i <= txt[index]; i++) {
            tab.push(txt[index + i].split(" ").filter(data=>{return data.length>0}));
        }
        square(tab)
    }

}

function square(tab) {
    let score = 0;
    tab.forEach(element => {
        if (element.filter(data => {
                return data == 1
            }).length >= 2) {
            ++score;
        }
    });
    console.log(score);
}

var numberOfSolutions = 0,
    count = +readline();
while(count--){
    var views = readline().split(" ");
    var sum = 0;
    for(var i = 0; i<3; i++){
        sum += +views[i];
    }
    if(sum >=2){
        numberOfSolutions++;
    }
}
print(numberOfSolutions);

var num_problemas = readline(); // Leemos el número de problemas que debemos tratar
var respuestas = 0;
var respuesta_individual;
// Por cada problema propuesto:
for (var i = 0; i < num_problemas; i++) {
    var problema = readline().split(" "); // Leemos y transformamos en un array las soluciones del equipo
    // Por cada solución individual propuesta:
    respuesta_individual = 0;
    for (var j = 0; j < problema.length; j++) {
        if (problema[j] == 1) {
            respuesta_individual++;
        }
    }
    // Si hay más de una respuesta afirmativa:
    if (respuesta_individual > 1) {
        respuestas++;
    }
}
print(respuestas);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {

    let solve=(A)=>{
        let n=A.length,result=0
        for(let i=0;i<n;i++){
            let total=A[i].reduce((a,c)=>a+Number(c),0)
            if(total>=2){
                result++
            }
        }
        return result
    }

    let n=readline()
    let A=[]
    for (let i = 0; i < n; i++) {
        A.push(readline().split(" ").map(d=>Number(d)))
    }

    let result=solve(A)
    console.log(result.toString())

}

// Sample code to perform I/O:

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

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

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

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

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

// Write your code here
function nameLookUp(arr) {
    let nLines = arr.split('\n');
    let problems = +nLines[0].trim();
    let problemSolArr = nLines;
    let solution = 0;
    for (let solProb of problemSolArr.slice(1)) {

        let bits = solProb.trim().split(' ');

        let sum = bits.reduce(function (acc, value) {
            return acc + parseInt(value);
        }, 0);
        if (sum > 1) {
            solution++;
        }
    }

    return solution.toString();

}

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() {
  var T = readLine();
  var count = 0;
  while (T--) {
    var str = readLine();
    var strSingle = str.split(" ");
    for (let i = 0; i <= T; i++) {
      if (
        (strSingle[0] == 1 && strSingle[1] == 1) ||
        (strSingle[0] == 1 && strSingle[2] == 1) ||
        (strSingle[1] == 1 && strSingle[2] == 1)
      ) {
        count++;
        break;
      }
    }
  }
  if (count) {
    console.log(count);
  } else {
    console.log(0);
  }
}

var x = parseInt(readline());

var total = 0;
for (var i=0 ; i<x;i++){
    var sum = 0;
    var a = readline().split('');

    a.forEach(function(i){
        var r = parseInt(i);
        if(r==1){sum+=1;}})
    if(sum ==2 || sum==3){total++}
}
print(total);

var input = readline().split(' ');
var result=0;
for(var i = 0; i<parseInt(input);i++)
{
  var line =readline();
  if(line[0]==1 && (line[2] == 1 || line[4] ==1))
    result++;
  else if(line[2]==1 && line[4] ==1)
    result++;

}
print(result);

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

const input = [];
readLine.on('line', line => input.push(line));

const aTeam = (a) => {
    +input.shift();
    let common = 0;
    for (let x of input) {
       const ar =  x.split(' ').map(x => +x);
        let score = 0;
        for (let y of ar) {
            score += y;
        }
        if (score >= 2) {
            common ++;
        }
    }
    console.log(common);
};

readLine.on('close', aTeam);

var n = parseInt(readline());

var input = [];

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

var solvedCount = 0;
var sureCount = 0;

input.forEach(function(line) {
    sureCount = 0;

    line.forEach(function(value) {
        if (parseInt(value)) {
            sureCount++;
        }
    });

    if (sureCount >= 2) {
        solvedCount++;
    }

});

print(solvedCount);

var n = parseInt(readline());
var output = 0;

for(var i = 0; i < n; i++)
{
	var tmp = 0;
	var sures = readline().split(' ').map(function(c){
		if(c == 1) tmp++;
	});
	if(tmp >= 2) output++;
}

print(output);

var n = parseInt(readline());
var output = 0;

for(var i = 0; i < n; i++)
{
	var tmp = 0;
	var sures = readline().split(' ').map(function(c){
		if(c == 1) tmp += 1;
	});
	if(tmp >= 2) output += 1;
}

print(output);

var n = parseInt(readline()), output = 0, sures;

for(var i = 0; i < n; i++)
{
	sures = readline();
	if(sures.indexOf('1') != sures.lastIndexOf('1')) output++;
}

print(output);

var counter=0;
var problems = readline();
var array2D=[];
for(var i=0;i<problems;i++){
    array2D.push(readline().split(" ").map(x => parseInt(x)));
}
for (var i = 0 ; i < problems ; i++)
{
    if ((array2D[i][0]==array2D[i][1] && array2D[i][0]==1) ||
        (array2D[i][0]==array2D[i][2] && array2D[i][0]==1) ||
        (array2D[i][1]==array2D[i][2] && array2D[i][1]==1)){
            counter++;
    }
}
print (counter)

readline()
var values;
var count = 0;
while(values = readline()){
    if(values.replace(/[ 0]/g, "").length > 1) count++
}

print(count)

var answer = readline();
var result = 0;
for(var i = 0; i < answer; i++){
    var input = readline().split('');
    var sum = 0;
    for(var x = 0; x < input.length; x++){
        if(input[x] == 1){
            sum ++;
        }
    }
    if(sum > 1){
        result ++;
    }
}
print(result);

var n = readline();
var ans = 0;
for (i = 0; i < n; ++i) {
  l = readline().split(' ').map(function(x) {
    return parseInt(x);
  });
  ans += (l[0] + l[1] + l[2] >= 2);
}
print(ans);

const n = Number(readline());
var c ;
var q = 0;
for(var i = 0; i < n ; i++){
    c = readline().split(" ");
    var k = c.reduce((acc, cur) => {
       if(cur == 1)
       return (acc + 1);
       else
        return acc;
    },0);
    (k >= 2) ? q++ : null;
}
print(q);

const n = Number(readline());
var c ;
var q = 0;
for(var i = 0; i < n ; i++){
    c = readline().split(" ");
    var k = c.reduce((acc, cur) => {
       if(cur == 1)
       return (acc + 1);
       else
        return acc;
    },0);
    (k >= 2) ? q++ : null;
}
print(q);
//

var noOfProblems = +readline();

var noOfSolutions = 0;

for (var i = 0; i < noOfProblems; i++) {
    var opinions = readline().split(" ");
    if (+opinions[0] === 1 && +opinions[1] === 1) {
        noOfSolutions += 1;
    } else if (+opinions[0] === 1 && +opinions[2] === 1) {
        noOfSolutions += 1;
    } else if (+opinions[1] === 1 && +opinions[2] === 1) {
        noOfSolutions += 1;
    }
}
print(noOfSolutions);

var r = readline();
var c = 0;
for(var i = 0; i<r; i++){
    var l = readline().split(' ');
    var d = 0;
    for (var j = 0; j<l.length; j++){
        if(l[j] == 1){
            d++;
        }
    }
    if (d >= 2){
        c++;
    }
}
print(c);

var n = readline();
var count = 0
for(var i = 0; i<n; i++){
    count += readline().split(' ').map(x => parseInt(x)).reduce((a,b) => a + b) >=2 ? 1 : 0
}
print(count)

var n = readline();
var count = 0
for(var i = 0; i<n; i++){
    if (readline().split(' ').map(x => parseInt(x)).reduce((a,b) => a + b) >=2){
        count += 1
    }
}
print(count)

var AtLeastTwoAgreed = array => {
  var howManyAgreed = 0;
  for(var number of array)
  {
    howManyAgreed += number === 1 ? 1 : 0;

    if(howManyAgreed === 2)
      return 1;
  }

  return 0;
}

print(
  [...Array(+readline())].map(x => readline().split(' ').map(n => +n))
    .map(values => AtLeastTwoAgreed(values))
    .reduce((result, current) => result + current, 0)
);

var problems = parseInt(readline());
var unsolved = 0;
while(problems--){
    var problem = readline().split(" ");
    var solution = 0;
    for(var i = 0; i < problem.length; i++){
        if(problem[i] == "1"){
            solution++;
        }
    }

   if(solution >= 2){
    unsolved++;
   }
}
print(unsolved);

var x=parseInt(readline());
var res=0;

while(x--){
    var z = readline().split(' ');
    var sum=findSum(z);
    // print("Sum:",sum);
    res+=Math.floor(sum/2);
}

function findSum(z){
    return z.reduce((a,b) => parseInt(a)+parseInt(b),0);
}

print(res);

var q = parseInt(readline());

var result = 0;
for (var i = 0; i < q; i++) {
    var known = readline().split(" ").map(x => parseInt(x));

    if (known[0] + known[1] + known[2] >= 2) {
        result++;
    }
}

print(result);

var n = readline();

var result = 0;

for(var i = 0 ; i < n; i++){
  var string = readline();
  string = string.replace(/\s/g,'');
  var decision = 0;

  for(var j =0; j < string.length;j++){
    if(string[j] == 1)
      decision++;
  }

  if(decision >= 2)
  result++;
}

print(result);

var n = parseInt(readline());
var arr = [];
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] === 1 && w[i + 1] === 1 || w[i + 1] === 1 && w[i + 2] === 1 || w[i] === 1 && w[i + 2] === 1) {
               result++;
               result += result;
               print(result.length);
            }else {
                result += result
                print(result.length);
            }

         }
}
//print (arr[0]);

var problems = readline();

function resolve(prb) {
    var problSolv=0;
    for (var i=0; i<parseInt(prb); i++) {
        var count=0;
        var persons = readline().split(' ');

        if (persons[0]===1) {
            count++;
        } else if (persons[1]===1) {
            count++;
        } else if (persons[2]===1) {
            count++;
        }

        if (count>=2) {
            problSolv++;
        }
    }
    return problSolv;
}

print (resolve(problems));

var input = readline().split("\n");
var count = 0;
for(var i = 1;i < input.length; i++){
    var sures = input[i].split(" ").filter(function(element){return element == 1});
    if(sures.length > 1) count++;
}
print(count);

process.stdin.on('data', input => {
  const testArguments = input.toString().split('\n').splice(1);
  let count = 0;
  testArguments.forEach(test => {
    count += checkIfSolveProblem(test.split(' '))
  })
  console.log(count);
});

function checkIfSolveProblem(arr) {
  const result = arr.reduce((acc, curr) => {
    if (curr) {
      acc++
    }

    return acc;
  }, 0)

  return result > 0 ? 1 : 0;
}

readline();
var ans = 0;
for (var s; s = readline(); ) {
    1 < s.split( ' ' ).reduce( function(it, last) { return it - '' + last; }, 0 ) && ans++;
}

print( ans );

var n = parseInt(readline()),
    p = readline().split(' ').map(function(x) { return parseInt(x); }),
    i,
    s = 0,
    c = 0;

for(i = 0; i < n; i++) {
    c += p[i];
}
if(c>=2) s=c;
write(s);

const readline = require('readline')

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

rl.on("line", main)
let i = 0
let n;
let imp = 0
function main(input){
	if(i == 0 ){
		n = input
		i++
		return
	}
	if(n == i){
		console.log(imp)
		return
	}
	let p, v, t

	const arr = input.split(' ')

	p = arr[0]
	v = arr[1]
	t = arr[2]

	let result = parseInt(p) + parseInt(v) + parseInt(t)
	if(result >= 2){
		//they will imp
		imp++
	}

	i++

}

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = parseInt(readline());
var datos = new Array();
var contador = 0;

for (var x = 0; x < problemas; x++){
	datos.push(readline().split(' '));
}

for (var y = 0; y <datos.length-1;y++){
	if(datos[y] == 1){
		contador++;
	}
}

print(contador);

/*
var problemas = 3;
var datos = [1,1,0,1,1,1,1,0,0];
var contador = 0;

for (var x = 0; x <= datos.length-1; x++){
	if(datos[x] == 1){
		contador++;
	}
}

document.write(contador/problemas);
*/

var outp = 1;
for (var i = 0; i < Number(readline()); i++) {
    var str = readline().split(' ');
    var count = Number(str[0]) + Number(str[1]) + Number(str[2]);
    if (count > 1) outp ++;
}
print(outp);

var problems = readline();

function resolve(prb) {
    var problSolv=0;

    for (var i=0; i<prb; i++) {
        var count=0;
        var persons = readline().split(' ');

        if (persons[0]===1) {
            count++;
        } else if (persons[1]===1) {
            count++;
        } else if (persons[2]===1) {
            count++;
        }

        if (count>=2) {
            problSolv++;
        }
    }

    return problSolv;
}

print (resolve(parseInt(problems)));

var count = parseInt(readline()),
    current = [], currentMas, sum, answer = 0;

for(var i = 0; i < count; i++) {
    current[i] = readline().split(" ");
}

for(var i = 0; i < count; i++) {
    currentMas = current[i];
    sum = 0;

    for(var j = 0; j < 3; j++) {
        sum+=currentMas[j];
    }

    if(sum >= 2) {
        answer+=1;
    }
}

print(answer);

var n = readline()
var zad = 0;

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

	var str = readline().split(' ');
	var sum = str.reduce((sum, current)=> parseInt(sum+current));

	if(sum=>2)
	zad++;
};
print(zad);

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = readline();
var input = [];

var resueltos = 0;

for (var x = 0; x < problemas; x++){
	input.push(readline().split(' '));

}

print(input);

n = readline();
var tedad = 0;
while(n--)
{
 	s=readline().split('0')

	if(s.length > 3){tedad++}

}
print(tedad)

var problems = readline();

function resolve(prb) {
    for (var i=0; i<prb; i++) {
        var problSolv=0;
        var persons = readline().split(' ');
        var total = parseInt(persons[0])+parseInt(persons[1])+parseInt(persons[2]);
        if (total>=2) {
            problSolv++;
        }
    }
    return problSolv;
}
print (resolve(parseInt(problems)));

var n = readline()
var zad = 0;

for (var i=0; i<n; i++){
	var sum=0;
	var str = readline().split(' ');
	sum = str.reduce((sum, current)=> +sum+ +current);

	if(sum=>2)
	++zad;
};
print(zad);
//console.log(zad);

var n = parseInt(readline());
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1 < w.length) {
               result++;
               result += result;
               write(result[0]);
            }else {
                write(result[0]);
            }

         }
}

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = parseInt(readline());
var datos = new Array();
var contador = 0;

for (var x = 0; x < problemas; x++){
	datos.push(readline().split(' '));
}

for (var y = 0; y <datos.length-1;y++){
	if(datos[x] == 1){
		contador++;
	}
}

print(contador);

/*
var problemas = 3;
var datos = [1,1,0,1,1,1,1,0,0];
var contador = 0;

for (var x = 0; x <= datos.length-1; x++){
	if(datos[x] == 1){
		contador++;
	}
}

document.write(contador/problemas);
*/

var n = parseInt(readline());
while (n--) {
        var w = readline();
        var result = 0;
         var arr = [];
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1 < w.length) {
               result++;
               result += result;
               arr.push(result);
            }else {
                result += result
                arr.push(result);
            }
         print (arr[0]);
         }
}

var n = readline()
var zad = 0;

for (var i=0; i<n; i++){
	var str = readline().split(' ');
	var sum = str.reduce((sum, current)=> +sum+ +current);

	if(sum=>2)
	++zad;
};
print(zad);
//console.log(zad);

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = readline();
var datos = new Array();
var contador = 0;

for (var x = 0; x < problemas; x++){
	datos.push(readline().split(' '));
}

for (var y = 0; y<datos.length-1;y++){
	if(datos[x] == 1){
		contador++;
	}
}

print(contador/problemas);

/*
var problemas = 3;
var datos = [1,1,0,1,1,1,1,0,0];
var contador = 0;

for (var x = 0; x <= datos.length-1; x++){
	if(datos[x] == 1){
		contador++;
	}
}

document.write(contador/problemas);
*/

var q = parseInt(readline());

var result = 0;
for (var i = 0; i < q; i++) {
    var known = readline().split(" ").map(x => parseInt(x));

    var res = 0;
    for (var j = 0; j < known; j++) {
        if (known[j] === 1) {
            res++;
        }
    }

    if (res >= 2) {
        result++;
    }
}

print(result);

const readline = require('readline')

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

rl.on("line", main)
let i = 0
let n = 0
let imp = 0
function main(input){
	if(n == 0 ){
		n = input
		return
	}
	if(n == i){
		console.log(imp)
		return
	}
	let p, v, t

	const arr = input.split(' ')

	p = arr[0]
	v = arr[1]
	t = arr[2]

	let result = parseInt(p) + parseInt(v) + parseInt(t)
	if(result >= 2){
		//they will imp
		imp++
	}

	i++

}

var t = readline();
count = 0;
for(var i=1;i<t;i++){
    var x=readline().split(' ');
    var a=Number(x[0]);
    var b=Number(x[1]);
    var c=Number(x[2]);
    if((+a)+(+b)+(+c)>=2){
    count++;
    }
}
print(count);

var nProblems = readline().split(" ").map(function(x) { return parseInt(x); })[0];

var result = 0;

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

    var implement = 0;

    for (var j = 0; j < randomRussians.length; j++)
    {
        if (randomRussians[i] == 1)
            implement++;

        if (implement >= 2)
        {
            result++;

            break;
        }
    }
}

print(result);

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = readline();
var datos = new Array();
var contador = 0;
var linea = 0;

for (var x = 0; x < problemas; x++){
	linea = readline().split(' ');
	if (linea[0]+linea[1]+linea[2] >= 2){
		contador++;
	}
}

print(contador);

var lines = readline();
var outp = 0;
for (var i = 0; i < lines; i++) {
    var str = readline().split(' ');
    var count = 0;
    for (var j = 0; j < 3; j++) {
        count += str[j];
    }
    if (count >= 2) outp ++;
}
print(outp);

var numberOfProblems = readline();
var arrOfAnswers = [];
for(var i = 0; i < numberOfProblems; ++i) {
    arrOfAnswers[i] = readline();
}
var friendsNum = 3;
var sureOfSolutions = 0
var countOfWhoSure = 0;

for(var i = 0; i < numberOfProblems; ++i) {
    countOfWhoSure = 0;
    for(var j = 0; j < friendsNum; ++j) {
        if(parseInt(arrOfAnswers[i][j])) {
            ++countOfWhoSure;
            if(countOfWhoSure == 2) {
                ++sureOfSolutions;
                break;
            }
        }
    }
}

print(sureOfSolutions);

'use strict';

// let inpArr = `
// 3
// X--
// --X
// X++
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

let n = Number(readline()), X = 0;
for (var i = 0; i < n; i++) {
  let str = readline();
  if (str.indexOf('+') !== -1) {
    X++;
  } else {
    X--;
  }
}
print(X);

var count = readline()
var totalRightAnswers = 0;

while(count){
    var round = readline()
    const haveAnswers = round.split(" ")
    const res = haveAnswers.reduce((accumulator, currentValue) => {
        if (currentValue == '1') return accumulator++
    });
    if(res >= 2){
        totalRightAnswers++
    }
    count--
}

print(totalRightAnswers)

var n = parseInt(readline());
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1 < w.length) {
               result++;
               result += result;
               write(result);
            }else {
                write(result);
            }

         }
}

var t = readline();
t=+t+1;
print(t);
count = 0;
for(var i=1;i<t;i++){
    var x=readline().split(' ');
    var a=+x[0];
    var b=+x[1];
    var c=+x[2];
    print(a+b+c);
    if(a+b+c>=2){
    count++;
    }
}
print(count);

var numberOfTestCases = parseInt(readline());

var input;

var ans = 0;

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

input = readline().split(" ");

var counter = 0;

for (var j=0; j<input.length; j++){
    if (input[j] == 1){
        counter++;
    }
}

if (counter > 2){
    ans++;
}

}

print(ans);

var loop = readline();
var correct = 0;
for (var i = 0; i < loop; i++){
    var total = readline().split(" ");
    if(total[0] + total[1] + total[2] > 2){
        correct++;
    }
}

print(correct);

var t = readline();
count = 0;
for(var i=1;i<t;i++){
    var x=readline().split(' ');
    var a=x[0];
    var b=x[1];
    var c=x[2];
    if((+a)+(+b)+(+c)>=2){
    count++;
    }
}
print(count);

var n = +readline(),
	result = 0;
while (n--) {
	var array = readline().split(' ').map(function (item) { return item > 0; });
    result += array.length > 1 ? 1 : 0;
}
print(result);

/*
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers n problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input
The first input line contains a single integer n (1 ≤ n ≤ 1000) — the number of problems in the contest. Then n lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output
Print a single integer — the number of problems the friends will implement on the contest.
*/

var problemas = parseInt(readline());
var datos = new Array();
var contador = 0;

for (var x = 0; x < problemas; x++){
	datos.push(readline().split(' '));
}

for (var y = 0; y <datos.length-1;y++){
	if(parseInt(datos[y]) == 1){
		contador++;
	}
}

print(contador);

/*
var problemas = 3;
var datos = [1,1,0,1,1,1,1,0,0];
var contador = 0;

for (var x = 0; x <= datos.length-1; x++){
	if(datos[x] == 1){
		contador++;
	}
}

document.write(contador/problemas);
*/

var count = readline()
var totalRightAnswers = 0;

while(count){
    var round = readline()
    const haveAnswers = round.split(" ")
    var accumulator = 0
    haveAnswers.forEach(element => {
        if (element == '1') return accumulator++
    });
    if(accumulator >= 2){
        totalRightAnswers++
    }
    count--
}

print(totalRightAnswers)

var n=readline();
var int=parseInt(n);
var count=0;

for(var i=1; i<=int; i++){

    for(var j=1; j<=int; ++j){
     var question=readline();
     var newint=parseInt(question);
     var sum=0;
      sum=sum+newint;

   }
    if(sum==2 || sum==3){
      count++;
}
 print(count);
}

var n = parseInt(readline());
var arr = [];
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] === 1 && w[i + 1] === 1 || w[i + 1] === 1 && w[i + 2] === 1 || w[i] === 1 && w[i + 2] === 1) {
               result++;
               result += result;
               arr.push(result);
            }else {
                result += result
                arr.push(result);
            }

         }
}
print (arr[0]);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let testcases=Number(readline())

    let solve=(A)=>{
        let n=A.length,result=0
        for(let i=0;i<n;i++){
            let total=A[i].reduce((a,c)=>a+c)
            if(total>=2){
                result++
            }
        }
        return result
    }

    for (let i = 0; i <testcases; i++) {
        let n=readline()
        let A=[]
        for (let i = 0; i < n; i++) {
            A.push(readline().split(" ").map(d=>Number(d)))
        }

        let result=solve(A)
        console.log(result.toString())
    }

}

var t = readline(),
    a = 0;
while(t--){
    var x = readline().split(' ');
    var count = 0;
    for(var i = 0;i<3;i++){
        if(x[i] === 1){count++;}
    }
    if(count>=2){
    a++;
    }
}
print(a);

var problems = readline();

function resolve(prb) {
    for (var i=0; i<prb; i++) {
        var problSolv=0;
        var persons = readline().split(' ');
        if ((persons[0]+persons[0]+persons[0])>=2) {
            problSolv++;
        }
    }
    return problSolv;
}
print (resolve(parseInt(problems)));

var pro = readline();
var tot = 0;
function getSum(total, num) {
    return total + num;
}
for (i = 0; i < pro; i++) {
   var arr = readline().split(' ');
    var col = arr.reduce(getSum);
    if (col >= pro) {
        var out = tot + 1;

    }

}
print(out);

var problems = readline();

function resolve(prb) {
    for (var i=0; i<prb; i++) {
        var problSolv=0;
        var persons = readline().split(' ');
        if ((persons[0]+persons[1]+persons[2])>=2) {
            problSolv++;
        }
    }
    return problSolv;
}
print (resolve(parseInt(problems)));

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
let numberOfProblems = 0
let numberofSolvedProblems = 0 ;
let counter = 0;
let arrofInputs = [];
let getuserInputs = ()=>{
  rl.on("line",(input)=>{
    if(!numberOfProblems) {
      numberOfProblems = parseInt(input)
      console.log("Problems We Got Today :"+numberOfProblems + "\n")
    }
    else
    {
      counter++
      arrofInputs = input.split(" ").map(Number)
      if(!arrofInputs.includes(0))numberofSolvedProblems++
      else{
        let temp = 0
        arrofInputs.forEach(element => {
          if(element===1) temp++
        });
        if (temp>=2) numberofSolvedProblems++
      }
      if (counter>=numberOfProblems){
         console.log(numberofSolvedProblems)
         rl.close();
        }
    }
 })}
getuserInputs()
// })
// let numberofSolvedProblems = 0;
// let numberOfProblems = parseInt(prompt());
// for(let i=0 ;i<numberOfProblems;i++){
//   let temp  = (prompt().split(" ")).map(Number)
//   if (!temp.includes(0))
//   {
//     numberofSolvedProblems++
//   }
//   else{
//     //console.log("First Else Fired")
//     let zeroCounter = 0 ;
//     temp.forEach(element => {
//       if(element === 0)
//       {
//         zeroCounter++
//       }
//     })
//     if(zeroCounter>1)
//     numberofSolvedProblems = numberofSolvedProblems
//     else
//     numberofSolvedProblems++
//   }
// }
// console.log(numberofSolvedProblems)

//// rl.close()

var count = parseInt(readline()),
    current = [], currentMas, sum, answer = 0;

for(var i = 0; i < count; i++) {
    current[i] = readline().split(" ");
}

for(var i = 0; i < count; i++) {
    currentMas = current[i];
    sum = 0;
    for(var j = 0; j < 3; j++) {
        sum+=currentMas[j];
    }

    if(sum>=2) {
        answer+=1;
    }
}

var lines = Number(readline());
var outp = 0;
for (var i = 0; i < lines; i++) {
    var str = readline().split(' ');
    var count = str[0] + str[1] + str[2];
    if (count >= 2) outp ++;
}
print(outp);

var result = 0;
  var count = parseInt(readline().split(''));
  function canResolve(value){
    return value === '1';
  }
  for (var i = 0; i < count; i++) {
    var array = readline().split(' ');
    result += array.filter(canResolve).length >= 2 ? 1 : 0;
  }
  print(result);

var n = parseInt(readline());

var input = [];

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

var solvedCount = 0;
input.forEach(function(line) {
    var sureCount = 0;
    line.forEach(function(value) {
        if (value) {
            sureCount++;
        }
    });
    if (sureCount >= 2) {
        solvedCount++;
    }
});

print(solvedCount);

var t = readline();
while(t--){
    var x = readline().split(' ');
    var a = 0,
        count = 0;
        for(var i = 0;i<3;i++){
            if(x[i] === 1){count++}
        }
        if(count=>2){
        a++
        }
}
print(a);

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() {
  var T = readLine();
  var count = 0;
  while (T--) {
    var str = readLine();
    var strSingle = str.split(" ");
    for (let i = 0; i <= T; i++) {
      if ((strSingle[0] == 1 && strSingle[1] == 1) || (strSingle[1] == 1 && strSingle[2] == 1)) {
        count++;
        break;
      }
    }
  }
  if (count) {
    console.log(count);
  } else {
    console.log(0);
  }
}

const stdin = process.openStdin();
let n;
let i = 0;
let output = 0;

process.stdin.on('data', function (chunk) {
  lines = chunk.toString().split('\n');
  lines.map(line => processLine(line));
});

function processLine(text) {
  if (n) { i += 1; }
  if (!n) { n = parseInt(text.toString()) }

  if (i > 0) {
    const solve = text.toString().trim().split(' ').reduce((a, b) => a + b, 0) > 1;
    console.log(solve)
    if (solve) { output += 1; }
  }

  if (i === n) { console.log(output); }
}

var n = readline()
var zad = 0;

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

	var str = readline().split(' ');
	var sum = str.reduce((sum, current)=> parseInt(sum+current));

	if(sum=>2)
	zad++;
};
print(zad);

var n = readline();
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1) {
               result++;
               result += result;
               if (result < w.length - 2) {
               print (result);
               }
            }else{
                print(result);
            }

         }
}

var n = parseInt(readline());
var output = 0;

for(var i = 0; i < n; i++)
{
	var tmp = 0;
	var sures = readline().split(' ').map(function(c){
		if(c == 1) tmp += 1;
	});
	if(tmp >= 2) output += 1;
}

var n = readline();
var zad = 0;

for (var i=0; i<n; i++){
	var sum = 0;
	var str = readline().split(' ');
	sum = str[0]+str[1]+str[2];

	if(sum>1)
	++zad;
};
print(zad);

var cases = readline();
var winMatch = 0;
for(var i = 0; i < cases; ++i){
    var points = readline();
    if(points.includes('1 1')){
        ++winMatch;
    }
}

print(winMatch);

var n = parseInt(readline());
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1 < w.length) {
               result++;
               result += result;
               write(result[0]);
            }else {
                write(result[0]);
            }

         }
}

var n = readline()
var zad = 0;
for (var i=0; i<n; i++){

	var str = readline().split(' ');
	var sum = str.reduce((sum, current)=> parseInt(sum+current));

	if(sum=>2)
	zad++;
};
print(zad);

var n=readline();
var int=parseInt(n);
var count=0;

for(var i=1; i<=int; i++){

     var question=readline();
     var numbers = question.split(" ");
     var sum=0;
     for(var j = 0; j < int; ++j) {
        var newint=parseInt(numbers[j]);

        sum=sum+newint;
     }

    if(sum==2 || sum==3){
      count++;
}
 print(count);
}

var loop = readline();
var correct = 0;
for (var i = 0; i < loop; i++){
    var total = readline().split(" ");
    if(total[0] + total[1] + total[2] >= 2){
        correct++;
    }
}

print(correct);

var lines = Number(readline());
var outp = 0;
for (var i = 0; i < lines; i++) {
    var str = readline().split(' ');
    var count = str[0] + str[1] + str[2];
    if (count >= 2) {
        outp ++;
    }
}
print(outp);

var count = readline()
var totalRightAnswers = 0;

while(count){
    var round = readline()
    var haveAnswers = round.split(" ")
    var res = haveAnswers.reduce((accumulator, currentValue) => accumulator + currentValue);
    if(res >= 2){
        totalRightAnswers++
    }
    count--
}

print(totalRightAnswers)

var n = readline();
var zad = 0;

for (var i=0; i<n; i++){
	var sum = 0;
	var str = readline().split(' ');
	sum = str[0]+str[1]+str[2];

	if(sum>1)
	{++zad;};
};
print(zad);

var t = readline();
count = 0;
for(var i=1;i<t;i++){
    var x=readline().split(' ');
    var a=x[0];
    var b=x[1];
    var c=x[2];
    if((+a)+(+b)+(+c)>=2){
    count++;
    }
}
print(count);

var n = parseInt(readline()),
    p = readline().split(' ').map(function(x) { return parseInt(x); }),
    i,
    s = 0,
    c = 0;

for(i = 0; i < n; i++) {
    c += p[i];
}
if(c>=2) s=c;
write(s);

process.stdin.on('data', input => {
  const testArguments = input.toString().split('\n').splice(1);
  let count = 0;
  testArguments.forEach(test => {
    count += checkIfSolveProblem(test.split(' '))
  })
  console.log(count);
});

function checkIfSolveProblem(arr) {
  const result = arr.reduce((acc, curr) => {
    if (curr) {
      acc++
    }

    return acc;
  }, 0)

  return result > 1 ? 1 : 0;
}

var a  =  readline();
var jami = 0;
for(i = 1; i < a; i ++ ) {
	var cin = readline().split(" ").sort(function(a,b){return a-b});
	if(cin[1] == 1) {
		jami += 1;
	}
        else {
                jami += 0;
        }
}

print(jami);

var input=readline();
var int = parseInt(input);
var varr;
var c = 0 ;
var count1 = 0;
var count0 = 0;

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

   varr = readline();
   count(varr);

    if (count1 > count0) {
        c++;
    }

}

function count(str)
{
    for (var i = 0 ; i < str.length ; i++)
    {

        if(str[i] == 1){
            count1++;

        }
        else{
       count0++;
        }
    }
}

print(c);

var n = readline().split(' ')[0];
var solutions = 0;
while(n) {
    var state = readline().split(' ');
    var a = state[0],
        b = state[1],
        c = state[2];

    if ((a && b) || (b && c) || (c && a)) {
        ++solutions;
    }

    --n;
}

print(solutions);

var n = parseInt(readline());
var s = 0;
var i;
for (i=0;i<n;i++){
    x=readline().split(' ');
    if ((x[0]+x[1]+x[2]) >= 2){
        s++;
    }
}
print(s);

var n = readline();

var result = 0;

for(var i = 0 ; i < n; i++){
  var string = readline();
  string = string.replace(/\s/g,'');
  var decision = 0;

  for(var j =0; j < string.length;j++){
    if(string[i] == 1)
      decision++;
  }

  if(decision >= 2)
  result++;
}

print(result);

var n = readline();
var sum=0;

for (var i=0; i<n; i++) {
    var line = readline().split(' ');
    var u = 1;
    for (var m=0; m<line.length; m++) {
         u = u*line[m];
    }
    sum = sum + u;

}
    print (sum);

var n=parseInt(readline());
var k=0;
for(var i=0;i<n;i++){
    var s=parseInt(readline())+parseInt(readline())+parseInt(readline());
    if(s>=2)
        k++;
}
print(k+1);

var n = parseInt(readline());
var arr = [];
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1 < w.length) {
               result++;
               result += result;
               arr.push(result);
            }else {
                result += result
                arr.push(result);
            }

         }
}
print (arr[0]);

        numOfLines = readline();
        num = parseInt(numOfLines);
        output = 0;
        outputInOneLine = 0;
        for (i = 0; i < num; i++) {
            line = readline();
            val = line.split(" ");
            val.map(el => {
                if (el == 1) {
                    outputInOneLine++;
                }
            })
            if (outputInOneLine > 1) {
                output++;
            }
            print(output);
            outputInOneLine = 0;
        }

var n = readline()
var zad = 0;

for (var i=0; i<n; i++){
	var sum=0;
	var str = readline().split(' ');
	sum = str.reduce((sum, current)=> +sum+ +current);

	if(sum=>2)
	++zad;
};
print(zad);
//console.log(zad);

var n = parseInt(readline());
var s = 0;
var i;
for (i=0;i<n;i++){
    x=readline().split(' ');
    if ((x[0]+x[1]+x[2]) >= 1){
        s++;
    }
}
print(s);

var problems = readline();

function resolve(prb) {
    for (var i=0; i<prb; i++) {
        var problSolv=0;
        var persons = readline().split(' ');
        var total = parseInt(persons[0])+parseInt(persons[1])+parseInt(persons[2]);
        if (total>=2) {
            problSolv++;
        }
    }
    return problSolv;
}
print (resolve(parseInt(problems)));

var n = parseInt(readline());
var arr = [];
while (n--) {
        var w = readline();
        var result = 0;
        for (var i = 0; i <= w.length; i++) {
           if(w[i] == 1 && w[i + 1] == 1 || w[i + 1] == 1 && w[i + 2] == 1 || w[i] == 1 && w[i + 2] == 1) {
               result++;
               result += result;
               arr.push(result);
            }else {
                result += result
                arr.push(result);
            }

         }
}
print (arr[0]);

var problems = readline();

function resolve(prb) {
    var problSolv=0;
    for (var i=0; i<prb; i++) {
        var count=0;
        var persons = readline().split(' ');

        if (persons[0]===1) {
            count++;
        } else if (persons[1]===1) {
            count++;
        } else if (persons[2]===1) {
            count++;
        }

        if (count>=2) {
            problSolv++;
        }
    }
    return problSolv;
}

print (resolve(problems));


print(function(n, s, t) {

  var p = ('0 ' + readline()).split(' ').map(Number);

  if (s === t) return 0;

  for (var i = p[s], ans = 1; i !== t && i !== s; ans++, i = p[i]);

  return i === t ? ans : -1;

}.apply(0, readline().split(' ').map(Number)));

;(function () {

	var n = readline().split(' '),
		s = +n[1],
		k = s,
		t = +n[2];
	n = +n[0];

	var p = readline().split(' ').map(Number);

	print((function () {
		var i = 0;
		while (s !== t) {
			s = p[s - 1];
			if (s === k) return -1;
			else i++;
		}

		return i;
	})());

}).call(this);


var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = new Array(N);
		var isOK = true;
		for(var j = 0; j < N; j++){
			list[j] = nextCharArray();
		}
		for(var j = 0; j < N; j++){
			for(var k = 0; k < N; k++){
				if(list[j][k] == "1"){
					var migi = true;
					var sita = true;
					if(j < N - 1){
						if(list[j + 1][k] == "0"){
							sita = false;
						}
					}
					if(k < N - 1){
						if(list[j][k + 1] == "0"){
							migi = false;
						}
					}
					if(!migi && !sita){
						isOK = false;
					}
				}
			}
		}
		if(isOK){
			output[i] = "YES";
		}else{
			output[i] = "NO";
		}
	}
	myout(myconv(output,9));
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    checkNext();
  }

}

function checkNext() {
  var n = +readline();
  var allowedCols = new Set();
  var lines = [];

  for (var j = 0; j < n; j++) {
    allowedCols.add(j);
    lines[j] = readline();
  }
  for (var j = n - 1; j >= 0; j--) {
    var nextLine = lines[j];
    var allowed = true;
    for (var k = n - 1; k >= 0; k--) {
      if (allowedCols.has(k)) {
        allowed = true;
      }
      if (!allowed && nextLine[k] === "1") {
        print("NO");
        return;
      }
      if (nextLine[k] === "1") {
        allowedCols.add(k);
      } else {
        allowed = false;
        allowedCols.delete(k);
      }
    }
  }
  print("YES");
}
main();

function solve() {
    var n = readInt();
    var i;
    var j;
    var x = createMatrix(n)
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            if(x[i][j] == 1) {
                if( !(j+1 == n || i + 1 == n || x[i][j+1] === 1 || x[i+1][j] === 1)) {
                    print("NO")
                    return
                }
            }
        }
    }
    print("YES")
}

function createMatrix(n) {
    var arr = new Array(n)
    var i
    for(i=0; i<n; i++) {
        arr[i] = readIntArray()
    }
    return arr
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split("").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    checkNext();
  }
}

function checkNext() {
  var n = +readline();
  var allowedCols = new Set();
  var lines = [];

  for (var j = 0; j < n; j++) {
    lines[j] = readline();
  }
  for (var j = n - 1; j >= 0; j--) {
    var nextLine = lines[j];
    var last0 = nextLine.lastIndexOf("0");
    for (var k = 0; k < n; k++) {
      if (nextLine[k] === "1" && k < last0 && !allowedCols.has(k)) {
        print("NO");
        return;
      }
      if (nextLine[k] === "1") {
        allowedCols.add(k);
      } else {
        allowedCols.delete(k);
      }
    }
  }
  print("YES");
}
main();

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    checkNext();
  }
}

function checkNext() {
  var n = +readline();
  var allowedCols = new Set();
  var lines = [];

  for (var j = 0; j < n; j++) {
    allowedCols.add(j);
    lines[j] = readline();
  }
  for (var j = n - 1; j >= 0; j--) {
    var nextLine = lines[j];
    var last0 = nextLine.lastIndexOf("0");
    for (var k = 0; k < n; k++) {
      if (nextLine[k] === "1" && k < last0 && !allowedCols.has(k)) {
        print("NO");
        return;
      }
      if (nextLine[k] === "1") {
        allowedCols.add(k);
      } else {
        allowedCols.delete(k);
      }
    }
  }
  print("YES");
}
main();


var n = Number(readline());
//var mas=[];
var str = "";
var res = 0;
while(n>1){
	res++;
	if (n-2>1){
		n-=2;
		str+=2+" ";
		//mas.push(2);
		}
	else {
		str+=n;
		break;}

}
print(res);
print(str);

var n = +readline();
print(n >> 1);
print(new Array(n % 2).fill(3).concat(new Array((n - n % 2 * 3) / 2 ).fill(2)).join(' '));

var n = +readline(), k = 0, res = [];
if (n % 2 == 1) {
    n -= 3;
    k += 1;
    res.push(3)
}
k += n / 2;
res.push(...new Array(n / 2).fill(2));
print(k);
print(res.join(' '));

var n = +readline();
print(n / 2 | 0);
print(new Array(n % 2).fill(3).concat(new Array((n - n % 2 * 3) / 2 ).fill(2)).join(' '));

var  n  = parseInt(readline());
var result = '';
var count = 0;
if(n % 2 == 0){
    for(var i = 0; i < n/2; i ++) {
        count ++;
        if(i == n/2 - 1){
            result += '2';
        }else {
            result += '2 ';
        }

    }
} else {
    for(var i = 0; i < (n-3)/2; i ++) {
        count ++;
        result += '2 ';
    }

    result += '3';
    count++;
}

print(count + '\n' + result);

var res = sol(readline(), readline());
print(res);

function sol(line1) {
    var input1 = line1.split(" ").map((x) => Number(x));

    var n = input1[0];

    var result = [];

    while (n > 3) {
        n -= 2;
        result.push(2);
    }

    result.push(n);

    return result.length + "\n" + result.join(" ");
}

(function() {
    'use strict';
    let n = readline();
    var x = 0;
    var y = [];
    let i = 0;
    if (n % 2 === 0) {
         x = n / 2;
        while (i < x) {
            y.push(2);
            i++;
        }
    } else {
        x = (n - n % 2) / 2;
        while (i < x - 1) {
            y.push(2);
            i++;
        }
        y.push(3);
    }
    print(x);
    print(y.join(' '));

}());

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

    var ans = n%2==0 ? n/2 : (n-3)/2+1;
    print( ans );
    while ( n > 3 )
    {
        write( 2 + ' ' );
        n -= 2;
    }

    if ( n == 2 ) write( 2 );
    else write( 3 );
    print();

} main();

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, ref, ref1, results, results1;

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 0, ref = (n - 3) / 2; 0 <= ref ? i < ref : i > ref; 0 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 0, ref1 = n / 2; 0 <= ref1 ? j < ref1 : j > ref1; 0 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

var n = +readline();

var pn = n & 1 ? [((n - 3) / 2), 1] : [n / 2, 0];

print(pn[0] + pn[1]);
print(new Array(pn[0]).fill('2').concat(new Array(pn[1]).fill('3')).join(' '));

var main = function(num)
{
	var arr = [];
	if (num % 2 === 0){
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		return arr;
	}
	else
	{
		num -= 3;
		if (num > 0)
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		arr.push(3);
		return arr;
	}
}

var input = readline();
print(main(+input).length);
print(main(+input).join(' '));

function sa(n){
        var k = Math.floor(n/2);
        var res = k + "\n";
        for(var i=0;i<k-1;i++){
            res += "2 ";
        }
        if(n%2==0){
            res += 2;
        } else {
            res += 3;
        }
        return res
    }

    var f = readline().split(" ").map(Number);
    var n = f[0];

    print(sa(n));

//var input = readline()
var n = parseInt(readline())

var k = parseInt(n / 2)
if(n % 2 == 0) {
    print(k)
    for(var i=1; i<=k; i++) {
        print(2 +' ')
    }
}
else {
    print(k)
    for(var i=1; i<k; i++) {
        print(2 +' ')
    }
    print(3)
}

//

var n = parseInt( readline(), 10 );
var twosCount = Math.floor(n / 2);
var addThree = n % 2;
var result = "";
if ( addThree ) {
  --twosCount;
  result += "3 ";
}

for ( var i = 0; i < twosCount; ++i ) {
    result += "2 ";
}

print( twosCount + addThree );
print( result.slice( 0, -1 ) );

let lines = [];
require('readline').createInterface({input: process.stdin,output: process.stdout})
				.on('line', line => {lines.push(line);})
				.on('close', () => {main(lines)});

const main = (input) => {
	var num = parseInt(input);

	console.log(Math.floor(num / 2));

	var ans = "";

	if (num % 2 == 1) {
		num -= 3;
		ans += "3 ";
	}

	for (var i = 0; i < num; i += 2) {
		ans += "2 ";
	}

	console.log(ans.trim());
}

function main() {
    // write code here:
    var n = Number(stdin[0]);
    var arr = [];
    var m=0;
    if (n % 2 === 0) {
        m = n / 2;
        for (let i = 0; i < m; i++) {
            arr.push(2);
        }
    }else{
        //既然要求的是最多可以有多少质数之和能等于n，那么2之后即为3
        n -= 3;
        if (n > 0)
            for (let i = 1; i <= n / 2; i++)
            {
                arr.push(2);//减去3之后要push几个2进arr
            }
        arr.push(3);
    }
    console.log(arr.length+'\n'+arr.join(' '));
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);

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

let input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const count = parseInt(input[0], 10)
  let iter = Math.floor(count / 2)
  let ostatok = count - (iter * 2)
  if (ostatok < 2) {
    ostatok += 2
    iter -= 1
  }
  let _res = ''
  for (let a = 0; a < iter; a++) {
    if (_res === '')
      _res = '2'
    else
      _res += ' 2'
  }
  if (_res === '')
    _res += ostatok
  else
    _res += ` ${ostatok}`
  let _iterOstatok = ostatok > 0 ? 1 : 0
  console.log(`${iter + _iterOstatok}\n${_res}`)
})

//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 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 N = nextInt();
  if(N % 2 == 0){
    var output = new Array(N / 2).fill(2);
    myout(output.length);
    myout(myconv(output, 8));
  }else{
    var output = new Array(Math.floor(N / 2)).fill(2);
    output[0] = 3;
    myout(output.length);
    myout(myconv(output, 8));
  }
}

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

rl.on('line', (d) => {
  let n = +d;
  let count = Math.floor(n / 2);

  console.log(count);
  if (n % 2 === 0) {
    console.log(new Array(count).fill(2).join(' '));
  }
  else {
    console.log(new Array(count - 1).fill(2).join(' ') + ' 3');
  }
});

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

const input = [];
readLine.on('line', line => input.push(line));

function gdc(x, y) {
  let cx = x, cy = y;
  while (cx != 0 && cy != 0) {
    if (cx > cy) cx = cx % cy;
    else cy = cy % cx;
  }
  return cx + cy;
}

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));

  const answer = [];

  for (let i = 0; i < ((n % 2 === 0) ? n / 2 : (n-1) / 2); i += 1)
    answer.push(2);

  if (n % 2 !== 0) {
    answer.pop();
    answer.push(3);
  }
  console.log(answer.length);
  console.log(answer.join(' '));
});

let input = [];

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

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

RL.on('close', () => {
    let n = input[0];
    let answer = '';
    if( n % 2 === 0){
        console.log(`${n/2}`)
        for(let i = 0; i < n/2; i++){
            answer += '2 ';
        }
    } else {
        n -= 3;
        console.log(`${n/2 + 1}`);
        answer = '3 ';
        for(let i = 0; i < n/2; i++){
            answer += '2 ';
        }
    }
    console.log(answer);
});

// Sample code to perform I/O:

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

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

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

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

let log = function () {
    return Function.prototype.bind.call(console.log, console, '');
}();

function removeEmptyItem(arr, index) {
    return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));
}

function range(min, max) {

    let arr = [];
    for (let index = min; index < max; index++) {
        arr.push(index);

    }
    return arr;
}

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

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

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

    let n = +str.trim();
    console.log(Math.floor(n / 2));
    let sum = '';
    if (n % 2 === 0) {
        for (let index = 0; index < Math.floor(n / 2); index++) {
            sum += '2 ';
        }
    }
    else if (n % 2 === 1) {
        for (let index = 0; index < Math.floor(n / 2) - 1; index++) {

            sum += '2 ';
        }
        sum += '3';
    }
    console.log(sum);

}

var  n  = parseInt(readline());
var result = '';
if(n % 2 == 0){
    for(var i = 0; i < n/2; i ++) {
        if(i == n/2 - 1){
            result += '2';
        }else {
            result += '2 ';
        }

    }
} else {
    for(var i = 0; i < (n-3)/2; i ++) {
        result += '2 ';
    }

    result += '3'
}

print(result);

var res = sol(readline(), readline());
print(res);

function sol(line1) {
    var input1 = line1.split(" ").map((x) => Number(x));

    var n = input1[0];

    var result = [];

    while (n > 3) {
        n -= 2;
        result.push(2);
    }

    result.push(n);

    return result;
}

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, n, readline, ref, results;

  readline = function() {
    return '6';
  };

  n = Number(readline());

  arr = (function() {
    results = [];
    for (var i = 1, ref = (n - n % 2) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
    return results;
  }).apply(this).map(function(x) {
    return '2';
  });

  if (n % 2 === 1) {
    arr.push('3');
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, readline, ref, ref1, results, results1;

  readline = function() {
    return '6';
  };

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 1, ref = (n - 3) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 1, ref1 = n / 2; 1 <= ref1 ? j <= ref1 : j >= ref1; 1 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, ref, ref1, results, results1;

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 1, ref = (n - 3) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 1, ref1 = n / 2; 1 <= ref1 ? j <= ref1 : j >= ref1; 1 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

var n = Number(readline());
var mas=[];
var res = 0;
while(n>1){
	res++;
	if (n-2>1){
		n-=2;
		mas.push(2);
		}
	else {
		mas.push(n)
		break;}

}
print(res);
print(mas);

var main = function(num)
{
	var arr = [];
	if (num % 2 === 0){
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		return arr;
	}
	else
	{
		num -= 3;
		if (num > 0)
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		arr.push(3);
		return arr;
	}
}

var input = +readline();
print(main(input));

var main = function(num)
{
	var del = 2, arr = [];
	while (num !== 1)
	{
		if (num % del === 0)
		{
			num /= del;
			arr.push(del);
			del = 2;
		}
		else del++;
	}
	return arr;
}

var input = +readline();
print(main(input));

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

let input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const count = parseInt(input[0], 10)
  let iter = Math.floor(count / 2)
  let ostatok = count - (iter * 2)
  if (ostatok < 2) {
    ostatok += 2
    iter -= 1
  }
  let _res = ''
  for (let a = 0; a < iter; a++) {
    if (_res === '')
      _res = '2'
    else
      _res += ' 2'
  }
  if (_res === '')
    _res += ostatok
  else
    _res += ` ${ostatok}`
  console.log(_res)
})


let finalInput = '';

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

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex < 0) aIndex = 0;
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = Math.max(lastVisitedIndex, aIndex);
        });
        console.log(result);
    }
});

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

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

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

  const t = readInt(arr)

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

    const indexes = new Array(100001)

    for(let j = 0; j < n; j++) {
      indexes[a[j]] = j
    }
    // wr(a, b, indexes)

    let ans = 0, y = -1
    for(let j = 0; j < m; j++) {
      if(indexes[b[j]] > y) {
        ans += 2 * (indexes[b[j]] - j) + 1
        y = indexes[b[j]]
      }
      else ans ++
    }

    wr(ans)
  }
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

function mod(a, m) {
  let x = a % m
  if(x >= 0 )  return x
  else return m + x
}

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

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

let finalInput = '';

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

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = aIndex;
        });
        console.log(result);
    }
});

let finalInput = '';

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

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex === -1) aIndex = 0;
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = aIndex;
        });
        console.log(result);
    }
});