Tasks:
 
Task DescriptionDiscussion (0)
Task :: BubbleMatrix
A perfect matrix is a matrix with integer elements in which each two neighboring elements are relatively prime (co-prime), and the absolute value of each element is greater than one. Each element has up to four neighbors.

You are given a matrix A_(m×n) with integer elements a[i][j],1≤im,1≤jn.

Check if there exists a perfect matrixB_(m×n) where b[i][j] divides a[i][j] for every 1≤im,1≤jn.


INPUT:
The first line contains positive integers m,n (1≤m,n≤80) — the dimensions of the matrix A_(m×n). Each of the next m lines contains a sequence of n integers separated by spaces, representing elements a[i][j] (2≤|a[i[j]|≤1000) of the matrix A_(m×n).


OUTPUT:
Output consists of one digit: “yes” (without quotes) if a perfect matrix exists; “no” if it doesn’t exist.



Input:
2 2
6 4
10 9

Output:
yes




Input:
1 3
4 6 9

Output:
no



Submit Solution
:
:
Available Languages
Task info
Name:BubbleMatrix
Time:1 sec.
Memory:16 MB
#Tests:26
AddedBy: andrejko
Task Ratings
Difficulty:

3.5 (2 votes)
Quality:

4 (2 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
halil 0.045 s.
kalinov 0.195 s.
Solved By
halil, kalinov