# №21 Кулабухова
def f(s1,s2,c,m):
    if s1 ==0 or  s2 == 0: return c%2 == m%2

    h =[]
    if s1>=3 and s2 >= 3: h.append(f(s1-3,s2-3,c+1,m))
    if s1%2==0: h.append(f(s1//2, s1//2, c + 1, m))
    if s2%2==0: h.append(f(s2//2, s2//2, c + 1, m))
    if len(h)==0: return c%2 == m%2
    if c == m: return 0

    return any(h) if (c+1)%2==m%2 else all(h)
for s2 in range (1,50):
    for m in range(1,5):
        if f(20,s2,0,m):
            if m==2 or m==4:
                print(s2,m)
            #break
#ответ 17