#include<iostream>
using namespace std;
int main()
{
int count;
int a[20][5] = {};
cin >> count;
for (int i = 0; i < count; i++) {
for (int j = 0; j < 4; j++) {
cin >> a[i][j];
}
}
int d, r;
bool arithmetic, geometric;
for (int i = 0; i < count; i++)
{
arithmetic = false, geometric = false;
if (a[i][3] - a[i][2] == a[i][2] - a[i][1] && a[i][2] - a[i][1] == a[i][1] - a[i][0])
{
arithmetic = true;
d = a[i][1] - a[i][0];
a[i][4] = a[i][3] + d;
}
else if (a[i][3] / a[i][2] == a[i][2] / a[i][1] && a[i][2] / a[i][1] == a[i][1] / a[i][0])
{
geometric = true;
r = a[i][1] / a[i][0];
a[i][4] = a[i][3] * r;
}
if (arithmetic == true || geometric == true)
{
for (int j = 0; j < 5; j++)
cout << a[i][j] << " ";
cout << endl;
}
}
return 0;
}