// wrong usage of mask's

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <vector>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42;
#endif

class DSU {
public:
    int n;
    vector <int> par;

    DSU() {};
    DSU(int n) {
        this->n = n;
        par.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }

    int root(int x) {
        return x == par[x] ? x : (par[x] = root(par[x]));
    }

    void join(int x, int y) {
        par[root(x)] = root(y);
    }
};

const int N = 12;

int a[N][N];
vector < pair <int, int> > edges;

inline void add(int u, int v, int c) {
    a[u][v] = a[v][u] = c;
    edges.push_back(make_pair(u, v));
}

inline int getLog(int x) {
    int ret = 0;
    while (x > 0) {
        ret++;
        x /= 2;
    }
    return ret;
}

int aa[N][N];
void makeGraph(int mask) {
    memcpy(aa, a, sizeof(a));
    for (int i = 0; i < (int)edges.size(); i++) {
        int u = edges[i].first;
        int v = edges[i].second;
        if (((mask >> i) & 1) && a[u][v] > 0) {
            aa[u][v] -= 1;
            aa[v][u] -= 1;
        }
    }
}


long long tot[N];
int odds[N];
int deg[N];
long long findAnswer() {
    DSU dsu(N);
    memset(deg, 0, sizeof(deg));
    for (int i = 0; i < (int)edges.size(); i++) {
        int u = edges[i].first;
        int v = edges[i].second;
        if (aa[u][v] > 0) {
            dsu.join(u, v);
            deg[u] += getLog(aa[u][v]);
            deg[v] += getLog(aa[v][u]);
        }
    }
    memset(odds, 0, sizeof(odds));
    for (int i = 0; i < N; i++) {
        if (deg[i] & 1) {
            odds[dsu.root(i)]++;
        }
    }
    memset(tot, 0, sizeof(tot));
    for (int i = 0; i < (int)edges.size(); i++) {
        int u = edges[i].first;
        int v = edges[i].second;
        tot[dsu.root(u)] += aa[u][v];
    }
    long long ret = 0;
    for (int i = 0; i < N; i++) {
        if (dsu.root(i) == i) {
            if (odds[i] <= 2 && tot[i] > ret) {
                ret = tot[i];
            }
        }
    }
    return ret;
}

int main() {
    clock_t start = clock();
    freopen("coins.in", "r", stdin);
    freopen("coins.out", "w", stdout);
    for (int i = 0; i < 5; i++) {
        int ii = i / 2;
        if (i & 1) {
            for (int j = 0, c; j < 4; j++) {
                scanf("%d", &c);
                add(4 * ii + j, 4 * (ii + 1) + j, c);
            }
        } else {
            for (int j = 0, c; j < 3; j++) {
                scanf("%d", &c);
                add(4 * ii + j, 4 * ii + j + 1, c);
            }
        }
    }
    long long best = 0;
    for (int mask = 0; mask < (1 << edges.size()); mask++) {
        makeGraph(mask);
        long long cur = findAnswer();
        if (cur > best) {
            best = cur;
        }
    }
    printf("%lld\n", best);
    eprintf("Total: %.2lf\n", (double)(clock() - start) / CLOCKS_PER_SEC);
    return 0;
}
