#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int N = 2000000;
const int M = 10;
char s[N + 1];
int ans[M][M][M];
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += M;
  return a;
}
int main() {
  scanf("%s", s);
  int n = strlen(s);
  memset(**ans, 0x3f, 4 * M * M * M);
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      for (int k = 0; k <= 10; ++k)
        for (int p = 0; p <= 10; ++p)
          if (p || k)
            ans[i][j][(i * k + j * p) % 10] =
                std::min(ans[i][j][(i * k + j * p) % 10], k + p);
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      int r = 0;
      bool ok = true;
      for (int k = 1; k < n; ++k) {
        int make = ans[i][j][sub(s[k], s[k - 1])];
        if (make == INF)
          ok = false;
        else
          r += std::max(make - 1, 0);
      }
      if (ok)
        printf("%d ", r);
      else
        printf("-1 ");
    }
    printf("\n");
  }
  return 0;
}
