#include <iostream>
#include <vector>
#include <ostream>
using namespace std;
bool isvalid (string s) {
    int n = s.size();
    if (n < 8 ) {
        return false;
    }
    bool A,a,num,other;
    A = a = num = other = false;
    int cnt = 0;
    for (auto c : s) {
        if (c >= '0' && c<='9') {
            if (num == false) {
                num = true;
                cnt ++;
            }
        } else if (c >= 'a' && c <= 'z') {
            if (a == false) {
                a = true;
                cnt ++;
            }
        } else if (c >= 'A' && c <= 'Z') {
            if (A == false) {
                A  = true;
                cnt ++;
            }
        } else {
            if (other == false) {
                other = true;
                cnt ++;
            }
        }
        if (cnt >= 3) {
            break;
        }
    }
    if (cnt < 3) {
        return false;
    }
    for (int i = 0 ; i < n-6; i++) {
        for(int begin = i + 3; begin < n-3; begin ++) {
            if (s[i] == s[begin] && s[i+1] == s[begin+1] && s[i+2] == s[begin + 2]) {
                return false;
            }
        }
    }
    return true;
}
int main() {
    string password;
    while (cin>>password) {
        if (isvalid(password)) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
}
// 64 位输出请用 printf("%lld")