Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def CurrentPos(ls,h=0,w=0):    
    if ls[h][w] == '>':
        w +=1
    elif ls[h][w] =='<':
        w -=1
    elif ls[h][w] =='^':
        h -=1
    elif ls[h][w] =='v':
        h +=1
    return [h,w]

def HasPosReached(pos_list,h,w):
    for k,j in pos_list:    
        if (h,w) == (k,j):
            return True
            break

while True:
    H,W =  map(int, raw_input().split())
    if [H,W] == [0,0]:
        break
    ls = []
    for h in range(H):
        ls.append(raw_input())
    
    pos_list=[]
    h =0; w=0
    while True:
        [h,w] = CurrentPos(ls,h,w)
        pos_list.append((h,w))
        if HasPosReached(h,w):
            print "LOOP"
            break
    else:
        print " ".join(map(str,[h,w]))

Fixed submission:
while True:
    H,W = map(int,raw_input().split())
    if (H,W) == (0,0): break
    array = [raw_input() for i in range(H)]
    saw = [[False for i in range(W)] for j in range(H)]
    X = 0
    Y = 0
    while True:
        if array[X][Y] == ">":
            Y += 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "<":
            Y -= 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "^":
            X -= 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] == "v":
            X += 1
            if saw[X][Y]:
                print 'LOOP'
                break
            saw[X][Y] = True
        elif array[X][Y] ==".":
            print Y,X
            break
Buggy python submission (verdict: Runtime Error):
def hantei(A,B,C,R=0):
    h,t = sorted([A,B,C])[:2]
    if h**2 + t**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))
    
    a,b,c = map(int,raw_input().split())
    if (a,b,c) == (0,0,0):
        break

Fixed submission:
def hantei(A,B,C,R=0):
    p,q = sorted([A,B,C])[:2]
    if p**2 + q**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
        if (A,B,C) == (0,0,0):
            break
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))

Buggy python submission (verdict: Runtime Error):
def hantei(A,B,C,R=0):
    h,t = sorted([A,B,C])[:2]
    if h**2 + t**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))
    
    a,b,c = map(int,raw_input().split())
    if (a,b,c) == (0,0,0):
        break

Fixed submission:
def hantei(A,B,C,R=0):
    p,q = sorted([A,B,C])[:2]
    if p**2 + q**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
        if (A,B,C) == (0,0,0):
            break
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))
Buggy python submission (verdict: Runtime Error):
def hantei(l):
    if l >= 1.1:
        return 'A'
    elif 0.6 <= l < 1.1:
        return 'B'
    elif 0.2 <= l < 0.6:
        return 'C'
    elif 0.2 < l:
        return 'D'

ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
    try:
        l,r = map(float,raw_input().split())
        ls.append((l,r))
    except EOFError:
        break
for l,r in ls:
    ldic[hantei(l)] += 1
    rdic[hantei(r)] += 1
    
for L,R in zip(sorted(ldic),sorted(rdic)):
    print L,R 

Fixed submission:
def hantei(l):
    if l >= 1.1:
        return 'A'
    elif 0.6 <= l < 1.1:
        return 'B'
    elif 0.2 <= l < 0.6:
        return 'C'
    elif l  < 0.2 :
        return 'D'

ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
    try:
        l,r = map(float,raw_input().split())
        ls.append((l,r))
    except EOFError:
        break
        
for i,j in ls:
    ldic[hantei(i)] += 1
    rdic[hantei(j)] += 1
    
for L,R in zip(sorted(ldic),sorted(rdic)):
    print ldic[L],rdic[R]

Buggy python submission (verdict: Runtime Error):
def hantei(l):
    if l >= 1.1:
        return 'A'
    elif 0.6 <= l < 1.1:
        return 'B'
    elif 0.2 <= l < 0.6:
        return 'C'
    elif 0.2 < l:
        return 'D'

ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
    try:
        l,r = map(float,raw_input().split())
        ls.append((l,r))
    except EOFError:
        break
        
for i,j in ls:
    ldic[hantei(i)] += 1
    rdic[hantei(j)] += 1
    
for L,R in zip(sorted(ldic),sorted(rdic)):
    print L,R 

Fixed submission:
def hantei(l):
    if l >= 1.1:
        return 'A'
    elif 0.6 <= l < 1.1:
        return 'B'
    elif 0.2 <= l < 0.6:
        return 'C'
    elif l  < 0.2 :
        return 'D'

ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
    try:
        l,r = map(float,raw_input().split())
        ls.append((l,r))
    except EOFError:
        break
        
for i,j in ls:
    ldic[hantei(i)] += 1
    rdic[hantei(j)] += 1
    
for L,R in zip(sorted(ldic),sorted(rdic)):
    print ldic[L],rdic[R]
