#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
void precalc() {}
const int inf = (int)1.01e9;
const int n = 4;
int xs[n][2];
bool read() {
  for (int i = 0; i < 4; ++i) {
    if (scanf("%d%d", &xs[i][0], &xs[i][1]) < 2) {
      return false;
    }
  }
  return true;
}
int res;
int axs[n][2];
int perm[4];
int calcans(int x[2], int y[2]) {
  for (int i = 0; i < n; ++i) {
    perm[i] = i;
  }
  int cres = inf;
  do {
    int cur = 0;
    for (int i = 0; i < n; ++i) {
      int cx = xs[perm[i]][0], cy = xs[perm[i]][1];
      int nx = x[i / 2], ny = y[i % 2];
      if (cx != nx && cy != ny) {
        cur = inf;
        break;
      }
      cur = max(cur, max(abs(cx - nx), abs(cy - ny)));
    }
    if (res > cur) {
      res = cur;
      for (int i = 0; i < n; ++i) {
        axs[perm[i]][0] = x[i / 2];
        axs[perm[i]][1] = y[i % 2];
      }
    }
    cres = min(cres, cur);
  } while (next_permutation(perm, perm + 4));
  return cres;
}
int dir[n];
map<int, vector<int> *> o[2];
void updans() {
  o[0].clear();
  o[1].clear();
  for (int i = 0; i < n; ++i) {
    int x = xs[i][dir[i]];
    auto it = o[dir[i]].find(x);
    vector<int> *v;
    if (it != o[dir[i]].end()) {
      v = it->second;
    } else {
      v = new vector<int>();
      o[dir[i]][x] = v;
    }
    v->push_back(i);
  }
  int mx = max(((int)(o[0]).size()), ((int)(o[1]).size()));
  int mn = min(((int)(o[0]).size()), ((int)(o[1]).size()));
  if (mx != 2) {
    return;
  }
  int x[2], y[2];
  int cntx = 0, cnty = 0;
  for (auto it : o[0]) {
    x[cntx++] = it.first;
  }
  for (auto it : o[1]) {
    y[cnty++] = it.first;
  }
  if (mn == 2) {
    if (abs(x[1] - x[0]) != abs(y[1] - y[0])) {
      return;
    }
    calcans(x, y);
    return;
  }
  if (mn == 1) {
    if (cntx == 1) {
      int dist = abs(y[1] - y[0]);
      for (int it = 0; it < 2; ++it) {
        x[1] = x[0] + (it ? (-dist) : dist);
        calcans(x, y);
      }
    } else {
      int dist = abs(x[1] - x[0]);
      for (int it = 0; it < 2; ++it) {
        y[1] = y[0] + (it ? (-dist) : dist);
        calcans(x, y);
      }
    }
    return;
  }
  if (mn == 0) {
    if (cntx == 0) {
      int dist = abs(y[1] - y[0]);
      int L = -inf, R = inf;
      while (R - L > 1) {
        int M = (L + R) / 2;
        x[0] = M, x[1] = M + dist;
        int curl = calcans(x, y);
        x[0] = M + 1, x[1] = M + 1 + dist;
        int curr = calcans(x, y);
        if (curl >= curr) {
          L = M;
        } else {
          R = M;
        }
      }
      x[0] = L, x[1] = L + dist;
      calcans(x, y);
      x[0] = R, x[1] = R + dist;
      calcans(x, y);
    } else {
      int dist = abs(x[1] - x[0]);
      int L = -inf, R = inf;
      while (R - L > 1) {
        int M = (L + R) / 2;
        y[0] = M, y[1] = M + dist;
        int curl = calcans(x, y);
        y[0] = M + 1, y[1] = M + 1 + dist;
        int curr = calcans(x, y);
        if (curl >= curr) {
          L = M;
        } else {
          R = M;
        }
      }
      y[0] = L, y[1] = L + dist;
      calcans(x, y);
      y[0] = R, y[1] = R + dist;
      calcans(x, y);
    }
  }
}
void gen(int i) {
  if (i == 4) {
    updans();
    return;
  }
  dir[i] = 0;
  gen(i + 1);
  dir[i] = 1;
  gen(i + 1);
}
void solve() {
  res = inf;
  gen(0);
  if (res == inf) {
    printf("-1\n");
    return;
  }
  printf("%d\n", res);
  for (int i = 0; i < 4; ++i) {
    printf("%d %d\n", axs[i][0], axs[i][1]);
  }
}
int main() {
  srand(rdtsc());
  precalc();
  int T = 0;
  scanf("%d", &T);
  for (int tn = 0; tn < T; ++tn) {
    assert(read());
    solve();
  }
  return 0;
}
