#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
ifstream in("input.txt");
int n,cerinta;
bitset<6> cube[100][100][100];
unsigned short int vcube[100][100][100];
struct t {
int x, y, z;
}data[6]{
{1,0,0},
{-1,0,0},
{0,1,0},
{0,-1,0},
{0,0,1},
{0,0,-1},
};
void citire() {
in >>cerinta >> n;
int x, y, z;
for (z = 0; z < n; z++) {
for (y = 0; y < n; y++) {
for (x = 0; x < n; x++) {
in >> cube[x][y][z];
}
}
}
}
bool check1(int x,int y,int z) {
if (x<0 || x>=n)
return 0;
if (y<0 || y>=n)
return 0;
if (z<0 || z>=n)
return 0;
return 1;
}
void rezolvare1() {
int x, y, z, i,_max=0;
int sx = 0, sy = 0, sz = 0;
for (z = 0; z < n; z++) {
for (y = 0; y < n; y++) {
for (x = 0; x < n; x++) {
printf("%d ", cube[x][y][z]);
for (i = 0; i < 6; i++) {
printf("i:%d=%d ", i, cube[x][y][z][i]);
if (cube[x][y][z][i]) {
if (check1(x + ::data[i].x, y + ::data[i].y, z + ::data[i].z))
vcube[x][y][z]++;
}
}
if (vcube[x][y][z] > _max)
_max = vcube[x][y][z], sx = x, sy = y, sz = z;
}
}
}
printf("%d %d %d", sx + 1, sy + 1, sz + 1);
}
void rezolvare2() {
}
int main()
{
citire();
if (cerinta == 1) {
rezolvare1();
}
else {
rezolvare2();
}
in.close();
}