package main

import "fmt"

func main() {
	var nQues, cnt int
	fmt.Scan(&nQues)

	for ques := 0; ques < nQues; ques++ {
		var Petya, Vasya, Tonya int8
		fmt.Scan(&Petya, &Vasya, &Tonya)

		isSolved := Petya + Vasya + Tonya

		if isSolved >= 2 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

package main

import "fmt"

func main() {
	var n int
	var p int
	var v int
	var t int
	var number int

	fmt.Scanln(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&p, &v, &t)
		if p + v + t >= 2 {
			number++
		}
	}
	fmt.Println(number)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func main() {
	defer writer.Flush()

	var line string
	scanner := bufio.NewScanner(os.Stdin)
	i := 0
	n := 0
	total := 0
	for scanner.Scan() {
		if i == 0 {
			n, _ = strconv.Atoi(scanner.Text())
		} else {
			line = scanner.Text()
			votes := ArrayStringToInt(strings.Split(line, " "))
			if Run(votes[0], votes[1], votes[2]) {
				total++
			}
		}

		if i >= n {
			break
		}
		i++
	}

	printf("%d", total)
}

func Run(a, b, c int) bool {
	if a+b+c >= 2 {
		return true
	}
	return false
}

// Utils

func ArrayStringToInt(t []string) (t2 []int) {
	for _, i := range t {
		j, err := strconv.Atoi(i)
		if err != nil {
			panic(err)
		}
		t2 = append(t2, j)
	}
	return t2
}

package main

import "fmt"

func main() {
	var m, num int
	fmt.Scanf("%d\n", &m)

	for i := 0; i < m; i++ {
		var x, y, z int
		fmt.Scanf("%d %d %d\n", &x, &y, &z)
		if (z + y + x) > 1 {
			num++
		}

	}
	fmt.Println(num)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	input := bufio.NewScanner(os.Stdin)
	hasInput := input.Scan()
	if hasInput == false {
		panic("Number of problems missing")
	}

	_, err := strconv.Atoi(input.Text())

	if err != nil {
		panic("Undefined number passed")
	}

	p := make([][]uint8, 0)

	for input.Scan() {
		elem := strings.Split(input.Text(), " ")

		mutated := []uint8{}
		for _, v := range elem {
			n, err := strconv.ParseInt(v, 10, 8)
			if err != nil {
				panic ("Undefined number in problemset")
			}

			mutated = append(mutated, uint8(n))
		}

		p = append(p, mutated)
	}

	fmt.Println(teamConsensus(p))

}

func teamConsensus(s [][]uint8) int {
	totalSum := 0
	for _, v := range s {
		sum := uint8(0)
		for _, w := range v {
			sum += w
		}

		if sum > 1 {
			totalSum += 1
		}
	}

	return totalSum
}

package main

import (
	"fmt"
)

func main() {
  var n int
  var x, z, y uint8
  var probs int
  fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
      fmt.Scanf("%d %d %d\n", &x, &y, &z)
      if(x+y+z>=2){
         probs++
      }
  }
  fmt.Println(probs)

}

package main

import (
	"fmt"
)

func main() {
	var n int
  //var a[][]uint8
  var x, z, y uint8
  var probs int
	fmt.Scanf("%d\n", &n)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d %d %d\n", &x, &y, &z)
    //a = append(a, []uint8{x, y, z})
    if( (x==1 && y==1) || (x==1 && z==1) || (z==1 && y==1)){
      probs++
    }
  }
  fmt.Println(probs)

}

package main

import (
	"fmt"
)

var n, a, b, c, ans int

func main() {
	fmt.Scanf("%d\n", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d%d%d\n", &a, &b, &c)
		a += b + c
		if a >= 2 {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var totalInput int
	fmt.Scanln(&totalInput)

	reader := bufio.NewReader(os.Stdin)

	solvable := 0

	for i := 0; i < totalInput; i++ {
		text, _ := reader.ReadString('\n')

		repeated := strings.Count(text, "1")
		if repeated > 1 {
			solvable++
		}
	}

	fmt.Println(solvable)
}

package main

import (
	"fmt"
)

var n, a, b, c, ans int

func main() {
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		fmt.Scan(&a, &b, &c)
		a += b + c
		if a >= 2 {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import "fmt"

func sum(ns [3]int8) int8 {
	var s int8
	for _, n := range ns {
		s += n
	}
	return s
}

func main() {
	var n int
	var s int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var t [3]int8
		fmt.Scanf("%d %d %d\n", &t[0], &t[1], &t[2])
		if sum(t) > 1 {
			s++
		}
	}
	fmt.Printf("%d\n", s)
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, ans int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Fscanf(reader, "%d %d %d\n", &a, &b, &c)
		if a+b+c >= 2 {
			ans++
		}
	}
	fmt.Printf("%d", ans)
}

package main

import "fmt"

func main() {
	var n, a, b, c int
	fmt.Scanf("%d\n", &n)
	count := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if a+b+c > 1 {
			count++
		}
	}
	fmt.Println(count)
}

package main
import "fmt"

func main(){
	// your code goes here
	var n int
	fmt.Scan(&n)
	count := 0
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		if a + b + c >= 2 {
			count += 1
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

func main(){

	var numberOfRows int = 0
	_,_ = fmt.Scanln(&numberOfRows)

	var twoDMatrix = make([][3]int,numberOfRows)

	for i:=0; i<numberOfRows; i++ {
		for j:=0; j<3; j++ {
			_,_ = fmt.Scan(&twoDMatrix[i][j])
		}
	}

	var count int = 0
	for i:=0; i<numberOfRows; i++ {
		temp := 0
		for j:=0; j<3; j++ {
			if twoDMatrix[i][j] == 1 {
				temp++
			}
		}
		if temp > 1 {
			count++
		}
	}

	fmt.Println(count)

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {

	numberOfProblems := scanInt()
	a, b, c, result := 0, 0, 0, 0

	for i := 0; i < numberOfProblems; i++{
		a, b, c = scanInt(), scanInt(), scanInt()
		if a + b + c > 1{
			result++
		}
	}

	printFmt(result)
	close(channelType)
	oWg.Wait()
}

/*********************** I/O ***********************/

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range channelType {
			writer.WriteString(line + "\n")
		}
	}()
}

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}
func scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}
func scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + " ")}; return sb.String()}
func spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + " ")}; return sb.String()}
func minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }

package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func print(f string, v ...interface{}) { fmt.Fprintf(w, f, v...) }
func scan(f string, v ...interface{})  { fmt.Fscanf(r, f, v...) }

func main() {
	defer w.Flush()
	var n, p, v, t, out int
	scan("%d\n", &n)
	for i := 0; i < n; i++ {
		scan("%d %d %d\n", &p, &v, &t)
		if p+v+t >= 2 {
			out++
		}
	}
	print("%d", out)
}

package main

import "fmt"

func main() {
	var ln, a, b, c, TackPartIn int
	fmt.Scanln(&ln)
	for i := 0; i < ln; i++ {
		fmt.Scanln(&a, &b, &c)
		if a+b+c >= 2 {
			TackPartIn++
		}
	}
	fmt.Println(TackPartIn)
}

package main

import (
	"fmt"
)

func main()  {
	var n, p, v, t int
	res := 0
	fmt.Scan(&n)
	for i:=0; i < n; i++{
		fmt.Scanf("\n%d %d %d", &p, &v, &t)
		if p + v + t > 1{
			res++
		}
	}
	fmt.Println(res)
	return
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b, c, rez, sum int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b, &c)
		rez += a + b + c
		if rez >= 2 {
			sum++
		}
		rez = 0
	}
	fmt.Print(sum)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	count := 0
	for i, a, b, c := 0, 0, 0, 0; i < n; i++ {
		fmt.Scanln(&a, &b, &c)
		if a + b + c >= 2 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import (
	"fmt"
)

func main() {
	var n, input int
	ind1, tot := 0, 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&input)
			if input == 1 {
				ind1 += 1
			}
		}
		if ind1 >= 2 {
			tot += 1
		}
		ind1 = 0
	}
	fmt.Print(tot)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	var lines []string

	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}

	lines = lines[1:] // drop first element of array -> useless

	result := 0
	for _, line := range lines {
		split := strings.Split(line, " ")

		if len(split) != 3 { // three friends
			panic("invalid input")
		}

		succ := 0
		for _, d := range split {
			n, err := strconv.Atoi(d)
			if err != nil {
				panic("invalid input")
			}
			succ += n
		}

		if succ >= 2 { // at least two of them are sure about the solution.
			result++
		}
	}

	fmt.Println(result)
}

