K = int(eval(input()))

l, h = list(map(int, input().split(' ')))



for n in range(l, h + 1):

    if n % K == 0:

        print('OK')

        break

else:

    print('NG')

K = int(eval(input()))

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



if B // K * K >= A:

    print('OK')

else:

    print('NG')

K = int(eval(input()))
l, h = list(map(int, input().split(" ")))
for n in range(l, h + 1):
    if n % K == 0:
        print("OK")
        break
else:
    print("NG")

K = int(eval(input()))
A, B = list(map(int, input().split(" ")))
if B // K * K >= A:
    print("OK")
else:
    print("NG")

-l, h = list(map(int, input().split(" "))) -for n in range(l, h + 1): -    if n % K == 0: -        print("OK") -        break +A, B = list(map(int, input().split(" "))) +if B // K * K >= A: +    print("OK")