K = int(eval(input()))

A, B = list(map(int, input().split()))



while True:

    if A % K == 0:

        print('OK')

        break

    A += 1

    if A == B + 1:

        print('NG')

        break

K = int(eval(input()))

A, B = list(map(int, input().split()))



while True:

    if A == B + 1:

        print('NG')

        break

    if A % K == 0:

        print('OK')

        break

    A += 1

K = int(eval(input()))
A, B = list(map(int, input().split()))
while True:
    if A % K == 0:
        print("OK")
        break
    A += 1
    if A == B + 1:
        print("NG")
        break

K = int(eval(input()))
A, B = list(map(int, input().split()))
while True:
    if A == B + 1:
        print("NG")
        break
    if A % K == 0:
        print("OK")
        break
    A += 1

+    if A == B + 1: +        print("NG") +        break -    if A == B + 1: -        print("NG") -        break