#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void solve(int cs) {
string s;
cin >> s;
vector<int> ok(5, 0);
if (s.size() >= 8) ok[0] = 1;
for (int i = 0; i < s.size(); i++) {
if (islower(s[i])) ok[1] = 1;
else if (isupper(s[i])) ok[2] = 1;
else if (isdigit(s[i])) ok[3] = 1;
else ok[4] = 1;
}
cout << (accumulate(ok.begin(), ok.end(), 0) == 5 ? "valid\n" : "invalid\n");
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
cin >> tc;
for (int cs = 1; cs <= tc; cs++) {
solve(cs);
}
return 0;
}