#include <bits/stdc++.h> #include<iostream> #include<map> #include<vector> #include <algorithm> #include<math.h> #include <iomanip> #include<set> #include <numeric> #include<string> using ll = long long; using namespace std; int main() { ll n, m; cin >> n >> m; map<string, int> 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; } }