#include <bits/stdc++.h>   using namespace std;   struct pnt {     int x, y;     pnt(int x = 0, int y = 0) : x(x), y(y) {}     bool operator<(const pnt &p) const { return x == p.x ? y < p.y : x < p.x; }     bool operator==(const pnt &p) const { return x == p.x && y == p.y; }   };   const int inf = 1e9;   int ans;   pnt p[4], rlt[4];   void check(pnt *q) {     sort(q, q + 4);     while (1) {       bool flag = 0;       int cur = -1;       for (int i = 0; i < 4; i++) {         if (q[i].x != p[i].x && q[i].y != p[i].y) {           flag = 1;           break;         }         cur = max(cur, abs(p[i].x - q[i].x) + abs(p[i].y - q[i].y));       }       if (!flag) {         if (cur < ans) {           ans = cur;           for (int i = 0; i < 4; i++) rlt[i] = q[i];         }       }       if (!next_permutation(q, q + 4)) break;     }   }   int dx[4] = {1, 0, -1, 0};   int dy[4] = {0, 1, 0, -1};   void solve() {     for (int i = 0; i < 4; i++) cin >> p[i].x >> p[i].y;     vector<pnt> u;     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++) {         u.push_back(pnt(p[i].x, p[j].y));       }     sort(u.begin(), u.end());     u.erase(unique(u.begin(), u.end()), u.end());     vector<int> a;     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++) {         a.push_back(abs(p[i].x - p[j].x));         a.push_back(abs(p[i].y - p[j].y));       }     sort(a.begin(), a.end());     a.erase(unique(a.begin(), a.end()), a.end());     vector<pnt> v;     vector<int> dist;     for (int i = 0; i < a.size(); i++)       for (int j = i; j < a.size(); j++) {         int d = a[j] - a[i];         dist.push_back(d >> 1);         dist.push_back(d + 1 >> 1);       }     sort(dist.begin(), dist.end());     dist.erase(unique(dist.begin(), dist.end()), dist.end());     for (int k = 0; k < u.size(); k++) {       for (int h = 0; h < 4; h++) {         for (int r = 0; r < dist.size(); r++)           v.push_back(pnt(u[k].x + dist[r] * dx[h], u[k].y + dist[r] * dy[h]));       }     }     ans = inf;     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 0; i < v.size(); i++) {       for (int j = 1; j < a.size(); j++) {         pnt q0[4] = {pnt(v[i].x, v[i].y), pnt(v[i].x, v[i].y + a[j]),                      pnt(v[i].x + a[j], v[i].y),                      pnt(v[i].x + a[j], v[i].y + a[j])};         check(q0);         pnt q1[4] = {pnt(v[i].x, v[i].y), pnt(v[i].x, v[i].y - a[j]),                      pnt(v[i].x + a[j], v[i].y),                      pnt(v[i].x + a[j], v[i].y - a[j])};         check(q1);         pnt q2[4] = {pnt(v[i].x, v[i].y), pnt(v[i].x, v[i].y + a[j]),                      pnt(v[i].x - a[j], v[i].y),                      pnt(v[i].x - a[j], v[i].y + a[j])};         check(q2);         pnt q3[4] = {pnt(v[i].x, v[i].y), pnt(v[i].x, v[i].y - a[j]),                      pnt(v[i].x - a[j], v[i].y),                      pnt(v[i].x - a[j], v[i].y - a[j])};         check(q3);       }     }     if (ans == inf) {       puts( -1 );     } else {       printf( %d n , ans);       for (int i = 0; i < 4; i++) printf( %d %d n , rlt[i].x, rlt[i].y);     }   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }   }