#include using namespace std; /* 测试用例: 4 5 1 5 5 2 3 4 2 3 答案:3 */ int n, m; const int N = 1e5 + 10; int w[N]; int main() { cin >> n >> m; w[1] = 1; // 1号碗里放小球 for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; swap(w[x], w[y]); } for (int i = 1; i <= m; i++) if (w[i]) { printf("%d\n", i); break; } return 0; }