#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string special = "!@#$%^&*()";
void solve(int T) {
string s; cin >> s;
int flag = 0;
if(s.length() >= 8) flag |= (1 << 0);
for(auto c : s) {
if(c <= 'z' && c > 'a') flag |= (1 << 1);
if(c <= 'Z' && c > 'A') flag |= (1 << 2);
if(c <= '9' && c >= '0') flag |= (1 << 3);
if(special.find(c) != string::npos) flag |= (1 << 4);
}
cout << ((flag == 31) ? "valid\n" : "invalid\n");
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef MYPC
cout << "==== OUTPUT ====\n";
#endif
int t; cin >> t;
for(int i = 1; i <= t; i++) {
solve(i);
}
}