#include <iostream>
#include <cstdio>

using namespace std;
const int NMAX = 2014;
long long d1[2*NMAX], d2[2*NMAX], sol[2];
pair < int , int > v[2];
int a[NMAX][NMAX];
inline void Update(const int c,const int i,const int j,const long long val){
    if(val > sol[c]){
        sol[c] = val;
        v[c].first = i;
        v[c].second = j;
    }
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("date.in","r",stdin);
        freopen("date.out","w",stdout);
    #endif
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    sol[0] = sol[1] = -1;
    for(int i = 1;i <= n; ++i)
        for(int j = 1;j <= n; ++j){
            int x;
            cin >> a[i][j];
            d1[i+j] += a[i][j];
            d2[i-j+n] += a[i][j];
        }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            Update((i+j)&1,i,j,d1[i+j]+d2[i-j+n]-a[i][j]);
    cout<<sol[0]+sol[1]<<"\n";
    if(v[0] > v[1])
        swap(v[0],v[1]);
    cout<<v[0].first<<" "<<v[0].second<<" ";
    cout<<v[1].first<<" "<<v[1].second<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	//ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
	ll* prim=new ll[2*n+1];
	ll* sec=new ll[2*n+1];
//	ll prim[2*n];
//	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
//	ll ret[2];
//	ret[0]=INT_MIN;
//	ret[1]=INT_MIN;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[n-(i-j)-1]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)%2==0)
			{
				if(maxe<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	int** board=new int*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new int[n];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	int prim[2*n];
	int sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[n-(i-j)-1]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<int,int> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	int maxo=INT_MIN;
	int maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)%2==0)
			{
				if(maxe<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first<<" "<<even.second<<" "<<odd.first<<" "<<odd.second<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	scanf("%d",&n);
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
//	ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%ld",&board[i][j]);
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
//	ll ret[2];
//	ret[0]=INT_MIN;
//	ret[1]=INT_MIN;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	//ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
	ll* prim=new ll[2*n+1];
	ll* sec=new ll[2*n+1];
//	ll prim[2*n];
//	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
//	ll ret[2];
//	ret[0]=INT_MIN;
//	ret[1]=INT_MIN;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

	//freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	int** board=new int*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new int[n];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	int prim[2*n];
	int sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[n-(i-j)-1]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<int,int> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	int maxo=INT_MIN;
	int maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)%2==0)
			{
				if(maxe<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	scanf("%d",&n);
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
//	ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d",&board[i][j]);
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
	ll ret[2];
	ret[0]=INT_MIN;
	ret[1]=INT_MIN;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

	//freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	//ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
//	ll ret[2];
//	ret[0]=INT_MIN;
//	ret[1]=INT_MIN;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	//ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
	ll* prim=new ll[2*n+1];
	ll* sec=new ll[2*n+1];
//	ll prim[2*n];
//	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[i-j+n]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}
	ll ret[2];
	ret[0]=INT_MIN;
	ret[1]=INT_MIN;

	pair < ll , ll > v[2];

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			int k=(i+j)&1;
			//if(k)
			//{
				if(ret[k]<prim[i+j]+sec[i-j+n]-board[i][j])
				{
//					even.first=i;
//					even.second=j;
					v[k].first=i;
					v[k].second=j;
					ret[k]=prim[i+j]+sec[i-j+n]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			//}
//			else
//			{
//				if(maxo<prim[i+j]+sec[i-j+n]-board[i][j])
//				{
//					odd.first=i;
//					odd.second=j;
//					maxo=prim[i+j]+sec[i-j+n]-board[i][j];
//				//	cout<<"maxo"<<maxo<<endl;
//				}
//			}
		}
	}

	cout<<ret[0]+ret[1]<<endl;
//	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;
	cout<<v[0].first+1<<" "<<v[0].second+1<<" "<<v[1].first+1<<" "<<v[1].second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
//	ll board[2014][2014];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[n-(i-j)-1]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937

int main()
{

//	freopen("input.txt", "r", stdin);
	int n;
	cin>>n;
	ll** board=new ll*[n];
	for(int i=0;i<n;i++)
	{
		board[i]=new ll[n];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>board[i][j];
		}
	}
//	int* prim=new int[2*n+1];
//	int* sec=new int[2*n+1];
	ll prim[2*n];
	ll sec[2*n];

	for(int i=0;i<2*n;i++)
	{
		prim[i]=sec[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			prim[i+j]+=board[i][j];
			sec[n-(i-j)-1]+=board[i][j];
//			cout<<"prim["<<i+j<<"="<<prim[i+j]<<endl;
//			cout<<"sec["<<n-(i-j)-1<<"="<<sec[n-(i-j)-1]<<endl;
		}
	}

	pair<ll,ll> odd,even;
//	odd.first=INT_MIN;
//	odd.second=INT_MIN;
//	even.first=INT_MIN;
//	even.second=INT_MIN;

	ll maxo=INT_MIN;
	ll maxe=INT_MIN;

//	for(int i=0;i<4;i++)
//	{
//		cout<<"prim["<<i<<"="<<prim[i]<<endl;
//		cout<<"sec["<<i<<"="<<sec[i]<<endl;
//	}

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(maxe<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					even.first=i;
					even.second=j;
					maxe=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
					//cout<<"maxe"<<maxe<<endl;
				}
			}
			else
			{
				if(maxo<prim[i+j]+sec[n-(i-j)-1]-board[i][j])
				{
					odd.first=i;
					odd.second=j;
					maxo=prim[i+j]+sec[n-(i-j)-1]-board[i][j];
				//	cout<<"maxo"<<maxo<<endl;
				}
			}
		}
	}

	cout<<maxo+maxe<<endl;
	cout<<even.first+1<<" "<<even.second+1<<" "<<odd.first+1<<" "<<odd.second+1<<endl;

