#include <bits/stdc++.h>
using namespace std;
inline bool read(long long &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
  if (ch == '\n') return 0;
  return 1;
}
inline void write(long long x) {
  static const long long maxlen = 100;
  static char s[maxlen];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  long long len = 0;
  for (; x; x /= 10) s[len++] = x % 10 + '0';
  for (long long i = len - 1; i >= 0; --i) putchar(s[i]);
}
const long long MAXN = 2110000;
char s[MAXN];
long long g[22][22][22][22];
long long len;
void prepare(long long x, long long y) {
  for (long long i = 0; i < 10; i++) {
    g[x][y][i][(i + x) % 10] = 1;
    g[x][y][i][(i + y) % 10] = 1;
  }
  for (long long k = 0; k < 10; k++)
    for (long long i = 0; i < 10; i++)
      if (g[x][y][i][k] != -1)
        for (long long j = 0; j < 10; j++)
          if (g[x][y][k][j] != -1)
            if (g[x][y][i][j] == -1)
              g[x][y][i][j] = g[x][y][i][k] + g[x][y][k][j];
            else
              g[x][y][i][j] = min(g[x][y][i][j], g[x][y][i][k] + g[x][y][k][j]);
}
long long ans[22][22];
void doit(long long pre, long long now) {
  for (long long i = 0; i < 10; i++)
    for (long long j = 0; j < 10; j++)
      if (ans[i][j] != -1)
        if (g[i][j][pre][now] != -1)
          ans[i][j] += g[i][j][pre][now] - 1;
        else
          ans[i][j] = -1;
}
int main() {
  memset(g, -1, sizeof(g));
  for (long long i = 0; i < 10; i++)
    for (long long j = 0; j < 10; j++) prepare(i, j);
  scanf("%s", s);
  len = strlen(s);
  memset(ans, 0, sizeof(ans));
  for (long long i = 1; i < len; i++) doit(s[i - 1] - '0', s[i] - '0');
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 9; j++) {
      write(ans[i][j]);
      printf(" ");
    }
    write(ans[i][9]);
    puts("");
  }
  return 0;
}
