
uppers = [(1,0,0), (0,1,0), (1,1,0), (1,0,1), (1,1,1)]
inners = { "0" : (1,1,0), "1" : (1,1,1)} 

def next(n, m):
    if m == 4:
        return (n + 1, m)
    else:
        return (n, m + 1)

def test(n, m):
    layers = list(map(lambda x : inners[x], bin(n)[2:])) + [uppers[m]]
    print (len(layers))
    for a, b, c in layers:
        print (a, b, c)

n, m = map(int, open('test.in').read().split())
n2, m2 = next(n, m)
test(n, m)
open('test.in', 'w').write(str(n2) + " " + str(m2))
