#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int table[11][11][11][11];
int calc(int x, int y, int a, int b) {
  int dist[11];
  memset(dist, -1, sizeof(dist));
  queue<int> q;
  q.push((a + x) % 10);
  q.push((a + y) % 10);
  dist[(a + x) % 10] = 1;
  dist[(a + y) % 10] = 1;
  while (!q.empty()) {
    auto now = q.front();
    q.pop();
    if (now == b) return dist[now];
    int nx = (now + x) % 10;
    int ny = (now + y) % 10;
    if (dist[nx] == -1) {
      dist[nx] = dist[now] + 1;
      q.push(nx);
    }
    if (dist[ny] == -1) {
      dist[ny] = dist[now] + 1;
      q.push(ny);
    }
  }
  return -1;
}
void calc(int x, int y) {
  for (int a = 0; a < 10; a++) {
    for (int b = 0; b < 10; b++) {
      table[x][y][a][b] = calc(x, y, a, b);
    }
  }
}
int main() {
  string s;
  cin >> s;
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      calc(x, y);
      int ans = 0;
      for (int i = 1; i < s.size(); i++) {
        int k = table[x][y][s[i - 1] - '0'][s[i] - '0'];
        if (k == -1) {
          ans = -1;
          break;
        }
        ans += max(0, k - 1);
      }
      printf("%d ", ans);
    }
    printf("\n");
  }
  return 0;
}
