#include void main(void){ int target = 0; int input = scanf("%d\n",&target); int shuffle = 0; int shuffleList[2]; input = scanf("%d\n",&shuffle); for(int i = 0 ; i < shuffle ; i++){ input = scanf("%d",shuffleList[0]); input = scanf("%d",shuffleList[1]); if(shuffleList[0] == target){ target = shuffleList[1]; }else if(shuffleList[1] == target){ target = shuffleList[0]; } } }