N, K = list(map(int, input().split() ))

if N%K == 0:

  print((0))

else:

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



if n%k == 0:

    print("0")

else:

    print("1")
N, K = list(map(int, input().split()))
if N % K == 0:
    print((0))
else:
    print((1))

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

-N, K = list(map(int, input().split())) -if N % K == 0: -    print((0)) +n, k = list(map(int, input().split())) +if n % k == 0: +    print("0") -    print((1)) +    print("1")