/*
 * e.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 500;
const int MAX_W = 500;

const int dxs[] = {1, 0, -1, -1}, dys[] = {-1, -1, -1, 0};

/* typedef */

/* global variables */

int flds[MAX_H][MAX_W], ens[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) cin >> flds[y][x];

  memset(ens, -1, sizeof(ens));
  
  for (int y = 1; y < h - 1; y++)
    for (int x = 1; x < w - 1; x++) {
      int k = flds[y - 1][x - 1];
      if (k > 1) {
	printf("%d %d %d %d\n", y, x, y, x);
	return 0;
      }
      if (k == 1) {
	for (int y0 = y - 1; y0 <= y + 1; y0++)
	  for (int x0 = x - 1; x0 <= x + 1; x0++)
	    flds[y0][x0]--;

	ens[y][x] = 0;
	for (int di = 0; di < 4; di++) {
	  int x0 = x + dxs[di], y0 = y + dys[di];
	  if (ens[y0][x0] >= 0)
	    ens[y0][x0]++, ens[y][x]++;
	}
      }
    }

  int sx, sy, tx = -1, ty = -1;
  for (int y = 1; y < h - 1; y++)
    for (int x = 1; x < w - 1; x++)
      if (ens[y][x] == 1) {
	if (tx < 0) tx = x, ty = y;
	else sx = x, sy = y;
      }
  printf("%d %d %d %d\n", sy, sx, ty, tx);
  return 0;
}