#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
string solve()
{
string s;
cin>>s;
if(s.size()<8)return "invalid";
ll up=0,lo=0,dig=0,spc=0;
for(auto x:s)
{
if(x>='A'&&x<='Z')up++;
if(x>='a'&&x<='z')lo++;
if(x>='0'&&x<='9')dig++;
if(x=='!'||x=='@'||x=='#'||x=='$'||x=='%'||x=='^'||x=='&'||x=='*'||x=='('||x==')')spc++;
}
if(up>0&&lo>0&&dig>0&&spc>0)return "valid";
else return "invalid";
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
ll t;cin>>t;
while(t--)
{
cout<<solve()<<endl;
}
}