// A. Team
/*
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.

Examples
Input
3
1 1 0
1 1 1
1 0 0

Output
2

Input
2
1 0 0
0 1 1

Output
1

Note
In the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it.

In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
*/
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d ", &n)

	total := 0
	for ; n > 0; n-- {
		var a, b, c int
		fmt.Scanf("%d %d %d ", &a, &b, &c)

		if a+b+c >= 2 {
			total++
		}
	}
	fmt.Print(total)
}

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;
	fmt.Scan(&n)
	var c int
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&p,&v,&t)
		if (p+v+t) >= 2 {
			c++
		}
	}
	fmt.Printf("%d\n",c)

}

/* https://codeforces.com/problemset/problem/231/A
A. Team
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Examples
inputCopy
3
1 1 0
1 1 1
1 0 0
outputCopy
2
inputCopy
2
1 0 0
0 1 1
outputCopy
1
Note
In the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it.

In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
*/

package main

import "fmt"

func main() {
	var number_of_input_lines, surity int
	fmt.Scanf("%d\n", &number_of_input_lines)

	number_of_input_lines_for_slice := number_of_input_lines + 1

	var problems_slice []int

	mathtesting := 0
	for i := 1; i < number_of_input_lines_for_slice; i++ {
		//	for i, _ := range problems_slice {
		var petya, vasya, tonya int
		fmt.Scanf("%d %d %d\n", &petya, &vasya, &tonya)

		mathtesting = petya + vasya + tonya
		problems_slice = append(problems_slice, mathtesting)
	}

	for _, value := range problems_slice {
		if value >= 2 {
			surity = surity + 1
		}
	}

	fmt.Println(surity)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var n int
	var arr [3]int
	scanf("%d\n", &n)
	ans := 0
	for n > 0 {
		count := 0
		for i := 0; i < 3; i++ {
			scanf("%d", &arr[i])
			if arr[i] > 0 {
				count++
			}
		}
		scanf("\n")
		if count > 1 {
			ans++
		}
		n--
	}

	printf("%d\n", ans)
}

package main

import (
	"fmt"
)

func main() {
	var n, p, v, t, buf int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&p, &v, &t)
		if p+v+t >= 2 {
			buf += 1
		}
	}
	fmt.Println(buf)
}

package main

import "fmt"

func main() {
	var n int
	var a, b, c int
	var total int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b, &c)
		if a+b+c >= 2 {
			total++
		}
	}

	fmt.Println(total)

}

package main

import (
	"fmt"
)

func main() {
	// take inputs
	// for each line
	// add friends' certainties.
	// bump count -> if <1 false, else true
	// return count

	// 1 <= numProblems <= 1000, so the default int32 is okay.
	numProblems := 0
	fmt.Scanln(&numProblems)
	// fmt.Printf("solving: %d problems\n", numProblems)

	implemented := 0
	for numProblems > 0 {
		a := 0
		b := 0
		c := 0
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		// fmt.Printf("a,b,c: %d,%d,%d\n", a, b, c)

		// should we implement?
		if (a + b + c) >= 2 {
			implemented++
		}
		/*
			count := 0
			for _, certain := range strings.Split(line, ",") {
				if num, _ := strconv.Atoi(certain); num > 2 {
					count++
				}
			}
			if count >= 2 {
				fmt.Printf("%d/3 are cetain, implementing!\n", count)
				implemented++
			}
		*/
		numProblems--
	}
	fmt.Println(implemented)
}

package main

import (
	"fmt"
	"os"
)

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	var ans int
	for i := 0; i < n; i++ {
		var a, b, c int
		scanf("%d%d%d\n", &a, &b, &c)
		if a+b+c >= 2 {
			ans++
		}
	}
	printf("%d\n", ans)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0
	for i := 0; i < n; i++ {
		a := 0
		b := 0
		c := 0
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)

		if a+b+c > 1 {
			sum = sum + 1
		}
	}
	fmt.Println(sum)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var a, b, c int8
	count := 0
	for ; n > 0; n-- {
		fmt.Scan(&a, &b, &c)
		if a+b+c >= 2 {
			count++
		}
	}
	fmt.Print(count)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	count := 0
	for ; n > 0; n-- {
		var x, y, z int
		fmt.Scan(&x, &y, &z)
		if x+y+z >= 2 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import(
	"fmt"
	"os"
)

var nContest int
var desicions [3]int
var solved int = 0

func isSolved() {
	count := 0
	for i := 0; i < 3; i++ {
		fmt.Fscan(os.Stdin, &desicions[i])
	}

	for i := 0; i < len(desicions); i++ {
		count = count + desicions[i]
	}

	if count >= 2 {
		solved+=1
	}
}

func main() {
	fmt.Fscan(os.Stdin, &nContest)
	for nContest > 0 {
		isSolved()
		nContest-=1
	}
	fmt.Println(solved)
}

package main

import "fmt"

func main() {
	var n, pet, vas, ton, count int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&pet)
		fmt.Scan(&vas)
		fmt.Scan(&ton)

		if (pet == 1 && vas == 1) || (pet == 1 && ton == 1) || (vas == 1 && ton == 1) {
			count++
		}
	}
	fmt.Println(count)
}

package main

import "fmt"

func main() {
	var n, res int
	fmt.Scanf("%d\n", &n)
	res = 0
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d%d%d\n", &a, &b, &c)
		if a + b + c >= 2 {
			res = res + 1
		}
	}
	fmt.Println(res)
}

package main

import "fmt"

func main() {
	var n int

	result := 0

	fmt.Scanf("%d\n", &n)

	var a, b, c int

	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if a + b + c >= 2 {
			result++
		}
	}

	fmt.Print(result)
}

package main

import "fmt"

func main() {
	var n int
	var f, s, t int
	solves := 0

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&f, &s, &t)
		v := f<<2 + s<<1 + t
		if v >= 5 || v == 3 { // 1 1 1 / 1 1 0 / 1 0 1 / 0 1 1
			solves += 1
		}
	}
	fmt.Println(solves)
}

package main

import (
	"fmt"
)

func main() {
	var m, n int
	res := 0

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j < 3; j++ {
			fmt.Scan(&m)
			if m == 1 {
				sum++
			}
			if sum == 2 {
				res++
				sum = 0
			}
		}
	}
	fmt.Println(res)
}

package main

import "fmt"

func main() {
	var n int
	result := 0

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		if a+b+c > 1 {
			result++
		}
	}
	fmt.Println(result)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	solution := 0
	for i := 0; i < n; i++ {
		var u, v, w int
		fmt.Scan(&u, &v, &w)
		if u+v+w >= 2 {
			solution += 1
		}
	}

	fmt.Print(solution)
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	ans := 0
	for i := 0; i < t; i++ {
		count := 0
		for j := 0; j < 3; j++ {
			var a int
			fmt.Scan(&a)
			count = count + a
		}
		if count >= 2 {
			ans = ans + 1
		}
	}
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	fmt.Println(parseInputs())
}

func parseInputs() int {
	in := getInput()
	canDo := 0
	for _, v := range in {
		values := strings.Split(v, " ")
		count := 0
		for _, vv := range values {
			if vv == "1" {
				count++
			}
		}
		if count >= 2 {
			canDo++
		}

	}
	return canDo
}

