toj4119HDFS

时间:2023-03-09 15:40:31
toj4119HDFS

In HDFS( Hadoop Distributed File System), each data may have a lot of copies in case of data lose. This problem, every data has its own id, from 1 to n. To make things simple, each data has only two copies. This time, the HDFS is cracked by some stupid reason. Fortunately, tmeteorj knows that there are actually 2 data lost by his keen intuition. Now, it is your time to show your value of life. You should tell tmeteorj the id of lost data.

INPUT

First line, there will a number T(1≤T≤10), means the test case of this problem. After this, each line is first a number n(1≤n≤5000000), means data id is from 1 to n. Then there will be 2(n-1) numbers means the id of data in health state.

OUTPUT

For each case, print the lost id of data. The smaller id is in the front of the bigger one.

Sample Input


3
4 1 1 2 3 4 4
4 1 2 3 1 2 4
4 2 3 4 2 3 1

Sample Output


2 3
3 4
1 4

Source: TJU School Competetion 2015

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath> using namespace std; int main()
{
long long n,i,a,b,x,y,d,z;
cin>>z;
while(z--)
{
cin>>n;
a = ,b = ;
for(i = ;i<*n-;i++)
{
long long t;
scanf("%lld",&t);
a += n-i/-t;
b += (n-i/)*(n-i/)-t*t; }
d = sqrt(*b-a*a);
x = (a-d)/,y = (a+d)/;
cout<<x<<" "<<y<<endl;
}
return ;
}