//	for(int i=0;i<n;i++)
//	{
//		int j=0;
//		int row=i;
//		int sum=0;
//		while(row>=0 && row<n && j<n && j>=0)
//		{
//			sum+=board[row][j];
//			row++;
//			j--;
//		}
//		prim[i]=sum;
//	}
//	for(int )

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    double maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        double t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    double maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        double a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    double d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,double &d,int &x1,int &y1,int &x2,int &y2)
{
    double maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        double t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    double maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        double a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    double d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    for(int i=0;i<B.size();i++)
    {
        long long int t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
        for(int j=0;j<W.size();j++)
        {
            //cout<<W[j].first<<" "<<W[j].second<<endl;
            long long int a=lr[n-1-W[j].first+W[j].second];
            a+=rl[W[j].first+W[j].second];
            a-=arr[W[j].first][W[j].second];
            if(d<(t+a))
            {
                d=t+a;
                x1=B[i].first;
                y1=B[i].second;
                x2=W[j].first;
                y2=W[j].second;
            }
        }
    }

}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    int curr=0;
    char temp;
    long long int sumb=LONG_MIN;
    long long int sumw=LONG_MIN;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            if(temp=='w')
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumw)
                {
                    sumw=t;
                    x1=i;
                    y1=j;
                }
                temp='b';
            }
            else
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumb)
                {
                    sumb=t;
                    x2=i;
                    y2=j;
                }
                temp='w';
            }
        }

    }
    d=sumw+sumb;

}
int main()
{
    int n;
    cin>>n;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
                cin>>arr[i][j];
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    int p,k;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
        p=B[i].first;
        k=B[i].second;
         t=lr[n-1-p+k];
         t+=rl[p+k];
         t-=arr[p][k];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        p=W[i].first;
        k=W[i].second;
        a=lr[n-1-p+k];
        a+=rl[p+k];
        a-=arr[p][k];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    int curr=0;
    char temp;
    long long int sumb=0;
    long long int sumw=0;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            if(temp=='w')
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumw)
                {
                    sumw=t;
                    x1=i;
                    y1=j;
                }
            }
            else
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumb)
                {
                    sumb=t;
                    x2=i;
                    y2=j;
                }
            }
        }

    }
    d=sumw+sumb;

}
int main()
{
    int n;
    cin>>n;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
                cin>>arr[i][j];
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    for(int i=0;i<B.size();i++)
    {
        long long int t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
        for(int j=0;j<W.size();j++)
        {
            //cout<<W[j].first<<" "<<W[j].second<<endl;
            long long int a=lr[n-1-W[j].first+W[j].second];
            a+=rl[W[j].first+W[j].second];
            a-=arr[W[j].first][W[j].second];
            if(d<(t+a))
            {
                d=t+a;
                x1=B[i].first;
                y1=B[i].second;
                x2=W[j].first;
                y2=W[j].second;
            }
        }
    }
    for(int i=0;i<W.size();i++)
    {
        long long int t=lr[n-1-W[i].first+W[i].second];
        t+=rl[W[i].first+W[i].second];
        t-=arr[W[i].first][W[i].second];
        for(int j=0;j<B.size();j++)
        {
            long long int a=lr[n-1-B[j].first+B[j].second];
            a+=rl[B[j].first+B[j].second];
            a-=arr[B[j].first][B[j].second];
            if(d<t+a)
            {
                d=t+a;
                x1=W[i].first;
                y1=W[i].second;
                x2=B[j].first;
                y2=B[j].second;
            }
        }
    }

}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<int>&lr,vector<int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=0;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<int>lr((2*n)-1,0);
    vector<int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    int p,k;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
        p=B[i].first;
        k=B[i].second;
         t=lr[n-1-p+k];
         t+=rl[p+k];
         t-=arr[p][k];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        p=W[i].first;
        k=W[i].second;
        a=lr[n-1-p+k];
        a+=rl[p+k];
        a-=arr[p][k];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<pair<int,int>>&B,vector<pair<int,int>>&W,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    long long int maxt=LONG_MIN;
    for(int i=0;i<B.size();i++)
    {
        long long int t=0;
         t=lr[n-1-B[i].first+B[i].second];
         t+=rl[B[i].first+B[i].second];
         t-=arr[B[i].first][B[i].second];
         if(t>maxt)
            {
                maxt=t;
                x1=B[i].first;
                y1=B[i].second;
            }
    }
    long long int maxt1=LONG_MIN;
    for(int i=0;i<W.size();i++)
    {
        long long int a=0;
        a=lr[n-1-W[i].first+W[i].second];
        a+=rl[W[i].first+W[i].second];
        a-=arr[W[i].first][W[i].second];
        if(a>maxt1)
        {
            maxt1=a;
            x2=W[i].first;
            y2=W[i].second;
        }
    }
    d=maxt+maxt1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<pair<int,int>>B;
    vector<pair<int,int>>W;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    int curr=0;
    char temp;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            cin>>arr[i][j];
            if(temp=='w')
            {
                W.push_back({i,j});
                temp='b';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
            else
            {
                B.push_back({i,j});
                temp='w';
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
            }
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,B,W,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
void doller(int n,vector<vector<int>>&arr,vector<long long int>&lr,vector<long long int>&rl,long long int &d,int &x1,int &y1,int &x2,int &y2)
{
    int curr=0;
    char temp;
    long long int sumb=LONG_MIN;
    long long int sumw=LONG_MIN;
    for(int i=0;i<n;i++)
    {
        if(curr)
        {
            temp='w';
            curr=1-curr;
        }
        else
        {
            temp='b';
            curr=1-curr;
        }
        for(int j=0;j<n;j++)
        {
            if(temp=='w')
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumw)
                {
                    sumw=t;
                    x1=i;
                    y1=j;
                }
                temp='b';
            }
            else
            {
                long long int t=0;
                t=lr[n-1-i+j];
                t+=rl[i+j];
                t-=arr[i][j];
                if(t>sumb)
                {
                    sumb=t;
                    x2=i;
                    y2=j;
                }
                temp='w';
            }
        }

    }
    d=sumw+sumb;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<long long int>lr((2*n)-1,0);
    vector<long long int>rl((2*n)-1,0);
    vector<vector<int>>arr(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
                cin>>arr[i][j];
                lr[n-1-i+j]+=arr[i][j];
                rl[i+j]+=arr[i][j];
        }

    }
    long long int d=LONG_MIN;
    int x1,y1,x2,y2;
    doller(n,arr,lr,rl,d,x1,y1,x2,y2);
    cout<<d<<endl;
    cout<<x1+1<<" "<<y1+1<<" "<<x2+1<<" "<<y2+1<<endl;
   return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