func getInput() []string {
	reader := bufio.NewReader(os.Stdin)
	inputs := []string{}
	l := -1
	current := 0

	for current != l {
		s, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}
		s = strings.TrimRight(s, "\r\n")

		if l == -1 {
			v, err := strconv.Atoi(s)
			if err != nil {
				log.Fatal(err)
			}
			l = v
			continue
		}
		inputs = append(inputs, s)
		current++
	}
	return inputs
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var u uint16 = 0
	var a, b, c uint8
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint16(i) < n; i++ {
		fmt.Fscanf(in, "%d %d %d\n", &a, &b, &c)
		if a+b+c >= 2 {
			u++
		}
	}
	fmt.Println(u)
}

package main

import "fmt"

func main() {
	var i int
	_, err := fmt.Scanf("%d\n", &i)
	if err != nil {
		panic(err)
	}

	r := 0
	for cpt := 0; cpt < i; cpt++ {
		var a, b, c int
		_, err = fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if err != nil {
			panic(err)
		}

		if a+b+c >= 2 {
			r++
		}

	}
	fmt.Println(r)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	solutions := 0
	for i := 0; i < n && scanner.Scan(); i++ {
		answers := answers(scanner.Text())
		if isGood(answers) {
			solutions++
		}
	}

	fmt.Println(solutions)
}

func answers(s string) []int {
	var n []int

	for _, i := range strings.Fields(s) {
		a, err := strconv.Atoi(i)
		if err == nil {
			n = append(n, a)
		}
	}

	return n
}

func isGood(answers []int) bool {
	knownSolutions := 0
	for _, a := range answers {
		if a == 1 {
			knownSolutions++
			if knownSolutions == 2 {
				return true
			}
		}
	}

	return false
}

package main

import (
	"fmt"
	"io"
	"os"
)

func cf231a(in io.Reader, out io.Writer) {
	var n int
	var a, b, c int
	var total int
	fmt.Fscan(in, &n)
	for n > 0 {
		fmt.Fscan(in, &a, &b, &c)
		if (a == 1 && b == 1) || (c == 1 && b == 1) || (a == 1 && c == 1) {
			total++
		}
		n--
	}

	fmt.Println(total)

}

func main() { cf231a(os.Stdin, os.Stdout) }

package main

import (
	"fmt"
)

func main() {
	var team [3]int
	var n, total int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d\n", &team[0], &team[1], &team[2])
		if (team[0] + team[1] + team[2]) >= 2 {
			total++
		}
	}

	fmt.Println(total)
}

package main

import "fmt"

func main() {
	var n int
	var ans int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var x, y, z int
		fmt.Scan(&x, &y, &z)
		if x+y+z >= 2 {
			ans++
		}
	}
	fmt.Println(ans)

}

package main

import "fmt"

func main() {
	var a, b, c, n, k int

	a = 0
	b = 0
	c = 0
	n = 0
	k = 0

	fmt.Scanln(&n)

	for i := 0; i < n; i++ {
		fmt.Scanln(&a, &b, &c)
		if a+b+c > 2 || a+b+c == 2 {
			k++
		}

	}
	fmt.Println(k)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func nextWords(scanner *bufio.Scanner) []string {
	scanner.Scan()
	return strings.Fields(scanner.Text())
}

func nextNumbers(scanner *bufio.Scanner) []int {
	var numbers = make([]int, 0)
	line := nextWords(scanner)
	for i:= range line {
		n, _ := strconv.Atoi(line[i])
		numbers = append(numbers, n)
	}
	return numbers
}

func sumInputs(numbers []int) int {
	var sum int
	for i := range numbers {
		sum += numbers[i]
	}
	return sum
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	n, _ := strconv.Atoi(nextLine(scanner))

	var result = 0

	if n > 0 {
		for i:= 0; i < n; i++ {
			numbers := nextNumbers(scanner)
			if sumInputs(numbers) > 1 {
				result++
			}
		}
	}

	fmt.Println(result)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	solutionArray := takeInput()
	validSolutions := checkValidSolutions(solutionArray)
	fmt.Println(validSolutions)
}

func takeInput() []string {
	var solutionArray []string

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		solutionArray = append(solutionArray, scanner.Text())
	}
	return solutionArray
}

func checkValidSolutions(solutions []string) int {
	var validSolutions int
	for i := 0; i < len(solutions); i++ {
		if strings.Count(solutions[i], "1") > 1 {
			validSolutions++
		}
	}
	return validSolutions
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scanf("%d\n", &T)
	ans := 0
	var a,b,c int
	for i := 0; i < T; i++ {
		fmt.Scanf("%d%d%d\n", &a, &b, &c)
		if a + b + c >= 2{
			ans ++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import "fmt"

func main() {
	var tries int

	fmt.Scan(&tries)

	var n, m, a int8
	total := 0
	for i := 0; i < tries; i++ {
		fmt.Scan(&n, &m, &a)

		if n+m+a >= 2 {
			total++
		}
	}

	fmt.Println(total)
}

package main
import "fmt"
func main() {
	var tries, n, m, a int
	fmt.Scan(&tries)
	total := 0
	for i := 0; i < tries; i++ {
		fmt.Scan(&n, &m, &a)

		if n+m+a >= 2 {
			total++
		}
	}
	fmt.Print(total)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader *bufio.Reader
	writer *bufio.Writer
)

func init() {
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
}
func scanf(format string, args ...interface{}) (int, error) {
	return fmt.Fscanf(reader, format, args...)
}

func printf(format string, args ...interface{}) (int, error) {
	return fmt.Fprintf(writer, format, args...)
}

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)

	arr := make([][]int, n)
	answer := 0
	for i := 0; i < n; i++ {
		arr[i] = make([]int, 3)
		scanf("%d %d %d\n", &arr[i][0], &arr[i][1], &arr[i][2])
		if arr[i][0]+arr[i][1]+arr[i][2] > 1 {
			answer++
		}
	}
	printf("%d", answer)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.Replace(text, "\r\n", "", -1)

	number, _ := strconv.Atoi(text)

	values := []string{}
	amount := 0

	for i := 0; i < number; i++ {
		text, _ = reader.ReadString('\n')
		text = strings.Replace(text, "\r\n", "", -1)
		values = strings.Split(text, " ")

		var cant_fila int = 0
		for _, num_string := range values {
			num, _ := strconv.Atoi(num_string)
			if num != 0 {
				cant_fila++
			}

		}
		if cant_fila >= 2 {
			amount++
		}
	}

	fmt.Println(amount)
}

package  main
import ("fmt")

func main(){
	var x ,y,z,n int
	fmt.Scan(&n);
	c:=0
	for i:=0;i<n;i++{
		//fmt.Scanf("%d %d %d\n",&x,&y,&z)

		fmt.Scan(&x);
		fmt.Scan(&y);
		fmt.Scan(&z);

		var ad = x+y+z
		//fmt.Print(ad)
		if(ad>=2){
			c++
		}
	}
	fmt.Print(c)
}

package main

import (
        "fmt"
)

func main() {
        var (
                inputnum int
                input1   int
                input2   int
                input3   int
        )
        fmt.Scan(&inputnum)
        output := 0
        for i := 0; i < inputnum; i++ {
                fmt.Scan(&input1, &input2, &input3)
                if input1+input2+input3 >= 2 {
                        output += 1
                }
        }
        fmt.Println(output)
}

package main

import (
	"fmt"
)

func main() {
	var count int
	fmt.Scanf("%d\n", &count)
	var c1, c2, c3 int
	var tasks [][]int
	for i := 0; i < count; i++ {
		fmt.Scanf("%d %d %d\n", &c1, &c2, &c3)
		tasks = append(tasks, []int{c1, c2, c3})
	}

	var res int

	f := func(b []int) int {
		if  (b[0] == 1 && b[1] == 1) ||
			(b[0] == 1 && b[2] == 1) ||
			(b[1] == 1 && b[2] == 1){
			return 1
		}
		return 0
	}

	for _, t := range tasks {
		res += f(t)
	}
	fmt.Println(res)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	if err := run(os.Args[1:]); err != nil {
	  fmt.Println(err)
	}
}

var CRLFReplacer = strings.NewReplacer("\n", "", "\r", "")

func run(args []string) error {
	reader := bufio.NewReader(os.Stdin)

	text, err := reader.ReadString('\n')
	if err != nil {
		return err
	}
	text = CRLFReplacer.Replace(text)

	lines, err := strconv.Atoi(text)
	if err != nil {
		return err
	}

	problems := 0

	for i := 0; i < lines; i++ {
		text, err := reader.ReadString('\n')
		if err != nil {
			return err
		}
		text = CRLFReplacer.Replace(text)

		parts := strings.Split(text, " ")
		agree := 0
		for _, v := range parts {
			if v == "1" {
				agree++
			}
		}
		if agree >= 2 {
			problems++
		}
	}

	fmt.Println(problems)
	return nil
}

package main

import "fmt"

func main() {
    var n int
    var a, b, c int
    var result int = 0

    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a, &b, &c)
        if a + b + c >= 2 {
            result++
        }
    }
    fmt.Println(result)
}

