snacks_num, persons = list(map(int, input().split()))



if snacks_num % persons == 0:

    print((0))

else:

    print((1))
m, k = list(map(int, input().split()))



print((0 if m % k == 0 else 1))

snacks_num, persons = list(map(int, input().split()))
if snacks_num % persons == 0:
    print((0))
else:
    print((1))

m, k = list(map(int, input().split()))
print((0 if m % k == 0 else 1))

-snacks_num, persons = list(map(int, input().split())) -if snacks_num % persons == 0: -    print((0)) -else: -    print((1)) +m, k = list(map(int, input().split())) +print((0 if m % k == 0 else 1))