#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int maxn = 3e6 + 10;
int n;
long long num[15][15], dp[15][15][15][15];
char s[maxn];
void init_dp() {
  for (int i = 0; i <= 9; ++i)
    for (int j = 0; j <= 9; ++j)
      for (int k = 0; k <= 9; ++k)
        for (int l = 0; l <= 9; ++l) dp[i][j][k][l] = inf;
  for (int i = 0; i <= 9; ++i)
    for (int j = 0; j <= 9; ++j)
      for (int k = 0; k <= 9; ++k)
        for (int l = 0; l <= 9; ++l)
          for (int a = 0; a <= 9; ++a)
            for (int b = 0; b <= 9; ++b) {
              if (a == 0 && b == 0) continue;
              if ((a * i + b * j + k) % 10 == l)
                dp[i][j][k][l] = min(dp[i][j][k][l], 1ll * a + 1ll * b);
            }
}
long long calc(int x, int y) {
  long long sum = 0;
  for (int i = 2; i <= n; i++)
    if (dp[x][y][s[i - 1] - '0'][s[i] - '0'] == inf) {
      return -1;
    } else
      sum += dp[x][y][s[i - 1] - '0'][s[i] - '0'] - 1;
  return sum;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init_dp();
  for (int i = 0; i <= 9; i++, printf("\n"))
    for (int j = 0; j <= 9; j++)
      if (j < i)
        printf("%lld ", num[j][i]);
      else
        num[i][j] = calc(i, j), printf("%lld ", num[i][j]);
  return 0;
}
