#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool checkPwd(string pwd)
{
int i, a, A, _a;
i = a = A = _a = 0;
for (auto ch: pwd) {
if (ch < 33 || ch > 126) {
return false;
}
if (ch >= '0' && ch <= '9') {
i = 1;
}
else if (ch >= 'A' && ch <= 'Z') {
A = 1;
}
else if (ch >= 'a' && ch <= 'z') {
a = 1;
} else {
_a = 1;
}
}
return i+a+A+_a >= 3;
}
bool isRepeat(string pwd)
{
string tmp, tmp2;
for (int i=0; i<pwd.length()-6; i++) {
tmp = pwd.substr(i, 3);
for (int j=i+3; j<pwd.length()-3; j++) {
tmp2 = pwd.substr(j, 3);
if (tmp == tmp2) {
return true;
}
}
}
return false;
}
int main() {
string a;
vector<string> retVec;
while (getline(cin, a)) {
if (a.length() < 8 || !checkPwd(a) || isRepeat(a)) {
retVec.push_back("NG");
} else {
retVec.push_back("OK");
}
}
for (auto ret: retVec) {
cout << ret << endl;
}
}
// 64 位输出请用 printf("%lld")