import scala.io.StdIn._
object Main extends App {
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.fill(h){readLine.trim.split(' ').map(_.toInt)}
  val isCenter = Array.fill(h){Array.fill(w){false}}
  for (d ← 0 until h + w - 1; y ← math.max(0, d - w + 1) to math.min(d, h - 1)) {
    val x = d - y
    while (state(y)(x) >= 1){
      isCenter(y + 1)(x + 1) = true
      for (dx ← 0 to 2; dy ← 0 to 2) state(y + dy)(x + dx) -= 1
    }
  }
  (1 until w - 1).flatMap(x ⇒ (1 until h - 1).filter(y ⇒ isCenter(y)(x) && (-1 to 1).map(dx ⇒ (-1 to 1).count(dy ⇒ isCenter(y + dy)(x + dx))).sum <= 2).map(y ⇒ (y, x))).sortBy{case (i, j) ⇒ 10000 * i + j}.toList match {
    case (ti, tj)::(si, sj)::_ ⇒
      println(s"$si $sj $ti $tj")
    case (ti, tj):: Nil ⇒
      println(s"$ti $tj $ti $tj")
    case _ ⇒ ???
  }
}
