#!/usr/bin/python
# -*- coding: utf8 -*-
import sys, socket

host, port = sys.argv[1:3]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, int(port)))
sf = s.makefile()

for line in sys.stdin:
    sf.write(line)
    sf.flush()
    print sf.readline(),

