
from yogi import *


for n in tokens(int):
    b = read(int)
    print(n, b, 1 if three_equal_consecutive_digits(n, b) else 0)
