Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. 

There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory shower door. As soon as the shower opens, the first person from the line enters the shower. After a while the first person leaves the shower and the next person enters the shower. The process continues until everybody in the line has a shower.

Having a shower takes some time, so the students in the line talk as they wait. At each moment of time the students talk in pairs: the (2*i* - 1)-th man in the line (for the current moment) talks with the (2*i*)-th one. 

Let's look at this process in more detail. Let's number the people from 1 to 5. Let's assume that the line initially looks as 23154 (person number 2 stands at the beginning of the line). Then, before the shower opens, 2 talks with 3, 1 talks with 5, 4 doesn't talk with anyone. Then 2 enters the shower. While 2 has a shower, 3 and 1 talk, 5 and 4 talk too. Then, 3 enters the shower. While 3 has a shower, 1 and 5 talk, 4 doesn't talk to anyone. Then 1 enters the shower and while he is there, 5 and 4 talk. Then 5 enters the shower, and then 4 enters the shower.

We know that if students *i* and *j* talk, then the *i*-th student's happiness increases by *g*<sub class="lower-index">*ij*</sub> and the *j*-th student's happiness increases by *g*<sub class="lower-index">*ji*</sub>. Your task is to find such initial order of students in the line that the total happiness of all students will be maximum in the end. Please note that some pair of students may have a talk several times. In the example above students 1 and 5 talk while they wait for the shower to open and while 3 has a shower.
The input consists of five lines, each line contains five space-separated integers: the *j*-th number in the *i*-th line shows *g*<sub class="lower-index">*ij*</sub> (0 ≤ *g*<sub class="lower-index">*ij*</sub> ≤ 10<sup class="upper-index">5</sup>). It is guaranteed that *g*<sub class="lower-index">*ii*</sub> = 0 for all *i*.

