#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <ctime>

#define dbg(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)

typedef std::pair <int,int> pii;
typedef long long ll;

clock_t startTime;
const double TIME_LIMIT = 2.0;

const int N = 3;
const int M = 4;
int a[2 * N - 1][2 * M - 1];

void printMap() {
    for (int x = 0; x < 2 * N - 1; ++x) {
        for (int y = 0; y < 2 * M - 1; ++y) {
            dbg("%15d", a[x][y]);
        }
        dbg("\n");
    }
    dbg("@@@@\n");
}

ll bestAns;

class HashTable {
private:
    static const int MAX_HASH = (1 << 25) - 1;
    ll values[MAX_HASH + 1], table[MAX_HASH + 1];
    int size_;
public:
    HashTable() {
        memset(table, 0xFF, sizeof(table));
        memset(values, 0xFF, sizeof(values));
        size_ = 0;
    }

    bool tryGetValue(ll hash, ll & value) const {
        int x = findPos(hash);
        if (table[x] == hash) {
            value = values[x];
            return true;
        }
        value = -1;
        return false;
    }

    void setValue(ll hash, int value) {
        int x = findPos(hash);
        if (table[x] != hash) {
            ++size_;
            table[x] = hash;
            if (size_ % 1000000 == 0) {
                dbg("cache.size() == %d, bestAns = %lld\n", size_, bestAns);
            }
        }
        values[x] = value;
    }

    int size() const {
        return size_;
    }

private:
    int findPos(ll hash) const {
        if (hash == -1) {
            dbg("Hash equals to -1 is forbidden!");
            throw 42;
        }
        int x = (int)(hash & MAX_HASH);
        while (table[x] != -1 && table[x] != hash) {
            x = (x + 1) & MAX_HASH;
        }
        return x;
    }
};

HashTable cache;

ll calcHash() {
    const ll P = ll(1e9) + 7;
    ll hash = a[0][0];
    for (int x = 0; x < 2 * N - 1; ++x) {
        for (int y = 0; y < 2 * M - 1; ++y) {
            if ((x + y) % 2 == 1) {
                hash = hash * P + a[x][y];
            }
        }
    }
    return hash;
}

const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};

bool used[2 * N - 1][2 * M - 1];

ll dfs(int x, int y) {
    ll res = 0;
    for (int i = 0; i < 4; ++i) {
        int x1 = x + dx[i];
        int y1 = y + dy[i];
        if (0 <= x1 && x1 < 2 * N - 1 && 0 <= y1 && y1 < 2 * M - 1 && a[x1][y1] != 0 && !used[x1][y1]) {
            used[x1][y1] = true;
            res += a[x1][y1];
            res += dfs(x1 + dx[i], y1 + dy[i]);
        }
    }
    return res;
}

bool hasSmallMaxBound(ll curSum) {
    int x0 = a[0][0] / (2 * M);
    int y0 = a[0][0] % (2 * M);
    memset(used, 0, sizeof(used));
    ll sum = dfs(x0, y0);
    return curSum + 2 * sum <= bestAns;
}

int timer;

ll brute(ll curSum, int cntMoves) {
    ++timer;
    if ((timer & ((1 << 18) - 1)) == 0) {
        if ((double)(clock() - startTime) / CLOCKS_PER_SEC > 0.9 * TIME_LIMIT) {
            std::cout << bestAns << std::endl;
            dbg("Exit by time limit. Time = %d\n", timer);
            exit(0);
        }
    }

    bool useCache = cntMoves % 3 == 0;
    ll hash = -1;
    if (useCache) {
        hash = calcHash();
        ll fromCache;
        if (cache.tryGetValue(hash, fromCache)) {
            return fromCache;
        }
    }

//    printMap();

    ll curRes = curSum;

    if (!hasSmallMaxBound(curSum)) {
        int x0 = a[0][0] / (2 * M);
        int y0 = a[0][0] % (2 * M);
        std::vector <pii> dirs;
        for (int i = 0; i < 4; ++i) {
            int x1 = x0 + dx[i];
            int y1 = y0 + dy[i];
            if (0 <= x1 && x1 < 2 * N - 1 && 0 <= y1 && y1 < 2 * M - 1 && a[x1][y1] != 0) {
                dirs.push_back(pii(-a[x1][y1], i));
            }
        }
        std::sort(dirs.begin(), dirs.end());
        for (int ii = 0; ii < int(dirs.size()); ++ii) {
            int i = dirs[ii].second;
            int x1 = x0 + dx[i];
            int y1 = y0 + dy[i];
            int x2 = x1 + dx[i];
            int y2 = y1 + dy[i];
            int oldValue = a[x1][y1];
            a[x1][y1] /= 2;
            a[0][0] = x2 * 2 * M + y2;
            curRes = std::max(curRes, brute(curSum + oldValue, cntMoves + 1));
            a[x1][y1] = oldValue;
        }
        a[0][0] = x0 * 2 * M + y0;
    }

    if (useCache) {
        cache.setValue(hash, curRes);
    }
    bestAns = std::max(bestAns, curRes);
    return curRes;
}

int main() {
    startTime = clock();

    freopen("coins.in", "r", stdin);
    freopen("coins.out", "w", stdout);

    for (int x = 0; x < 2 * N - 1; ++x) {
        for (int y = 0; y < 2 * M - 1; ++y) {
            if ((x + y) % 2 == 1) {
                scanf("%d", &a[x][y]);
            }
        }
    }

    bestAns = 0;
    for (int x = 0; x < 2 * N - 1; ++x) {
        for (int y = 0; y < 2 * M - 1; ++y) {
            if (x % 2 == 0 && y % 2 == 0) {
                a[0][0] = x * 2 * M + y;
                brute(0, 0);
            }
        }
    }
    std::cout << bestAns << std::endl;

    dbg("cache.size() = %d\n", cache.size());
    return 0;
}