#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
const int INF = 0x3f3f3f3f;
int T;
int G[20][20];
int d[20][20][20][20];
char s[N];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int u = 0; u < 10; u++) {
        for (int v = 0; v < 10; v++) {
          d[i][j][u][v] = INF;
        }
      }
      for (int k = 0; k < 10; k++) {
        d[i][j][k][(k + i) % 10] = 1;
        d[i][j][k][(k + j) % 10] = 1;
      }
      for (int k = 0; k < 10; k++) {
        for (int u = 0; u < 10; u++) {
          for (int v = 0; v < 10; v++) {
            d[i][j][u][v] = min(d[i][j][u][v], d[i][j][u][k] + d[i][j][k][v]);
          }
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int ans = 0;
      for (int k = 0; k < n - 1; k++) {
        ans += d[i][j][s[k] - '0'][s[k + 1] - '0'] - 1;
        if (ans >= INF - 1) {
          ans = -1;
          break;
        }
      }
      printf("%d%s", ans, j == 9 ? "\n" : " ");
    }
  }
  return 0;
}
