func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Pt {     long long int x, y;     friend ostream& operator<<(ostream& os, const Pt& a) {       os << a.x <<     << a.y;       return os;     }   };   struct R {     long long int a, b, c;   };   int main() {     ios::sync_with_stdio(false);     long long int N, K;     cin >> N >> K;     vector<long long int> w[4];     for (long long int i = 0; i < (long long int)(4); ++i)       w[i] = vector<long long int>(N);     vector<Pt> wp[4];     for (long long int i = 0; i < (long long int)(4); ++i) wp[i] = vector<Pt>(N);     for (long long int i = 0; i < (long long int)(4); ++i)       for (int j = 0; j < N; ++j) wp[i][j] = {i + 1, j + 1};     for (long long int i = 0; i < (long long int)(4); ++i)       for (int j = 0; j < N; ++j) cin >> w[i][j];     vector<long long int> a[2];     for (long long int i = 0; i < (long long int)(2); ++i)       a[i] = vector<long long int>(2 * N);     vector<Pt> p[2];     for (long long int i = 0; i < (long long int)(2); ++i)       p[i] = vector<Pt>(2 * N);     for (long long int i = 0; i < (long long int)(N); ++i) a[0][i] = w[0][i];     for (long long int i = 0; i < (long long int)(N); ++i)       a[0][N + i] = w[3][N - 1 - i];     for (long long int i = 0; i < (long long int)(N); ++i) a[1][i] = w[1][i];     for (long long int i = 0; i < (long long int)(N); ++i)       a[1][N + i] = w[2][N - 1 - i];     for (long long int i = 0; i < (long long int)(N); ++i) p[0][i] = wp[0][i];     for (long long int i = 0; i < (long long int)(N); ++i)       p[0][N + i] = wp[3][N - 1 - i];     for (long long int i = 0; i < (long long int)(N); ++i) p[1][i] = wp[1][i];     for (long long int i = 0; i < (long long int)(N); ++i)       p[1][N + i] = wp[2][N - 1 - i];     N *= 2;     vector<R> res;     for (int t = 0; t < 151; ++t) {       long long int c = 0;       for (long long int i = 0; i < (long long int)(N); ++i) {         if (a[1][i] != 0 && a[1][i] == a[0][i]) {           res.push_back({a[1][i], p[0][i].x, p[0][i].y});           a[1][i] = 0;         }         if (a[1][i] == 0) c++;       }       if (c == N) break;       if (c == 0 || t == 150) {         cout << -1 << endl;         return 0;       }       int j = 0;       for (; j < N; ++j)         if (a[1][j] == 0) break;       for (int i = 0; i < N - 1; ++i) {         long long int w = (j + i) % N;         long long int q = (j + i + 1) % N;         if (a[1][q] != 0) {           res.push_back({a[1][q], p[1][w].x, p[1][w].y});           a[1][w] = a[1][q];           a[1][q] = 0;         }       }     }     cout << res.size() << endl;     for (long long int i = 0; i < (long long int)(res.size()); ++i) {       cout << res[i].a <<     << res[i].b <<     << res[i].c <<     << endl;     }     return 0;   }   