next up previous
Next: Computing Factorial for Large Up: 1997 UMCP High School Programming Contest Previous: Detecting Palindromes

Symmetric Matrices

A two dimension array of numbers is often called a matrix. The transpose of a matrix is matrix formed by exchanging the rows and columns of a matrix (i.e. row 1 column 2 becomes row 2 column 1). A symmetric matrix is one where every element in the transpose of the matrix has the same value as the original matrix. Write a program that reads in a series of matrices and tests if they are symmetric. You may assume the matrix contains at most 100 rows and 100 columns.

Input Format

The input will consist of a number of integer matrices. The input format for each matrix will consist of two values indicating the number of rows and columns in the matrix followed by one line for each row containing the elements for each column in that row. Elements of the matrix are integers. A line containing two zeros indicates end of input.

Output Format

The output will consist of one line per matrix indicating if it is symmetric or not.

Example

Input: Output:
3 3
1 2 3
4 5 6
7 8 9
2 2
1 2
2 1
0 0
Matrix #1 is not symmetric
Matrix #2 is symmetric

Test data used in judging

Input Output

Our solution



next up previous
Next: Computing Factorial for Large Up: 1997 UMCP High School Programming Contest Previous: Detecting Palindromes

Bill Pugh
Mon Mar 17 14:34:34 EST 1997