#include <iostream>
using namespace std;
int mul(int);
string str = "";
char cre[20] = {};
int credit[20] = {};
int main(){
int T = 0 ;
cin >> T;
getline(cin,str);
for(int N = 0 ; N < T ; N++){
getline(cin,str);
for(int i = 18 ; i >= 0 ; i--){
cre[18-i] = str[i];
}
for(int i = 0 ; i <= 18 ; i++){
if(cre[i] != ' ')
credit[i] = cre[i] - '0' ;
}
int odd = mul(credit[18]) + mul(credit[16]) + mul(credit[13]) + mul(credit[11]) +mul(credit[8]) + mul(credit[6]) + mul(credit[3]) + mul(credit[1]);
int even = credit[17] + credit[15] + credit[12] + credit[10] + credit[7] + credit[5] + credit[2] + credit[0] ;
int S = odd + even ;
if(S % 10 == 0){
cout << "Valid" << endl;
}else{
cout << "Invalid" << endl;
}
}
}
int mul(int a){
int sum = 0 ;
a *= 2;
while(a != 0){
sum += a % 10;
a /= 10;
}
return sum ;
}
謝謝~:)