import bisect import copy import decimal import fractions import heapq import itertools import math import random import sys import time from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines write=sys.stdout.write ans="OK" A=readline().rstrip() B=readline().rstrip() num=[str(i) for i in range(10)] for a in A: if not a in num: ans="NG" for b in B: if not b in num: ans="NG" if len(A)>=2 and A[0]=="0": ans="NG" if len(B)>=2 and B[0]=="0": ans="NG" if ans=="OK": if not 0<=int(A)<=12345 or not 0<=int(B)<=12345: ans="NG" print(ans)