#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
} pos[5], anspos[5], tmppos[5];
int cnt;
int tmpx[5], tmpy[5];
set<int> a, b;
bool used[5];
void dfs(int x1, int y1, int x2, int y2, int i, int dis) {
  if (i == 4) {
    if (cnt == -1 || dis < cnt) {
      cnt = dis;
      for (int j = 0; j < 4; j++) {
        anspos[j].x = tmppos[j].x;
        anspos[j].y = tmppos[j].y;
      }
    }
    return;
  }
  if (!used[0]) {
    if (pos[i].x == x1 || pos[i].y == y1) {
      used[0] = 1;
      tmppos[i].x = x1;
      tmppos[i].y = y1;
      dfs(x1, y1, x2, y2, i + 1,
          max(dis, max(abs(pos[i].x - x1), abs(pos[i].y - y1))));
      used[0] = 0;
    }
  }
  if (!used[1]) {
    if (pos[i].x == x1 || pos[i].y == y2) {
      used[1] = 1;
      tmppos[i].x = x1;
      tmppos[i].y = y2;
      dfs(x1, y1, x2, y2, i + 1,
          max(dis, max(abs(pos[i].x - x1), abs(pos[i].y - y2))));
      used[1] = 0;
    }
  }
  if (!used[2]) {
    if (pos[i].x == x2 || pos[i].y == y1) {
      used[2] = 1;
      tmppos[i].x = x2;
      tmppos[i].y = y1;
      dfs(x1, y1, x2, y2, i + 1,
          max(dis, max(abs(pos[i].x - x2), abs(pos[i].y - y1))));
      used[2] = 0;
    }
  }
  if (!used[3]) {
    if (pos[i].x == x2 || pos[i].y == y2) {
      used[3] = 1;
      tmppos[i].x = x2;
      tmppos[i].y = y2;
      dfs(x1, y1, x2, y2, i + 1,
          max(dis, max(abs(pos[i].x - x2), abs(pos[i].y - y2))));
      used[3] = 0;
    }
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    cnt = -1;
    a.clear();
    b.clear();
    for (int i = 0; i < 4; i++) {
      scanf("%d%d", &pos[i].x, &pos[i].y);
      tmpx[i] = pos[i].x;
      tmpy[i] = pos[i].y;
    }
    if (pos[0].x == pos[1].x && pos[1].x == pos[2].x && pos[2].x == pos[3].x &&
        pos[0].y == pos[1].y && pos[1].y == pos[2].y && pos[2].y == pos[3].y) {
      printf("-1\n");
      continue;
    }
    sort(tmpx, tmpx + 4);
    sort(tmpy, tmpy + 4);
    for (int i = 0; i < 4; i++) {
      a.insert(tmpx[i]);
      b.insert(tmpy[i]);
    }
    for (int i = 0; i < 4; i++) {
      a.insert((tmpx[i + 1] + tmpx[i]) / 2);
      if ((tmpx[i + 1] + tmpx[i]) % 2)
        a.insert((tmpx[i + 1] + tmpx[i]) / 2 + 1);
      b.insert((tmpy[i + 1] + tmpy[i]) / 2);
      if ((tmpy[i + 1] + tmpy[i]) % 2)
        b.insert((tmpy[i + 1] + tmpy[i]) / 2 + 1);
    }
    if (a.size() == 1) {
      printf("%d\n", max(1, min(tmpy[1] - tmpy[0], tmpy[3] - tmpy[2])));
      bool vis[5] = {};
      for (int i = 0; i < 4; i++) {
        if (pos[i].y == tmpy[0] && vis[0] == 0) {
          vis[0] = 1;
          printf("%d %d\n", pos[i].x + 1, tmpy[0]);
        } else if (pos[i].y == tmpy[1] && vis[1] == 0) {
          vis[1] = 1;
          printf("%d %d\n", pos[i].x, tmpy[0]);
        } else if (pos[i].y == tmpy[2] && vis[2] == 0) {
          vis[2] = 1;
          printf("%d %d\n", pos[i].x, tmpy[3]);
        } else if (pos[i].y == tmpy[3] && vis[3] == 0) {
          vis[3] = 1;
          printf("%d %d\n", pos[i].x + 1, tmpy[3]);
        }
      }
      continue;
    }
    if (b.size() == 1) {
      printf("%d\n", max(1, min(tmpx[1] - tmpx[0], tmpx[3] - tmpx[2])));
      bool vis[5] = {};
      for (int i = 0; i < 4; i++) {
        if (pos[i].x == tmpx[0] && vis[0] == 0) {
          vis[0] = 1;
          printf("%d %d\n", tmpx[0], pos[i].y + 1);
        } else if (pos[i].x == tmpx[1] && vis[1] == 0) {
          vis[1] = 1;
          printf("%d %d\n", tmpx[0], pos[i].y);
        } else if (pos[i].x == tmpx[2] && vis[2] == 0) {
          vis[2] = 1;
          printf("%d %d\n", tmpx[3], pos[i].y);
        } else if (pos[i].x == tmpx[3] && vis[3] == 0) {
          vis[3] = 1;
          printf("%d %d\n", tmpx[3], pos[i].y + 1);
        }
      }
      continue;
    }
    for (set<int>::iterator it1 = a.begin(); it1 != a.end(); it1++)
      for (set<int>::iterator it2 = b.begin(); it2 != b.end(); it2++)
        for (set<int>::iterator it3 = a.begin(); it3 != a.end(); it3++)
          for (set<int>::iterator it4 = b.begin(); it4 != b.end(); it4++) {
            int x1 = *it1, y1 = *it2, x2 = *it3, y2 = *it4;
            if (x1 != x2 && y1 != y2) {
              memset(used, 0, sizeof(used));
              dfs(x1, y1, x2, y1 + x2 - x1, 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, y1, x1 + y2 - y1, y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, y2 + x1 - x2, x2, y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x2 + y1 - y2, y1, x2, y2, 0, 0);
              int d = y2 - y1;
              memset(used, 0, sizeof(used));
              dfs((x1 + x2) / 2 - d / 2, y1, (x1 + x2) / 2 + d / 2 + (d % 2),
                  y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs((x1 + x2) / 2 - d, y1, (x1 + x2) / 2, y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs((x1 + x2) / 2, y1, (x1 + x2) / 2 + d, y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs((2 * x1 + x2) / 3 - d / 2, y1,
                  (2 * x1 + x2) / 3 + d / 2 + (d % 2), y2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs((x1 + 2 * x2) / 3 - d / 2, y1,
                  (x1 + 2 * x2) / 3 + d / 2 + (d % 2), y2, 0, 0);
              d = x2 - x1;
              memset(used, 0, sizeof(used));
              dfs(x1, (y1 + y2) / 2 - d / 2, x2,
                  (y1 + y2) / 2 + d / 2 + (d % 2), 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, (y1 + y2) / 2 - d, x2, (y1 + y2) / 2, 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, (y1 + y2) / 2, x2, (y1 + y2) / 2 + d, 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, (2 * y1 + y2) / 3 - d / 2, x2,
                  (2 * y1 + y2) / 3 + d / 2 + (d % 2), 0, 0);
              memset(used, 0, sizeof(used));
              dfs(x1, (y1 + 2 * y2) / 3 - d / 2, x2,
                  (y1 + 2 * y2) / 3 + d / 2 + (d % 2), 0, 0);
            }
          }
    printf("%d\n", cnt);
    if (cnt != -1) {
      for (int i = 0; i < 4; i++) printf("%d %d\n", anspos[i].x, anspos[i].y);
    }
  }
  return 0;
}
