func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 501;   int a[N][N], b[N][N];   void solve() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> b[i][j];       }     }     for (int i = 0; i < m; i++) {       vector<int> comp1, comp2;       int x = 0, y = i;       while (x < n && y >= 0) {         comp1.push_back(a[x][y]);         comp2.push_back(b[x][y]);         x++, y--;       }       sort(comp1.begin(), comp1.end());       sort(comp2.begin(), comp2.end());       if (comp1 != comp2) {         cout <<  NO n ;         return;       }     }     for (int i = 1; i < n; i++) {       vector<int> comp1, comp2;       int x = i, y = m - 1;       while (x < n && y >= 0) {         comp1.push_back(a[x][y]);         comp2.push_back(b[x][y]);         x++, y--;       }       sort(comp1.begin(), comp1.end());       sort(comp2.begin(), comp2.end());       if (comp1 != comp2) {         cout <<  NO n ;         return;       }     }     cout <<  YES n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     for (int tt = 1; tt <= t; tt++) {       solve();     }   }   