func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 1, x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) {         f = -1;       }       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int N = 55;   struct W {     int x, y, tx, ty, id;   } up[N], down[N];   bool cmp_down(W a, W b) { return a.tx == b.tx ? a.ty < b.ty : a.tx > b.tx; }   bool cmp_up(W a, W b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }   vector<pair<int, int> > ans_fr, ans_to;   bool has[N][N];   void move_up(int& x, int y) {     int dx = x;     has[x][y] = 0;     has[x - 1][y] = 1;     ans_fr.push_back(make_pair(dx, y));     ans_to.push_back(make_pair(dx - 1, y));     --x;   }   void move_down(int& x, int y) {     int dx = x;     has[x][y] = 0;     has[x + 1][y] = 1;     ans_fr.push_back(make_pair(dx, y));     ans_to.push_back(make_pair(dx + 1, y));     ++x;   }   void move_left(int x, int& y) {     int dy = y;     has[x][y] = 0;     has[x][y - 1] = 1;     ans_fr.push_back(make_pair(x, dy));     ans_to.push_back(make_pair(x, dy - 1));     --y;   }   void move_right(int x, int& y) {     int dy = y;     has[x][y] = 0;     has[x][y + 1] = 1;     ans_fr.push_back(make_pair(x, dy));     ans_to.push_back(make_pair(x, dy + 1));     ++y;   }   void move_row(int& x, int& y, int tx, int ty) {     while (y < ty && has[x][y + 1] == 0) {       move_right(x, y);     }     while (y > ty && has[x][y - 1] == 0) {       move_left(x, y);     }   }   void move(int& x, int& y, int tx, int ty) {     while (x < tx) {       move_down(x, y);     }     while (x > tx) {       move_up(x, y);     }     while (y < ty) {       move_right(x, y);     }     while (y > ty) {       move_left(x, y);     }   }   int check(W a) {     if (a.x == a.tx) {       return a.y == a.ty ? 0 : 1;     } else {       return a.y == a.ty ? 2 : 3;     }   }   int nx[N], ny[N];   char mp[N][N];   int vis[N];   void write(int n) {     for (int i = 1; i <= n; i++) {       cout << mp[i] + 1 << endl;     }     puts( ---------------------- );   }   void deal(int n, int m) {     if (n == 1) {       puts( 0 );     } else {       if (m == 1) {         move(up[1].x, up[1].y, up[1].tx, up[1].ty);       } else {         if (cmp_up(up[1], up[2]) == 0) {           swap(up[1], up[2]);         }         if (up[1].x == 2) {           move_up(up[1].x, up[1].y);           move_up(up[2].x, up[2].y);         } else if (up[2].x == 2) {           move_up(up[2].x, up[2].y);         }         switch (check(up[1])) {           case 0:             break;           case 1:             move(up[2].x, up[2].y, 2, 1);             move_right(up[1].x, up[1].y);             break;           case 2:             move(up[1].x, up[1].y, up[1].tx, up[1].ty);             break;           case 3:             move(up[1].x, up[1].y, up[1].tx, up[1].ty);             move_left(up[2].x, up[2].y);             break;         }         move(up[2].x, up[2].y, up[2].tx, up[2].ty);       }       cout << ans_fr.size() << endl;       for (int i = 0; i < ans_fr.size(); i++) {         int xx1 = ans_fr[i].first, xx2 = ans_to[i].first;         int yy1 = ans_fr[i].second, yy2 = ans_to[i].second;         printf( %d %d %d %d n , xx1, yy1, xx2, yy2);       }     }   }   int main() {     int n = read(), m = read();     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         mp[i][j] =  . ;       }     }     for (int i = 1; i <= m; i++) {       up[i].id = i;       nx[i] = up[i].x = read();       ny[i] = up[i].y = read();       has[nx[i]][ny[i]] = 1;       mp[nx[i]][ny[i]] = i +  0 ;     }     for (int i = 1; i <= m; i++) {       up[i].tx = read();       up[i].ty = read();     }     if (n <= 2) {       deal(n, m);       return 0;     }     copy(up + 1, up + 1 + m, down + 1);     sort(up + 1, up + 1 + m, cmp_up);     int cnt = m;     while (cnt) {       for (int i = 1; i <= m; i++) {         if (vis[i] == 0) {           int id = up[i].id;           move_row(nx[id], ny[id], 1, i);           if (ny[id] == i) {             vis[i] = 1;             cnt--;           }         }       }     }     for (int i = 1; i <= m; i++) {       int id = up[i].id;       while (nx[id] > 1) {         move_up(nx[id], ny[id]);       }     }     for (int i = 1; i <= m; i++) {       move_down(nx[i], ny[i]);       move_down(nx[i], ny[i]);     }     sort(down + 1, down + 1 + m, cmp_down);     for (int i = 1; i <= m; i++) {       int id = down[i].id;       move_up(nx[id], ny[id]);       move_row(nx[id], ny[id], 1, i);       move_up(nx[id], ny[id]);     }     for (int i = 1; i <= m; i++) {       int id = down[i].id;       while (nx[id] < down[i].tx) {         move_down(nx[id], ny[id]);       }     }     cnt = m;     while (cnt) {       for (int i = 1; i <= m; i++) {         if (vis[i] == 1) {           int id = down[i].id;           move_row(nx[id], ny[id], nx[id], down[i].ty);           if (ny[id] == down[i].ty) {             vis[i] = 2;             cnt--;           }         }       }     }     assert(ans_fr.size() == ans_to.size());     assert(ans_fr.size() <= 10800);     cout << ans_fr.size() << endl;     for (int i = 0; i < ans_fr.size(); i++) {       int xx1 = ans_fr[i].first, xx2 = ans_to[i].first;       int yy1 = ans_fr[i].second, yy2 = ans_to[i].second;       printf( %d %d %d %d n , xx1, yy1, xx2, yy2);     }     return 0;   }   