package main

import "fmt"

func main() {
    var N, t int
    fmt.Scan(&N)
    res := 0
    for i := 0; i < N; i++ {
        val := 0
        for friend := 0; friend < 3; friend++ {
            fmt.Scan(&t)
            val += t
        }
        if val >= 2 {
            res += 1
        }
    }
    fmt.Println(res)
}

package main

import "fmt"

func main() {
    var N, t int
    fmt.Scan(&N)
    var cnt [1005]int
    for friend := 0; friend < 3; friend++ {
        for i := 0; i < N; i++ {
            fmt.Scan(&t)
            cnt[i] += t
        }
    }
    res := 0
    for _, number := range cnt {
        if number >= 2 {
            res += 1
        }
    }
    fmt.Println(res)
}

package main

import "fmt"

func main() {
	var amountOfProblems, problemsImplemented int
	problemsImplemented = 0
	fmt.Scanf("%d", &amountOfProblems)
	for i := 0; i < amountOfProblems; i++ {
		var friend1, friend2, friend3 int
		fmt.Scanf("%d %d %d\n", &friend1, &friend2, &friend3)
		if friend1+friend2+friend3 >= 2 {
			problemsImplemented++
		}
	}
	fmt.Println(problemsImplemented)
}

package main

import "fmt"

func main() {
	var amountOfProblems, problemsImplemented int
	problemsImplemented = 0
	fmt.Scanf("%d", &amountOfProblems)
	for i := 0; i < amountOfProblems; i++ {
		friend1, friend2, friend3 := 0, 0, 0
		fmt.Scanf("%d %d %d\n", &friend1, &friend2, &friend3)
		if friend1+friend2+friend3 == 2 || friend1+friend2+friend3 == 3 {
			problemsImplemented++
		}
	}
	fmt.Println(problemsImplemented)
}

package main

import "fmt"

func main() {
	var amountOfProblems, problemsImplemented int
	problemsImplemented = 0
	fmt.Scanf("%d", &amountOfProblems)
	for i := 0; i < amountOfProblems; i++ {
		var friend1, friend2, friend3 int
		fmt.Scanf("%d %d %d\n", &friend1, &friend2, &friend3)
		if friend1+friend2+friend3 == 2 || friend1+friend2+friend3 == 3 {
			problemsImplemented++
		}
	}
	fmt.Println(problemsImplemented)
}

package main

import "fmt"

func main() {
	var amountOfProblems, problemsImplemented int
	problemsImplemented = 0
	fmt.Scanf("%d", &amountOfProblems)
	for i := 0; i < amountOfProblems; i++ {
		var friend1, friend2, friend3 int
		fmt.Scanf("%d %d %d", &friend1, &friend2, &friend3)
		if friend1+friend2+friend3 == 2 || friend1+friend2+friend3 == 3 {
			problemsImplemented++
		}
	}
	fmt.Println(problemsImplemented)
}

package main

import "fmt"

func main() {
	var m, num int
	fmt.Scanf("%d", &m)

	for i := 0; i < m; i++ {
		var x, y, z int
		fmt.Scanf("%d %d %d", &x, &y, &z)
		if (z + y + x) > 1 {
			num++
		}

	}
	fmt.Println(num)

}

package main

import "fmt"

func main() {
	var m int
	fmt.Scanf("%d", &m)
	var num int
	i := 1
	for i <= m {
		var a, b, c int
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if (a + b + c) > 1 {
			num++
		}

		i++
	}
	fmt.Println(num)

}

package main

import "fmt"

func main() {
    var n int;
    petya, vasya, tonya, counter := 0,0,0,0
    fmt.Scanf("%d", &n)
    for i :=0; i < n; i++ {
      fmt.Scanf("%d %d %d", &petya, &vasya, &tonya)
      if petya + vasya + tonya >= 2 {
              counter++
      }
    }
    fmt.Print(counter)
}

package main

import "fmt"

func main() {
	var n int
	petya, vasya, tonya, counter := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &petya, &vasya, &tonya)
		if petya+vasya+tonya >= 2 {
			counter++
		}
	}
	fmt.Print(counter)
}

package main

import "fmt"

var n, a, b, c, ans int

