求出子序列

题目:

Polycarp had an array aa of 3 positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array bb of 7 integers.

For example, if a={1,4,3}, then Polycarp wrote out 1, 4, 3, 1+4=5, 1+3=4, 4+3=7, 1 + 4 + 3 = 8. After sorting, he got an array b={1,3,4,4,5,7,8}.

Unfortunately, Polycarp lost the array aa. He only has the array bb left. Help him to restore the array aa.

Input

The first line contains one integer t ( 1≤t≤5000) — the number of test cases.

Each test case consists of one line which contains 7 integers b_1, b_2, \dots, b_7b1​,b2​,…,b7​ (1 \le b_i \le 10^91≤bi​≤109; b_i \le b_{i+1}bi​≤bi+1​).

Additional constraint on the input: there exists at least one array awhich yields this array b as described in the statement.

Output

For each test case, print 33 integers — a1​, a2​ and a3​. If there can be several answers, print any of them.

Example

Input

5
1 3 4 4 5 7 8
1 2 3 4 5 6 7
300000000 300000000 300000000 600000000 600000000 600000000 900000000
1 1 2 999999998 999999999 999999999 1000000000
1 2 2 3 3 4 5

Output

1 4 3
4 1 2
300000000 300000000 300000000
999999998 1 1
1 2 2

Note

The subsequence of the array aa is a sequence that can be obtained from aa by removing zero or more of its elements.

Two subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length 3 has exactly 7 different non-empty subsequences.

翻译:

Polycarp有一个包含3个正整数的数组a。 他写出了这个数组中所有非空子序列的和,按非递减顺序排列,得到了一个包含7个整数的数组b。  

例如,如果a= {1,4,3 }那么Polycarp写出1,4,3,1+4= 5,1 +3= 4,4 +3= 7,1 +4+3= 8。 排序后,他得到了一个数组b={1,3,4,4,5,7,8}。  

不幸的是,Polycarp丢失了a数组。 他只剩下b数组了。 帮他恢复数组a。  

输入  

第一行包含一个整数t (1≤t≤5000)-测试用例的数量。  

每个测试用例由一行包含7个整数b1,b2,b3,b4,...b7组成  

对输入的附加约束:至少存在一个数组a,该数组b在语句中描述。  

输出  

对于每个测试用例,输出3个整数-a1,a2,a3;  

.  如果有几个答案,那就选一个出来。  

思路:

既然已经明确规定了b数组有7个整数,a数组有3个整数,并且可以确定a数组是b数组的子集,那么可以确定前两个最小的数是a数组中的数,但我们并不能确定第三个数是否是由前两个数相加得到的,所以我们可以用最大的数减去前两个数即可得到第三个数。

代码:

#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	long long a[7],i,n;
	scanf("%lld",&n);
	while(n--)
	{
		for(i=0;i<7;i++)
		{
			scanf("%lld",&a[i]);
		}
		sort(a,a+7);
		printf("%lld %lld %lld\n",a[0],a[1],a[6]-a[0]-a[1]);
	}
	return 0;
 } 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值