#include <bits/stdc++.h>
using namespace std;
long long func(long long n, long long x, long long a, long long b) {
  queue<long long> q;
  long long V[11] = {0};
  vector<long long> D(11, INT_MAX);
  if (x == n && (a == 0 || b == 0)) return 0;
  D[(x + a) % 10] = 1;
  q.push((x + a) % 10);
  D[(x + b) % 10] = 1;
  q.push((x + b) % 10);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    if (V[x] == 1) continue;
    V[x] = 1;
    if (x == n) return D[x];
    if (D[x] >= 10) return -1;
    if (D[(x + a) % 10] > D[x] + 1) {
      D[(x + a) % 10] = D[x] + 1;
      q.push((x + a) % 10);
    }
    if (D[(x + b) % 10] > D[x] + 1) {
      D[(x + b) % 10] = D[x] + 1;
      q.push((x + b) % 10);
    }
  }
  return -1;
}
int main() {
  string s;
  cin >> s;
  long long A[10][10];
  long long E[10][10][10][10];
  for (long long i = 0; i < 10; i++)
    for (long long j = 0; j < 10; j++)
      for (long long k = 0; k < 10; k++)
        for (long long l = 0; l < 10; l++) E[i][j][k][l] = func(k, l, i, j);
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j <= i; j++) {
      long long ans = 0;
      long long y = 0;
      for (long long k = 1; k < (int)s.size(); k++) {
        long long x = E[i][j][s[k] - '0'][y];
        if (x == -1) {
          ans = -1;
          break;
        } else
          ans += x == 0 ? 0 : x - 1;
        y = s[k] - '0';
      }
      A[i][j] = ans;
    }
  }
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++)
      if (j <= i)
        cout << A[i][j] << " ";
      else
        cout << A[j][i] << " ";
    cout << endl;
  }
}
