#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7IGNvbnN0IGludCBOID0gMjAwMTsgaW50IGFbIE4gXVsgTiBdOyBsbCBzdW1bIE4gXVsgTiBdOwoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKCBmYWxzZSApLCBjaW4udGllKCBudWxscHRyICksIGNvdXQudGllKCBudWxscHRyICk7CgogICAgaW50IGFfbWluID0gSU5UX01BWCwgaywgbCwgbiwgeDAsIHkwLCB4MSwgeTEsIHgyLCB5MjsgbGwgciwgcywgdDsgCiAgICAKICAgIGNpbiA+PiBrID4+IG4sIGwgPSAyICogazsgY29uc3Qgc3RyaW5nIG5vX3NvbHV0aW9uID0gIk5JRSI7CgogICAgZm9yKCB5MCA9IDA7IHkwIDwgbjsgeTArKyApCiAgICAgICAgZm9yKCBpbnQgeDAgPSAwOyB4MCA8IG47IHgwKysgKQogICAgICAgICAgICBjaW4gPj4gYVsgeTAgXVsgeDAgXSwKICAgICAgICAgICAgYV9taW4gPSBtaW4oIGFfbWluLCBhWyB5MCBdWyB4MCBdICk7CgogICAgZm9yKCB5MCA9IDAsIHkxID0gMTsgeTAgPCBuOyB5MCA9IHkxKysgKQogICAgICAgIGZvciggeDAgPSAwLCB4MSA9IDE7IHgwIDwgbjsgeDAgPSB4MSsrICkKICAgICAgICB7CiAgICAgICAgICAgIGF1dG8gJnogPSBzdW1bIHkxIF1bIHgxIF07CgkgICAgCiAgICAgICAgICAgIHogID0gICBhWyB5MCBdWyB4MCBdLAogICAgICAgICAgICB6ICs9IHN1bVsgeTAgXVsgeDEgXSwKICAgICAgICAgICAgeiArPSBzdW1bIHkxIF1bIHgwIF0sCiAgICAgICAgICAgIHogLT0gc3VtWyB5MCBdWyB4MCBdOwogICAgICAgIH0KCiAgICBpZiAoIHN1bVsgbiBdWyBuIF0gPCBrIG9yIGFfbWluID4gbCApCiAgICB7CiAgICAgICBjb3V0IDw8IG5vX3NvbHV0aW9uOyByZXR1cm4gMDsKICAgIH0KCiAgICBpZiAoIHN1bVsgbiBdWyBuIF0gPD0gbCApCiAgICB7CiAgICAgICBjb3V0IDw8ICIxIDEgIiA8PCBuIDw8ICIgIiA8PCBuOyByZXR1cm4gMDsKICAgIH0KCiAgICBmb3IoIHkwID0gMCwgeTEgPSAxOyB5MCA8IG47IHkwID0geTErKyApCiAgICAgICAgZm9yKCB4MCA9IDAsIHgxID0gMTsgeDAgPCBuOyB4MCA9IHgxKysgKQogICAgICAgICAgICBpZiAoIGFbIHkwIF1bIHgwIF0gPD0gbCApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZvciggciA9IHN1bVsgeTAgXVsgeDAgXSwgeTIgPSB5MTsgeTIgPD0gbjsgeTIrKyApCiAgICAgICAgICAgICAgICAgICAgZm9yKCBzID0gc3VtWyB5MiBdWyB4MCBdIC0gciwgeDIgPSB4MTsgeDIgPD0gbjsgeDIrKyApCiAgICAgICAgICAgICAgICAgICAgICAgIGlmICggKCB0ID0gc3VtWyB5MiBdWyB4MiBdIC0gc3VtWyB5MCBdWyB4MiBdIC0gcyApID4gbCApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCB0ID49IGsgKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291dCA8PCB4MSA8PCAnICcgPDwgeTEgPDwgJyAnIDw8IHgyIDw8ICcgJyA8PCB5MjsgcmV0dXJuIDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgIH0KCiAgICBjb3V0IDw8IG5vX3NvbHV0aW9uOyAKfQ==