Buggy python submission (verdict: Time Limit Exceeded):
def prime_table(n):
    list = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
        while j <= n:
            list[j] = False
            j += i
        i += 1

    table = [i for i in xrange(n + 1) if list[i] and i >= 2]
    return table

table = prime_table(10000)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = [i for i in xrange(1,n+1)]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j in table and k in table:
            ans += 1
    print ans

Fixed submission:
def prime_table_boolean(n):
    list1 = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list1[i]:
            j = i + i
        while j <= n:
            list1[j] = False
            j += i
        i += 1
    list1[1] = False
    del list1[0]

    #table = [i for i in xrange(n + 1) if list1[i] and i >= 2]
    #return table
    return list1

table = prime_table_boolean(10001)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = table[:n]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j and k:
            ans += 1
    print ans

Buggy python submission (verdict: Time Limit Exceeded):
def prime_table(n):
    list = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
        while j <= n:
            list[j] = False
            j += i
        i += 1

    table = [i for i in xrange(n + 1) if list[i] and i >= 2]
    return table

table = prime_table(10000)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = (i for i in xrange(1,n+1))
    r = (i for i in xrange(n,0,-1))
    ans = 0
    for j,k in zip(l,r):
        if j in table and k in table:
            ans += 1
    print ans

Fixed submission:
def prime_table_boolean(n):
    list1 = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list1[i]:
            j = i + i
        while j <= n:
            list1[j] = False
            j += i
        i += 1
    list1[1] = False
    del list1[0]

    #table = [i for i in xrange(n + 1) if list1[i] and i >= 2]
    #return table
    return list1

table = prime_table_boolean(10001)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = table[:n]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j and k:
            ans += 1
    print ans
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break    
    
    ls = []
    for i in range(n):
        ls.append(int(raw_input()))
    
    maxvalue = -999999999999999999999999999999
    for k in range(len(ls)):
        for j in range(1,k+1):
            if ls[k]-ls[k-j] > maxvalue:
                maxvalue = ls[k]-ls[k-j]
    print maxvalue

Fixed submission:
n = int(raw_input())
R = []
R.append(int(raw_input()))
minv = R[0]
maxv = -1 * 10**9
for j in xrange(1,n):
    R.append(int(raw_input()))
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print maxv

Buggy python submission (verdict: Runtime Error):
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break    
    
    ls = []
    for i in range(n):
        ls.append(int(raw_input()))
    
    maxvalue = -999999999999999999999999999999
    for k in range(len(ls)):
        temp = ls[k] - min(ls[:k])
        if  temp > maxvalue:
            maxvalue = temp
    print maxvalue

Fixed submission:
n = int(raw_input())
R = []
R.append(int(raw_input()))
minv = R[0]
maxv = -1 * 10**9
for j in xrange(1,n):
    R.append(int(raw_input()))
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print maxv

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break    
    
    ls = []
    for i in range(n):
        ls.append(int(raw_input()))
    
    maxvalue = -999999999999999999999999999999
    for k in range(len(ls)):
        if k == 0:
            continue
        else:
            temp = ls[k] - min(ls[:k])
        if  temp > maxvalue:
            maxvalue = temp
    print maxvalue

Fixed submission:
n = int(raw_input())
R = []
R.append(int(raw_input()))
minv = R[0]
maxv = -1 * 10**9
for j in xrange(1,n):
    R.append(int(raw_input()))
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print maxv

Buggy python submission (verdict: Time Limit Exceeded):
# for loop
n = int(raw_input())
ls = []
for i in range(n):
    ls.append(int(raw_input()))

ans = None
for k in range(n):
    for j in range(k+1,n):
        dif = ls[j]-ls[k]
        if ans is None:
            ans = dif
        elif ans < dif:
            ans = dif
print ans

Fixed submission:
n = int(raw_input())
R = []
R.append(int(raw_input()))
minv = R[0]
maxv = -1 * 10**9
for j in xrange(1,n):
    R.append(int(raw_input()))
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print maxv
Buggy python submission (verdict: Runtime Error):
from collections import deque
n=int(raw_input())
que = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':
        del que[0]
    elif o == 'deleteLast':
        del que[-1]
    else:
        c,p = o.split()
        p = int(p)
        if c == 'insert':
            que.appendleft(p)
        elif c == 'delete':
            que.remove(p)
print ' '.join(map(str,que))

Fixed submission:
from collections import deque
n=int(raw_input())
q = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass
print ' '.join(map(str,q))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from collections import deque
n=int(raw_input())
que = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':
        del que[0]
    elif o == 'deleteLast':
        del que[-1]
    else:
        c,p = o.split()
        p = int(p)
        if c == 'insert':
            que.appendleft(p)
        elif c == 'delete':
            que.remove(p)
print ' '.join(map(str,que))

