#include <iostream>
#include <string>
using namespace std;
int main()
{
short width; // the number of cells on the X axis
cin >> width; cin.ignore();
short height; // the number of cells on the Y axis
cin >> height; cin.ignore();
string *node = new string[height];
short x, y;
for (y = 0; y < height; ++y)
{
getline(cin, node[y]);
}
for (y = 0; y < height; ++y)
{
for (x = 0; x < width; ++x)
{
if (node[y][x] == '0')
{
cout << x << ' ' << y << ' ';
short x2, y2, ansX = -1, ansY = -1;
for (x2 = x+1; x2 < width; ++x2)
{
if (node[y][x2] == '0')
{
ansX = x2;
ansY = y;
break;
}
}
cout << ansX << ' ' << ansY << ' ';
ansX = -1; ansY = -1;
for (y2 = y+1; y2 < height; ++y2)
{
if (node[y2][x] == '0')
{
ansX = x;
ansY = y2;
break;
}
}
cout << ansX << ' ' << ansY << '\n';
x = x2-1;
}
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBzaG9ydCB3aWR0aDsgLy8gdGhlIG51bWJlciBvZiBjZWxscyBvbiB0aGUgWCBheGlzCiAgICBjaW4gPj4gd2lkdGg7IGNpbi5pZ25vcmUoKTsKICAgIHNob3J0IGhlaWdodDsgLy8gdGhlIG51bWJlciBvZiBjZWxscyBvbiB0aGUgWSBheGlzCiAgICBjaW4gPj4gaGVpZ2h0OyBjaW4uaWdub3JlKCk7CiAgICBzdHJpbmcgKm5vZGUgPSBuZXcgc3RyaW5nW2hlaWdodF07CiAgICBzaG9ydCB4LCB5OwogICAgZm9yICh5ID0gMDsgeSA8IGhlaWdodDsgKyt5KQogICAgewogICAgICAgIGdldGxpbmUoY2luLCBub2RlW3ldKTsKICAgIH0KICAgIGZvciAoeSA9IDA7IHkgPCBoZWlnaHQ7ICsreSkKICAgIHsKICAgICAgICBmb3IgKHggPSAwOyB4IDwgd2lkdGg7ICsreCkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChub2RlW3ldW3hdID09ICcwJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291dCA8PCB4IDw8ICcgJyA8PCB5IDw8ICcgJzsKICAgICAgICAgICAgICAgIHNob3J0IHgyLCB5MiwgYW5zWCA9IC0xLCBhbnNZID0gLTE7CiAgICAgICAgICAgICAgICBmb3IgKHgyID0geCsxOyB4MiA8IHdpZHRoOyArK3gyKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmIChub2RlW3ldW3gyXSA9PSAnMCcpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBhbnNYID0geDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGFuc1kgPSB5OwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb3V0IDw8IGFuc1ggPDwgJyAnIDw8IGFuc1kgPDwgJyAnOwogICAgICAgICAgICAgICAgYW5zWCA9IC0xOyBhbnNZID0gLTE7CiAgICAgICAgICAgICAgICBmb3IgKHkyID0geSsxOyB5MiA8IGhlaWdodDsgKyt5MikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAobm9kZVt5Ml1beF0gPT0gJzAnKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5zWCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGFuc1kgPSB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY291dCA8PCBhbnNYIDw8ICcgJyA8PCBhbnNZIDw8ICdcbic7CiAgICAgICAgICAgICAgICB4ID0geDItMTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQ==