using
System;
using
System.Linq;
class
GFG {
static
void
reverse(
int
[,]arr,
int
N,
int
M)
{
for
(
int
i = 0; i < M; i++) {
int
start = 0;
int
end = N - 1;
while
(start < end) {
int
temp = arr[i,start];
arr[i, start] = arr[i, end];
arr[i, end] = temp;
start++;
end--;
}
}
}
static
bool
isEqual(
int
[,] arr,
int
[,] brr,
int
n,
int
m)
{
for
(
int
i = 0; i < n; i++) {
for
(
int
j = 0; j < m; j++) {
if
(arr[i,j] != brr[i,j])
return
false
;
}
}
return
true
;
}
static
void
rotate(
int
[,] arr,
int
n,
int
m)
{
for
(
int
i = 0; i < n; i++)
for
(
int
j = 0; j < i; j++)
{
int
curr = arr[i,j];
arr[i,j] = arr[j,i];
arr[j,i] = curr;
}
reverse(arr,n,m);
}
static
void
findRotation(
int
[,] arr,
int
[,] brr,
int
n,
int
m)
{
if
(isEqual(arr, brr, n, m)) {
Console.Write(0);
return
;
}
for
(
int
i = 1; i < 4; i++) {
rotate(arr,n,m);
if
(isEqual(arr, brr,n,m)) {
if
(i < 4 - i) {
Console.Write(
"+"
+ i);
}
else
Console.Write(
"-"
+ (4 - i));
return
;
}
}
Console.Write(
"NA"
);
}
public
static
void
Main()
{
int
[,] arr =
new
int
[,] { { 2, 3 }, { 4, 5 } };
int
[,] brr =
new
int
[,] { { 4, 2 }, { 5, 3 } };
int
N = 2;
int
M = 2;
findRotation(arr, brr, N, M);
}
}