n, k = list(map(int, input().split()))

ans = 0 if n % k == 0 else 1

print(ans)
n, k = list(map(int, input().split()))

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

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

-ans = 0 if n % k == 0 else 1 -print(ans) +print((0 if n % k == 0 else 1))