int top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

bool ok(int x1,int y1,int x2,int y2){

     if(x1==x2){

        if(abs(y1-y2)%2 == 0)
          return false;
     }

     return true;
}

priority_queue<pair<int,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                 q.push({pre[i][j],{i,j}});
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

            bool wa = (best1.second.first+best1.second.second)%2;
           while(!q.empty()){

              if( (q.top().second.first + q.top().second.second)%2 != wa   ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%d\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define int long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;

int a[N][N],top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

priority_queue<pair<int,pair<int,int> > > q;

 main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%lld",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%lld",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                 q.push({pre[i][j],{i,j}});
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

           while(!q.empty()){

              if(abs(best1.second.first-q.top().second.first)!=abs(best1.second.second-q.top().second.second)){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%lld %lld %lld %lld",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
ll l[N][N],r[N][N];

int ehseb(int y,int mark){
    int x=0,ret=0;
    if (!mark)
        while(y<=n && x<n)
            ret+=a[x++][y++];
    else
        while (x<n && y>=0)
            ret+=a[x++][y--];
    return ret;
}

void pree(){
    for(int i=0;i<=n+1;i++)
        r[0][i]=ehseb(i,0),l[0][i]=ehseb(i,1);
    for(int i=1;i<n;i++){
        for(int j=1;j<=n;j++){
            r[i][j]=r[i-1][j-1];
            l[i][j]=l[i-1][j+1];
        }
    }
}

priority_queue<pair<ll,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);

         for(int i=0;i<n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pree();

           for(int i=0;i<n;i++){

             for(int j=1;j<=n;j++){
                 q.push({l[i][j]+r[i][j]-a[i][j],{i+1,j}});
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

            bool wa = (best1.second.first+best1.second.second)%2;
           while(!q.empty()){

              if( (q.top().second.first + q.top().second.second)%2 != wa   ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
int top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

bool ok(int x1,int y1,int x2,int y2){

     if(x1==x2){

        if(abs(y1-y2)%2 == 0)
          return false;
     }

     return true;
}

priority_queue<pair<int,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                 q.push({pre[i][j],{i,j}});
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

           while(!q.empty()){

              if(abs(best1.second.first-q.top().second.first)!=abs(best1.second.second-q.top().second.second) && ok(best1.second.first,best1.second.second,q.top().second.first,q.top().second.second)  ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%d\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
ll top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

bool ok(int x1,int y1,int x2,int y2){

     if(x1==x2){

        if(abs(y1-y2)%2 == 0)
          return false;
     }

     return true;
}

priority_queue<pair<ll,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                 q.push({pre[i][j],{i,j}});
             }
           }

           pair<ll,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

           while(!q.empty()){

              if(abs(best1.second.first-q.top().second.first)!=abs(best1.second.second-q.top().second.second) && ok(best1.second.first,best1.second.second,q.top().second.first,q.top().second.second)  ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
ll l[N][N],r[N][N];

int ehseb(int y,int mark){
    int x=0,ret=0;
    if (!mark)
        while(y<=n && x<n)
            ret+=a[x++][y++];
    else
        while (x<n && y>=1)
            ret+=a[x++][y--];
    return ret;
}

void pree(){
    for(int i=0;i<=n+1;i++)
        r[0][i]=ehseb(i,0),l[0][i]=ehseb(i,1);
    for(int i=1;i<n;i++){
        for(int j=1;j<=n;j++){
            r[i][j]=r[i-1][j-1];
            l[i][j]=l[i-1][j+1];
        }
    }
}

priority_queue<pair<ll,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);

         for(int i=0;i<n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pree();

           for(int i=0;i<n;i++){

             for(int j=1;j<=n;j++){
                 if(l[i][j]&& r[i][j])
                 q.push({l[i][j]+r[i][j]-a[i][j],{i+1,j}});
                 else
                   q.push({l[i][j]+r[i][j],{i+1,j}});
             }
           }

           pair<ll,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

            bool wa = (best1.second.first+best1.second.second)%2;
           while(!q.empty()){

              if( (q.top().second.first + q.top().second.second)%2 != wa   ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define int long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;

int a[N][N],top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

bool ok(int x1,int y1,int x2,int y2){

     if(x1==x2){

        if(abs(y1-y2)%2 == 0)
          return false;
     }

     return true;
}

priority_queue<pair<int,pair<int,int> > > q;

 main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%lld",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%lld",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                 q.push({pre[i][j],{i,j}});
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

           while(!q.empty()){

              if(abs(best1.second.first-q.top().second.first)!=abs(best1.second.second-q.top().second.second) && ok(best1.second.first,best1.second.second,q.top().second.first,q.top().second.second)  ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%lld %lld %lld %lld",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n;

int a[N][N];
ll r[4*N],l[4*N];

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

      scanf("%d",&n);

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

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

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

             r[i+j]+=a[i][j];
             l[i-j+n]+=a[i][j];
         }
      }

      pair<ll,pair<int,int> > best[2];

       best[0].first=best[1].first=-1;

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

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

             if( (r[i+j]+l[i-j+n]-a[i][j])>best[(i+j)%2].first ){
                int wa=(i+j)%2;
                best[wa].first =r[i+j]+l[i-j+n]-a[i][j];
                best[wa].second.first = i;
                best[wa].second.second = j;
             }
         }
      }

      printf("%lld\n%d %d %d %d",best[0].first+best[1].first,best[0].second.first,best[0].second.second,best[1].second.first,best[1].second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
#define int long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;

int a[N][N],top_right[N][N],top_left[N][N],bot_left[N][N],bot_right[N][N],pre[N][N];

bool vis[N][N];
void pre1(){

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

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

          top_left[i][j]=top_left[i-1][j-1]+a[i][j];
       }
    }
}

void pre2(){

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

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

          top_right[i][j]=top_right[i-1][j+1]+a[i][j];
       }
    }
}

void pre3(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_right[i][j]=bot_right[i+1][j+1]+a[i][j];
       }
    }

}

void pre4(){

    for(int i=n;i>=1;i--){

       for(int j=n;j>=1;j--){

           bot_left[i][j]=bot_left[i+1][j-1]+a[i][j];
       }
    }

}

void pre5(){

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

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

          pre[i][j]=top_right[i-1][j+1]+top_left[i-1][j-1]+bot_left[i+1][j-1]+bot_right[i+1][j+1]+a[i][j];
       }
    }
}

priority_queue<pair<int,pair<int,int> > > q;
void go(int x,int y){

    int x1,x2,x3,x4,y1,y2,y3,y4;
    x1=x2=x3=x4=x,y1=y2=y3=y4=y;

    pair<int,pair<int,int> >best;

    best.first=0;

    while(x1<=n && y1<=m ){
         vis[x1][y1]=1;
        if(pre[x1][y1]>best.first){

            best.first=pre[x1][y1];

            best.second.first=x1;
            best.second.second=y1;

        }
            x1++;
            y1++;

    }
    while(x2<=n && y2>=1 ){

          vis[x2][y2]=1;
      if(pre[x2][y2]>best.first){

            best.first=pre[x2][y2];

            best.second.first=x2;
            best.second.second=y2;

        }

         x2++;
          y2--;

    }
    while(x3>=1 && y3<=m ){
          vis[x3][y3]=1;
         if(pre[x3][y3]>best.first){

            best.first=pre[x3][y3];

            best.second.first=x3;
            best.second.second=y3;

        }
        x3--;
        y3++;

    }
    while(x4>=1 && y4>=1 ){
           vis[x4][y4]=1;

          if(pre[x4][y4]>best.first){

            best.first=pre[x4][y4];

            best.second.first=x4;
            best.second.second=y4;

        }
         x4--;
         y4--;
    }

    q.push(best);
}
 main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%lld",&n);
         m=n;
         for(int i=1;i<=n;i++)
          for(int j=1;j<=n;j++)
            scanf("%lld",&a[i][j]);

           pre1();
           pre2();
           pre3();
           pre4();
           pre5();

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

             for(int j=1;j<=n;j++){
                if(vis[i][j])
                  continue;
                 go(i,j);
             }
           }

           pair<int,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();
           best2=q.top();
           while(best2==best1 && !q.empty()){

                 best2=q.top();
                 q.pop();
           }

           printf("%lld\n%lld %lld %lld %lld",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=2005,MOD=1e9+7,MAX=1e5;

int n,m;
int a[N][N];
ll l[N][N],r[N][N];

int ehseb(int y,int mark){
    int x=0,ret=0;
    if (!mark)
        while(y<=n && x<n)
            ret+=a[x++][y++];
    else
        while (x<n && y>=0)
            ret+=a[x++][y--];
    return ret;
}

void pree(){
    for(int i=0;i<=n+1;i++)
        r[0][i]=ehseb(i,0),l[0][i]=ehseb(i,1);
    for(int i=1;i<n;i++){
        for(int j=1;j<=n;j++){
            r[i][j]=r[i-1][j-1];
            l[i][j]=l[i-1][j+1];
        }
    }
}

priority_queue<pair<ll,pair<int,int> > > q;

int  main()
{
           #ifndef ONLINE_JUDGE
     freopen("test.txt","r",stdin);
   #endif

         scanf("%d",&n);

         for(int i=0;i<n;i++)
          for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);

           pree();

           for(int i=0;i<n;i++){

             for(int j=1;j<=n;j++){
                 q.push({l[i][j]+r[i][j]-a[i][j],{i+1,j}});
             }
           }

           pair<ll,pair<int,int> > best1,best2;

           best1=q.top();
           q.pop();

            bool wa = (best1.second.first+best1.second.second)%2;
           while(!q.empty()){

              if( (q.top().second.first + q.top().second.second)%2 != wa   ){

                 best2=q.top();
                 break;
              }

              q.pop();
           }

           printf("%lld\n%d %d %d %d",best1.first+best2.first,best1.second.first,best1.second.second,best2.second.first,best2.second.second );

 return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*2], huyen[2005*2];

int main() {
   // freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=-4010; i <= 4010 ; i++) {
        sac[i] = 0;
        huyen[i] = 0;
    }
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*2], huyen[2005*2];

int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=1; i <= 4010 ; i++) {
        sac[i] = 0;
        huyen[i] = 0;
    }
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = (long long)sac[i+j] + huyen[j-i] - a[i][j] ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = (long long)sac[i+j] + huyen[j-i] - a[i][j] ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*2], huyen[2005*2];

