#include <iostream>
#include <string>
#include <unordered_set>
#include <cctype>
bool isPasswordValid(const std::string& password) {
// 检查长度
if (password.length() < 8) {
return false;
}
// 检查字符类型
bool hasUpper = false, hasLower = false, hasDigit = false, hasSpecial = false;
for (char ch : password) {
if (isupper(ch)) {
hasUpper = true;
} else if (islower(ch)) {
hasLower = true;
} else if (isdigit(ch)) {
hasDigit = true;
} else if (ch >= 33 && ch <= 126) {
hasSpecial = true;
}
}
int typeCount = (hasUpper ? 1 : 0) + (hasLower ? 1 : 0) + (hasDigit ? 1 : 0) + (hasSpecial ? 1 : 0);
if (typeCount < 3) {
return false;
}
// 检查子串重复
for (size_t len = 3; len <= password.length(); ++len) {
for (size_t i = 0; i <= password.length() - len; ++i) {
std::string substr = password.substr(i, len);
if (password.find(substr, i + substr.size()) != -1) {
return false;
}
}
}
return true;
}
int main() {
std::string password;
while (std::getline(std::cin, password)) {
if (isPasswordValid(password)) {
std::cout << "OK" << std::endl;
} else {
std::cout << "NG" << std::endl;
}
}
return 0;
}