#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isMoreThan8(const string& str) {
return str.size() > 8 ? true : false;
}
bool isValidWords(const string& str) {
vector<bool> wordCnt(4, false);
for (char c : str) {
if (c >= 'A' && c <= 'Z') {
wordCnt[0] = true;
}
else if (c >= 'a' && c <= 'z') {
wordCnt[1] = true;
}
else if (c >= '0' && c <= '9') {
wordCnt[2] = true;
}
else {
wordCnt[3] = true;
}
}
int cnt = 0;
for(bool flag : wordCnt){
if(flag){
++cnt;
}
}
return cnt >= 3 ? true : false;
}
bool isNoDuplicate(const string& str) {
int n = str.size();
bool isNoDup = true;
for(int i = 0; i < n-5; ++i){
for(int j = i+3; j < n-2; ++j){
if(str.substr(i, 3) == str.substr(j, 3)){
isNoDup = false;
break;
}
}
}
return isNoDup;
}
int main(int argc, char* argv[]) {
string str;
while (getline(cin, str)) {
bool flag = isMoreThan8(str) && isValidWords(str) && isNoDuplicate(str);
flag ? cout << "OK" << endl : cout << "NG" << endl;
}
return 0;
}