from pwn import *

r = remote('pwnable.kr', 9007)
r.recvuntil('. -\n\t\n')

for i in range(100):
    a = re.search(r'N=(\d+) C=(\d+)', r.recvline())
    N = int(a.group(1))
    C = int(a.group(2))

    p = log.progress(str(i) + ' ' + a.group())

    low = 0
    high = N - 1
    for _ in range(C+1):
        mid = (low + high) // 2
        coin = ' '.join(map(str, range(low, mid+1)))
        p.status(coin)
        r.sendline(coin)

        try:
            weight = int(r.recvline())
        except ValueError:
            p.success(coin) # Correct!
            break

        if weight % 10:
            high = mid
        else:
            low = mid+1
r.interactive()
