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 (2i - 1)-th man in the line (for the current moment) talks with the (2i)-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 gij and the j-th student's happiness increases by gji. 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.

Input

The input consists of five lines, each line contains five space-separated integers: the j-th number in the i-th line shows gij (0 ≤ gij ≤ 105). It is guaranteed that gii = 0 for all i.

Assume that the students are numbered from 1 to 5.

Output

Print a single integer — the maximum possible total happiness of the students.

Examples

Input

0 0 0 0 9
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
7 0 0 0 0


Output

32


Input

0 43 21 18 2
3 0 21 11 65
5 2 0 1 4
54 62 12 0 99
87 64 81 33 0


Output

620

Note

In the first sample, the optimal arrangement of the line is 23154. In this case, the total happiness equals:

(g23 + g32 + g15 + g51) + (g13 + g31 + g54 + g45) + (g15 + g51) + (g54 + g45) = 32.
import java.io.*;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*; 



// public
class Solution{

  static int[] sieve(int n)
    {
        boolean height[] = new boolean[n+1];
        int prime[] = new int[n+1];
        for(int i=0;i<=n;i++)
            height[i] = true;
        height[0] = false;
        height[1] = false;
        int count=0;
        for(int i=2;i*i<=n;i++)
        {
            if(height[i])
            {
                for(int j=i*i;j<=n;j+=i)
                {
                    height[j] = false;
                }
            }
        }
        int prime_prime_count = 0;
        for(int i=0;i<=n;i++)
        {
            if(height[i])
            {
               count++;
               if(height[count])
               {
                prime_prime_count++;
                prime[i] = prime_prime_count;
               }
               else
                prime[i] =prime_prime_count;

            }
            else
            {
                if(height[count])
               {
                prime_prime_count++;
                prime[i] = prime_prime_count;
               }
               else
                prime[i] =prime_prime_count;
            }
        }
        // for(int i=0;i<=n;i++)
            // System.out.println(height[i]+" "+prime[i]);
       return prime;
    }
  static class Pair{
    int strength;
    int bonus;
    Pair(int strength,int bonus)
    {
        this.strength = strength;
        this.bonus = bonus;
    }

  }
 static class SortbyStrength implements Comparator<Pair> 
{ 
    public int compare(Pair a, Pair b) 
    { 
        return a.strength - b.strength; 
    } 
} 
  private static BigInteger ncr(int n, int r) 
{
    BigInteger top = BigInteger.ONE;
    BigInteger bot = BigInteger.ONE;
    if(n==r)
        return top;
    for(int i = n; i >n-r; --i){
        top = top.multiply(BigInteger.valueOf(i));
    }

    for(int i = r; i > 1; --i){
        bot = bot.multiply(BigInteger.valueOf(i));
    }

    return top.divide(bot);
}
   
