#include <bits/stdc++.h>
using namespace std;
const int maxn = 11, maxs = 2 * 1000 * 1000 + 10;
int tmp, mn[maxn][maxn], dp[maxn][maxn][maxn], ted[maxn];
char s[maxs];
long long ans[maxn][maxn];
int main() {
  memset(mn, 31, sizeof mn);
  memset(dp, 31, sizeof dp);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        if ((k * j) % 10 == i) {
          mn[i][j] = k;
          break;
        }
      }
    }
  }
  scanf("%s", s);
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      if (x == 0 || y == 0)
        dp[0][x][y] = 1;
      else
        dp[0][x][y] = 10;
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int x = 0; x < 10; x++) {
      for (int y = 0; y < 10; y++) {
        for (int t = 0; t < 10; t++) {
          tmp = (i + 100 - t * x) % 10;
          if (mn[tmp][y] < 10 && t + mn[tmp][y] > 0)
            dp[i][x][y] = min(dp[i][x][y], t + mn[tmp][y]);
        }
      }
    }
    for (int x = 0; x < 10; x++) {
      for (int y = 0; y < 10; y++) dp[i][x][y] = min(dp[i][x][y], dp[i][y][x]);
    }
  }
  for (int i = 0; s[i + 1] >= '0'; i++) {
    tmp = ((s[i + 1] - '0') + 10 - (s[i] - '0')) % 10;
    ted[tmp]++;
  }
  for (int i = 0; i < 10; i++) {
    if (ted[i] == 0) continue;
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        if (dp[i][j][k] > 18)
          ans[j][k] = -1;
        else if (ans[j][k] != -1)
          ans[j][k] += (long long)ted[i] * (dp[i][j][k] - 1);
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) printf("%lld ", ans[i][j]);
    printf("\n");
  }
  return 0;
}
