// Slower C++ solution:
/* 

 * File:   main.cpp

 * Author: Prowindy

 *

 * Created on 2011å¹´8æ24æ¥, ä¸å2:27

 */

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <string.h>

#include <queue>

using namespace std;

int dp[16][16][8][8][8];



int main() {

    for (int h, w; scanf("%d%d", &h, &w) && h;) {

        int table[16][16];

        int x, y;

         for (y = 0; y < h; y++)

        for (x = 0; x < w; x++)

                scanf("%d", &table[x][y]);



        int startX, startY, goalX, goalY;

        cin >> startY >> startX >> goalY >> goalX;

        vector<int> node;

        priority_queue<vector<int>, vector<vector<int> >, greater<vector<int> > > q;

        {



            node.push_back(0);

            node.push_back(startX);

            node.push_back(startY);

            node.push_back(1);

            node.push_back(2);

            node.push_back(3);

            q.push(node);

        }



        memset(dp, 100, sizeof (dp));



        int oo = dp[0][0][0][0][0];

        dp[startX][startY][1][2][3] = 0;



        while (!q.empty()) {

            const vector<int> node = q.top();

            q.pop();

            const int cost = node[0];

            const int x = node[1];

            const int y = node[2];

            const int up = node[3];

            const int south = node[4];

            const int east = node[5];



            if (dp[x][y][up][south][east] != cost) {

                continue;

            }



            // æ±è¥¿åå

            for (int dir = 0; dir < 4; ++dir) {

                int nx, ny, nup, nsouth, neast, ncost;



                switch (dir) {

                    case 0:

                        //æ±

                        if (x + 1 == w) {

                            continue;

                        }

                        nx = x + 1;

                        ny = y;

                        nup = 7 - east;

                        nsouth = south;

                        neast = up;

                        break;

                    case 1:

                        //è¥¿

                        if (x == 0) {

                            continue;

                        }

                        nx = x - 1;

                        ny = y;

                        nup = east;

                        nsouth = south;

                        neast = 7 - up;

                        break;

                    case 2:

                        //å

                        if (y + 1 == h) {

                            continue;

                        }

                        nx = x;

                        ny = y + 1;

                        nup = 7 - south;

                        nsouth = up;

                        neast = east;

                        break;

                    case 3:

                        //å

                        if (y == 0) {

                            continue;

                        }

                        nx = x;

                        ny = y - 1;

                        nup = south;

                        nsouth = 7 - up;

                        neast = east;

                        break;

                }



                ncost = cost + table[nx][ny] * (7 - nup);



                if (dp[nx][ny][nup][nsouth][neast] <= ncost) {

                    continue;

                }

                dp[nx][ny][nup][nsouth][neast] = ncost;



                vector<int> next;

                next.push_back(ncost);

                next.push_back(nx);

                next.push_back(ny);

                next.push_back(nup);

                next.push_back(nsouth);

                next.push_back(neast);



                q.push(next);

            }

        }



        int best = oo;

        for (int i = 1; i <= 6; ++i) {

            for (int j = 1; j <= 6; ++j) {

                for (int k = 1; k <= 6; ++k) {

                    best = min(best, dp[goalX][goalY][i][j][k]);

                }

            }

        }

        cout << best << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 4.8913504991815895x):
#include<stdio.h>

typedef struct duitype

{

	long x,y,z;

}duitype;

duitype dui[1000000];

long jl[7][7][7][7][7][7];

bool bj[11][11][1000];

long temp[7];

long vv[7];

long v[46657][7];

long have[11][11][1000];

long aa,a1,b1,c1,d1,e1,f1,a2,b2,head,last,x,y,z,top,i,ans,k,j,place,zz,n,m;

long map[105][105];

void cha(long a,long b,long c,long d)

{

	long t;

	t=temp[a];

	temp[a]=temp[b];

	temp[b]=temp[c];

	temp[c]=temp[d];

	temp[d]=t;

}

long change(long z,char c)

{

	long i;

	for (i=1;i<=6;i++)

	  temp[i]=v[z][i];

	switch(c)

	{

		case 'u':cha(6,3,4,5);break;

		case 'd':cha(4,3,6,5);break;

		case 'r':cha(1,5,2,3);break;

		case 'l':cha(1,3,2,5);break;

	}

	return jl[temp[1]][temp[2]][temp[3]][temp[4]][temp[5]][temp[6]];

}

void ind(long x,long y,long z,long all,char c)

{

	long ne;

  if (x<=0 || x>n || y<=0 || y>m)

    return;

	ne=change(z,c);

  if (have[x][y][ne]>all+vv[v[ne][5]]*map[x][y])

	{

	  have[x][y][ne]=all+vv[v[ne][5]]*map[x][y];

		if (!bj[x][y][ne]){

			bj[x][y][ne]=true;

			last++;

			dui[last].x=x;

			dui[last].y=y;

			dui[last].z=ne;

		}

	} 

	if (x==a2 && y==b2)

	  if (ans>have[x][y][ne])

	  {

	    ans=have[x][y][ne];

	  }

}

int main()

{

	top=0;

	for (a1=1;a1<=6;a1++)

	  for (b1=1;b1<=6;b1++)

  		if (b1!=a1)

	    	for (c1=1;c1<=6;c1++)

	      	if (c1!=a1 && c1!=b1)

						for (d1=1;d1<=6;d1++)

	        		if (d1!=a1 && d1!=b1 && d1!=c1)

								for (e1=1;e1<=6;e1++)

		          		if (e1!=a1 && e1!=b1 && e1!=c1 && e1!=d1)

  	  	        		{

  	  	        			f1=21-a1-b1-c1-d1-e1;

    	  	      			top++;jl[a1][b1][c1][d1][e1][f1]=top;

      	  	    			v[top][1]=a1;v[top][2]=b1;v[top][3]=c1;v[top][4]=d1;v[top][5]=e1;v[top][6]=f1;

        	  	  		} 

  while (scanf("%d %d",&n,&m)==2){

  	if (n==0)

  	  return 0;

  	for (i=1;i<=n;i++)

    	for (j=1;j<=m;j++)

      	for (k=1;k<=top;k++){

        	have[i][j][k]=10000000;

      	  bj[i][j][k]=false;

				}

	  ans=10000000;

  	for (i=1;i<=n;i++)

    	for (j=1;j<=m;j++)

      	scanf("%d",&map[i][j]);

 	  scanf("%d%d%d%d",&a1,&b1,&a2,&b2);

  	a1++;a2++;b1++;b2++;

  	vv[1]=4;vv[2]=3;vv[3]=1;vv[4]=2;vv[5]=6;vv[6]=5;

		z=zz=jl[1][2][3][4][5][6]; 

  	head=0;last=1;dui[1].x=a1;dui[1].y=b1;dui[1].z=z;

  	have[a1][b1][z]=0;

  	while (head<last)

  	{

  		head++;

  		x=dui[head].x;y=dui[head].y;z=dui[head].z;

  	  bj[x][y][z]=false;

			ind(x+1,y,z,have[x][y][z],'d');

    	ind(x-1,y,z,have[x][y][z],'u');

  	  ind(x,y+1,z,have[x][y][z],'r');

    	ind(x,y-1,z,have[x][y][z],'l');

		}

		printf("%ld\n",ans);

  }

}