   public static int getCeil(ArrayList<Integer> A, int x)
    {
        int left = 0, right = A.size() - 1;
 
        int ceil = -1;
 
         while (left <= right)
        {
                int mid = (left + right) / 2;
 
              if (A.get(mid) == x) {
                return A.get(mid);
            }
 
                  else if (x < A.get(mid))
            {
                ceil = A.get(mid);
                right = mid - 1;
            }
 
            else
                left = mid + 1;
        }
 
        return ceil;
    }
     public static int getFloor(ArrayList<Integer> A, int x)
    {
        int left = 0, right = A.size() - 1;
 
        int floor = -1;
       while (left <= right)
        {
              int mid = (left + right) / 2;
 
           if (A.get(mid) == x) {
                return A.get(mid);
            }
 
                else if (x < A.get(mid)) {
                right = mid - 1;
            }
 
          else {
                floor = A.get(mid);
                left = mid + 1;
            }
        }
 
        return floor;
    }
   static ArrayList<Integer> sieveOfEratosthenes(int n) 
    { 
        ArrayList<Integer> height = new ArrayList<>();
        boolean prime[] = new boolean[n+1]; 
        for(int i=0;i<n;i++) 
            prime[i] = true; 
        
        for(int p = 2; p*p <=n; p++) 
        { 
            if(prime[p] == true) 
            { 
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        }

        for(int i = 2; i <= n; i++) 
        { 
            if(prime[i] == true) 
                height.add(i);
        } 
        return height;
    } 
      
      static void merge(int height[], int l, int m, int r) 
    { 
       
        int n1 = m - l + 1; 
        int n2 = r - m; 

        int L[] = new int [n1]; 
        int R[] = new int [n2]; 
  

        for (int i=0; i<n1; ++i) 
            L[i] = height[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = height[m + 1+ j]; 
  
  
        
        int i = 0, j = 0; 
  
       
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                height[k] = L[i]; 
                i++; 
            } 
            else
            { 
                height[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
  
    
        while (i < n1) 
        { 
            height[k] = L[i]; 
            i++; 
            k++; 
        } 
  
        while (j < n2) 
        { 
            height[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
  
  
   static void sort(int height[], int l, int r) 
    { 
        if (l < r) 
        { 
            int m = (l+r)/2; 
  
            sort(height, l, m); 
            sort(height , m+1, r); 
  
           merge(height, l, m, r); 
        } 
    } 
      
    public static long fibologn(long n,HashMap<Long,Long> map)
      {
        if(map.get(n)!=null) return map.get(n);
        long k = n/2;
        if(n%2==0)
        {
             map.put(n,((fibologn(k,map)*fibologn(k,map))+(fibologn(k-1,map)*fibologn(k-1,map)))%1000000007);
            return map.get(n);
        }
        else
        {
             map.put(n,((fibologn(k,map)*fibologn(k+1,map))+(fibologn(k-1,map)*fibologn(k,map)))%1000000007);
             return map.get(n);
        }

      }
    static int ceilSearch(int height[], int low, int high, int x) 
    { 
      int mid;     
        
      if(x <= height[low]) 
        return low;  
    
      if(x > height[high]) 
        return -1;   
       
      mid = (low + high)/2;  

      if(height[mid] == x) 
        return mid; 
    
      else if(height[mid] < x) 
      { 
        if(mid + 1 <= high && x <= height[mid+1]) 
          return mid + 1; 
        else
          return ceilSearch(height, mid+1, high, x); 
      } 
       
    
      { 
        if(mid - 1 >= low && x > height[mid-1]) 
          return mid; 
        else    
          return ceilSearch(height, low, mid - 1, x); 
      } 
    }
    static long countOdd(long L, long R) 
    { 
        long N = (R - L) / 2; 
        if (R % 2 != 0 || L % 2 != 0) 
            N++; 
  
        return N; 
    } 
 public static int[] swap(int data[], int left, int right) 
    { 
        int a = data[left]; 
        data[left] = data[right]; 
        data[right] = a;  
        return data; 
    } 
  
    public static int[] reverse(int data[], int left, int right) 
    { 
        while (left < right) { 
            int a = data[left]; 
            data[left++] = data[right]; 
            data[right--] = a; 
        } 
  
       
        return data; 
    } 
  
    public static boolean findNextPermutation(int data[]) 
    { 

        if (data.length <= 1) 
            return false; 
  
        int last = data.length - 2; 
  
        while (last >= 0) { 
            if (data[last] < data[last + 1]) { 
                break; 
            } 
            last--; 
        } 

        if (last < 0) 
            return false; 
  
        int nextGreater = data.length - 1; 


        for (int i = data.length - 1; i > last; i--) { 
            if (data[i] > data[last]) { 
                nextGreater = i; 
                break; 
            } 
        } 
        data = swap(data, nextGreater, last); 
        data = reverse(data, last + 1, data.length - 1); 
        return true; 
    } 
      
      public static void main(String[] args) throws Exception {
        FastScanner cin = new FastScanner(System.in);
        StringBuffer ans = new StringBuffer();
        int arr[][] = new int[6][6];
        for(int i=1;i<6;i++)
        {
            for(int j=1;j<6;j++)
            {
                arr[i][j] = cin.nextInt();
            }
        }
        int a[] = {1,2,3,4,5};
        int max=Integer.MIN_VALUE;
        do
        {
            // System.out.println("YES");
            int temp_sum = arr[a[0]][a[1]] + arr[a[1]][a[0]]+
            arr[a[2]][a[3]]+arr[a[3]][a[2]]+arr[a[1]][a[2]]+
            arr[a[2]][a[1]]+arr[a[3]][a[4]]+arr[a[4]][a[3]]+
            arr[a[2]][a[3]]+arr[a[3]][a[2]]+arr[a[3]][a[4]]+
            arr[a[4]][a[3]];
            if(temp_sum>max)
                max = temp_sum;
        }while(findNextPermutation(a));
        System.out.println(max);

    }
        
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
 
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
 
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
 
            return tokenizer.nextToken("\n");
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
         
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}
