Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a plate, can run a powerful chain reaction under certain conditions. 

To be precise, researchers introduced a rectangular Cartesian coordinate system on a flat plate and selected four distinct points with integer coordinates where bots will be placed initially. Next each bot will be assigned with one of the four directions (up, down, left or right) parallel to the coordinate axes. After that, each bot is shifted by an integer distance (which may be different for different bots) along its direction. The chain reaction starts, if the bots are in the corners of a square with positive area with sides parallel to the coordinate axes. Each corner of the square must contain one nanobot. This reaction will be stronger, if bots spend less time to move. We can assume that bots move with unit speed. In other words, the lesser is the maximum length traveled by bot, the stronger is reaction.

Scientists have prepared a set of plates and selected starting position for the bots for each plate. Now they ask you to assign the direction for each bot to move after landing such that the maximum length traveled by bot is as small as possible.
The first line contains an integer number *t* (1 ≤ *t* ≤ 50) — the number of plates.

*t* descriptions of plates follow. A description of each plate consists of four lines. Each line consists of a pair of integers numbers *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> ( - 10<sup class="upper-index">8</sup> ≤ *x*<sub class="lower-index">*i*</sub>, *y*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">8</sup>) — coordinates of the next bot. All bots are in different locations.

Note, though, the problem can include several records in one test, you can hack other people's submissions only with the test of one plate, i.e. parameter *t* in a hack test should be equal to 1.
none
2
1 1
1 -1
-1 1
-1 -1
1 1
2 2
4 4
6 6
0
1 1
1 -1
-1 1
-1 -1
-1
1
31 85
9 49
52 57
11 85
15
37 85
9 57
37 57
9 85
1
183 65
100 121
138 31
81 31
49
183 114
100 114
183 31
100 31
1
152 76
152 112
118 17
83 129
59
152 17
152 86
83 17
83 86
1
54 42
41 32
83 57
83 28
19
54 61
54 32
83 61
83 32
1
41 153
-6 153
112 92
6 83
45
67 153
6 153
67 92
6 92
1
78 92
98 10
40 -17
122 112
38
40 92
122 10
40 10
122 92
1
97 85
108 10
24 91
29 10
9
99 85
99 10
24 85
24 10
1
3 0
5 0
4 9
5 9
4
0 0
9 0
0 9
9 9
1
-5 -1
-4 -6
-11 -6
-4 -1
3
-8 -1
-3 -6
-8 -6
-3 -1
1
-5 -2
-3 -5
-1 -1
-4 -4
2
-4 -2
-1 -5
-1 -2
-4 -5
1
35 23
49 28
28 28
23 23
11
38 23
38 28
33 28
33 23
1
0 3
0 14
10 3
10 8
3
0 1
0 11
10 1
10 11
1
7434523 11523154
7611807 5876512
3910524 11523154
3373024 5876512
1061322
8495844 11523154
8495844 5876512
2849202 11523154
2849202 5876512
1
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
1
-100000000 -100000000
100000000 -100000000
-100000000 100000000
100000000 99999999
1
-100000000 -100000001
100000000 -100000001
-100000000 99999999
100000000 99999999
import sys
sys.stderr = sys.stdout


def flip(b):
    return (b[1], b[0], b[2])


def reaction1(B, V):
    Bv = sorted(B[i] for i in range(4) if V[i])
    Bh = sorted(flip(B[i]) for i in range(4) if not V[i])

    if len(Bv) == 0:
        if not (Bh[0][0] == Bh[1][0]
                and Bh[1][0] != Bh[2][0]
                and Bh[2][0] == Bh[3][0]):
            return None, None
        d = Bh[2][0] - Bh[1][0]
        X = [Bh[0][1], Bh[1][1] - d, Bh[2][1], Bh[3][1] - d]
        X.sort()
        x0 = (X[0] + X[3]) // 2
        l = X[3] - x0
        S = [None] * 4
        for j, (y, x, i) in enumerate(Bh):
            x = x0 + (d if j % 2 else 0)
            S[i] = (x, y)
        return l, S
    elif len(Bv) == 1:
        if Bh[0][0] == Bh[1][0] and Bh[1][0] != Bh[2][0]:
            d = Bh[2][0] - Bh[0][0]
            x0 = Bv[0][0]
            x1 = Bh[0][1]
            x2 = Bh[1][1]
            x3 = Bh[2][1]
            S = [None] * 4
            S[Bv[0][2]] = Bv[0][0], Bh[2][0]
            l1 = max(abs(x0 - x1), abs(x0 + d - x2), abs(x0 + d - x3))
            l2 = max(abs(x0 - d - x1), abs(x0 - x2), abs(x0 - d - x3))
            if l1 <= l2:
                l = l1
                S[Bh[0][2]] = x0, Bh[0][0]
                S[Bh[1][2]] = x0 + d, Bh[1][0]
                S[Bh[2][2]] = x0 + d, Bh[2][0]
            else:
                l = l2
                S[Bh[0][2]] = x0 - d, Bh[0][0]
                S[Bh[1][2]] = x0, Bh[1][0]
                S[Bh[2][2]] = x0 - d, Bh[2][0]
            return l, S
        elif Bh[0][0] != Bh[1][0] and Bh[1][0] == Bh[2][0]:
            d = Bh[2][0] - Bh[0][0]
            x0 = Bv[0][0]
            x1 = Bh[0][1]
            x2 = Bh[1][1]
            x3 = Bh[2][1]
            S = [None] * 4
            S[Bv[0][2]] = Bv[0][0], Bh[0][0]
            l1 = max(abs(x0 + d - x1), abs(x0 - x2), abs(x0 + d - x3))
            l2 = max(abs(x0 - d - x1), abs(x0 - d - x2), abs(x0 - x3))
            if l1 <= l2:
                l = l1
                S[Bh[0][2]] = x0 + d, Bh[0][0]
                S[Bh[1][2]] = x0, Bh[1][0]
                S[Bh[2][2]] = x0 + d, Bh[2][0]
            else:
                l = l2
                S[Bh[0][2]] = x0 - d, Bh[0][0]
                S[Bh[1][2]] = x0 - d, Bh[1][0]
                S[Bh[2][2]] = x0, Bh[2][0]
            return l, S
        else:
            return None, None
    elif len(Bv) == 2:
        if Bv[0][0] != Bv[1][0] and Bh[0][0] != Bh[1][0]:
            x0 = Bv[0][0]
            x1 = Bv[1][0]
            y0 = Bh[0][0]
            y1 = Bh[1][0]
            if x1 - x0 != y1 - y0:
                return None, None
            l1 = max(abs(Bh[0][1] - x0), abs(Bv[0][1] - y1),
                     abs(Bh[1][1] - x1), abs(Bv[1][1] - y0))
            l2 = max(abs(Bh[0][1] - x1), abs(Bv[0][1] - y0),
                     abs(Bh[1][1] - x0), abs(Bv[1][1] - y1))
            S = [None] * 4
            if l1 <= l2:
                l = l1
                S[Bh[0][2]] = x0, y0
                S[Bh[1][2]] = x1, y1
                S[Bv[0][2]] = x0, y1
                S[Bv[1][2]] = x1, y0
            else:
                l = l2
                S[Bh[0][2]] = x1, y0
                S[Bh[1][2]] = x0, y1
                S[Bv[0][2]] = x0, y0
                S[Bv[1][2]] = x1, y1
            return l, S
        elif Bv[0][0] != Bv[1][0]:
            x0 = Bv[0][0]
            x1 = Bv[1][0]
            y0 = Bh[0][0]
            d = x1 - x0
            lh = max(abs(Bh[0][1] - x0), abs(Bh[1][1] - x1))
            l1 = max(lh, abs(y0 - d - Bv[0][0]), abs(y0 - d - Bv[1][0]))
            l2 = max(lh, abs(y0 + d - Bv[0][0]), abs(y0 + d - Bv[1][0]))
            S = [None] * 4
            if l1 <= l2:
                l = l1
                S[Bh[0][2]] = x0, y0
                S[Bh[1][2]] = x1, y0
                S[Bv[0][2]] = x0, y0 - d
                S[Bv[1][2]] = x1, y0 - d
            else:
                l = l2
                S[Bh[0][2]] = x0, y0
                S[Bh[1][2]] = x1, y0
                S[Bv[0][2]] = x0, y0 + d
                S[Bv[1][2]] = x1, y0 + d
            return l, S
        elif Bh[0][0] != Bh[1][0]:
            y0 = Bh[0][0]
            y1 = Bh[1][0]
            x0 = Bv[0][0]
            d = y1 - y0
            lh = max(abs(Bv[0][1] - y0), abs(Bv[1][1] - y1))
            l1 = max(lh, abs(x0 - d - Bh[0][0]), abs(x0 - d - Bh[1][0]))
            l2 = max(lh, abs(x0 + d - Bh[0][0]), abs(x0 + d - Bh[1][0]))
            S = [None] * 4
            if l1 <= l2:
                l = l1
                S[Bv[0][2]] = x0, y0
                S[Bv[1][2]] = x0, y1
                S[Bh[0][2]] = x0 - d, y0
                S[Bh[1][2]] = x0 - d, y1
            else:
                l = l2
                S[Bv[0][2]] = x0, y0
                S[Bv[1][2]] = x0, y1
                S[Bh[0][2]] = x0 + d, y0
                S[Bh[1][2]] = x0 + d, y1
            return l, S
        else:
            return None, None
    elif len(Bv) == 3:
        if Bv[0][0] == Bv[1][0] and Bv[1][0] != Bv[2][0]:
            d = Bv[2][0] - Bv[0][0]
            y0 = Bh[0][0]
            y1 = Bv[0][1]
            y2 = Bv[1][1]
            y3 = Bv[2][1]
            S = [None] * 4
            S[Bh[0][2]] = Bv[2][0], Bh[0][0]
            l1 = max(abs(y0 - y1), abs(y0 + d - y2), abs(y0 + d - y3))
            l2 = max(abs(y0 - d - y1), abs(y0 - y2), abs(y0 - d - y3))
            if l1 <= l2:
                l = l1
                S[Bv[0][2]] = Bv[0][0], y0
                S[Bv[1][2]] = Bv[1][0], y0 + d
                S[Bv[2][2]] = Bv[2][0], y0 + d
            else:
                l = l2
                S[Bv[0][2]] = Bv[0][0], y0 - d
                S[Bv[1][2]] = Bv[1][0], y0
                S[Bv[2][2]] = Bv[2][0], y0 - d
            return l, S
        elif Bv[0][0] != Bv[1][0] and Bv[1][0] == Bv[2][0]:
            d = Bv[2][0] - Bv[0][0]
            y0 = Bh[0][0]
            y1 = Bv[0][1]
            y2 = Bv[1][1]
            y3 = Bv[2][1]
            S = [None] * 4
            S[Bh[0][2]] = Bv[2][0], Bh[0][0]
            l1 = max(abs(y0 + d - y1), abs(y0 - y2), abs(y0 + d - y3))
            l2 = max(abs(y0 - d - y1), abs(y0 - d - y2), abs(y0 - y3))
            if l1 <= l2:
                l = l1
                S[Bv[0][2]] = Bv[0][0], y0 + d
                S[Bv[1][2]] = Bv[1][0], y0
                S[Bv[2][2]] = Bv[2][0], y0 + d
            else:
                l = l2
                S[Bv[0][2]] = Bv[0][0], y0 - d
                S[Bv[1][2]] = Bv[1][0], y0 - d
                S[Bv[2][2]] = Bv[2][0], y0
            return l, S
        else:
            return None, None
    elif len(Bv) == 4:
        if not (Bv[0][0] == Bv[1][0]
                and Bv[1][0] != Bv[2][0]
                and Bv[2][0] == Bv[3][0]):
            return None, None
        d = Bv[2][0] - Bv[1][0]
        Y = [Bv[0][1], Bv[1][1] - d, Bv[2][1], Bv[3][1] - d]
        Y.sort()
        y0 = (Y[0] + Y[3]) // 2
        l = Y[3] - y0
        S = [None] * 4
        for j, (x, y, i) in enumerate(Bv):
            y = y0 + (d if j % 2 else 0)
            S[i] = (x, y)
        return l, S


def reaction(B):
    l = None
    S = None
    for v0 in (True, False):
        for v1 in (True, False):
            for v2 in (True, False):
                for v3 in (True, False):
                    l1, S1 = reaction1(B, (v0, v1, v2, v3))
                    if l1 is not None and (l is None or l1 < l):
                        l = l1
                        S = S1
    return l, S


def readb(i):
    x, y = readinti()
    return (x, y, i)

def main():
    t = readint()
    L = []
    for _ in range(t):
        B = [readb(i) for i in range(4)]
        l, S = reaction(B)
        if l is None:
            L.append('-1')
        else:
            L.append(str(l))
            L.extend(f'{b1} {b2}' for b1, b2 in S)
    print('\n'.join(L))

##########

def readint():
    return int(input())


def readinti():
   return map(int, input().split())


def readintt():
   return tuple(readinti())


def readintl():
   return list(readinti())


def readinttl(k):
    return [readintt() for _ in range(k)]


def readintll(k):
    return [readintl() for _ in range(k)]


def log(*args, **kwargs):
    print(*args, **kwargs, file=sys.__stderr__)


if __name__ == '__main__':
    main()
