#include<stdio.h>
int main(){
	int k,a,b,i,max,j,flag=0;
	scanf("%d",&k);
	int p[100];
	p[1]=1;
	for (i=2;i<=10;i++)
	{p[i]=p[i-1]*k;
	 if (p[i]>1000) {
	 max=i;break;}
	}
	scanf("%d",&a,&b);
	for (i=a;i<=b;i++)
	{for (j=1;j<=max;j++) if (i==p[j])
	    flag=1;
	}
	if (flag==1){printf("OK");
	}else printf("NG");
}