2301Drunken Masters

2301   Drunken Masters

题目描述

Tony Lang,one of the best drunken masters around the world,is crazy about creating a unique kind of wine.

One day,an idea struck him:what if put yellow wine,rice wine and coke together?He has n bottles of yellow wine with size a1,a2,a3,...,an ml,m bottles of rice wine with size b1,b2,b3,...,bn ml,p bottles of coke with size c1,c2,c3...,cp ml,and an empty cup with size h ml.At the beginning,all the bottles are full.Suffering from obsessive-compulsive disorder(强迫症),Tony Lang could not bear to have a partial container,which means,whatever bottle or cup,it must be empty or full.

For each of three drinks,Tony wants to select one bottle and pour into the cup.Finally,The cup is full and drinks does not overflow.But Tony’s collection is so large that he has to turn to you for help.He wants to know the size of three bottles selected.If there are multiple solutions,please output the solution with the smallest degree of difference.If you choose the ith yellow wine,the jth rice wine,the kth coke,then the degree of difference is max(ai,bj,ck)-min(ai,bj,ck).If there is no solution ,please output -1.

输入格式:

The first line of data is the number of cases T.

Within each case data :

The first line contains three integers n,m,p,separated by space.

The second line contains n integers a1,a2,a3,...,an.

The third line contains m integers b1,b2,b3,...,bm.

The fourth line contains p integers c1,c2,c3,...,cp.

The fifth line is an integer h.

T <= 10

1<=n,m,p<=1000;

1<=ai,bj,ck<=2e9;

1<=h<=2e9.

输出格式:

One line for each case,output the size of three bottles selected in the order of yellow wine,rice wine and coke.If there are multiple solutions,please output the solution with the smallest degree of difference.If there is no solution ,please output -1.

输入样例 复制
2
4 5 6
1 2 5 4
2 8 6 3 4
9 2 8 4 5 6
12 
3 3 3
1 2 3
4 5 6
7 8 9
10
输出样例 复制
4 4 4
-1

说明

1
2
通过提交
时空限制2000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度