import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;

void main() {
    int[] w;
    foreach (i; 0..10) {
        w ~= readln.chomp.to!int;
    }
    int[] k;
    foreach (i; 0..10) {
        k ~= readln.chomp.to!int;
    }

    writefln("%d %d", solve(w), solve(k));
}

int solve(int[] a) {
    return a.sort!("a > b")[0..3].reduce!("a + b");
}