#include <bits/stdc++.h>

using namespace std;

typedef long long ll; const int N = 2001; int a[ N ][ N ]; ll sum[ N ][ N ];

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    int a_min = INT_MAX, k, l, n, x0, y0, x1, y1, x2, y2; ll r, s, t; 
    
    cin >> k >> n, l = 2 * k; const string no_solution = "NIE";

    for( y0 = 0; y0 < n; y0++ )
        for( int x0 = 0; x0 < n; x0++ )
            cin >> a[ y0 ][ x0 ],
            a_min = min( a_min, a[ y0 ][ x0 ] );

    for( y0 = 0, y1 = 1; y0 < n; y0 = y1++ )
        for( x0 = 0, x1 = 1; x0 < n; x0 = x1++ )
        {
            auto &z = sum[ y1 ][ x1 ];
	    
            z  =   a[ y0 ][ x0 ],
            z += sum[ y0 ][ x1 ],
            z += sum[ y1 ][ x0 ],
            z -= sum[ y0 ][ x0 ];
        }

    if ( sum[ n ][ n ] < k or a_min > l )
    {
       cout << no_solution; return 0;
    }

    if ( sum[ n ][ n ] <= l )
    {
       cout << "1 1 " << n << " " << n; return 0;
    }

    for( y0 = 0, y1 = 1; y0 < n; y0 = y1++ )
        for( x0 = 0, x1 = 1; x0 < n; x0 = x1++ )
            if ( a[ y0 ][ x0 ] <= l )
            {
                for( r = sum[ y0 ][ x0 ], y2 = y1; y2 <= n; y2++ )
                    for( s = sum[ y2 ][ x0 ] - r, x2 = x1; x2 <= n; x2++ )
                        if ( ( t = sum[ y2 ][ x2 ] - sum[ y0 ][ x2 ] - s ) > l )
                            break;
                        else
                            if ( t >= k )
                            {
                               cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2; return 0;
                            }
                                            
            }

    cout << no_solution; 
}