#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     map<string, string> mp;     map<string, string>::iterator it;     for (int i = 0; i < n; ++i) {       string x, y;       cin >> x >> y;       it = mp.begin();       bool found = false;       for (; it != mp.end(); ++it) {         if (it->second == x) {           it->second = y;           found = true;         }       }       if (!found) mp[x] = y;     }     cout << mp.size() << endl;     it = mp.begin();     for (; it != mp.end(); it++) cout << it->first <<     << it->second << endl;     return 0;   }   