#include <iostream>
using namespace std;
int difference(int s1,int s2,int s3,int s4)
{
int s5;
if(s2-s1 == s4-s3) //判斷差1
{
s5 = s4+(s2-s1);
}
else if(s2/s1 == s4/s3) //判斷差2倍
{
s5 = s4*(s2/s1);
}
return s5;
}
int main()
{
int input,s1,s2,s3,s4,s5;
cin>>input; //輸入迴圈次數
for(input;input>0;input--)
{
cin>>s1>>s2>>s3>>s4; //輸入範例輸入
s5 = difference(s1,s2,s3,s4); //輸出第5個數
cout<<s1<<" "<<s2<<" "<<s3<<" "<<s4<<" "<<s5<<endl;
}
return 0;
}