Fixed submission:
from collections import deque
n=int(raw_input())
q = deque()
for i in xrange(n):
    o = raw_input()
    if o == 'deleteFirst':  q.popleft()
    elif o == 'deleteLast': q.pop()
    else:
        c,p = o.split(); p = int(p)
        if c == 'insert': q.appendleft(p)
        elif c == 'delete':
            try: q.remove(p)
            except: pass
print ' '.join(map(str,q))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
def maxHeapify(A, i):
    l = A[2*(i+1)-1]
    r = A[2*(i+1)]
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:???# i ???????????????????????§????????´???
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(A, largest) # ?????°??????????????????
        
def buildMaxHeap(A):
    for i in range(H/2,0,-1):
        maxHeapify(A,i)

H = int(raw_input())
A = map(int, raw_input().split())
buildMaxHeap(A)
print A

Fixed submission:
# coding: utf-8
def maxHeapify(A, i):
    l = 2*i
    r = 2*i+1
    
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
        
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(A, largest)
        
def buildMaxHeap(A):
    for i in range(H/2,0,-1):
        maxHeapify(A,i)

H = int(raw_input())
A = map(int, [0]+raw_input().split())
buildMaxHeap(A)
print " " + " ".join(map(str,A[1:]))
Buggy python submission (verdict: Time Limit Exceeded):
class Dice:
    def __init__(self,ls):
        self.a = ls[1-1] # top
        self.b = ls[2-1] # front
        self.c = ls[3-1] # right
        self.d = ls[4-1] # left
        self.e = ls[5-1] # back
        self.f = ls[6-1] # bottom
    
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a

import random
ls = map(int,raw_input().split())
q = int(raw_input())
for i in range(q):
    dice = Dice(ls)
    a,b = map(int,raw_input().split())
    while dice.a != a or dice.b != b:
        random.choice([dice.E(), dice.W(), dice.S(), dice.N()])

    print dice.c

Fixed submission:
class Dice:
    
    def __init__(self,ls):
        self.a = ls[1-1] # top
        self.b = ls[2-1] # front
        self.c = ls[3-1] # right
        self.d = ls[4-1] # left
        self.e = ls[5-1] # back
        self.f = ls[6-1] # bottom
    
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a   
                        
import random
ls = map(int,raw_input().split())
q = int(raw_input())
for i in range(q):
    dice = Dice(ls)
    a,b = map(int,raw_input().split())
    while dice.a != a or dice.b != b:
        i = random.choice([1,2,3,4])
        if i == 1: dice.E()
        elif i == 2: dice.W()
        elif i == 3 : dice.S()
        elif i == 4 : dice.N()
    print dice.c
Buggy python submission (verdict: Runtime Error):
import sys
num = sys.stdin.readline()
ans = num*num*num
print ans

Fixed submission:
num=raw_input()
num = int(num)
ans = num*num*num
print ans
Buggy python submission (verdict: Runtime Error):
W,H,x,y,r = raw_input()
W,H,x,y,r = map(int,(W,H,x,y,r))
def isXok(W,H,x,y,r):
    if x-r<0 or x+r>W:
        return False
    else:
        return True
def isYok(W,H,x,y,r):
    if y-r<0 or y+r>H:
        return False
    else:
        return True
if isXok(W,H,x,y,r) and isXok(W,H,x,y,r):
    print True
else:
    print False

Fixed submission:
W,H,x,y,r = raw_input().split()
W,H,x,y,r = map(int,(W,H,x,y,r))
def isXok(W,H,x,y,r):
    if x-r<0 or x+r>W:
        return False
    else:
        return True
def isYok(W,H,x,y,r):
    if y-r<0 or y+r>H:
        return False
    else:
        return True
if isXok(W,H,x,y,r) and isYok(W,H,x,y,r):
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
i = 0
while True:
    x = raw_input()
    if x == 0:
        break
    i += 1
    print "Case %d: %d" % (i, x)

Fixed submission:
i = 0
while True:
    x = int(raw_input())
    if x == 0:
        break
    i += 1
    print "Case %d: %d" % (i, x)

Buggy python submission (verdict: Runtime Error):
i = 0
while True:
    x = int(raw_input())
    if x == 0:
        break
    i += 1
    i=str(i)
    x=str(x)
    print "Case %d: %d" % (i, x)

Fixed submission:
i = 0
while True:
    x = int(raw_input())
    if x == 0:
        break
    i += 1
    print "Case %d: %d" % (i, x)
Buggy python submission (verdict: Runtime Error):
i = 0
while True:
    x,y = raw_input()
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x
    i += 1
    #print "Case %d: %d" % (i, x)

Fixed submission:

while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y

Buggy python submission (verdict: Runtime Error):

while True:
    x,y = raw_input()
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x