int main() {
 //   freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            scanf( "%d", &a[i][j]) ;
            sac[i+j] += a[i][j];
            huyen[i-j+n+1] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[i-j+n+1] - a[i][j] > kq1 ) {
                    kq1 = (long long) (sac[i+j] + huyen[i-j+n+1] - a[i][j]) ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[i-j+n+1] - a[i][j] > kq2 ) {
                    kq2 = (long long) (sac[i+j] + huyen[i-j+n+1] - a[i][j]) ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*4], huyen[2005*4];

int main() {
   // freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=-4010; i <= 4010 ; i++) {
        sac[i] = 0;
        huyen[i] = 0;
    }
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*5], huyen[2005*5];

int main() {
 //   freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[i-j+n+1] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[i-j+n+1] - a[i][j] > kq1 ) {
                    kq1 = (long long) (sac[i+j] + huyen[i-j+n+1] - a[i][j]) ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[i-j+n+1] - a[i][j] > kq2 ) {
                    kq2 = (long long) (sac[i+j] + huyen[i-j+n+1] - a[i][j]) ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*2], huyen[2005*2];

int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1 =0, kq2 = 0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = sac[i+j] + huyen[j-i] - a[i][j] ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = sac[i+j] + huyen[j-i] - a[i][j] ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*5], huyen[2005*5];

