def testWithIO(inp, out, f):
 try:
  (oldin, sys.stdin) = (sys.stdin, inp)
  (oldout, sys.stdout) = (sys.stdout, out)
  x = f()
 finally:
  sys.stdin = oldin
  sys.stdout = oldout
 return x

def testWithIO ( inp , out , f ) : try : ( oldin , sys . stdin ) = ( sys . stdin , inp ) ( oldout , sys . stdout ) = ( sys . stdout , out ) x = f ( ) finally : sys . stdin = oldin sys . stdout = oldout return x
calls the function f with sys .