#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
signed main() {
  string s;
  cin >> s;
  for (long long i = (long long)(0); i < (long long)(((long long)s.size()));
       i++)
    s[i] -= '0';
  vector<vector<long long> > cnt(10, vector<long long>(10));
  for (long long i = (long long)(1); i < (long long)(((long long)s.size()));
       i++) {
    cnt[s[i - 1]][s[i]]++;
  }
  for (long long x = (long long)(0); x < (long long)(10); x++)
    for (long long y = (long long)(0); y < (long long)(10); y++) {
      vector<vector<long long> > d(10, vector<long long>(10, inf));
      for (long long v = (long long)(0); v < (long long)(10); v++)
        for (long long cx = (long long)(0); cx < (long long)(10); cx++)
          for (long long cy = (long long)(0); cy < (long long)(10); cy++) {
            if (cx + cy == 0) continue;
            chmin(d[v][(v + cx * x + cy * y) % 10], cx + cy);
          }
      long long ans = 0;
      for (long long v = (long long)(0); v < (long long)(10); v++) {
        for (long long to = (long long)(0); to < (long long)(10); to++) {
          if (d[v][to] >= inf and cnt[v][to] > 0) {
            ans = -1;
            break;
          }
          ans += (d[v][to] - 1) * cnt[v][to];
        }
        if (ans == -1) break;
      }
      cout << ans << " \n"[y == 9];
    }
  return 0;
}