int main() {
   // freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=-4010; i <= 4010 ; i++) {
        sac[i] = 0;
        huyen[i] = 0;
    }
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = (long long) (sac[i+j] + huyen[j-i] - a[i][j]) ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>
using namespace std;

long long n, a[2005][2005], sac[2005*2], huyen[2005*2];

int main() {
   // freopen("test.txt","r",stdin);
    cin >> n;
    for (int i=1; i <= 4010 ; i++) {
        sac[i] = 0;
        huyen[i] = 0;
    }
    for (int i=1; i <= n ; i++) {
        for (int j=1; j <= n ; j++) {
            cin >> a[i][j];
            sac[i+j] += a[i][j];
            huyen[j-i] += a[i][j];
        }
    }
    int x1, x2, y1 , y2 ;
    long long kq1,kq2;
    kq1=kq2=0;
    for (int i=1 ; i <= n ; i++) {
        for (int j=1 ; j <= n ; j++) {
            if ( (i + j) % 2 != 0) {
                if ( sac[i+j] + huyen[j-i] - a[i][j] > kq1 ) {
                    kq1 = (long long)sac[i+j] + huyen[j-i] - a[i][j] ;
                    x1 = i; y1 = j;
                }
            } else {
                 if ( sac[i+j] + huyen[j-i] - a[i][j] > kq2 ) {
                    kq2 = (long long)sac[i+j] + huyen[j-i] - a[i][j] ;
                    x2 = i; y2 = j;
                }
            }
        }
    }
    cout << (long long)kq1 + kq2 << endl;
    cout << x1 << " " << y1 << " " << x2 << " " << y2;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 2;
int n;
int ara[N][N];
long long dp[N];
long long dp2[N];
vector < pair < long long, pair < int,int > > > cell, cell2;
typedef long long ll;

bool cmp(pair < ll, pair <int, int> >& x, pair < ll, pair <int,int > >&y) {
  return x.first > y.first;
}

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for(int i = 1 ; i <= n;  ++i) {
    for(int j = 1 ; j <= n ; ++j) {
      cin >> ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n;  ++j) {
      dp[i + j] += ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n; ++j) {
      ///cout << (j - i) + n << " ";
      dp2[j - i + n] += ara[i][j];
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
      if((i + j) % 2 == 0) {
        cell.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
      else {
        cell2.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
    }
  }
  sort(cell.begin(),cell.end(),cmp);
  sort(cell2.begin(),cell2.end(),cmp);
  cout << cell[0].first + cell2[0].first << '\n';
  cout << cell[0].second.first << " " << cell[0].second.second << " " << cell2[0].second.first << " " << cell2[0].second.second << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  priority_queue < tuple < long long, int, int > > Q, P;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      cin >> ara[i][j];
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
        Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
      }
      else {
        P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
      }
    }
  }
  cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long inf = (1LL << 62);
