#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int coins[100005][3];
int asgn[100005];
set<pair<int,int>> moves[3][3];

void erase_move(int c1, int c2, int i)
{
    assert(moves[c1][c2].find(mp(coins[i][c2]-coins[i][c1], i)) != moves[c1][c2].end());
    moves[c1][c2].erase(mp(coins[i][c2]-coins[i][c1], i));
}

void add_move(int c1, int c2, int i)
{
    assert(moves[c1][c2].find(mp(coins[i][c2]-coins[i][c1], i)) == moves[c1][c2].end());
    moves[c1][c2].insert(mp(coins[i][c2]-coins[i][c1], i));
}

void move_asgn(int c1, int c2, int i)
{
    //prl(i)
    assert(asgn[i] == c1);
    asgn[i] = c2;
    erase_move(c1, (c1+1)%3, i);
    erase_move(c1, (c1+2)%3, i);
    add_move(c2, (c2+1)%3, i);
    add_move(c2, (c2+2)%3, i);
}

bool find_2_cycle(int c1, int c2)
{
    //find a negative-weight cycle c1->c2->c1
    if (!moves[c1][c2].empty() && !moves[c2][c1].empty() && moves[c1][c2].begin()->first + moves[c2][c1].begin()->first < 0) {
        //printf("found cycle %lld->%lld->%lld\n",c1,c2,c1);
        int i = moves[c1][c2].begin()->second;
        int j = moves[c2][c1].begin()->second;
        move_asgn(c1,c2,i);
        move_asgn(c2,c1,j);
        return true;
    }
    return false;
}

bool find_3_cycle(int c1, int c2, int c3) 
{
    //find a negative-weight cycle c1->c2->c3->c1 
    if (!moves[c1][c2].empty() && !moves[c2][c3].empty() && !moves[c3][c1].empty() && 
        moves[c1][c2].begin()->first + moves[c2][c3].begin()->first + moves[c3][c1].begin()->first < 0) {
        //printf("found cycle %lld->%lld->%lld->%lld\n",c1,c2,c3,c1);
        int i = moves[c1][c2].begin()->second;
        int j = moves[c2][c3].begin()->second;
        int k = moves[c3][c1].begin()->second;
        move_asgn(c1,c2,i);
        move_asgn(c2,c3,j);
        move_asgn(c3,c1,k);
        return true;
    }
    return false;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    
    int x,y,z;
    read(x); read(y); read(z);
    int n = x+y+z;
    ll total = 0;
    for0(i,x+y+z) {
        int g,s,b;
        read(g); read(s); read(b);
        int m = max(g,max(s,b));
        coins[i][0] = m-g;
        coins[i][1] = m-s;
        coins[i][2] = m-b;
        total += m;
    }
    //print2D(coins,n,3)
    
    //arbitrarily assign each player to any colour, as long as we have the correct 
    //number of each colour
    int i=0;
    for (; i<x; i++) {
        asgn[i] = 0;
        moves[0][1].insert(mp(coins[i][1]-coins[i][0], i));
        moves[0][2].insert(mp(coins[i][2]-coins[i][0], i));
    }
    for (; i<x+y; i++) {
        asgn[i] = 1;
        moves[1][0].insert(mp(coins[i][0]-coins[i][1], i));
        moves[1][2].insert(mp(coins[i][2]-coins[i][1], i));
    }
    for (; i<x+y+z; i++) {
        asgn[i] = 2;
        moves[2][0].insert(mp(coins[i][0]-coins[i][2], i));
        moves[2][1].insert(mp(coins[i][1]-coins[i][2], i));
    }
    
    bool found;
    do {
        //printa(asgn,n);
        found = false;
        found = found or find_2_cycle(0,1);
        found = found or find_2_cycle(0,2);
        found = found or find_2_cycle(1,2);
        found = found or find_3_cycle(0,1,2);
        found = found or find_3_cycle(0,2,1);
    } while(found);
    
    for0(i,n) 
        total -= coins[i][asgn[i]];
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 15872