from pwn import *
import re
import time
def main():
r = remote("pwnable.kr", 9007)
res = r.recvuntil("Ready") + r.recvuntil("\x0a")
print res
time.sleep(3)
for i in range(100):
res = r.recvuntil("=") + r.recvuntil("\x0a")
info = res.split(" ")
p = re.compile("\d+")
for i in range(0,2):
info[i] = p.findall(info[i])
N = int("".join(info[0]))
C = int("".join(info[1]))
print "N : {0}, C : {1}\n".format(N, C)
src = 0
des = N
chance_check = 0
while src <= des:
chance_check += 1
dat = ""
mid = (src + des) / 2
for i in range(src, mid + 1):
dat += str(i) + " "
r.sendline(dat)
weight = r.recv()
if int(weight) == 9:
break
if int(weight) % 10 == 0:
src = mid + 1
elif int(weight) % 10 == 9:
des = mid - 1
for i in range(C - chance_check + 1):
if int(weight) % 10 == 0 and i == 0:
dat = str(int(dat)+1)
r.sendline(dat)
res = r.recv()
print res
res = r.recv()
print res
if __name__ == "__main__":
main()