#include"testlib.h"
typedef long long ll;
void judge(int line) {
    ll answer=ans.readLong();
    ll out=ouf.readLong();
    if(out<-1 or out==0 or out>1e9){
    	quitf(_wa,"The answer is wrong on %d line: the first number cannot be %lld.",line,out);
	}
	ll in=inf.readLong();
    if(answer==-1){
    	if(out!=-1){
			quitf(_wa,"The answer is wrong on %d line: expected -1, found %lld.",line,out);
		}
	}else{
		ans.readLong();
		ll out2=ouf.readLong();
		if(out2<-1 or out2==0 or out2>1e9){
	    	quitf(_wa,"The answer is wrong on %d line: the second number cannot be %lld.",line,out2);
		}
		ll squared=abs(out*out-out2*out2);
		if(squared!=in){
			quitf(_wa,"The answer is wrong on %d line: square difference excepted %lld, found %lld.",line,in,squared);
		}
	}
} 
int main(int argc, char* argv[]){
    registerTestlibCmd(argc, argv);	
    ll q=inf.readLong();
    for(int i=0;i<q;i++){
    	judge(i+1);
	}
	quitf(_ok,"All the answers are correct");
}