Assume that the students are numbered from 1 to 5.
    /*⠀⠀⠀⢀⣴⢟⡵⢢⣒⣀⡠⢤⠄⢤⡀⠥⢖⡬⡀⠔⠢⣤⣉⠳⣤⡈⣿⣿⣿⣿
    ⠀⠀⢀⣼⢣⢿⣿⢿⡿⣿⣿⣿⣾⣷⣦⣤⣑⢿⣽⣾⣴⣬⣻⣿⣾⣿⣾⣿⣿⣿
    ⠀⢠⢊⣧⣾⡎⣧⢀⣧⢻⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⠀⠁⢸⣿⣿⣽⣿⣾⣾⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⠀⢠⣿⣿⣿⣿⣿⣿⡝⡟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⢲⠞⢹⡏⣿⣿⣿⣿⣷⣾⢼⣻⣿⣿⣟⢿⢯⡻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
    ⡇⢀⠸⠀⢻⣸⣿⣿⡯⠉⠉⢙⠉⠻⣿⢦⠙⠿⣿⡯⠽⢿⣿⣿⣿⣿⣿⣿⣿⣿
    ⠀⠈⡄⠇⢸⠇⢿⣿⣿⡀⠀⡘⠀⠀⠀⠁⠁⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣯
    ⢀⠀⠰⠀⡈⡘⡸⡟⣧⠉⠀⠣⣤⣤⡀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠁⠻⣏⠻⢿
    ⠈⣆⠀⢣⠐⡁⠀⠇⢫⢡⡀⢀⣈⠉⠀⠀⠀⠀⠀⠀⠀⣼⣹⣏⡏⠀⠀⠈⡶⠁
    ⠀⠸⣆⠀⠡⡐⠌⠀⠈⡇⡿⡦⢃⡧⠭⠐⠂⠀⠀⣀⡾⠋⣿⠿⠀⠀⡠⠊⠀⠀
    ⡀⠐⢝⠦⡀⠐⢌⠄⢀⡠⠋⣠⣾⡁⠀⠀⣀⣴⠞⠋⢀⣠⠇⠀⡠⠊⡠⠂⠀⠀
    ⠀⠉⠉⢛⡪⢕⣖⡩⠤⣀⣀⡀⠉⠉⢻⢟⣫⣉⠉⣉⡡⢗⡪⣋⣀⣜⡁⠀⠀⠀
    ⠀⠠⠐⣂⡥⠊⠁⠀⠀⠀⠙⠫⣽⡳⡌⡦⣈⡙⣺⠶⠚⢓⡉⠀⠀⠀⠀⠉⠉⠁
    */

    #include <cmath>
    #include <unordered_set>
    #include <unordered_map>
    #include <list>
    #include <set>
    #include <climits>
    #include <queue>
    #include <vector>
    #include <map>
    #include <cstdlib>
    #include <fstream>
    #include <iomanip>
    #include <iostream>
    #include <sstream> // istringstream buffer(myString);
    #include <stack>
    #include <algorithm>
    #include <cstring>
    #include <cassert>
    using namespace std;
    #define bit(x, i) (x & (1 << i)) // select the bit of position i of x
    #define ttt cin.tie(NULL)
    #define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x
    #define hBit(msb, n) asm("bsrl %1,%0": "=r"(msb): "r"(n)) // get the highest bit of x, maybe the fastest
    #define max(a, b) (a < b ? b : a)
    #define min(a, b) (a < b ? a : b)
    #define IN(i, l, r) (l < i && i < r) // the next for are for checking bound
    #define LINR(l, i, r) (l <= i && i <= r)
    #define LIN(l, i, r) (l <= i && i < r)
    #define INR(l, i, r) (l < i && i <= r)
    #define F(i, low, high_1) for (int i = low; i < high_1; i++) // next four are for "for loops"
    #define FE(i, low, high) for (int i = low; i <= high; i++)
    #define FF(i, high_1, low) for (int i = low; i > high_1; i--)
    #define rep(i, n) for (i = 0; i < n; ++i)
    #define repp(i, n) for (i = 0; i <= n; ++i)
    #define FFE(i, high, low) for (int i = low; i >= high; i--)
    #define getI(a) scanf("%d", &a) // next three are handy ways to get ints, it's also force you to use '&' sign
    #define getII(a, b) scanf("%d%d", &a, &b)
    #define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
    #define wez(n) int(n);scanf("%d", &(n)) // if the input is right after the definition of a variable
    #define wez2(n, m) int(n), (m);scanf("%d %d", &(n), &(m))
    #define wez3(n, m, k) int(n), (m), (k); scanf("%d %d %d", &(n), &(m), &(k))
    #define CY cout << "YES\n";
    #define CN cout << "NO\n";
    #define TESTS wez(testow) while (testow--) // for multilple cases problems
    #define whileZ int T; getI(T); while (T--)                           // the same as above
    #define getS(x) scanf("%s", x)            // get a char* string
    #define all(a, x) memset(a, x, sizeof(a)) // set elements of array to some value
    #define char2Int(c) (c - '0')
    #define lastEle(vec) vec[vec.size() - 1]
    #define SZ(x) ((int)((x).size()))
    #define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b
    #define REMIN(a, b) (a) = min((a), (b));
    #define FOREACH(i, t) for (typeof(t.begin()) i = t.begin(); i != t.end(); i++) // traverse an STL data structure
    #define ALL(c) (c).begin(), (c).end()                                          // handy for function like "sort()"
    #define PRESENT(c, x) ((c).find(x) != (c).end())
    #define CONTAINS(c, x) (find(ALL(c), x) != (c).end())
    #define ll long long // data types used often, but you don't want to type them time by time
    #define ull unsigned long long
    #define ui unsigned int
    #define us unsigned short
    #define IOS ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf
    #define INF 1001001001
    #define SI set<int>
    #define PI 3.1415926535897932384626
    // for map, pair
    #define mp make_pair
    #define fi first
    #define se second
    // for debug
    inline void pisz(int n) { printf("%d\n", n); }
    #define DBG(vari) cerr << #vari << " = " << (vari) << endl;
    #define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ')
    #define printV(a) printA(a, 0, a.size() - 1)
    #define MAXN 10000
    #define INFF 0x7FFFFFFF
    #define dp(n, x) vector<int> dp(n, x) // make dp array
    // for vectors
    #define pb push_back
    #define pp pop_back
    #define REVERSE(v) reverse(ALL(v))
    #define factorial(p, n) int i = 0;FE(i, 1, p) n *= i;
    typedef int elem_t;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef pair<int, int> ii;
    // directions
    const int mod = 1000000007;
    const int MAX6 = 1000005;
    const int ud[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    const int udrl[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
    template <typename T, typename TT>
    ostream &operator<<(ostream &s, pair<T, TT> t) { return s << "(" << t.first << "," << t.second << ")"; }
    template <typename T>
    ostream &operator<<(ostream &s, vector<T> t){ F(i, 0, SZ(t)) s << t[i] << " ";return s;}
    bool compare_str(string &s1,string &s2){ return s1.size() < s2.size();}
    //ordered set



class Trie {
public:
    Trie() {}
    void insert(string word) {
        Trie* node = this;
        for (char ch : word) {
            if (!node->next.count(ch)) { node->next[ch] = new Trie(); }
            node = node->next[ch];
        }
        node->isword = true;
    }

    bool search(string word) {
        Trie* node = this;
        for (char ch : word) {
            if (!node->next.count(ch)) { return false; }
            node = node->next[ch];
        }
        return node->isword;
    }

    bool startsWith(string prefix) {
        Trie* node = this;
        for (char ch : prefix) {
            if (!node->next.count(ch)) { return false; }
            node = node->next[ch];
        }
        return true;
    }

private:
    map<char, Trie*> next = {};
    bool isword = false;
};









void solve() {
    vector<vector<int>> a(5, vector<int>(5));
    vi perm = {0, 1, 2, 3, 4};
    for(auto &x : a){
        for(auto &p : x){
            cin>>p;
        }
    }
    ll ans = 0;
    do{
        ll res = a[perm[1]][perm[0]]+a[perm[0]][perm[1]]+a[perm[3]][perm[2]]+a[perm[2]][perm[3]]+a[perm[2]][perm[1]]+a[perm[1]][perm[2]]+a[perm[4]][perm[3]]+a[perm[3]][perm[4]]+a[perm[3]][perm[2]]+a[perm[2]][perm[3]]+a[perm[4]][perm[3]]+a[perm[3]][perm[4]];
        REMAX(ans, res);
    }
    while(next_permutation(ALL(perm)));
    cout<<ans<<'\n';
}

int main()
{
    IOS; ttt; solve();
    return 0;
}