#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[55][55];
int n, m;
scanf("%d %d", &n, &m);
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++) scanf("%d", &a[i][j]);
}
int num=0;
pair<int,int> point[2550];
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
int distance=a[i][j];
int sum=0;
for (int x=max(0, i-distance); x<=min(n-1, i+distance); x++)
{
for (int y=max(0, j-distance); y<=min(m-1, j+distance); y++)
{
if(abs(x-i)+abs(y-j)<=distance) sum+=a[x][y];
}
}
if(sum%10==distance)
{
point[num++]={i,j};
}
}
}
printf("%d\n", num);
for (int i=0; i<num; i++) printf("%d %d\n", point[i].first, point[i].second);
}