#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
using namespace std;

int main() {
    int t;
        cin >> t;
        cin.ignore();
        for(int i=0; i<t; i++) {
         string line;
         getline(cin, line);
        transform(line.begin(), line.end(), line.begin(), ::toupper);
        bool valid= (line.length() <=1000);
        if(valid) {
            for(char c : line) {
                if(! isalnum(static_cast<unsgined char>(c))) {valid=false;
                break;
            }
        }
        }
     if(valid) {
         cout<<"VALID" <<endl;
     }   
     else {
         cout <<"INVALID" << endl;
     }
}
return 0;
}