const int N = 1005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  priority_queue < tuple < long long, int, int > > Q, P;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      cin >> ara[i][j];
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
        Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
      }
      else {
        P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
      }
    }
  }
  cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 10;
int n;
long long ara[N][N];
long long dp[N + N];
long long dp2[N + N];
vector < pair < long long, pair < int,int > > > cell, cell2;
typedef long long ll;

bool cmp(pair < ll, pair <int, int> >& x, pair < ll, pair <int,int > >&y) {
  return x.first > y.first;
}

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for(int i = 1 ; i <= n;  ++i) {
    for(int j = 1 ; j <= n ; ++j) {
      cin >> ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n;  ++j) {
      dp[i + j] += ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n; ++j) {
      ///cout << (j - i) + n << " ";
      dp2[j - i + n] += ara[i][j];
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
      if((i + j) % 2 == 0) {
        cell.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
      else {
        cell2.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
    }
  }
  sort(cell.begin(),cell.end(),cmp);
  sort(cell2.begin(),cell2.end(),cmp);
  cout << cell[0].first + cell2[0].first << '\n';
  cout << cell[0].second.first << " " << cell[0].second.second << " " << cell2[0].second.first << " " << cell2[0].second.second << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 10;
int n;
long long ara[N][N];
long long dp[N];
long long dp2[N];
vector < pair < long long, pair < int,int > > > cell, cell2;
typedef long long ll;

bool cmp(pair < ll, pair <int, int> >& x, pair < ll, pair <int,int > >&y) {
  return x.first > y.first;
}

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for(int i = 1 ; i <= n;  ++i) {
    for(int j = 1 ; j <= n ; ++j) {
      cin >> ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n;  ++j) {
      dp[i + j] += ara[i][j];
    }
  }
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= n; ++j) {
      ///cout << (j - i) + n << " ";
      dp2[j - i + n] += ara[i][j];
    }
  }
  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n; ++j) {
      if((i + j) % 2 == 0) {
        cell.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
      else {
        cell2.push_back({(dp[i + j] + dp2[j - i + n] -  ara[i][j]),{i, j}});
      }
    }
  }
  sort(cell.begin(),cell.end(),cmp);
  sort(cell2.begin(),cell2.end(),cmp);
  cout << cell[0].first + cell2[0].first << '\n';
  cout << cell[0].second.first << " " << cell[0].second.second << " " << cell2[0].second.first << " " << cell2[0].second.second << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

int main() {
  //std :: ios :: sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  cin >> n;
  //priority_queue < tuple < long long, int, int > > Q, P;
  tuple < long long, int, int > p, q;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      //cin >> ara[i][j];
      scanf("%d",&ara[i][j]);
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  long long odd = -1, even = -1;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
       // Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > odd) {
          odd = l[i + j] + r[j - i + n] - ara[i][j];
          p = {odd, i + 1, j + 1};
        }
      }
      else {
       // P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > even) {
          even = l[i + j] + r[j - i + n] - ara[i][j];
          q = {even, i + 1, j + 1};
        }
      }
    }
  }
  ///cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  ///cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
  cout << get < 0 > (q) + get < 0 > (p) << endl;
  cout << get < 1 > (q) << " " << get < 2 > (q) << " " << get < 1 > (p) << " " << get < 2 > (p) << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
