题干:

Alice is planning her travel route in a beautiful valley. In this valley, there are NN lakes, and MM rivers linking these lakes. Alice wants to start her trip from one lake, and enjoys the landscape by boat. That means she need to set up a path which go through every river exactly once. In addition, Alice has a specific number (a1,a2,...,ana1,a2,...,an) for each lake. If the path she finds is P0→P1→...→PtP0→P1→...→Pt, the lucky number of this trip would be aP0XORaP1XOR...XORaPtaP0XORaP1XOR...XORaPt. She want to make this number as large as possible. Can you help her?

Input

The first line of input contains an integer tt, the number of test cases. tt test cases follow. 

For each test case, in the first line there are two positive integers N (N≤100000)N (N≤100000) and M (M≤500000)M (M≤500000), as described above. The ii-th line of the next NN lines contains an integer ai(∀i,0≤ai≤10000)ai(∀i,0≤ai≤10000) representing the number of the ii-th lake. 

The ii-th line of the next MM lines contains two integers uiui and vivi representing the ii-th river between the uiui-th lake and vivi-th lake. It is possible that ui=viui=vi.

Output

For each test cases, output the largest lucky number. If it dose not have any path, output "Impossible".

Sample Input

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

Sample Output

2
Impossible

题目大意:

一个图,每一条边必须且只能经过一次,写出经过点的路径,类似于p1->p2->p1,求一条路径,使得路径的点的异或和最大,求这个最大值。

解题报告:

首先判断联通,然后看是否有欧拉回路或者欧拉通路,然后两种情况分别判断。如果都没有则输出impossible。

AC代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cctype>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n,m,in[maxn];
int a[maxn];
vector<int> vv[maxn];
int main()
{
	int t,i,j,k,cnt,u,v,ans=0;
	int sum=0;
	cin>>t;	
	while(t--){
		scanf("%d%d",&n,&m);
		cnt=0;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
			in[i]=0;
			vv[i].clear();
		}
		for(i=1;i<=m;i++){
			scanf("%d%d",&u,&v);
			vv[u].push_back(v);
			vv[v].push_back(u);
			in[u]++; in[v]++;
		}
		for(i=1;i<=n;i++){
		//	cout<<i<<":"<<in[i]<<endl;
			cnt+=(in[i]&1);
		}

		if(cnt==1||cnt>2){
			puts("Impossible");
			continue;
		}
		ans=0;
		if(cnt){
			for(i=1;i<=n;i++){
				if(in[i]&1){
					ans^=a[i];
					if(((in[i]-1)/2)%2)
						ans^=a[i];
				}
				else if((in[i]/2)%2)
					ans^=a[i];
			}
		}
		else {
			sum=0;
			for(i=1;i<=n;i++){
				if((in[i]/2)%2)
					sum^=a[i];
			}
			for(i=1;i<=n;i++)
				ans=max(ans,sum^a[i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}