#include<stdio.h>
#define MAXN10000
typedef int set[MAXN];voidInitialization(setS, int N);voidInput_connection(setS);voidCheck_connection(setS);voidCheck_networks(setS, int N);
int Find(setS, int x);voidUnion(setS, int root1, int root2);
int main(){
int N, i;setS;scanf("%d\n",&N);Initialization(S,N);
char in;do{scanf("%c",&in);switch(in){case'I':Input_connection(S);break;case'C':Check_connection(S);break;case'S':Check_networks(S,N);break;}}while(in!='S');return0;}voidInitialization(setS, int N){
int i;for(i =0; i <N; i++)S[i]=-1;}voidInput_connection(setS){
int x1, x2, root1, root2;scanf("%d %d\n",&x1,&x2);
root1 =Find(S, x1 -1);
root2 =Find(S, x2 -1);if(root1 != root2)Union(S, root1, root2);}voidCheck_connection(setS){
int x1, x2, root1, root2;scanf("%d %d\n",&x1,&x2);
root1 =Find(S, x1 -1);
root2 =Find(S, x2 -1);if(root1 != root2)printf("no\n");elseprintf("yes\n");}voidCheck_networks(setS, int N){
int i, counter =0;for(i =0; i <N; i++){if(S[i]<0) counter++;}if(counter ==1)printf("The network is connected.");elseprintf("There are %d components.",counter);}
int Find(setS, int x){if(S[x]<0)return x;elsereturnS[x]=Find(S,S[x]);}voidUnion(setS, int root1, int root2){if(root1 == root2)return;if(S[root1]<S[root2]){S[root1]+=S[root2];S[root2]= root1;}else{S[root2]+=S[root1];S[root1]= root2;}}