func_code_string: #include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     int v = 0, f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = (c & 15);     while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);     x = v * f;   }   inline void read(long long &x) {     long long v = 0ll, f = 1ll;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - )       f = -1;     else       v = (c & 15);     while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);     x = v * f;   }   inline void readc(char &x) {     char c;     while (((c = getchar()) ==    ) || c ==   n )       ;     x = c;   }   int t, n, m, i, j, k, l, px[5], py[5], c[5], res, sx[5], sy[5], tx[5], ty[5],       tt[5];   void check(int d, int x, int y) {     tx[1] = tx[2] = x;     tx[3] = tx[4] = x + d;     ty[1] = ty[3] = y;     ty[2] = ty[4] = y + d;     int i, j;     for (((i)) = (1); ((i)) <= ((4)); ((i))++) c[i] = i;     do {       int s = 0;       for (((i)) = (1); ((i)) <= ((4)); ((i))++) {         if (px[i] == tx[c[i]]) {           s = max(s, abs(py[i] - ty[c[i]]));           continue;         }         if (py[i] == ty[c[i]]) {           s = max(s, abs(px[i] - tx[c[i]]));           continue;         }         s = 0x3bbbbbbb;         break;       }       if (s < res) {         res = s;         for (((i)) = (1); ((i)) <= ((4)); ((i))++) {           sx[i] = tx[c[i]];           sy[i] = ty[c[i]];         }       }     } while (next_permutation(c + 1, c + 5));   }   int main() {     read(t);     while (t--) {       for (((i)) = (1); ((i)) <= ((4)); ((i))++) {         read(px[i]);         read(py[i]);       }       res = 0x3bbbbbbb;       for (((i)) = (1); ((i)) <= ((4)); ((i))++)         for ((j) = (i + 1); (j) <= (4); (j)++) {           for (((k)) = (1); ((k)) <= ((4)); ((k))++)             for (((l)) = (1); ((l)) <= ((4)); ((l))++) {               int d = abs(px[i] - px[j]);               check(d, px[k], py[l]);               check(d, px[k], py[l] - d);               check(d, px[k] - d, py[l]);               check(d, px[k] - d, py[l] - d);               d = abs(py[i] - py[j]);               check(d, px[k], py[l]);               check(d, px[k], py[l] - d);               check(d, px[k] - d, py[l]);               check(d, px[k] - d, py[l] - d);             }         }       for (((i)) = (1); ((i)) <= ((4)); ((i))++)         for ((j) = (i + 1); (j) <= (4); (j)++) {           k = 1;           while (k == i || k == j) k++;           l = 4 ^ i ^ j ^ k;           if (px[i] == px[j] && px[k] == px[l]) {             int d = abs(px[i] - px[k]);             int t1 = min(py[i], py[j]), t2 = max(py[i], py[j]) - d;             int t3 = min(py[k], py[l]), t4 = max(py[k], py[l]) - d;             tt[1] = t1;             tt[2] = t2;             tt[3] = t3;             tt[4] = t4;             sort(tt + 1, tt + 5);             check(d, min(px[i], px[k]), (tt[1] + tt[4]) / 2);           }           if (py[i] == py[j] && py[k] == py[l]) {             int d = abs(py[i] - py[k]);             int t1 = min(px[i], px[j]), t2 = max(px[i], px[j]) - d;             int t3 = min(px[k], px[l]), t4 = max(px[k], px[l]) - d;             tt[1] = t1;             tt[2] = t2;             tt[3] = t3;             tt[4] = t4;             sort(tt + 1, tt + 5);             check(d, (tt[1] + tt[4]) / 2, min(py[i], py[k]));           }         }       if (res >= 0x3bbbbbbb) {         puts( -1 );       } else {         printf( %d n , res);         for (((i)) = (1); ((i)) <= ((4)); ((i))++) {           printf( %d %d n , sx[i], sy[i]);         }       }     }     return 0;   }   