using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Myon
{
public Myon() { }
public static int Main()
{
new Myon().calc();
return 0;
}
Scanner cin;
int[,] b = new int[3, 3];
int[,] c = new int[3, 3];
int[,] used = new int[3, 3];
int N = 3;
int dfs(int d)
{
if (d == 9)
{
//全部埋まった時
int ans = 0;
for (int i = 0; i < N - 1; i++)
{
for (int j = 0; j < N; j++)
{
if (used[i, j] == used[i + 1, j])
{
ans += b[i, j];
}
}
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N - 1; j++)
{
if (used[i, j] == used[i, j + 1])
{
ans += c[i, j];
}
}
}
return ans;
}
//直大くんのターン
else if (d % 2 == 0)
{
int ans = 0;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (used[i, j] != 0) continue;
used[i, j] = 1;
int temp = dfs(d + 1);
ans = Math.Max(temp, ans);
used[i, j] = 0;
}
}
return ans;
}
//直子さんのターン
else
{
int ans = 9999999;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (used[i, j] != 0) continue;
used[i, j] = 2;
int temp = dfs(d + 1);
ans = Math.Min(temp, ans);
used[i, j] = 0;
}
}
return ans;
}
}
void calc()
{
cin = new Scanner();
int sum = 0;
for (int i = 0; i < N - 1; i++)
{
for (int j = 0; j < N; j++)
{
b[i, j] = cin.nextInt();
sum += b[i, j];
}
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N - 1; j++)
{
c[i, j] = cin.nextInt();
sum += c[i, j];
}
}
int ans = dfs(0);
int ans2 = sum - ans;
Console.WriteLine(ans);
Console.WriteLine(ans2);
}
}
class Scanner
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner()
{
s = new string[0];
i = 0;
}
public string next()
{
if (i < s.Length) return s[i++];
string st = Console.ReadLine();
while (st == "") st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt()
{
return int.Parse(next());
}
public long nextLong()
{
return long.Parse(next());
}
public double nextDouble()
{
return double.Parse(next());
}
}