func main() {
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d%d%d", &a, &b, &c)
		a += b
		a += c
		if a >= 2 {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

import "fmt"

var n, a, b, c, ans int

func main() {
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d %d %d", &a, &b, &c)
		a += b
		a += c
		if a >= 2 {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var n, ans int
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		var a, b, c int
		fmt.Scanf("%d%d%d", &a, &b, &c)
		a = a + b
		a = a + c
		if a >= 2 {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import "fmt"

func main() {
	var n, a, b, c, ans int
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d%d%d", &a, &b, &c)
		a += b
		a += c
		if a >= 2 {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import "fmt"

var n, a, b, c, ans int

func main() {
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d%d%d", &a, &b, &c)
		a += b + c
		if a >= 2 {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	sum := 0
	for i := 0; i < n; i++ {
		var p, q, r int
		fmt.Scanf("%d %d %d", &p, &q, &r)
		if (p + q + r) >= 2 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	sum := 0
	for i := 0;i < n; i++ {
		var p, q, r int
		fmt.Scanf("%d %d %d", &p, &q, &r)
		if (p + q + r) >= 2 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main
import (
		"fmt"
		"strings"
		)

func main() {
	var input string
	fmt.Scan(&input)
	input = strings.ToLower(input)
	for i := 0; i < len(input); i++ {
		ch := input[i]
		if ch == 'a' || ch == 'o' || ch == 'y' || ch == 'e' || ch == 'u' || ch == 'i' {
			continue
		} else {
			fmt.Printf(".%c", ch)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	sum := 0
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		fmt.Scanf("%d", &c)

		if a+b+c > 1 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	// reader := bufio.NewReader(os.Stdin)
	var n int
	var input string
	fmt.Scanln(&input)
	n, _ = strconv.Atoi(input)

	sum := 0
	for i := 0; i < n-1; i++ {
		fmt.Scanln(&input)
		s := strings.Split(input, " ")
		a, _ := strconv.Atoi(s[0])
		fmt.Scanln(&input)
		s = strings.Split(input, " ")
		b, _ := strconv.Atoi(s[0])
		fmt.Scanln(&input)
		s = strings.Split(input, " ")
		c, _ := strconv.Atoi(s[0])

		if a+b+c > 1 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	sum := 0
	for i := 0; i < n; i++ {
		a := 0
		b := 0
		c := 0
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		fmt.Scanf("%d", &c)

		if a+b+c > 1 {
			sum = sum + 1
		}
	}
	fmt.Println(sum)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	sum := 0
	for i := 0; i < n; i++ {
		a := 0
		b := 0
		c := 0
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		fmt.Scanf("%d", &c)

		if a+b+c > 1 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	var input string
	fmt.Scanln(&input)
	n, _ = strconv.Atoi(input)

	sum := 0
	for i := 0; i < n; i++ {
		input, _ = reader.ReadString('\n')
		input = strings.Replace(input, "\n", "", -1)
		// fmt.Scanln(&input)
		s := strings.Split(input, " ")
		a, _ := strconv.Atoi(s[0])
		// fmt.Scanln(&input)
		// s = strings.Split(input, " ")
		b, _ := strconv.Atoi(s[1])
		// fmt.Scanln(&input)
		// s = strings.Split(input, " ")
		c, _ := strconv.Atoi(s[2])

		// fmt.Println("a, b, c:", a+b+c)
		if a+b+c > 1 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	var input string
	fmt.Scanln(&input)
	n, _ = strconv.Atoi(input)

	sum := 0
	for i := 0; i < n; i++ {
		input, _ = reader.ReadString('\n')
		// input = strings.Replace(input, "\n", "", -1)
		// fmt.Scanln(&input)
		s := strings.Split(input, " ")
		a, _ := strconv.Atoi(s[0])
		// fmt.Scanln(&input)
		// s = strings.Split(input, " ")
		b, _ := strconv.Atoi(s[1])
		// fmt.Scanln(&input)
		// s = strings.Split(input, " ")
		c, _ := strconv.Atoi(s[2])

		// fmt.Println("a, b, c:", a+b+c)
		if a+b+c > 1 {
			sum++
		}
	}
	fmt.Println(sum)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	res := 0
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d%d%d", &a, &b, &c)
		if a + b + c >= 2 {
			res++
		}
	}
	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var m, n int
	res := 0

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j < 3; j++ {
			fmt.Scan(&m)
			if m == 1 {
				sum++
			}
			if sum == 2 {
				res++
			}
		}
	}
	fmt.Println(res)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	solution := 0
	for i := 0; i < n; i++ {
		var u, v, w int
		fmt.Scanf("%d %d %d", &u, &v, &w)
		if u+v+w >= 2 {
			solution += 1
		}
	}

	fmt.Print(solution)
}

package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	s := 0
	for i := 0; i < n; i++ {
		var p, v, t int
		_, _ = fmt.Scanln(&p, &v, &t)
		if p+v+t >= 2 {
			s += 1
		}
	}
	fmt.Print(s)
}

package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	s := 0
	for i := 0; i < n; i++ {
		var p, v, t int
		_, _ = fmt.Scanln(&p, &v, &t)
		if p+v+t >= 2 {
			s += 1
		}
	}
	fmt.Println(s)
}

package main

import "fmt"

func main() {
	var i int
	_, err := fmt.Scanf("%d\n", &i)
	if err != nil {
		panic(err)
	}

	for cpt := 0; cpt < i; cpt++ {
		var a, b, c int
		_, err = fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if err != nil {
			panic(err)
		}

		// judging system bugs
		//r := 0

		if a+b+c >= 2 {
			//r++
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}

		//fmt.Println(r)

	}

}

package main

import "fmt"

func main() {
	var i int
	_, err := fmt.Scanf("%d\n", &i)
	if err != nil {
		panic(err)
	}

	for cpt := 0; cpt < i; cpt++ {
		var a, b, c int
		_, err = fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if err != nil {
			panic(err)
		}

		r := 0

		if a+b+c >= 2 {
			r++
		}

		fmt.Println(r)

	}

}

package  main
import ("fmt")

func main(){
	var x,y,z,n int
	fmt.Scan(&n);
	c:=0
	for i:=0;i<n;i++{
		fmt.Scanf("%d %d %d",&x,&y,&z)

		var ad = x+y+z
		if(ad>=2){
			c++
		}
	}
	fmt.Print(c)
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scanf("%d", &T)
	ans := 0
	for i := 0; i < T; i++ {
		var a,b,c int
		fmt.Scanf("%d%d%d", &a, &b, &c)
		if a + b + c >= 2{
			ans ++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scanf("%d\n", &T)
	ans := 0
	for i := 0; i < T; i++ {
		var a,b,c int
		fmt.Scanf("%d%d%d", &a, &b, &c)
		if a + b + c >= 2{
			ans ++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import (
        "fmt"
)

func main() {
        var (
                inputnum int
                input1   int
                input2   int
                input3   int
        )
        fmt.Scanf("%d", &inputnum)
        var output int
        for i := 0; i < inputnum; i++ {
                fmt.Scanf("%d %d %d", &input1, &input2, &input3)
                if input1+input2+input3 >= 2 {
                        output += 1
                }
        }
        fmt.Println(output)
}

package main

import (
        "fmt"
)

func main() {
        var (
                inputnum int
                input1   int
                input2   int
                input3   int
        )
        fmt.Scanf("%d", &inputnum)
        output := 0
        for i := 0; i < inputnum; i++ {
                fmt.Scanf("%d %d %d", &input1, &input2, &input3)
                if input1+input2+input3 >= 2 {
                        output += 1
                }
        }
        fmt.Println(output)
}

package main

import (
        "fmt"
)

func main() {
        var inputnum int
        fmt.Scanf("%d", &inputnum)
        output := 0
        for i := 0; i < inputnum; i++ {
                var (
                        input1 int
                        input2 int
                        input3 int
                )
                fmt.Scanf("%d %d %d", &input1, &input2, &input3)
                if input1+input2+input3 >= 2 {
                        output += 1
                }
        }
        fmt.Println(output)
}

package main

import "fmt"

func main() {
    var n int
    var a, b, c int
    var result int = 0

    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d %d %d\n", &a, &b, &c)
        if a + b + c >= 2 {
            result++
        }
    }
    fmt.Println(result)
}

package main

import "fmt"

func main() {
	var seccess int
	var count int
	fmt.Scan(&count)
	var a,b,c int
	for i := 0; i < count; i++ {
		fmt.Scanf("%d %d %d\n",&a, &b, &c)
		if a+b+c >=2 {
			seccess++
		}
	}
	fmt.Println(seccess)
}

package main

import (
	"fmt"
)

func main()  {
	var n, p, v, t int
	res := 0
	fmt.Scan(&n)
	for i:=0; i < n; i++{
		fmt.Scanf("%d %d %d", &p, &v, &t)
		if p + v + t > 1{
			res++
		}
	}
	fmt.Println(res)
	return
}

package main

import (
	"fmt"
)

func main()  {
	var n, p, v, t int
	res := 0
	fmt.Scan(&n)
	for i:=0; i < n; i++{
		fmt.Scanf("%d %d %d", &p, &v, &t)
		if p + v + t >= 2{
			res++
		}
	}
	fmt.Println(res)
	return
}

package main

import (
	"fmt"
)

func main() {
	var n, input int
	ind1, tot := 0, 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&input)
			if input == 1 {
				ind1 += 1
			}
		}
		if ind1 >= 2 {
			tot += 1
			ind1 = 0
		}
	}
	fmt.Print(tot)
}

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	c := 0
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) > 1 {
			c++
		}
	}
	fmt.Printf("%d\n",c)

}

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	var c int
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) >= 2 {
			c++
		}
	}
	fmt.Printf("%d\n",c)

}

// func Compt{
// 	reader := bufio.NewReader(os.Stdin)
// 	city,_:= reader.ReadInteger('\n')
// 	var n int
// 	fmt.Scanf("%d",&n)
// 	var ar = make([]int,n)
// 	for i := 0 ; i < n ; i++ {
// 		fmt.Scanf("%d",&ar[i])
// 	}
// 	for _,el := range ar{
// 		fmt.Println(el)
// 	}
// }
// func ScanArr(n int) []int{
// 	var ar = make([]int,n)
// 	for i:= 0 ; i < n ; i++{
// 		fmt.Scanf("%d",&ar[i])
// 	}
// 	return ar
// }

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	c := 0
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) > 1 {
			c++
		}
	}
	fmt.Printf("%d\n",c)

}

// func Compt{
// 	reader := bufio.NewReader(os.Stdin)
// 	city,_:= reader.ReadInteger('\n')
// 	var n int
// 	fmt.Scanf("%d",&n)
// 	var ar = make([]int,n)
// 	for i := 0 ; i < n ; i++ {
// 		fmt.Scanf("%d",&ar[i])
// 	}
// 	for _,el := range ar{
// 		fmt.Println(el)
// 	}
// }
// func ScanArr(n int) []int{
// 	var ar = make([]int,n)
// 	for i:= 0 ; i < n ; i++{
// 		fmt.Scanf("%d",&ar[i])
// 	}
// 	return ar
// }

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	c := 0
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) > 1 {
			c += 1
		}
	}
	fmt.Printf("%d\n",c)

}

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	c := 0
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) >= 2 {
			c += 1
		}
	}
	fmt.Println(c)

}

