1720 - Rent House

Time Limit : 1 Second

Memory Limit : 256 MB

Submission: 11

Solved: 2

Description

Bob signed BRICK company in Beijing after he graduated from HUST. Another 3 students graduated from Blue Feces also joined this company. All of them want to rent a good house in the form entry before. Strangely, they fancy the same community. The community’s shape is N * M rectangle, each grid means a building with individual height. They do not want to live in same building, while Bob is a math geek. He wants to choose building according to the laws of mathematics. He proposed that the GCD(greatest common divisor) of four building’s heights we choose should be 1. Sounds ridiculous, while Bob just want to do that. 


Now he found that there are many kinds of the situation, please tell him what the number it is.


 

Input

There are multiple test cases.


For each test case, there is one line contains 2 integers N(1<=N<=100) and M(1<=M<=100) representing the community’s size.


Then there are N lines, each line include M numbers, each number means the building’s height. Each height is positive integer and no greater than 10000.


 

Output

For each test cases, there is only one number what we asked.


 

sample input
2 2
1 3
5 7
2 2
2 4
6 8
sample output
1
0
hint
source
zhangji
© 2015 HUST ACMICPC TEAM. All Right Reserved.