#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int k, n, m;
cin >> k >> n >> m;
vector<pair<int, int>> data(k);
for (int i = 0; i < k; ++i) {
cin >> data[i].first >> data[i].second; // a_i, b_i
}
// Sắp xếp theo giá trị trọng số lớn nhất giữa a_i và b_i
sort(data.begin(), data.end(), [](pair<int, int> &a, pair<int, int> &b) {
return max(a.first, a.second) > max(b.first, b.second);
});
// Tách danh sách a và b
vector<int> group1, group2;
for (int i = 0; i < k; ++i) {
if (group1.size() < n && data[i].first >= data[i].second) {
group1.push_back(data[i].first); // Chọn nhóm loại 1
} else if (group2.size() < m) {
group2.push_back(data[i].second); // Chọn nhóm loại 2
}
}
// Tính tổng trọng số
int total_weight = 0;
for (int w : group1) total_weight += w;
for (int w : group2) total_weight += w;
cout << total_weight << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgaywgbiwgbTsKICAgIGNpbiA+PiBrID4+IG4gPj4gbTsKICAgIHZlY3RvcjxwYWlyPGludCwgaW50Pj4gZGF0YShrKTsKCiAgICBmb3IgKGludCBpID0gMDsgaSA8IGs7ICsraSkgewogICAgICAgIGNpbiA+PiBkYXRhW2ldLmZpcnN0ID4+IGRhdGFbaV0uc2Vjb25kOyAvLyBhX2ksIGJfaQogICAgfQoKICAgIC8vIFPhuq9wIHjhur9wIHRoZW8gZ2nDoSB0cuG7iyB0cuG7jW5nIHPhu5EgbOG7m24gbmjhuqV0IGdp4buvYSBhX2kgdsOgIGJfaQogICAgc29ydChkYXRhLmJlZ2luKCksIGRhdGEuZW5kKCksIFtdKHBhaXI8aW50LCBpbnQ+ICZhLCBwYWlyPGludCwgaW50PiAmYikgewogICAgICAgIHJldHVybiBtYXgoYS5maXJzdCwgYS5zZWNvbmQpID4gbWF4KGIuZml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