package main

import (
	"fmt"
)

func main() {

	var n , p , v , t int ;

	fmt.Scanf("%d",&n)
	c := 0
	for i := 0 ; i < n ; i++ {
		fmt.Scanf("%d %d %d",&p,&v,&t)
		if (p+v+t) >= 2 {
			c += 1
		}
	}
	fmt.Printf("%d\n",c)

}

// 9.Codeforce 231A-Michael542
package main

import (
    "fmt"
)

func main() {
    var n, a, can, cou int
    fmt.Scanf("%d", &n)
    for x := 0; x < n; x++ {
        for y:= 0; y < 3; y++ {
            fmt.Scanf("%d", &a )
            if a == 1 {
                can++
            }
        }
        if can >=2 {
            cou++
        }
        can = 0
    }
    fmt.Println(cou)
    cou = 0
}

// 9.Codeforce 231A-Michael542
package main

import (
    "fmt"
)

func main() {
    var n, p, v, t, can, cou int
    fmt.Scanf("%d", &n)
    for x := 0; x < n; x++ {
        fmt.Scanf("%d %d %d", &p, &v, &t)
        if p == 1 {
            can++
        }
        if v == 1 {
            can++
        }
        if t == 1 {
            can++
        }
        if can >=2 {
            cou++
        }
        can = 0
    }
    fmt.Println(cou)
}

package main

import "fmt"

func main() {
	var testcount, a, b, c, count int
	fmt.Scanf("%d", &testcount)
	for i := 0; i < testcount; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if a+b+c >= 2 {
			count++
		}
	}
	fmt.Printf("%d", count)
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	ans := 0
	for i := 0; i < t; i++ {
		count := 0
		for j := 0; j < 3; j++ {
			var a int
			fmt.Scanf("%d", &a)
			count = count + a
		}
		if count >= 2 {
			ans = ans + 1
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	var mat = make([][]int, t)
	ans := 0
	for i := 0; i < t; i++ {
		count := 0
		for j := 0; j < 3; j++ {
			var a int
			fmt.Scanf("%d", &a)
			mat[i] = append(mat[i], a)
			count = count + a
		}
		if count >= 2 {
			ans = ans + 1
		}
	}
	fmt.Println(ans)
}

package main
import "fmt"
func main() {
  var n int
  var result int
  result = 0
  fmt.Scanf("%d",&n)
  for i := 0; i < n; i++ {
    var a, b, c int
    fmt.Scanf("%d %d %d",&a,&b,&c)
    fmt.Printf("== %d %d %d\n",a,b,c)
    if a + b + c >= 2 {
      result++
    }
  }
  fmt.Printf("%d\n",result)
}

package main
import "fmt"
func main() {
  var n int
  var result int
  result = 0
  fmt.Scanf("%d",&n)
  for i := 0; i < n; i++ {
    var a, b, c int
    fmt.Scanf("%d %d %d",&a,&b,&c)
    if a + b + c >= 2 {
      result++
    }
  }
  fmt.Printf("%d\n",result)
}

package main
import "fmt"
func main() {
  var n int
  var result int
//  result := 0
  fmt.Scanf("%d",&n)
  for i := 0; i < n; i++ {
    var a, b, c int
    fmt.Scanf("%d %d %d",&a,&b,&c)
    if a + b + c >= 2 {
      result++
    }
  }
  fmt.Printf("%d\n",result)
}

package main

import "fmt"

func sum(ns [3]int8) int8 {
	var s int8
	for _, n := range ns {
		s += n
	}
	return s
}

func main() {
	var n int
	var s int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var t [3]int8
		fmt.Scanf("%d %d %d", &t[0], &t[1], &t[2])
		if sum(t) > 1 {
			s++
		}
	}
	fmt.Printf("%d\n", s)
}

package main

import (
	"fmt"
)

func main() {
	var N, cnt, inp, que int
	fmt.Scanf("%d\n", &N)

	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scanf("%d", &inp)
			if inp == 1 {
				cnt++
			}
		}
		if cnt >= 2 {
			que++
		}
		cnt = 0
		fmt.Println("\n")
	}
	fmt.Println(que)
}

package main

import (
	"fmt"
)

func main() {
	var N, cnt, inp, que int
	fmt.Scanf("%d\n", &N)

	for i := 0; i < N; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scanf("%d", &inp)
			if inp == 1 {
				cnt++
			}
		}
		if cnt >= 2 {
			que++
		}
		cnt = 0
	}
	fmt.Println(que)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	var stringMatrix []string

	var number uint8
	_, _ = fmt.Scanln(&number)
	for number > 0 {
		myString, _ := bufio.NewReader(os.Stdin).ReadString('\n')
		stringMatrix = append(stringMatrix, myString)
		number--
	}

	var count uint8 = 0

	for _,value := range stringMatrix {

		var vector []int64
		tempArray := strings.Split(value," ")

		for i:=0; i<len(tempArray); i++ {
			temp,_ := strconv.ParseInt(strings.TrimSpace(tempArray[i]),10,64)
			vector = append(vector,temp)
		}
		var temp uint8
		for i:=0; i<len(vector); i++ {
			if vector[i] == 1 {
				temp++
			}
		}

		if temp > 1 {
			count++
		}

	}

	fmt.Printf("%d",count)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	var stringMatrix []string

	var number uint8
	_, _ = fmt.Scanln(&number)
	for number > 0 {
		myString, _ := bufio.NewReader(os.Stdin).ReadString('\n')
		stringMatrix = append(stringMatrix, myString)
		number--
	}

	var count uint8 = 0

	for _, value := range stringMatrix {

		var vector []int64
		tempArray := strings.Split(value, " ")

		for i := 0; i < len(tempArray); i++ {
			temp, _ := strconv.ParseInt(strings.TrimSpace(tempArray[i]), 10, 64)
			vector = append(vector, temp)
		}
		var temp uint8
		for i := 0; i < len(vector); i++ {
			if vector[i] == 1 {
				temp++
			}
		}

		if temp > 1 {
			count++
		}

	}

	fmt.Printf("%d", count)

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	var stringMatrix []string

	var number uint8
	_, _ = fmt.Scanln(&number)
	for number > 0 {
		myString, _ := bufio.NewReader(os.Stdin).ReadString('\n')
		stringMatrix = append(stringMatrix, myString)
		number--
	}

	var count uint8 = 0

	for _, value := range stringMatrix {

		var vector []int64
		tempArray := strings.Split(value, " ")

		for i := 0; i < len(tempArray); i++ {
			temp, _ := strconv.ParseInt(strings.TrimSpace(tempArray[i]), 10, 64)
			vector = append(vector, temp)
		}
		var temp uint8 = 0
		for i := 0; i < len(vector); i++ {
			if vector[i] == 1 {
				temp++
			}
		}

		if temp > 1 {
			count++
		}

	}

	fmt.Printf("%d", count)

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	var a, b, c = make([]int, n), make([]int, n), make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for i := range b {
		fmt.Scan(&b[i])
	}
	for i := range c {
		fmt.Scan(&c[i])
	}
	count := 0
	for i := range a {
		if a[i] + b[i] + c[i] >= 2 {
			count++
		}
	}
	fmt.Println(count)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	total := 0
	for ; n > 0; n-- {
		var a, b, c int
		i, err := fmt.Scanf("%d %d %d", &a, &b, &c)
        fmt.Println(i, err)
        fmt.Println(a, b, c)
		if a+b+c >= 2 {
			total++
		}
	}
	fmt.Print(total)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d ", &n)

	total := 0
	for ; n > 0; n-- {
		var a, b, c int
		i, err := fmt.Scanf("%d %d %d ", &a, &b, &c)
		fmt.Println("ERR = ",i, err)
		fmt.Println(a, b, c)
		if a+b+c >= 2 {
			total++
		}
	}
	fmt.Print(total)
}

