#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
string s;
int n;
int ans[10][10];
int dist[10][10];
int solve(int x, int y) {
  memset(dist, 0x3f, sizeof(dist));
  for (int i = 0; i < 10; i++) {
    dist[i][(i + x) % 10] = 1;
    dist[i][(i + y) % 10] = 1;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  int ret = 0;
  for (int i = 1; i < n; i++) {
    if (dist[s[i - 1] - '0'][s[i] - '0'] == 0x3f3f3f3f) return -1;
    ret += dist[s[i - 1] - '0'][s[i] - '0'] - 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = (int)s.size();
  for (int x = 0; x < 10; x++) {
    for (int y = x; y < 10; y++) {
      ans[x][y] = ans[y][x] = solve(x, y);
    }
  }
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      cout << ans[x][y] << " \n"[y == 9];
    }
  }
  return 0;
}
