#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>

using namespace std;

string trueFlag = "OK";
string falseFlag = "NG";


/*
密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有长度大于2的不含公共元素的子串重复 (注:其他符号不含空格或换行)
思路:输入字符串必须大于8,字符的种类大于3,将字符串的子字符串隔离出来,进行统计,查看出现重复子串且查看字符类型种类个数
*/
string PasswaordAuth(string strIn)
{
    int SubstrCount = 0;
    int flag = 0;
    int strInLen = strIn.length();
    unordered_set<int> strTypeCount;
    string strTem;
    
    //要求1
    if(strInLen <= 8) {
        return falseFlag;
    }
    
    //要求2
    for(int i = 0; i < strInLen; i++)  {
        if(strIn[i] >= '0' && strIn[i] <= '9') {
            strTypeCount.insert(1);
        } else if(strIn[i] >= 'A' &&strIn[i] <= 'Z') {
            strTypeCount.insert(2);
        } else if(strIn[i] >= 'a' &&strIn[i] <= 'z') {
            strTypeCount.insert(3);
        } else {
            strTypeCount.insert(4);
        }
    }
    
    if(strTypeCount.size() < 3) {
        return falseFlag;
    }
    
    //  要求3
    for(int i = 0; i < strInLen - 3; i++) {
       for(int j = i+1; j < strInLen - 2; j++) {
           if(strIn.substr(i, 3) == strIn.substr(j, 3)) {
               flag = 1;
               break;
           }
       }
        if(flag == 1) {
            break;
        }
    }
    
   if(flag == 1) {
       return falseFlag;
   }
    
    return trueFlag;
}
int main()
{
    string strIn;
    while(cin>>strIn) {
        cout<<PasswaordAuth(strIn)<<endl;
    }
}