#include<bits/stdc++.h>
using namespace std;
void solve()
{
string s; cin>>s;
int n=s.size();
if(n<8) {cout<<"invalid"<<endl; return;}
bool lower=false,upper=false,digit=false,special=false;
for(auto x:s)
{
lower |=(x>='a' && x<='z');
upper |=(x>='A' && x<='Z');
digit |=(x<='9' && x>='0');
special |=(x=='.' || x=='[' || x==']' || x=='!' || x=='@' || x=='#' || x=='$' || x=='%' || x=='^' || x=='&' || x=='*' || x=='(' || x==')' || x=='{' || x=='}');
}
if(lower && upper && digit && special) cout<<"valid"<<endl;
else cout<<"invalid"<<endl;
}
int main()
{
int t; cin>>t; while(t--) solve();
}