#include<bits/stdc++.h>;

using namespace std;

long i,j,x,n,m;
long a[1000][1000],b[1000][1000];
long tracerow[1000],tracecol[1000],num;

long Max(long x, long y)
{
 return (x>y) ? x:y;
}

int main()
{
	
 freopen("BAI5.INP","r",stdin);
 freopen("BAI5.OUT","w",stdout);
 cin>>n>>m;
 for (i=1;i<=n;i++)
  for (j=1;j<=m;j++) cin>>a[i][j];
 memset(b,0,sizeof(b));
 b[n][1]=a[n][1];
 for (i=n-1;i>=1;i--) b[i][1]=b[i+1][1]+a[i][1];
 for (j=2;j<=m;j++) b[n][j]=b[n][j-1]+a[n][j];
 for (i=n-1;i>=1;i--)
  for (j=2;j<=m;j++)
   b[i][j]=Max(b[i+1][j],b[i][j-1])+a[i][j];
 cout<<b[1][m]<<endl;
 num=1;
 tracerow[1]=1;
 tracecol[1]=m;
 i=1; j=m;
 while ((i!=n) || (j!=1))
 {
  if (j==1)
  {
   num++; i++;
   tracerow[num]=i;
   tracecol[num]=j;
  }
  else
  if (i==n)
  {
   num++; j--;

   tracerow[num]=i;
   tracecol[num]=j;
  }
  else
  {
   if (a[i][j]+b[i+1][j]==b[i][j])
   {
    num++; i++;
    tracerow[num]=i;
    tracecol[num]=j;
   }
   else
   {
    num++; j--;
    tracerow[num]=i;
    tracecol[num]=j;
   }
  }
 }
 for (i=num;i>1;i--) cout<<"("<<tracerow[i]<<","<<tracecol[i]<<") => ";
 cout<<"("<<tracerow[1]<<","<<tracecol[1]<<")";

 return 0;}
