#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
cin.ignore();
const int MAX_WORKERS = 10001;
int workHours[MAX_WORKERS] = {0};
for (int i = 0; i < n; ++i) {
string line;
getline(cin, line);
int id = 0, hours = 0;
bool foundId = false, foundHours = false;
for (size_t j = 0; j < line.size(); ++j) {
if (line[j] >= '0' && line[j] <= '9') {
int number = 0;
while (j < line.size() && line[j] >= '0' && line[j] <= '9') {
number = number * 10 + (line[j] - '0');
++j;
}
if (!foundId) {
id = number;
foundId = true;
} else if (!foundHours) {
hours = number;
foundHours = true;
}
}
}
workHours[id] += hours;
}
int maxHours = 0, bestWorker = 0;
for (int i = 1; i < MAX_WORKERS; ++i) {
if (workHours[i] > maxHours) {
maxHours = workHours[i];
bestWorker = i;
}
}
cout << bestWorker;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgY2luLmlnbm9yZSgpOwoKICAgIGNvbnN0IGludCBNQVhfV09SS0VSUyA9IDEwMDAxOwogICAgaW50IHdvcmtIb3Vyc1tNQVhfV09SS0VSU10gPSB7MH07CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBzdHJpbmcgbGluZTsKICAgICAgICBnZXRsaW5lKGNpbiwgbGluZSk7CiAgICAgICAgaW50IGlkID0gMCwgaG91cnMgPSAwOwogICAgICAgIGJvb2wgZm91bmRJZCA9IGZhbHNlLCBmb3VuZEhvdXJzID0gZmFsc2U7CiAgICAgICAgZm9yIChzaXplX3QgaiA9IDA7IGogPCBsaW5lLnNpemUoKTsgKytqKSB7CiAgICAgICAgICAgIGlmIChsaW5lW2pdID49ICcwJyAmJiBsaW5lW2pdIDw9ICc5JykgewogICAgICAgICAgICAgICAgaW50IG51bWJlciA9IDA7CiAgICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxpbmUuc2l6ZSgpICYmIGxpbmVbal0gPj0gJzAnICYmIGxpbmVbal0gPD0gJzknKSB7CiAgICAgICAgICAgICAgICAgICAgbnVtYmVyID0gbnVtYmVyICogMTAgKyAobGluZVtqXSAtICcwJyk7CiAgICAgICAgICAgICAgICAgICAgKytqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFmb3VuZElkKSB7CiAgICAgICAgICAgICAgICAgICAgaWQgPSBudW1iZXI7CiAgICAgICAgICAgICAgICAgICAgZm91bmRJZCA9IHRydWU7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFmb3VuZEhvdXJzKSB7CiAgICAgICAgICAgICAgICAgICAgaG91cnMgPSBudW1iZXI7CiAgICAgICAgICAgICAgICAgICAgZm91bmRIb3VycyA9IHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgd29ya0hvdXJzW2lkXSArPSBob3VyczsKICAgIH0KICAgIGludCBtYXhIb3VycyA9IDAsIGJlc3RXb3JrZXIgPSAwOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPCBNQVhfV09SS0VSUzsgKytpKSB7CiAgICAgICAgaWYgKHdvcmtIb3Vyc1tpXSA+IG1heEhvdXJzKSB7CiAgICAgICAgICAgIG1heEhvdXJzID0gd29ya0hvdXJzW2ldOwogICAgICAgICAgICBiZXN0V29ya2VyID0gaTsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGJlc3RXb3JrZXI7CiAgICByZXR1cm4gMDsKfQo=
NQpNdW5jaXRvcnVsIDEgYSBtdW5jaXQgMTAgb3JlCk11bmNpdG9ydWwgMjMgYSBtdW5jaXQgNSBvcmUKTXVuY2l0b3J1bCAzIGEgbXVuY2l0IDMgb3JlCk11bmNpdG9ydWwgMjMgYSBtdW5jaXQgMTEgb3JlCk11bmNpdG9ydWwgMSBhIG11bmNpdCAyIG9yZQ==
5
Muncitorul 1 a muncit 10 ore
Muncitorul 23 a muncit 5 ore
Muncitorul 3 a muncit 3 ore
Muncitorul 23 a muncit 11 ore
Muncitorul 1 a muncit 2 ore