#include<stdio.h>
#define MAXN10000
typedef int set_type[MAXN];voidInitialization(set_type S, int N);voidInput_connection(set_type S);voidCheck_connection(set_type S);voidCheck_network(set_type S, int N);
int Find(set_type S, int x);voidUnion(set_type S, int root1, int root2);
int main(){
int N;
set_type S;
char in;scanf("%d\n",&N);Initialization(S,N);do{scanf("%c",&in);switch(in){case'I':Input_connection(S);break;case'C':Check_connection(S);break;case'S':Check_network(S,N);break;}}while(in!='S');return0;}voidInitialization(set_type S, int N){
int i;for(i =0; i <N; i++)S[i]=-1;}voidInput_connection(set_type S){
int x1, x2;scanf("%d %d\n",&x1,&x2);
int root1 =Find(S, x1-1);
int root2 =Find(S, x2-1);if(root1 != root2)Union(S, root1, root2);}voidCheck_connection(set_type S){
int x1, x2;scanf("%d %d\n",&x1,&x2);
int root1 =Find(S, x1-1);
int root2 =Find(S, x2-1);if(root1 != root2)printf("no\n");elseprintf("yes\n");}voidCheck_network(set_type S,int N){
int counter =0;
int i;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(set_type S, int x){if(S[x]<0)return x;elsereturnS[x]=Find(S,S[x]);}voidUnion(set_type S, int root1, int root2){if(root1 < root2){S[root1]+=S[root2];S[root2]= root1;}else{S[root2]+=S[root1];S[root1]= root2;}}