# uvalive4487 带权并查集

```#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<cmath>
///LOOP
#define REP(i, n) for(int i = 0; i < n; i++)
#define FF(i, a, b) for(int i = a; i < b; i++)
#define FFF(i, a, b) for(int i = a; i <= b; i++)
#define FD(i, a, b) for(int i = a - 1; i >= b; i--)
#define FDD(i, a, b) for(int i = a; i >= b; i--)
///INPUT
#define RI(n) scanf("%d", &n)
#define RII(n, m) scanf("%d%d", &n, &m)
#define RIII(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define RIV(n, m, k, p) scanf("%d%d%d%d", &n, &m, &k, &p)
#define RV(n, m, k, p, q) scanf("%d%d%d%d%d", &n, &m, &k, &p, &q)
#define RFI(n) scanf("%lf", &n)
#define RFII(n, m) scanf("%lf%lf", &n, &m)
#define RFIII(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define RFIV(n, m, k, p) scanf("%lf%lf%lf%lf", &n, &m, &k, &p)
#define RS(s) scanf("%s", s)
///OUTPUT
#define PN printf("\n")
#define PI(n) printf("%d\n", n)
#define PIS(n) printf("%d ", n)
#define PS(s) printf("%s\n", s)
#define PSS(s) printf("%s ", n)
///OTHER
#define PB(x) push_back(x)
#define CLR(a, b) memset(a, b, sizeof(a))
#define CPY(a, b) memcpy(a, b, sizeof(b))
#define display(A, n, m) {REP(i, n){REP(j, m)PIS(A[i][j]);PN;}}

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 100000000;
const int INFI = 1e9 * 2;
const LL LINFI = 1e17;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int N = 22222;
const int M = 22;
const int move[8][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1};

int n;
bool vis[N];
char op[2], s[M];
int f[N], d[N], a[M];

int find(int x)
{
if(x == f[x])return x;
int tmp = f[x];
f[x] = find(f[x]);
d[x] ^= d[tmp];
return f[x];
}

bool add(int p, int q, int v)
{
int x = find(p);
int y = find(q);
if(x == y)return v == (d[p] ^ d[q]);
if(x == n)swap(x, y);
f[x] = y;
d[x] = d[p] ^ d[q] ^ v;
return 1;
}

int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int m, p, q, v, k, fact, go, cas = 1;
while(RII(n, m), n + m)
{
REP(i, n + 1)f[i] = i;
CLR(vis, 0);
CLR(d, 0);
fact = 0;
go = 1;
printf("Case %d:\n", cas++);
while(m--)
{
RS(op);
if(!go)
{
gets(s);
continue;
}
if(op[0] == 'I')
{
fact++;
gets(s);
if(sscanf(s, "%d%d%d", &p, &q, &v) == 2)v = q, q = n;
{
printf("The first %d facts are conflicting.\n", fact);
go = 0;
}
}
else
{
RI(k);
v = 0;
REP(i, k)
{
RI(a[i]);
p = find(a[i]);
v ^= d[a[i]];
a[i] = p;
vis[p] = !vis[p];
}
q = 1;
REP(i, k)if(vis[a[i]])
{
if(a[i] != n)q = 0;
vis[a[i]] = 0;
}
if(q)PI(v);
else puts("I don't know.");
}
}
puts("");
}
return 0;
}
```