long long ara[N][N];
long long l[N + N], r[N + N];

int main() {
  std :: ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  //priority_queue < tuple < long long, int, int > > Q, P;
  tuple < long long, int, int > p, q;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      cin >> ara[i][j];
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  long long odd = -1, even = -1;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
       // Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > odd) {
          odd = l[i + j] + r[j - i + n] - ara[i][j];
          p = {odd, i + 1, j + 1};
        }
      }
      else {
       // P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > even) {
          even = l[i + j] + r[j - i + n] - ara[i][j];
          q = {even, i + 1, j + 1};
        }
      }
    }
  }
  ///cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  ///cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
  cout << get < 0 > (q) + get < 0 > (p) << endl;
  cout << get < 1 > (q) << " " << get < 2 > (q) << " " << get < 1 > (p) << " " << get < 2 > (p) << endl;
  return 0;
}


#include <stdio.h>

//using namespace std;

//const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

struct edge {
  long long val;
  int x, y;
};

edge p, q;

int main() {
  //std :: ios :: sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  scanf("%d",&n);
  //priority_queue < tuple < long long, int, int > > Q, P;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      //cin >> ara[i][j];
      scanf("%d",&ara[i][j]);
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  long long odd = -1, even = -1;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
       // Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > odd) {
          odd = l[i + j] + r[j - i + n] - ara[i][j];
          p = {odd, i + 1, j + 1};
        }
      }
      else {
       // P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > even) {
          even = l[i + j] + r[j - i + n] - ara[i][j];
          q = {even, i + 1, j + 1};
        }
      }
    }
  }
  ///cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
 // cout << get < 1 > (q) << " " << get < 2 > (q) << " " << get < 1 > (p) << " " << get < 2 > (p) << endl;
  printf("%lld\n", p.val + q.val);
  printf("%d %d %d %d\n", p.x, p.y, q.x, q.y);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

struct edge {
  long long val;
  int x, y;
};

edge p, q;

int main() {
  //std :: ios :: sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  scanf("%d",&n);
  //priority_queue < tuple < long long, int, int > > Q, P;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      //cin >> ara[i][j];
      scanf("%d",&ara[i][j]);
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  long long odd = -1, even = -1;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
       // Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > odd) {
          odd = l[i + j] + r[j - i + n] - ara[i][j];
          p = {odd, i + 1, j + 1};
        }
      }
      else {
       // P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > even) {
          even = l[i + j] + r[j - i + n] - ara[i][j];
          q = {even, i + 1, j + 1};
        }
      }
    }
  }
  ///cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  ///cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
 // cout << get < 0 > (q) + get < 0 > (p) << endl;
 // cout << get < 1 > (q) << " " << get < 2 > (q) << " " << get < 1 > (p) << " " << get < 2 > (p) << endl;
  printf("%lld\n", p.val + q.val);
  printf("%d %d %d %d\n", p.x, p.y, q.x, q.y);
  return 0;
}


#include <stdio.h>

//using namespace std;

//const long long inf = (1LL << 62);
const int N = 2005;
int n, m;
int ara[N][N];
long long l[N + N], r[N + N];

struct edge {
  long long val;
  int x, y;
};

edge p, q;

int main() {
  //std :: ios :: sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  scanf("%d",&n);
  //priority_queue < tuple < long long, int, int > > Q, P;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      //cin >> ara[i][j];
      scanf("%d",&ara[i][j]);
      l[i + j] += ara[i][j];
      r[j - i + n] += ara[i][j];
    }
  }
  long long odd = -1, even = -1;
  for(int i = 0 ; i < n ; ++i) {
    for(int j = 0 ; j < n ; ++j) {
      if((i + j) % 2) {
       // Q.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > odd) {
          odd = l[i + j] + r[j - i + n] - ara[i][j];
          p = {odd, i + 1, j + 1};
        }
      }
      else {
       // P.push({(l[i + j] + r[j - i + n] - ara[i][j]), i + 1, j + 1});
        if(l[i + j] + r[j - i + n] - ara[i][j] > even) {
          even = l[i + j] + r[j - i + n] - ara[i][j];
          q = {even, i + 1, j + 1};
        }
      }
    }
  }
  ///cout << get < 0 > (Q.top()) + get < 0 > (P.top()) << endl;
  ///cout << get < 1 > (Q.top()) << " " << get < 2 > (Q.top()) << " " << get < 1 > (P.top()) << " " << get < 2 > (P.top()) << endl;
 // cout << get < 0 > (q) + get < 0 > (p) << endl;
 // cout << get < 1 > (q) << " " << get < 2 > (q) << " " << get < 1 > (p) << " " << get < 2 > (p) << endl;
  printf("%lld\n", p.val + q.val);
  printf("%d %d %d %d\n", p.x, p.y, q.x, q.y);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long  a[4005],b[4005];
