#include <iostream>
#include <string>
using namespace std;
//字串重复出现次数
int count(string& s,string& t){
int m=s.size(),n=t.size();
int res=0;
for(int i=0;i<m;i++){
int u=i,v=0;
while(u<m&&v<n){
if(s[u]!=t[v]) break;
u++;
v++;
}
if(v==n) res++;
}
return res;
}
bool isValid(string& s){
int n=s.size();
if(n<8) return false;//长度小于8,NG
int f1=0,f2=0,f3=0,f4=0;
for(char c:s){
if(c>='A'&&c<='Z') f1=1;
else if(c>='a'&&c<='z') f2=1;
else if(c>='0'&&c<='9') f3=1;
else f4=1;
}
if(f1+f2+f3+f4<3) return false; //字符包含3种以下 NG
for(int i=0;i<n-3;i++){
string tmp=s.substr(i,3);
if(count(s,tmp)>=2) return false;//字串重复出现 NG
}
return true;//OK
}
int main()
{
string s;
while(getline(cin,s)){
bool res=isValid(s);
if(res) cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}
}