#include <bits/stdc++.h>
using namespace std;
const double eps = (double)1e-9;
const int inf = (int)1e9 + 7;
string s;
int d[12];
int solve(int x, int y) {
  for (int i = 0; i <= 10; i++) d[i] = 100;
  for (int i = 0; i <= 10; i++) {
    for (int j = 0; j <= 10; j++) {
      if (i == 0 and j == 0) continue;
      d[(x * i + y * j) % 10] = min(d[(x * i + y * j) % 10], i + j);
    }
  }
  int sum = 0, r;
  for (int i = 1; i < (int)s.size(); i++) {
    r = s[i] - s[i - 1];
    if (r < 0) r += 10;
    if (d[r] == 100) return -1;
    sum += d[r] - 1;
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      cout << solve(x, y) << " ";
    }
    cout << '\n';
  }
  return 0;
}
