using
System;
using
System.Collections.Generic;
class
GFG
{
static
readonly
int
n = 3;
static
readonly
int
m = 3;
static
bool
check(
int
[,]a,
int
[,]b)
{
for
(
int
i = 0; i < n; i++)
{
List<
int
> v1 =
new
List<
int
>();
List<
int
> v2 =
new
List<
int
>();
int
r = i;
int
col = 0;
while
(r >= 0 && col < m)
{
v1.Add(a[r, col]);
v2.Add(b[r, col]);
r--;
col++;
}
v1.Sort();
v2.Sort();
for
(
int
j = 0; j < v1.Count; j++)
{
if
(v1[j] != v2[j])
{
return
false
;
}
}
}
for
(
int
j = 1; j < m; j++)
{
List<
int
> v1 =
new
List<
int
>();
List<
int
> v2 =
new
List<
int
>();
int
r = n - 1;
int
col = j;
while
(r >= 0 && col < m)
{
v1.Add(a[r, col]);
v2.Add(b[r, col]);
r--;
col++;
}
v1.Sort();
v2.Sort();
for
(
int
i = 0; i < v1.Count; i++)
{
if
(v1[i] != v2[i])
{
return
false
;
}
}
}
return
true
;
}
public
static
void
Main()
{
int
[,]a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int
[,]b = {{1, 4, 7}, {2, 5, 6}, {3, 8, 9}};
if
(check(a, b))
{
Console.WriteLine(
"Yes"
);
}
else
{
Console.WriteLine(
"No"
);
}
}
}