#include <bits/stdc++.h>
using namespace std;
int n, dis[15][15];
char s[2000005];
int fun(int x, int y) {
  memset(dis, 0x3f, sizeof(dis));
  for (int i = 0; i < 10; i++)
    dis[i][(i + x) % 10] = 1, dis[i][(i + y) % 10] = 1;
  for (int k = 0; k < 10; k++)
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < 10; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (dis[s[i] - '0'][s[i + 1] - '0'] == 0x3f3f3f3f) return -1;
    ans += dis[s[i] - '0'][s[i + 1] - '0'] - 1;
  }
  return ans;
}
int main() {
  cin >> s;
  n = strlen(s);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cout << fun(i, j) << ' ';
    }
    puts("");
  }
}
