#include <bits/stdc++.h>
#define int long long
#define fr(i, a, b) for (int i = a; i < b; i++)
#define mmst(i,a) memset(i,a,sizeof(i))
#define all(i) i.begin(),i.end()
#define allr(i) i.rbegin(),i.rend()
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define SS " "
#define ddd cout<<"D"<<endl;
#define dd(i) cout<<i<<endl;
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
const char nl = '\n';
using namespace std;
const int mod = 1e9 + 7;
const int sz = 1e6 + 5;
const int inf = 1e18;
int q(int n){
if(n == 0)return 3;
else if(n == 1)return 1;
else return 0;
}
void solve()
{
int pa,pb,pc;cin>>pa>>pb>>pc;
int arr[3] = {0, 1, 3};
for(int i = 0; i <= 2; i++){
for(int j = 0; j <= 2; j++){
int tmpPa, tmpPb, tmpPc;
for(int k = 0; k <= 2; k++){
tmpPa = arr[i] + arr[j];
tmpPb = q(i) + arr[k];
tmpPc = q(j) + q(k);
if(tmpPa == pa && tmpPb == pb && tmpPc == pc){
cout<<"perfectus"<<nl;
return;
}
}
}
}
cout<<"invalidum"<<nl;
}
int32_t main()
{
fast int T = 1;
cin >> T;
for (int tc = 1; tc <= T; tc++)
{
cout<<"Case "<<tc<<": ";
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGZyKGksIGEsIGIpIGZvciAoaW50IGkgPSBhOyBpIDwgYjsgaSsrKQojZGVmaW5lIG1tc3QoaSxhKSBtZW1zZXQoaSxhLHNpemVvZihpKSkKI2RlZmluZSBhbGwoaSkgaS5iZWdpbigpLGkuZW5kKCkKI2RlZmluZSBhbGxyKGkpIGkucmJlZ2luKCksaS5yZW5kKCkKI2RlZmluZSBmYXN0ICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgXAogICAgY2luLnRpZShOVUxMKTsgICAgICAgICAgICAgICAgICAgIFwKICAgIGNvdXQudGllKE5VTEwpOwojZGVmaW5lIFNTICIgIgojZGVmaW5lIGRkZCBjb3V0PDwiRCI8PGVuZGw7CiNkZWZpbmUgZGQoaSkgY291dDw8aTw8ZW5kbDsKI2RlZmluZSB5ZXMgY291dCA8PCAiWWVzIiA8PCBlbmRsCiNkZWZpbmUgbm8gY291dCA8PCAiTm8iIDw8IGVuZGwKY29uc3QgY2hhciBubCA9ICdcbic7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbW9kID0gMWU5ICsgNzsKY29uc3QgaW50IHN6ID0gMWU2ICsgNTsKY29uc3QgaW50IGluZiA9IDFlMTg7CgppbnQgcShpbnQgbil7CiAgICBpZihuID09IDApcmV0dXJuIDM7CiAgICBlbHNlIGlmKG4gPT0gMSlyZXR1cm4gMTsKICAgIGVsc2UgcmV0dXJuIDA7Cn0KCnZvaWQgc29sdmUoKQp7CiAgICBpbnQgcGEscGIscGM7Y2luPj5wYT4+cGI+PnBjOwogICAgaW50IGFyclszXSA9IHswLCAxLCAzfTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPD0gMjsgaSsrKXsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDw9IDI7IGorKyl7CiAgICAgICAgICAgIGludCB0bXBQYSwgdG1wUGIsIHRtcFBjOwogICAgICAgICAgICBmb3IoaW50IGsgPSAwOyBrIDw9IDI7IGsrKyl7CiAgICAgICAgICAgICAgICB0bXBQYSA9IGFycltpXSArIGFycltqXTsKICAgICAgICAgICAgICAgIHRtcFBiID0gcShpKSArIGFycltrXTsKICAgICAgICAgICAgICAgIHRtcFBjID0gcShqKSArIHEoayk7CiAgICAgICAgICAgICAgICBpZih0bXBQYSA9PSBwYSAmJiB0bXBQYiA9PSBwYiAmJiB0bXBQYyA9PSBwYyl7CiAgICAgICAgICAgICAgICAgICAgY291dDw8InBlcmZlY3R1cyI8PG5sOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGNvdXQ8PCJpbnZhbGlkdW0iPDxubDsKfQoKaW50MzJfdCBtYWluKCkKewogICAgZmFzdCBpbnQgVCA9IDE7CiAgICBjaW4gPj4gVDsKICAgIGZvciAoaW50IHRjID0gMTsgdGMgPD0gVDsgdGMrKykKICAgIHsKICAgICAgICBjb3V0PDwiQ2FzZSAiPDx0Yzw8IjogIjsKICAgICAgICBzb2x2ZSgpOwogICAgfQogICAgcmV0dXJuIDA7Cn0=