#include <bits/stdc++.h>
using namespace std;
string s;
int a[10][10][10];
int f[10];
int ans[10][10];
int main() {
  cin >> s;
  for (int i = 1; i <= s.size() - 1; i++) {
    int x = s[i] - s[i - 1];
    f[(x + 10) % 10]++;
  }
  memset(a, 255, sizeof(a));
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++)
        for (int l = 0; l < 10; l++)
          if (k + l != 0) {
            int x = (i * k + j * l) % 10;
            if (a[x][i][j] == -1)
              a[x][i][j] = k + l - 1;
            else
              a[x][i][j] = min(a[x][i][j], k + l - 1);
          }
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++)
        if (a[k][i][j] == -1 && f[k]) {
          ans[i][j] = -1;
          break;
        } else
          ans[i][j] += a[k][i][j] * f[k];
      printf("%d%c", ans[i][j], (j == 9) ? 10 : 32);
    }
  return 0;
}
