#include <iostream>
using namespace std;
int main() {
string str {};
int hi,low,num,spe;
while (getline(cin ,str) ) {
hi=0;low=0;num=0;spe=0;
unsigned long int len=str.size();
for(int i=0;i<len;i++)
{
if(str[i]>47&&str[i]<58)num=1;
else if(str[i]>64&&str[i]<91)hi=1;
else if(str[i]>96&&str[i]<123)low=1;
else if(str[i]>32&&str[i]<127)spe=1;
}
bool isok=true;
if(len<8||hi+low+num+spe<3)
cout << "NG" <<endl;
else
{
for (int i = 0; isok&&i <= len - 6; i++)
{
for (int j = i + 3; j <= len - 3; j++)
{
if ((str[i] == str[j]) && (str[i + 1] == str[j + 1]) && (str[i + 2] == str[j + 2]))
{
isok=false;cout << "NG" <<endl;break;
}
}
}
if(isok)cout << "OK" <<endl;
}
str="";
}
}
// 64 位输出请用 printf("%lld")