#include <bits/stdc++.h>
char s[2000000L + 1L];
long F[10][10][10][10], ans[10][10];
int main() {
  for (long i = 0L; i < 10L; ++i) {
    for (long j = 0L; j < 10L; ++j) {
      for (long k = 0L; k < 10L; ++k) {
        for (long l = 0L; l < 10L; ++l) {
          F[i][j][k][l] = LONG_MAX >> 1;
          for (long m = 0L; m < 10L; ++m) {
            for (long n = 0L; n < 10L; ++n) {
              if (m == 0L && n == 0L) continue;
              if ((k + m * i + n * j) % 10L == l)
                F[i][j][k][l] = std::min(F[i][j][k][l], m + n);
            }
          }
          if (F[i][j][k][l] == LONG_MAX >> 1) F[i][j][k][l] = -1L;
        }
      }
    }
  }
  scanf("%s", s);
  for (long i = 1L; s[i]; ++i) {
    for (long j = 0L; j < 10L; ++j) {
      for (long k = 0L; k < 10L; ++k) {
        if (ans[j][k] == -1L) continue;
        if (F[j][k][s[i - 1L] - '0'][s[i] - '0'] == -1L)
          ans[j][k] = -1L;
        else
          ans[j][k] += F[j][k][s[i - 1L] - '0'][s[i] - '0'] - 1L;
      }
    }
  }
  for (long i = 0L; i < 10L; ++i) {
    for (long j = 0L; j < 10L; ++j)
      printf(j == 9L ? "%ld\n" : "%ld ", ans[i][j]);
  }
  return 0;
}
