#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 %d\n",&shuffleList[0],&shuffleList[1]); if(shuffleList[0] == target){ target = shuffleList[1]; }else if(shuffleList[1] == target){ target = shuffleList[0]; } } printf("%d",target); }