#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; string s; int t; for (int i = 0; i < n; i++){ cin >> s >> t; mp[s] = t; } for (int i = 0; i < m; i++){ cin >> s >> t; mp[s] = t; } for (auto x :mp){ cout << x.first << " " << x.second << endl; } }