#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define maxn 1050
using namespace std;
int a[maxn];
struct Node{
int x;
int y;
double d;
bool operator <(const Node &other) const{
return d>other.d;
}
}node[maxn];
int sum[maxn];
double dou[maxn];
string s,b;
//bool compare(const double &a,const double &b){
// return a<b;
//}
int main(){
int n,m=0,index;
int a1,b1,c1;
double count=0;
int t,cnt=0;
while(cin>>t){
for(int i=0;i<t;i++){
cin>>a1>>b1>>c1;
if(a1*a1+b1*b1==c1*c1||a1*a1+c1*c1==b1*b1||c1*c1+b1*b1==a1*a1){
cout<<"good"<<endl;
}
else if(a1==b1||b1==c1||a1==c1){
cout<<"perfect"<<endl;
}
else{
cout<<"just a triangle"<<endl;
}
}
}
return 0;
}