#include <bits/stdc++.h>
using namespace std;
const long long N = 20;
long long dp[N][N];
long long power_mod(long long a, long long p = 1000000007 - 2,
                    long long MOD = 1000000007) {
  long long result = 1;
  while (p > 0) {
    if (p & 1) result = a * result % MOD;
    a = a * a % MOD;
    p >>= 1;
  }
  return result;
}
void solve() {
  string s;
  cin >> s;
  long long n = s.length();
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      const long long INF = 1e16;
      for (long long k = 0; k < 10; k++) {
        for (long long l = 0; l < 10; l++) {
          dp[k][l] = INF;
        }
      }
      for (long long from = 0; from < 10; from++) {
        dp[from][(from + i) % 10] = 1;
        dp[from][(from + j) % 10] = 1;
      }
      for (long long k = 0; k < 10; k++) {
        for (long long i = 0; i < 10; i++) {
          for (long long j = 0; j < 10; j++) {
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
          }
        }
      }
      bool ok = 1;
      long long ans = 0;
      for (long long now = 0; now < n - 1; now++) {
        long long NOW = s[now] - '0';
        long long NEXT = s[now + 1] - '0';
        if (dp[NOW][NEXT] >= INF) {
          cout << "-1 ";
          ok = 0;
          break;
        } else {
          ans += dp[NOW][NEXT] - 1;
        }
      }
      if (ok) cout << ans << " ";
    }
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
