#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    string str;

    while(cin >> str)
    {
        if(str.size() < 9)
        {
            cout << "NG" << endl;
            continue;
        }
        unsigned flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0;
        bool flag = false;
        for(auto const &c: str)
        {
            if(c >= 'a' && c <= 'z') flag1 = 1;
            else if(c >= 'A' && c <= 'Z') flag2 = 1;
            else if(c >= '0' && c <= '9') flag3 = 1;
            else flag4 = 1;
            if(flag1 + flag2 + flag3 + flag4 > 2)
            {
                flag = true;
                break;
            }
        }
        if(!flag)
        {
            cout << "NG" << endl;
            continue;
        }
        flag = false;
        string subs;
        for(auto it = str.begin(); it < str.end() - 6; ++it)
        {
            subs = str.substr(it - str.begin(), 3);
            auto pos = str.find(subs, it - str.begin() + 3);
            if(pos != string :: npos)
            {
                flag = true;
                continue;
            }
        }
        if(flag) cout << "NG" << endl;
        else cout << "OK" << endl;
    }

    return 0;
}