#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main() { ll n, m; cin >> n >> m; map mp; for (int i = 0; i < n; i++){ string s; int t; cin >> s >> t; mp[s] = t; } for (int i = 0; i < m; i++){ string s; int t; cin >> s >> t; mp[s] = t; } for (auto x :mp){ cout << x.first << " " << x.second << endl; } }