#include <bits/stdc++.h>
using namespace std;
const int N = 15, M = 2000010, inf = 0x3f3f3f3f;
int dp[N][N], ans[N][N], len;
char s[M];
int init(int x, int y) {
  memset(dp, 0x3f, sizeof dp);
  for (int i = 0; i <= 9; ++i) dp[i][(i + x) % 10] = 1, dp[i][(i + y) % 10] = 1;
  for (int k = 0; k <= 9; ++k)
    for (int i = 0; i <= 9; ++i)
      for (int j = 0; j <= 9; ++j)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int res = 0;
  for (int i = 1; i < len; ++i) {
    if (dp[s[i] - '0'][s[i + 1] - '0'] >= inf / 2) return inf;
    res += dp[s[i] - '0'][s[i + 1] - '0'] - 1;
  }
  return res;
}
int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  for (int i = 0; i <= 9; ++i)
    for (int j = i; j <= 9; ++j) {
      int tmp = init(i, j);
      if (tmp == inf)
        ans[i][j] = ans[j][i] = -1;
      else
        ans[i][j] = ans[j][i] = tmp;
    }
  for (int i = 0; i <= 9; ++i) {
    for (int j = 0; j <= 9; ++j) printf("%d ", ans[i][j]);
    cout << endl;
  }
  return 0;
}