Fixed submission:

while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y

Buggy python submission (verdict: Runtime Error):

while True:
    x,y = raw_input()
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x

Fixed submission:

while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y

Buggy python submission (verdict: Runtime Error):
while True:
    x,y = raw_input()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x

Fixed submission:

while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y

Buggy python submission (verdict: Runtime Error):

while True:
    x,y = raw_input().split()
    #x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print x + " " + y
    else:
        x,y = map(str,(x,y))
        print y + " " + x

Fixed submission:

while True:
    x,y = raw_input().split()
    x,y = map(int,(x,y))
    if x == 0 and y == 0:
        break
    if x > y:
        x,y = map(str,(x,y))
        print y + " " + x
    else:
        x,y = map(str,(x,y))
        print x + " " + y
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(raw_input())
    try:
        ls = map(int,raw_input().split())
        mi = min(ls)
        ma = max(ls)
        su = sum(ls)
        print "%d %d %d" %(mi,ma,su)
        
    except EOFError:
        break        

Fixed submission:
n = int(raw_input())

ls = map(int,raw_input().split())
mi = min(ls)
ma = max(ls)
su = sum(ls)
print "%d %d %d" % (mi,ma,su)

Buggy python submission (verdict: Runtime Error):
while True:
    n = int(raw_input())
    ls = []
    try:
        ls = map(int,raw_input().split())
        mi = min(ls)
        ma = max(ls)
        su = sum(ls)
        print "%d %d %d" %(mi,ma,su)
        
    except EOFError:
        break        

Fixed submission:
n = int(raw_input())

ls = map(int,raw_input().split())
mi = min(ls)
ma = max(ls)
su = sum(ls)
print "%d %d %d" % (mi,ma,su)

Buggy python submission (verdict: Runtime Error):
    n = int(raw_input())
    ls = []
    try:
        ls = map(int,raw_input().split())
        mi = min(ls)
        ma = max(ls)
        su = sum(ls)
        print "%d %d %d" % (mi,ma,su)

Fixed submission:
n = int(raw_input())

ls = map(int,raw_input().split())
mi = min(ls)
ma = max(ls)
su = sum(ls)
print "%d %d %d" % (mi,ma,su)

Buggy python submission (verdict: Runtime Error):
        n = int(raw_input())

        ls = map(int,raw_input().split())
        mi = min(ls)
        ma = max(ls)
        su = sum(ls)
        print "%d %d %d" % (mi,ma,su)

Fixed submission:
n = int(raw_input())

ls = map(int,raw_input().split())
mi = min(ls)
ma = max(ls)
su = sum(ls)
print "%d %d %d" % (mi,ma,su)
Buggy python submission (verdict: Runtime Error):
while True:
    H,W = map(int,raw_input().split())
    if H,W == 0,0:
        break
    for k in range(H):
        print "#"*W
    print ""

Fixed submission:
while True:
    H,W = map(int,raw_input().split())
    if (H,W) == (0,0):
        break
    for k in range(H):
        print "#"*W
    print ""
Buggy python submission (verdict: Runtime Error):
try:
    s = []
    while True:
        t = raw_input()
        s.append(t)
except EOFError:
    for i in range(len(s)):
        a = int(s[i].split(' ')[0])
        b = int(s[i].split(' ')[1])
        print(len(str(a + b)))

Fixed submission:
try:
    s = []
    while True:
        t = input()
        s.append(t)
except EOFError:
    for i in range(len(s)):
        a = int(s[i].split(' ')[0])
        b = int(s[i].split(' ')[1])
        print(len(str(a + b)))
Buggy python submission (verdict: Runtime Error):
import sys
import math

if sys.version_info[0] >= 3:
    raw_input = input
N = int(raw_input())
for i in range(N):
    x1, y1, x2, y2, x3, y3 = [float(e) for e in raw_input().split()]
    a1 = 2*x2 - 2*x1
    b1 = 2*y2 - 2*y1
    c1 = x1**2 - x2**2 + y1**2 - y2**2
    a2 = 2 * x3 - 2 * y1
    b2 = 2 * y3 - 2 * y1
    c2 = x1**2 - x3**2 + y1**2 - y3**2
    x = (b1*c2-b2*c1)/(a1*b2-a2*b1)
    y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
    print("%.3f %.3f %.3f" %(x, y, math.hypot(x1-x, y1-y)))

Fixed submission:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
 
import sys
import math
 
n = int(input())
 
for data in sys.stdin:
    x1, y1, x2, y2, x3, y3 = map(float, data.split())
    a1 = x2 - x1
    b1 = y2 - y1
    a2 = x3 - x1
    b2 = y3 - y1
    px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
    py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
    r = math.sqrt(px * px + py * py)
    px += x1
    py += y1
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))