#include <bits/stdc++.h>
using namespace std;
const int maxlongint = 2147483647;
int dp[10][10];
long long ans[10][10];
char st[2000011];
int main() {
  scanf("%s", st + 1);
  int n = strlen(st + 1);
  for (int i = 1; i <= n; i++) st[i] -= '0';
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= i; j++) {
      memset(dp, 31, sizeof(dp));
      for (int s = 0; s <= 9; s++)
        dp[s][(s + i) % 10] = 1, dp[s][(s + j) % 10] = 1;
      for (int k = 0; k <= 9; k++) {
        for (int s = 0; s <= 9; s++) {
          for (int t = 0; t <= 9; t++) {
            dp[s][t] = min(dp[s][t], dp[s][k] + dp[k][t]);
          }
        }
      }
      for (int k = 2; k <= n; k++) {
        ans[i][j] += dp[st[k - 1]][st[k]] - 1;
      }
      if (ans[i][j] > n * 10) ans[i][j] = -1;
    }
  }
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      cout << (ans[i][j] | ans[j][i]) << ' ';
    }
    putchar('\n');
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
