import java. io. *;
class EqMat
{
int a [ ] [ ];
int m, n;
EqMat (int mm, int nn)
{
m = mm;
n = nn;
a = new int[m][n];
}
void readarray ( )
{
int i, j;
BufferedReader br = new BufferedReader (new InputStreamReader (System. in));
System. out. println ("Enter" + m + n + "values"); for (i = 0; i < m; i + +)
{
for (j = 0; j < n; j ++)
a [i] [j] = Integer. parseInt (br. readLine ());
}
}
int check (EqMat P, EqMat Q)
{
int i, j;
for (i = 0; i < m; i ++)
{
for (j = 0; j < n; j++)
if (P. a [i] [j] ! = Q. a [i] [j]) return (0);
}
return (1);
}
void print ( )
{
int i, j;
for (i = 0; i < m; i ++)
{
for (j = 0; j < n; j ++) System. out. print (a [i] [j]);
system. out. println ( ) ;
}
}
public static void main (String args [ ])
{
BufferedReader br = new BufferedReader (new InputStreamReader (System. in));
system. out. println ("Enter no. of rows of matrix");
int row = Integer. parseInt (br. readLine ( ));
system . out. println ("Enter no. of Columns of matrix ");
int col = Integer. parseInt (br. readLine ( ));
EqMat Ob1 = new EqMat (row, col);
Ob1. readarray ( );
Ob1. print ( );
EqMat Ob2 = new EqMat(row, col);
Ob2. readarray ( );
Ob2. print ( );
EqMat Ob3 = new EqMat (row, col);
if (Ob3. check (Ob1, Ob2) = = 1)
system. out. println (" Matrices are equal");
else
system. out. println (" Matrices are not equal");
}
}