#include <iostream>
#include <string>
using namespace std;
bool number(string str) {
for (char ch : str) {
if (ch >= '0' && ch <= '9') {
return true;
}
}
return false;
}
bool uppchar(string str) {
for (char ch : str) {
if (ch >= 'A' && ch <= 'Z') {
return true;
}
}
return false;
}
bool lowchar(string str) {
for (char ch : str) {
if (ch >= 'a' && ch <= 'z') {
return true;
}
}
return false;
}
bool others(string str) {
for (char ch : str) {
if ((ch < '0' || (ch > '9' && ch < 'A') || (ch > 'Z' && ch < 'a') ||
ch > 'z') && ch != ' ' && ch != '\n') {
return true;
}
}
return false;
}
bool sub_string(string str) {
string A, B;
int i, j;
for (i = 0; i < str.size() - 3; i++) {
for (j = i + 1; j < str.size() - 2; j++) {
A = str.substr(i, 3);
B = str.substr(j, 3);
if (A == B) {
return false;
}
A.clear();
B.clear();
}
}
return true;
}
int main() {
// int a, b;
// while (cin >> a >> b) { // 注意 while 处理多个 case
// cout << a + b << endl;
// }
string str;
while (cin >> str) {
if (str.size() < 8) {
cout << "NG" << endl;
continue;
}
int count = 0;
count = number(str) + uppchar(str) + lowchar(str) + others(str);
if (count < 3) {
cout << "NG" << endl;
continue;
}
if (!sub_string(str)) {
cout << "NG" << endl;
continue;
}
cout << "OK" << endl;
}
}