#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
string str;
cin >> str;
int character=0,lower_case=0,upper_case=0,digit=0,special=0;
for(int i=0; i<str.length(); i++)
{
character++;
if(str[i]>='a' && str[i]<='z')
lower_case++;
else if(str[i]>='A' && str[i]<='Z')
upper_case++;
else if(str[i]>='0' && str[i]<='9')
digit++;
else if(str[i]=='!' || str[i]=='@' || str[i]=='#' || str[i]=='$' || str[i]=='%' || str[i]=='^' || str[i]=='&' || str[i]=='*' || str[i]=='(' || str[i]==')')
special++;
}
if(character>=8 && lower_case>0 && upper_case>0 && digit>0 && special>0)
cout << "valid" << endl;
else
cout << "invalid" << endl;
}
return 0;
}