// code from chatgpt , i am testing the judge , i am a new user of this platform just submited it for testing
#include <bits/stdc++.h>
using namespace std;
bool isValid(const string& password) {
if (password.length() < 8) return false;
bool hasLower = false, hasUpper = false, hasDigit = false, hasSpecial = false;
string specials = "!@#$%^&*()";
for (char c : password) {
if (islower(c)) hasLower = true;
else if (isupper(c)) hasUpper = true;
else if (isdigit(c)) hasDigit = true;
else if (specials.find(c) != string::npos) hasSpecial = true;
}
return hasLower && hasUpper && hasDigit && hasSpecial;
}
int main() {
int T;
cin >> T;
cin.ignore();
while (T--) {
string password;
getline(cin, password);
cout << (isValid(password) ? "valid" : "invalid") << endl;
}
return 0;
}