#include #include #include using namespace std; const int N = 1e5 + 7; int n, m; int a[N]; int d[N]; int main() { #ifndef ONLINE_JUDGE freopen("HDU5883.in", "r", stdin); #endif int T; scanf("%d", &T); while (T--) { memset(d, 0, sizeof d); scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); while (m--) { int a, b; scanf("%d%d", &a, &b); d[a]++, d[b]++; } // 奇数度点的个数 int cnt = 0; for (int i = 1; i <= n; i++) if (d[i] & 1) cnt++; // 不是0,而且个数不是2,那么肯定没有欧拉通路,也没有欧拉回路 if (cnt && cnt != 2) { puts("Impossible"); continue; } int ans = 0; for (int i = 1; i <= n; i++) { int x = (d[i] + 1) >> 1; if (x & 1) ans ^= a[i]; } // 如果没有度数为奇数的点,也就是欧拉回路,出发点终点是同一个点,这样会造成起点的权值被异或干掉 // 因为欧拉回路可以以任意一个点做为起点和终点,所以,需要枚举一遍,分别尝试以i这起点,找出最大异或值 int res = ans; if (cnt == 0) for (int i = 1; i <= n; i++) res = max(res, ans ^ a[i]); // 输出异或和 printf("%d\n", res); } return 0; }