// A. Team
/*
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.

Examples
Input
3
1 1 0
1 1 1
1 0 0

Output
2

Input
2
1 0 0
0 1 1

Output
1

Note
In the first sample Petya and Vasya are sure that they know how to solve the first problem and all three of them know how to solve the second problem. That means that they will write solutions for these problems. Only Petya is sure about the solution for the third problem, but that isn't enough, so the friends won't take it.

In the second sample the friends will only implement the second problem, as Vasya and Tonya are sure about the solution.
*/
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	total := 0
	for ; n > 0; n-- {
		var a, b, c int
		fmt.Scanf("%d %d %d", &a, &b, &c)

		if a+b+c >= 2 {
			total++
		}
	}
	fmt.Print(total)
}

package main

import "fmt"

func main() {
	var n int
	var result int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if a+b+c > 1 {
			result++
		}
	}
	fmt.Println(result)

}

package main

import "fmt"

func main() {
	var n int
	result := 0

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if a+b+c > 1 {
			result++
		}
	}
	fmt.Println(result)
}

package main

import "fmt"

func main() {
	var n, result int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if a + b + c >= 2 {
			result++
		}
	}

	fmt.Print(result)
}

package main

import "fmt"

func main() {
	var n, result int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var a, b, c int

		fmt.Scanf("%d %d %d", &a, &b, &c)

		if a + b + c >= 2 {
			result++
		}
	}

	fmt.Print(result)
}

package main

import "fmt"

func main() {
	var n, result int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var a, b, c int

		fmt.Scanf("%d %d %d\n", &a, &b, &c)

		if a + b + c >= 2 {
			result++
		}
	}

	fmt.Print(result)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	get := wrapStdin()
	n, s, t := get.Int(), get.Int(), get.Int()
	if s == t {
		fmt.Println("0")
		return
	}

	v := get.Nint(n)

	for i := 1; i < n; i++ {
		s = v[s-1]
		if s == t {
			fmt.Println(i)
			return
		}
	}
	fmt.Println("-1")
}

type Input struct {
	*bufio.Scanner
}

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func (in Input) Int() int {
	in.Scan()
	x, _ := strconv.Atoi(in.Text())
	return x
}
func (in Input) IntOk() (int, bool) {
	ok := in.Scan()
	x, _ := strconv.Atoi(in.Text())
	return x, ok
}
func (in Input) Nint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = in.Int()
	}
	return v
}
func (in Input) Vint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = in.IntOk()
	}
	return ok
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

func main() {
	var n,s,t int
	var c [100010]int
	input := bufio.NewScanner(os.Stdin)
    	input.Split(bufio.ScanWords)

	fmt.Scan(&n,&s,&t)
	for i:=1;i<=n;i++ {
		input.Scan()
       		aa, _ := strconv.Atoi(input.Text())
		c[i]=aa
		//fmt.Scan(&c[i])
	}
	ans:=0
	for ;s!=t&&ans<=n; ans++ {
		s=c[s]
	}
	if ans>n {
		fmt.Println("-1")
	} else {
		fmt.Println(ans)
	}
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,s,t int
    var p [100005]int
    fmt.Scan(&n,&s,&t)
    for i := 1; i <= n; i++ {
        scanner.Scan()
        p[i], _ = strconv.Atoi(scanner.Text())
    }
    f := make([]bool,n+1)
    ans := 0
    for s != t {
        f[s] = true
        if !f[p[s]] {
            s = p[s]
            ans++
        } else {
            break
        }
    }
    if s != t { fmt.Println(-1) } else { fmt.Println(ans) }
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := NewScanner()
	t := s.NextInt()

Next:
	for i := 0; i < t; i++ {
		n := s.NextInt()

		m := make([][]int, n)
		for j := 0; j < n; j++ {
			m[j] = make([]int, n)
			s := s.NextString()
			for k, c := range strings.Split(s, "") {
				if c == "0" {
					m[j][k] = 0
				} else {
					m[j][k] = 1
				}
			}
		}

		for j := 0; j < n; j++ {
			for k := 0; k < n; k++ {
				if m[j][k] == 0 {
					continue
				}

				var good bool
				if j < n-1 {
					if m[j+1][k] == 1 {
						good = true
					}
				}

				if k < n-1 {
					if m[j][k+1] == 1 {
						good = true
					}
				}

				if !good && j != n-1 && k != n-1 {
					fmt.Println("NO")
					continue Next
				}
			}
		}

		fmt.Println("YES")
	}
}

type scanner struct {
	*bufio.Scanner
}

func NewScanner() *scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &scanner{s}
}

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
)

func main() {
	for t := nextInt(); t != 0; t-- {
		n := nextInt()
		mat := make([][]bool, n)
		for i := range mat {
			mat[i] = make([]bool, n)
			s := next()
			for idx, v := range s {
				mat[i][idx] = v == '1'
			}
		}
		// algo
		res := true
		for i, row := range mat {
			if i == n-1 {
				continue
			}
			for j := range row {
				if j == n-1 {
					continue
				}
				if mat[i][j] && mat[i][j+1] == mat[i+1][j] && mat[i+1][j] == false {
					res = false
					break
				}
			}
			if !res {
				break
			}
		}
		// Print
		if res {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-
func init() {
	sc.Split(bufio.ScanWords)
}
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		G := make([][]byte, n)

		for i := 0; i < n; i++ {
			G[i], _ = reader.ReadBytes('\n')
		}
		res := solve(n, G)

		if res {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func solve(n int, G [][]byte) bool {
	dp := make([][]bool, n)

	for i := 0; i < n; i++ {
		dp[i] = make([]bool, n)
	}

	for i := 0; i < n; i++ {
		if G[i][n-1] == '1' {
			dp[i][n-1] = true
		}
		if G[n-1][i] == '1' {
			dp[n-1][i] = true
		}
	}

	for i := n - 2; i >= 0; i-- {
		for j := n - 2; j >= 0; j-- {
			if G[i][j] == '0' {
				continue
			}
			if !dp[i+1][j] && !dp[i][j+1] {
				return false
			}
			dp[i][j] = true
		}
	}

	return true
}

// https://codeforces.com/contest/1355/problem/A
package main

import (
	"bufio"
	"fmt"
	"os"
	"io"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}
var (
	n int
	p []string
	good [][]bool
)

func solver() string {
	fmt.Fscanln(input, &n)
	p = make([]string, n)
	good = make([][]bool, n)
	for i := 0; i < n; i++ {
		good[i] = make([]bool, n)
		fmt.Fscanln(input, &p[i])
	}

	for i := 0; i < n; i++ {
		mark(n - 1, i)
		mark(i, n - 1)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if p[i][j] == '1' && !good[i][j] {
				return "NO"
			}
		}
	}

	return "YES"
}

func mark(i, j int) {
	if good[i][j] {
		return
	}
	if p[i][j] == '1' {
		good[i][j] = true
		if i > 0 {
			mark(i - 1, j)
		}
		if j > 0 {
			mark(i, j - 1)
		}
	}
}

// https://codeforces.com/contest/1355/problem/A
package main

import (
	"bufio"
	"fmt"
	"os"
	"io"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}
var (
	n int
	p []string
	good [][]bool
)

func solver() string {
	fmt.Fscanln(input, &n)
	p = make([]string, n)
	good = make([][]bool, n)
	for i := 0; i < n; i++ {
		good[i] = make([]bool, n)
		fmt.Fscanln(input, &p[i])
	}

	last := n - 1
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if p[i][j] == '1' {
				if i == last || j == last {
					continue
				}
				if i < last  {
					if p[i + 1][j] == '1' {
						continue
					}
				}

				if j < last  {
					if p[i][j + 1] == '1' {
						continue
					}
				}

				return "NO"
			}
		}
	}

	return "YES"
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
  "strings"
  "strconv"
  "math"
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		aa := make([][]int, n)
		for i:=range aa {
			aa[i]=make([]int, n)
		}

		for i := 0; i < len(aa); i++ {
			line:=reader.NextString();
			split:=strings.Split(line,"")
			for j:=0;j<len(split);j++{
				aa[i][j],_=strconv.Atoi(split[j])
			}
		}
		sol(aa)
	}
}

