def solve(line):
sqs = map(lambda x: float(x) ** 2, line.strip().split())
print '%.4f' % ((1/144.0) * (sqs[0]*sqs[4]*(sqs[1]+sqs[2]+sqs[3]+sqs[5]-sqs[0]-sqs[4]) + sqs[1]*sqs[5]*(sqs[0]+sqs[2]+sqs[3]+sqs[4]-sqs[1]-sqs[5]) + sqs[2]*sqs[3]*(sqs[0]+sqs[1]+sqs[4]+sqs[5]-sqs[2]-sqs[3]) - sqs[0]*sqs[1]*sqs[3] - sqs[1]*sqs[2]*sqs[4] - sqs[0]*sqs[2]*sqs[5] - sqs[3]*sqs[4]*sqs[5]))**0.5
def main():
from sys import stdin
stdin.next()
[solve(x) for x in stdin]
main()
It's 'print' line that raises the exception, and it isn't neither ValueError nor IndexError. I tested the code at ideone.com with different test-cases, it works fine. What can be the problem.