#include #include #include int main(void){ // カップの個数 int *judgment[3] = {0,0,0}; // 初めに〇がついてるカップの位置 int loc; scanf("%d",&loc); // 〇の位置を配列に格納 for(int i = 0;i < 3;i++){ if(i == (loc - 1)){ *judgment[i] = 1; } } // 入れ替える回数 int count = 0; scanf("%d",&count); int i = 0; while(i != count){ int rep1 = 0; scanf("%d",&rep1); int rep2 = 0; scanf("%d",&rep2); for(int i = 0;i < 3;i++){ if(i == rep1){ rep1 = *judgment[i]; }else if(i == rep2){ rep2 = *judgment[i]; } } int tmp = 0; tmp = rep1; rep1 = rep2; rep2 = tmp; i++; } for(int i = 0;i < 3;i++){ if(*judgment[i] == 1){ printf("%d",i + 1); } } }