#include <bits/stdc++.h>

#define pii pair<ll, ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()

#define y1 what

using namespace std;

const ll N = (ll) 2e5 + 10;
const ll M = (ll) 1e6 + 7;
const ll LINF = (ll) 1e18;
const ll INF = (ll) 1e9 + 7;
const double EPS = (double) 1e-9;

ll n, a, b;
pii pts[N];
ll pref[N];
ll suff[N];

vector<ll> all_num;

ll get_id(ll x) {
    return lower_bound(all(all_num), x) - all_num.begin();
}

struct node {
    ll cnt;
    ll sum;

    node() {
        cnt = sum = 0;
    }
};

node t[4 * N];

void upd(ll x, ll y, ll v = 1, ll l = 0, ll r = sz(all_num) - 1) {
    if (l == r) {
        ++t[v].cnt;
        t[v].sum += y;
        return;
    }
    ll m = (l + r) / 2;
    if (x <= m) {
        upd(x, y, v + v, l, m);
    } else {
        upd(x, y, v + v + 1, m + 1, r);
    }
    t[v].sum = t[v + v].sum + t[v + v + 1].sum;
    t[v].cnt = t[v + v].cnt + t[v + v + 1].cnt;
}

ll get(ll k, ll v = 1, ll l = 0, ll r = sz(all_num) - 1) {
    if (k == 0) 
        return 0;
    if (l == r) {
        if (!(t[v].cnt >= k)) {
            assert(0);
            cout << "WTF?\n";
            exit(0);
        }
        if (t[v].cnt == 0) return 0;
        return k * 1ll * (t[v].sum / t[v].cnt);
    }
    ll m = (l + r) / 2;
    if (t[v + v + 1].cnt >= k)
        return get(k, v + v + 1, m + 1, r);
    return get(k - t[v + v + 1].cnt, v + v, l, m) + t[v + v + 1].sum;
}

void add(ll x) {
    upd(get_id(x), x);
}

ll solve() {
    for (ll i = 0; i < 4 * N; i++) {
        t[i].cnt = 0;
        t[i].sum = 0;
    }
    all_num.clear();
    sort(pts + 1, pts + n + 1, greater<pii>());
    //ai, bi -> X, Y
    for (ll i = 1; i <= n; i++) {
        //cout << pts[i].f << ' ' << pts[i].s << endl;
        all_num.pb(pts[i].s);
        all_num.pb(pts[i].s - pts[i].f);
    }
    sort(all(all_num));
   // cout << endl;
    for (ll i = n; i >= 1; i--) {
        if (i >= a && i <= a + b) {
            if (0==1) { //continue;
                cout<<b - (i - a)<<endl;
                for(ll j=i+1;j<=n;j++){
                    cout<<pts[j].s<<" ";
                }
                cout << endl;
            }
            suff[i] = get(b - (i - a));
        }
        add(pts[i].s);
    }
    for (ll i = 0; i < 4 * N; i++) {
        t[i].cnt = 0;
        t[i].sum = 0;
    }
    ll ans = -LINF;
    for (ll i = 1; i <= a + b; i++) {
        pref[i] = pref[i - 1] + pts[i].f;
        add(pts[i].s - pts[i].f);
        // we want to delete from back so that we have chosen already a silver
        if (i >= a) {
            //cout << suff[i] << endl;
            ans = max(ans, pref[i] + suff[i] + get(i - a));
        }
    }
    return ans;
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> a >> b;
    n += a + b;
    ll sum = 0, ans = -LINF;
    for (ll i = 1, x, y, z; i <= n; i++) {
        cin >> x >> y >> z;
        y -= x;
        z -= x;
        sum += x;
        pts[i] = mp(y, z);
    }
    cout << sum + solve();
    return 0;
}

Measured memory_bytes: 20852