#include <bits/stdc++.h>
using namespace std;
double pi = acos(-1);
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
long long powerm(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b & 1) return a * powerm(a * a % m, b / 2, m) % m;
  return powerm(a * a % m, b / 2, m);
}
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b & 1) return a * power(a * a, b / 2);
  return power(a * a, b / 2);
}
long long sqroot(long long number) {
  long long x = sqrt(number);
  while (x * x < number) x++;
  while (x * x > number) x--;
  return x;
}
long long cbroot(long long number) {
  long long x = cbrt(number);
  while (x * x * x < number) x++;
  while (x * x * x > number) x--;
  return x;
}
const int maxn = 1e5 + 5;
int ch[10][10][10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++) ch[i][j][k] = 1e9;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int a = 0; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
          if (a or b)
            ch[i][j][(a * i + b * j) % 10] =
                min(ch[i][j][(a * i + b * j) % 10], a + b - 1);
        }
      }
    }
  }
  string s;
  cin >> s;
  int t = 0;
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans = 0;
      for (int k = 1; k < s.length(); k++) {
        t = (s[k] - s[k - 1] + 10) % 10;
        if (ch[i][j][t] != 1e9) {
          ans += ch[i][j][t];
        } else {
          ans = -1;
          break;
        }
      }
      cout << ans << " ";
    }
    cout << "\n";
  }
  return 0;
}
