#include <iostream>
using namespace std;
int main()
{
int n, m, x;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
cin >> x;
if (x != 0)
cout << i << " " << j << " " << x << endl;
}
return 0;
}
int ans1()
{
int n, m;
int a[150][150] = {};
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i][j] != 0)
cout << i << " " << j << " " << a[i][j] << endl;
return 0;
}