#include <bits/stdc++.h>
using namespace std;
const int maxn = 15;
int dis[maxn][maxn];
char str[2000100];
void cal(int p, int q) {
  memset(dis, 0x3f3f3f3f, sizeof dis);
  for (int i = 0; i <= 9; i++) {
    dis[i][(i + p) % 10] = min(dis[i][(i + p) % 10], 1);
    dis[i][(i + q) % 10] = min(dis[i][(i + q) % 10], 1);
  }
  for (int k = 0; k <= 9; k++)
    for (int i = 0; i <= 9; i++)
      for (int j = 0; j <= 9; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
}
int main() {
  cal(0, 1);
  scanf("%s", str);
  int len = strlen(str);
  int ans[15][15];
  memset(ans, -1, sizeof ans);
  for (int i = 0; i < 10; i++)
    for (int j = i; j < 10; j++) {
      cal(i, j);
      int sm = 0;
      for (int k = 1; k < len; k++) {
        int ti = str[k - 1] - '0', tj = str[k] - '0';
        if (dis[ti][tj] == 0x3f3f3f3f || dis[ti][tj] == 0) {
          sm = -1;
          break;
        } else
          sm += dis[ti][tj] - 1;
      }
      ans[i][j] = ans[j][i] = sm;
    }
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      printf(j == 9 ? "%d\n" : "%d ", ans[i][j]);
    }
  return 0;
}
