#define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mpair make_pair #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef long double ld; const ld epsylon = 1e-9; int main() { freopen("exam.in","r",stdin); freopen("exam.out","w",stdout); int n,m; cin >> n >> m; map pts; for (int i = 0; i < n; ++i){ string temp; int p; cin >> temp >> p; pts[temp] = p; } for (int i = 0; i < m; ++i){ string temp; int p; cin >> temp >> p; map::iterator it = pts.find(temp); if (it == pts.end()) { pts[temp] = p; } else { it->second += p; } } for (map::iterator it = pts.begin(); it!=pts.end();++it){ if (it->second > 119) { cout << it->first << "\n"; } } return 0; }