Where's the Marble?

  • + 0 comments
    #include <iostream>
    int main() {
        int n, m, a, b;
        std::cin >> m >> n;
        while(n--){
            std::cin >> a >> b;
            if(a == m || b == m)
                m = a + b - m;
        }
        std::cout << m;
        return 0;
    }