#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define fi first
#define sc second
#define endl '\n'
#define gcd(x, y) (__gcd(x, y))
#define lcm(x, y) ((x/gcd(x, y))*y)
#define mem(a,b) memset(a, b, sizeof(a))
#define de(x) cerr<<#x<<" :: "<<x<<" "<<endl
void solve()
{
string s;
cin>>s;
bool mn=false,lo=false,up=false,od=false,sp=false;
if(s.size()>=8)mn=true;
for(int i=0;i<s.size();i++){
if(s[i]=='a'||s[i]=='b'||s[i]=='c'||s[i]=='d'||s[i]=='e'||s[i]=='f'||s[i]=='g'||s[i]=='h'||s[i]=='i'||s[i]=='j'
||s[i]=='k'||s[i]=='l'||s[i]=='m'||s[i]=='n'||s[i]=='o'||s[i]=='p'||s[i]=='q'||s[i]=='r'||s[i]=='s'||s[i]=='t'
||s[i]=='u'||s[i]=='v'||s[i]=='w'||s[i]=='x'||s[i]=='y'||s[i]=='z')lo=true;
if(s[i]=='A'||s[i]=='B'||s[i]=='C'||s[i]=='D'||s[i]=='E'||s[i]=='F'||s[i]=='G'||s[i]=='H'||s[i]=='I'||s[i]=='J'
||s[i]=='K'||s[i]=='L'||s[i]=='M'||s[i]=='N'||s[i]=='O'||s[i]=='P'||s[i]=='Q'||s[i]=='R'||s[i]=='S'||s[i]=='T'
||s[i]=='U'||s[i]=='V'||s[i]=='W'||s[i]=='X'||s[i]=='Y'||s[i]=='Z') up=true;
if(s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9'||s[i]=='0') od=true;
if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='$'||s[i]=='^'||s[i]=='&'||s[i]=='('||s[i]==')'||s[i]=='%'||s[i]=='*') sp =true;
}
if(mn&&lo&&up&&od&&sp)cout<<"valid"<<endl;
else cout<<"invalid"<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}