#include <iostream>
#include <map>

using namespace std;

int main(){
    string str;
    while (cin>>str){
        map<string,int> sub;
        bool flag = 1;
        int ch[4] = {0};
        int n = str.size();
        if (n>8){
            for (int i = 0; i < n; ++i) {
                if (str[i]>='a'&&str[i]<='z') ch[0] = 1;
                else if (str[i]>='A'&&str[i]<='Z') ch[1] = 1;
                else if (str[i]>='0'&&str[i]<='9') ch[2] = 1;
                else ch[3] = 1;

                if (sub.find(str.substr(i,3)) != sub.end()){
                    // 不能有长度大于2的包含公共元素的子串重复
                    flag = false;
                } else{
                    sub[str.substr(i,3)] = 1;
                }
            }
            int count = 0;
            for (int j = 0; j < 4; ++j) {
                if (ch[j]) count++;
            }
            if (count<3){
                // 不同字符数不足
                flag = false;
            }
        }
        else{
            // 长度不足
            flag = false;
        }
        if (flag){
            cout<<"OK"<<endl;
        } else{
            cout<<"NG"<<endl;
        }
    }
    return 0;
}