/* Combine the enemy and friends in a collection, and use another array (rel [I]) to store I and the set to represent the relationship between elements (that is, saved in Ji [I. If the two elements are not in the same set, the relationship between them is unclear. If the two elements are in the same set: 1. they have the same relationship with the element represented by the set, and they are friends 2. the difference is the enemy */# include <stdio. h> int Ji [100010], rel [100010]; // Ji [] stores the set representing elements, RE; [I] int root (INT X) {int t; If (x = Ji [x]) return X; T = Ji [X]; JI [x] = root (JI [x]); rel [x] = (rel [T] + REL [x]) % 2; // The relationship between update and set representing elements return Ji [X];} int main () {int t, n, m, I; char O; int X, Y, FX, FY; scanf ("% d", & T); While (t --) {scanf ("% d", & N, & M ); for (I = 0; I <= N; I ++) {Ji [I] = I; rel [I] = 0;} If (n = 2) {Ji [2] = 1; rel [2] = 1;} for (I = 1; I <= m; I ++) {getchar (); scanf ("% C % d", & O, & X, & Y); FX = root (x); FY = root (y ); if (O = 'A') {If (FX = FY) {If (rel [x] = rel [y]) printf ("in the same gang. \ n "); else printf (" in different gangs. \ n ");} else printf (" not sure yet. \ n ") ;}else {If (FX <FY) {Ji [FY] = FX; rel [FY] =! (Rel [x] + REL [y]) % 2);} else {Ji [FX] = FY; rel [FX] =! (Rel [x] + REL [y]) % 2) ;}}} return 0 ;}