#include #include using namespace std; int main() { freopen("exam.in", "r", stdin); freopen("exam.out", "w", stdout); int N, M, s, t; map hash; scanf("%d%d", &N, &M); for(int i = 0; i < N; i++) { scanf("%d%d", &s, &t); hash[s] += t; } for(int i = 0; i < M; i++) { scanf("%d%d", &s, &t); hash[s] += t; } for(map::iterator it = hash.begin(); it != hash.end(); ++it) { if((*it).second > 119) { printf("%d\n", (*it).first); } } return 0; }