Problem:
Score : 800 points

Problem Statement

There are X+Y+Z people, conveniently numbered 1 through X+Y+Z.
Person i has A_i gold coins, B_i silver coins and C_i bronze coins.

Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people.
It is not possible to get two or more different colors of coins from a single person.
On the other hand, a person will give all of his/her coins of the color specified by Snuke.

Snuke would like to maximize the total number of coins of all colors he gets.
Find the maximum possible number of coins.

Constraints

1 \leq X

1 \leq Y

1 \leq Z

X+Y+Z \leq 10^5

1 \leq A_i \leq 10^9

1 \leq B_i \leq 10^9

1 \leq C_i \leq 10^9

Input

Input is given from Standard Input in the following format:

X Y Z
A_1 B_1 C_1
A_2 B_2 C_2
:
A_{X+Y+Z} B_{X+Y+Z} C_{X+Y+Z}

Output

Print the maximum possible total number of coins of all colors he gets.

Sample Input 1

1 2 1
2 4 4
3 2 1
7 6 7
5 2 3

Sample Output 1

18

Get silver coins from Person 1, silver coins from Person 2, bronze coins from Person 3 and gold coins from Person 4.
In this case, the total number of coins will be 4+2+7+5=18.
It is not possible to get 19 or more coins, and the answer is therefore 18.

Sample Input 2

3 3 2
16 17 1
2 7 5
2 16 12
17 7 7
13 2 10
12 18 3
16 15 19
5 6 2

Sample Output 2

110

Sample Input 3

6 2 4
33189 87907 277349742
71616 46764 575306520
8801 53151 327161251
58589 4337 796697686
66854 17565 289910583
50598 35195 478112689
13919 88414 103962455
7953 69657 699253752
44255 98144 468443709
2332 42580 752437097
39752 19060 845062869
60126 74101 382963164

Sample Output 3

3093929975

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		long sum;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int x = in.nextInt();
			int y = in.nextInt();
			int z = in.nextInt();
			int n = x + y + z;
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
				c[i] = in.nextInt();
			}

			TreeSet<Integer> ab = new TreeSet<>(diffComparator(a, b));
			TreeSet<Integer> ac = new TreeSet<>(diffComparator(a, c));
			TreeSet<Integer> ba = new TreeSet<>(diffComparator(b, a));
			TreeSet<Integer> bc = new TreeSet<>(diffComparator(b, c));
			TreeSet<Integer> ca = new TreeSet<>(diffComparator(c, a));
			TreeSet<Integer> cb = new TreeSet<>(diffComparator(c, b));

			sum = 0;
			for (int i = 0; i < n; i++) {
				if (i < x) {
					sum += a[i];
					ab.add(i);
					ac.add(i);
				} else if (i < x + y) {
					sum += b[i];
					ba.add(i);
					bc.add(i);
				} else {
					sum += c[i];
					ca.add(i);
					cb.add(i);
				}
			}

			while (true) {
				boolean changed = false;

				if (move2(ab, ba, ac, bc, a, b)) changed = true;
				if (move2(ba, ab, bc, ac, b, a)) changed = true;

				if (move2(ac, ca, ab, cb, a, c)) changed = true;
				if (move2(ca, ac, cb, ab, c, a)) changed = true;

				if (move2(bc, cb, ba, ca, b, c)) changed = true;
				if (move2(cb, bc, ca, ba, c, b)) changed = true;

				if (move3(ab, ac, ba, bc, ca, cb, a, b, c)) changed = true;
				if (move3(ab, ac, ca, cb, ba, bc, a, c, b)) changed = true;
				if (move3(ba, bc, ab, ac, ca, cb, b, a, c)) changed = true;
				if (move3(ba, bc, ca, cb, ab, ac, b, c, a)) changed = true;
				if (move3(ca, cb, ab, ac, ba, bc, c, a, b)) changed = true;
				if (move3(ca, cb, ba, bc, ab, ac, c, b, a)) changed = true;

				if (!changed) {
					break;
				}
			}

			out.println(sum);
		}

		private Comparator<Integer> diffComparator(int[] a, int[] b) {
			return (i, j) -> {
				int u = a[i] - b[i];
				int v = a[j] - b[j];
				if (u != v) {
					return u < v ? -1 : 1;
				}
				if (!i.equals(j)) {
					return i < j ? -1 : 1;
				}
				return 0;
			};
		}

		private boolean move2(TreeSet<Integer> ab, TreeSet<Integer> ba, TreeSet<Integer> ac, TreeSet<Integer> bc, int[] a, int[] b) {
			int i = ab.first();
			int j = ba.first();
			long add = (long) -a[i] + b[i] - b[j] + a[j];
			if (add > 0) {
				ab.remove(i);
				ac.remove(i);
				ab.add(j);
				ac.add(j);
				ba.remove(j);
				bc.remove(j);
				ba.add(i);
				bc.add(i);
				sum += add;
				return true;
			}
			return false;
		}

		private boolean move3(TreeSet<Integer> ab, TreeSet<Integer> ac, TreeSet<Integer> ba, TreeSet<Integer> bc, TreeSet<Integer> ca, TreeSet<Integer> cb, int[] a, int[] b, int[] c) {
			int i = ab.first();
			int j = bc.first();
			int k = ca.first();
			long add = (long) -a[i] + b[i] - b[j] + c[j] - c[k] + a[k];
			if (add > 0) {
				ab.remove(i);
				ac.remove(i);
				ab.add(k);
				ac.add(k);
				ba.remove(j);
				bc.remove(j);
				ba.add(i);
				bc.add(i);
				ca.remove(k);
				cb.remove(k);
				ca.add(j);
				cb.add(j);
				sum += add;
				return true;
			}
			return false;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}