#include<bits/stdc++.h>
#include <ctype.h>
using namespace std;
int main()
{
int p,n,N;
cin>>N;
while(N--) {
string a;
bool b=false;
bool l = false;
bool u = false;
bool d = false;
bool s = false;
cin >> a;
if(a.size()>=8) {
for (int i = 0; i < a.size(); i++)
if (islower(a[i])) {
l = true;
} else if (isupper(a[i])) {
u = true;
} else if (isdigit(a[i])) {
d = true;
} else if (a[i] == '!' || a[i] == '@' || a[i] == '#' || a[i] == '$' || a[i] == '%' || a[i] == '^' || a[i] == '&' || a[i] == '*')
s = true;
}
if(!l && !u && !d && !s)
cout<<"invalid"<<endl;
else
cout<<"valid"<<endl;
}}