#include <stdio.h>
int main() {
int count, len = 5, prev, curr, dev, temp;
int arr[len];
scanf("%d", &count);
for (int times = 0; times < count; times++) {
scanf("%d %d %d %d", &arr[0], &arr[1], &arr[2], &arr[3]);
for(int point = 1; point < len - 1; point++ ) { //使用當前數值比較前一個,所以由 1 開始
prev = arr[point - 1]; //前一個數值
curr = arr[point]; //當前數值
temp = dev; //因題目透漏只會有等比和等差,我採用等差方式比對,儲存前次比對的差值
dev = curr - prev; //此次比對的差值
arr[4] = temp == dev ? curr + dev : curr * curr / prev; //當此次比對差與前次比對差相同,則視為等差數列,否則視為等比數列,並將計算數值指派給陣列最後一個位置
}
printf("%d %d %d %d %d\n", arr[0], arr[1], arr[2], arr[3], arr[4]);
}
}