# Echo server program
import socket

HOST = 'localhost'         # Symbolic name meaning all available interfaces
PORT = 50008              # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print('Connected by', addr)
mynumbers = [3, 4, 1, 1]
while 1:
    data = conn.recv(1024)
    if not data: break
    numbers = data.split(" ")
    exactposcount = 0
    correctnumbercount = 0
    i = 0
    while i < len(numbers):
	# print "Numbers: ", int(numbers[i])
	# print "Mynumbers: ", mynumbers[i]
	if int(numbers[i]) == mynumbers[i]:
		exactposcount += 1
	elif int(numbers[i]) in mynumbers:
		correctnumbercount += 1
	i+= 1
    conn.send("%d %d" % (exactposcount,correctnumbercount))
conn.close()