func sol(aa [][]int) {
	for i:=0;i<len(aa)-1;i++{
		for j:=0;j<len(aa)-1;j++{
			if(aa[i][j]==1){
				if(aa[i+1][j]==0 && aa[i][j+1]==0){
					writer.Printf("NO \n")
					return;
				}
			}
		}
	}
	writer.Printf("YES \n")

}

/*********************** I/O ***********************/

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}
/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

/*
URL:
https://codeforces.com/contest/1360/problem/E
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int
	n int
	A [][]rune
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()

		A = [][]rune{}

		for j := 0; j < n; j++ {
			row := ReadRuneSlice()
			A = append(A, row)
		}

		solve(n, A)
	}
}

func solve(n int, A [][]rune) {
	// 右端を埋める
	for i := 0; i < n; i++ {
		A[i] = append(A[i], '1')
	}
	// 一番下を埋める
	row := []rune{}
	for i := 0; i < n+1; i++ {
		row = append(row, '1')
	}
	A = append(A, row)

	// for i := 0; i < n+1; i++ {
	// 	PrintfDebug("%v\n", string(A[i]))
	// }
	// PrintfDebug("\n")

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if A[i][j] == '1' {
				ok := A[i+1][j] == '1' || A[i][j+1] == '1'
				if !ok {
					fmt.Println("NO")
					return
				}
			}
		}
	}
	fmt.Println("YES")
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, n int
o:
	for Scan(&t); t > 0; t-- {
		Scan(&n)
		a := make([][]byte, n)
		for i := range a {
			Scan(&a[i])
		}
		for i, s := range a[:n-1] {
			for j, b := range s[:n-1] {
				if b == '1' && a[i][j+1] == '0' && a[i+1][j] == '0' {
					Println("NO")
					continue o
				}
			}
		}
		Println("YES")
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t, n int
o:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([][]byte, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		vis := make([][]bool, n)
		for i := range vis {
			vis[i] = make([]bool, n)
		}
		var f func(i, j int)
		f = func(i, j int) {
			if a[i][j] != '1' || vis[i][j] {
				return
			}
			vis[i][j] = true
			if i > 0 {
				f(i-1, j)
			}
			if j > 0 {
				f(i, j-1)
			}
		}
		for j := 0; j < n; j++ {
			f(n-1, j)
		}
		for i := 0; i < n; i++ {
			f(i, n-1)
		}
		for i, row := range a {
			for j, v := range row {
				if v == '1' && !vis[i][j] {
					Fprintln(out, "NO")
					continue o
				}
			}
		}
		Fprintln(out, "YES")
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import (
	"fmt"
)

var n int
var a []string
var vis [][]bool

func dfs(i, j int) {
    vis[i][j] = true
    if (i - 1 >= 0 && a[i - 1][j] == '1' && !vis[i - 1][j]) {
        dfs(i - 1, j)
    }
    if (j - 1 >= 0 && a[i][j - 1] == '1' && !vis[i][j - 1]) {
        dfs(i, j - 1)
    }
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for tc := 0; tc < t; tc++ {
		fmt.Scanf("%d\n", &n)
		a = make([]string, n)
		for i := 0; i < n; i++ {
		    fmt.Scanf("%s\n", &a[i])
		}
		vis = make([][]bool, n)
		for i := 0; i < n; i++ {
		    vis[i] = make([]bool, n)
		}
		for i := 0; i < n; i++ {
		    if (a[i][n - 1] == '1' && !vis[i][n - 1]) {
		        dfs(i, n - 1)
		    }
		    if (a[n - 1][i] == '1' && !vis[n - 1][i]) {
		        dfs(n - 1, i)
		    }
		}
		flag := true
		for i := 0; flag && i < n; i++ {
		    for j := 0; flag && j < n; j++ {
		        if (a[i][j] == '1' && !vis[i][j]) {
		            flag = false;
		        }
		    }
		}
		if flag {
		    fmt.Println("YES")
		} else {
		    fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

var (
	inn = bufio.NewScanner(os.Stdin)
	// in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	inn.Split(bufio.ScanWords)
	for tt := rd(); tt > 0; tt-- {
		n := rd()
		a := make([]string, n)
		for i := 0; i < n; i++ {
			a[i] = rds()
		}
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if a[i][j] == '0' {
					continue
				}
				if i != n-1 && j != n-1 && a[i+1][j] == '0' && a[i][j+1] == '0' {
					Fprintln(out, "NO")
					goto next
				}
			}
		}
		Fprintln(out, "YES")
	next:
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	data := inn.Bytes()
	f := 1
	if data[0] == '-' {
		f = -1
		data = data[1:]
	}
	for _, b := range data {
		x = x*10 + int(b&15)
	}
	return f * x
}
func rdll() (x int64) {
	inn.Scan()
	data := inn.Bytes()
	f := int64(1)
	if data[0] == '-' {
		f = -1
		data = data[1:]
	}
	for _, b := range data {
		x = x*10 + int64(b&15)
	}
	return f * x
}

func rds() string {
	inn.Scan()
	data := inn.Bytes()
	return string(data)
}

package main

import (
	"fmt"
)

func main(){
	var T int
	fmt.Scan(&T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Scan(&n)
		G := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&G[i])
		}
		good := true
		for i := 0; i+1 < n; i++ {
			for j := 0; j+1 < n; j++ {
				if G[i][j] == '1' && G[i+1][j] == '0' && G[i][j+1] == '0' {
					good = false
				}
			}
		}
		ans := "NO"
		if good {
			ans = "YES"
		}
		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%d", &nCount)

	var n int

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &n)
		polygon := make([][]bool, n)

		// create empty polygon
		for i := 0; i < n; i++ {
			polygon[i] = make([]bool, n)
		}

		// read polygon
		for i := 0; i < n; i++ {
			scanner.Scan()
			line := scanner.Text()
			for j := 0; j < n; j++ {
				if line[j] == '1' {
					polygon[j][i] = true
				}
			}
		}

		// test polygon
		res := true
		for x := n - 2; (x >= 0) && res; x-- {
			for y := n - 2; y >= 0; y-- {
				if (polygon[x][y]) && (!polygon[x+1][y]) && (!polygon[x][y+1]) {
					res = false
					break
				}
			}
		}
		if res {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
)

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		a := make([]string, n)
		for i := range a {
			a[i] = reader.NextString()
		}
		writer.Printf("%s\n", sol(a))
	}
}

func sol(a []string) string {
	n := len(a)
	for i := range a {
		for j := range a[i] {
			b := a[i][j]
			if b == '1' && i != n-1 && j != n-1 {
				if a[i+1][j] == '0' && a[i][j+1] == '0' {
					return "NO"
				}
			}
		}
	}
	return "YES"
}

// https://codeforces.com/contest/1355/problem/A
package main

import (
	"bufio"
	"fmt"
	"os"
	"io"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}
var (
	n int
	p []string
	good [][]bool
)

func solver() string {
	fmt.Fscanln(input, &n)
	p = make([]string, n)
	good = make([][]bool, n)
	for i := 0; i < n; i++ {
		good[i] = make([]bool, n)
		fmt.Fscanln(input, &p[i])
	}

	last := n - 1
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if p[i][j] == '1' {
				if i < last  {
					if p[i + 1][j] != '1' {
						return "NO"
					}
				}

				if j < last  {
					if p[i][j + 1] != '1' {
						return "NO"
					}
				}
			}
		}
	}

	return "YES"
}