#K92397. Prime Rows and Columns

    ID: 38188 Type: Default 1000ms 256MiB

Prime Rows and Columns

Prime Rows and Columns

Given an integer N and an N x N matrix of integers, your task is to determine if there exists at least one row or one column such that every number in that row or column is a prime number.

If at least one row or column is composed entirely of prime numbers, print "YES". Otherwise, print "NO".

Note: When N is 0, the matrix is considered empty and you should output "NO".

inputFormat

The first line contains an integer N, the size of the matrix. If N > 0, each of the following N lines contains N space-separated integers representing the matrix.

outputFormat

Output a single line with the word "YES" if there is at least one row or one column where every element is a prime number, otherwise output "NO".## sample

3
2 3 5
4 6 8
7 11 13
YES