@contextmanager
def control_stdin(input=None):
 org = sys.stdin
 sys.stdin = StringIO(input)
 if six.PY2:
  sys.stdin.encoding = 'utf-8'
 try:
  (yield sys.stdin)
 finally:
  sys.stdin = org

@ contextmanager def control_stdin ( input = None ) : org = sys . stdin sys . stdin = StringIO ( input ) if six . PY2 : sys . stdin . encoding = 'utf-8' try : ( yield sys . stdin ) finally : sys . stdin = org
sends input to stdin .