#include<unordered_map>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<set>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
signed main(void){
int n, m; cin >> n >> m;
vector<pair<int, int> > ans;
vector<vector<int> > input(n, vector<int>(m));
for(auto& v : input){
for(int& i : v) cin >> i;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
int mod = input[i][j] % 10, sum = 0;
for(int i2 = 0; i2 < n; i2++){
for(int j2 = 0; j2 < m; j2++){
if(abs(i2 - i) + abs(j2 - j) <= input[i][j]) sum += input[i2][j2];
}
}
if(sum % 10 == mod) ans.push_back(make_pair(i, j));
}
}
cout << ans.size() << "\n";
for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << "\n";
}
#include<unordered_map>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<set>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
signed main(void){
int n, m; cin >> n >> m;
vector<pair<int, int> > ans;
vector<vector<int> > input(n, vector<int>(m));
for(auto& v : input){
for(int& i : v) cin >> i;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
int mod = input[i][j] % 10, sum = 0;
for(int i2 = 0; i2 < n; i2++){
for(int j2 = 0; j2 < m; j2++){
if(abs(i2 - i) + abs(j2 - j) <= input[i][j]) sum += input[i2][j2];
}
}
if(sum % 10 == mod) ans.push_back(make_pair(i, j));
}
}
cout << ans.size() << "\n";
for(int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << "\n";
}