int main ()
{
    int n;
    cin>>n;
    int arr[n][n];
    for(int i=0  ;i<n ; i++)
    {
        for(int j=0 ;j<n ; j++)
        {
            int x;
            scanf("%d",&x);

            a[i+j]+=x;
            b[i-j+n]+=x;
            arr[i][j]=x;

        }
    }
    vector<pair<int,int> > ij;
    vector<pair<long long , pair<int ,int > > >v;
    for(int i =0 ; i<n*2 ; i++)
    {
        for(int j=0 ; j<n*2 ; j++)
        {
           // cout<<i<<" "<<j<<endl;
            if (a[i]==0 || b[j]==0)continue;
            long long q=i,r=j-n;
            int x=(q+r)/2;
            int y=q-x;
           // if (x==1&& y==1)cout<<i<<" "<<j-n<<endl;

           // cout<<x<<" "<<y<<endl;
            long long sum=a[i]+b[j]-arr[x][y];
            if ((q+r)%2!=0|| x<0 || y<0 || x>=n || y>=n )continue;
            //if (sum==8)cout<<x<<" "<<y<<endl;
            v.push_back({sum,{x,y}});
            ij.push_back({i,j});

        }
    }
    long long Max=0;
    int maxx,maxy,maxx2,maxy2;
    for(int i=0 ; i<v.size() ; i++)
    {
        for(int j=0 ; j<v.size() ; j++)
        {
            long long sum=v[i].first+v[j].first;
            int x1=v[i].second.first;
            int y1=v[i].second.second;
            int x2=v[j].second.first;
            int y2=v[j].second.second;
            int ii1=ij[i].first,ii2=ij[j].first,jj1=ij[i].second,jj2=ij[j].second;

            if (ii1%2==((jj2-n)%2+2)%2)continue;
             if (ii2%2==((jj1-n)%2+2)%2)continue;

            if (x1+y1==x2+y2 || x1-y1==x2-y2 )continue;
            if (sum>Max)
            {
         //   cout<<v[i].first<<" "<<v[j].first<<endl;

                //cout<<sum<<" "<<x1+1<<" "<<y1+1<<endl;
                Max=sum;
                maxx=x1+1;
                maxy=y1+1;
                maxx2=x2+1;
                maxy2=y2+1;
            }

        }
    }
    cout<<Max<<endl<<maxx<<" "<<maxy<<" "<<maxx2<<" "<<maxy2;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long  a[4005],b[4005];
int main ()
{
    int n;
    cin>>n;
    int arr[n][n];
    for(int i=0  ;i<n ; i++)
    {
        for(int j=0 ;j<n ; j++)
        {
            int x;
            scanf("%d",&x);

            a[i+j]+=x;
            b[i-j+n]+=x;
            arr[i][j]=x;

        }
    }
    vector<pair<int,int> > ij;
    vector<pair<long long , pair<int ,int > > >v;
    for(int i =0 ; i<n*2 ; i++)
    {
        for(int j=0 ; j<n*2 ; j++)
        {
           // cout<<i<<" "<<j<<endl;
            if (a[i]==0 || b[j]==0)continue;
            long long q=i,r=j-n;
            int x=(q+r)/2;
            int y=q-x;
           // if (x==1&& y==1)cout<<i<<" "<<j-n<<endl;

           // cout<<x<<" "<<y<<endl;
            long long sum=a[i]+b[j]-arr[x][y];
            if ((q+r)%2!=0|| x<0 || y<0 || x>=n || y>=n )continue;
            //if (sum==8)cout<<x<<" "<<y<<endl;
            v.push_back({sum,{x,y}});
            ij.push_back({i,j});

        }
    }
    long long Max=0;
    int maxx,maxy,maxx2,maxy2;
    for(int i=0 ; i<v.size()-1 ; i++)
    {
        for(int j=i+1 ; j<v.size() ; j++)
        {
            long long sum=v[i].first+v[j].first;
            int x1=v[i].second.first;
            int y1=v[i].second.second;
            int x2=v[j].second.first;
            int y2=v[j].second.second;
            int ii1=ij[i].first,ii2=ij[j].first,jj1=ij[i].second,jj2=ij[j].second;

            if (ii1%2==((jj2-n)%2+2)%2)continue;
             if (ii2%2==((jj1-n)%2+2)%2)continue;

            if (x1+y1==x2+y2 || x1-y1==x2-y2 )continue;
            if (sum>Max)
            {
         //   cout<<v[i].first<<" "<<v[j].first<<endl;

                //cout<<sum<<" "<<x1+1<<" "<<y1+1<<endl;
                Max=sum;
                maxx=x1+1;
                maxy=y1+1;
                maxx2=x2+1;
                maxy2=y2+1;
            }

        }
    }
    cout<<Max<<endl<<maxx<<" "<<maxy<<" "<<maxx2<<" "<<maxy2;

    return 0;
}