#include <cctype>
#include <iostream>
#include <vector>
#include <unordered_set>
#include <string>
using namespace std;

bool consist_str(string& str) {
    int n = str.size();
    for (int len = 3; len <= n / 2; len++) {
        for (int i = 0; i <= n - 2 * len; i++) {
            string sub1 = str.substr(i, len);
            for (int j = i + len; j <= n - len; j++) {
                if (str.substr(j, len) == sub1) {
                    return false;
                }
            }
        }
    }
    return true;
}

bool include_all(string& str) {
    vector<int> mark(4);
    for (char& c : str) {
        if (islower(c)) mark[0] = 1;
        else if (isupper(c)) mark[1] = 1;
        else if (isdigit(c)) mark[2] = 1;
        else
            mark[3] = 1;
    }
    int num = 0;
    for (int& m : mark) {
        num += m;
    }
    return num > 2;
}

int main() {
    string str;
    while (getline(cin, str)) {
        if (str.size() > 8 && include_all(str) && consist_str(str)) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }

    return 0;
}
// 64 位输出请用 printf("%lld")