#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
const double PI = acos(-1);
const double eps = 1e-6;
const long long inf = 1e9;
inline long long lgput(long long a, long long b, long long mod) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (ret % mod);
}
inline long long inv(long long x, long long MOD) {
  return lgput(x, MOD - 2, MOD);
}
inline bool exist(double nr) { return (nr < -eps) || (nr > eps); }
long long big_rand() { return rand() * RAND_MAX + rand(); }
int dp[11][11][11][11];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << setprecision(10) << fixed;
  mt19937 rng(time(nullptr));
  srand(time(nullptr));
  string s;
  cin >> s;
  int n = 10;
  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++) {
          dp[i][j][a][b] = inf;
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int start = 0; start < 10; start++) {
        for (int a = 0; a <= 10; a++) {
          for (int b = 0; b <= 10; b++) {
            if (a + b == 0) {
              continue;
            }
            int now = i * a + j * b + start;
            now %= 10;
            dp[i][j][start][now] = min(dp[i][j][start][now], a + b);
          }
        }
        for (int end = 0; end < 10; end++) {
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      long long ans = 0;
      for (int x = 0; x < (int)s.size() - 1; x++) {
        if (dp[i][j][s[x] - '0'][s[x + 1] - '0'] == inf) {
          ans = -1;
          break;
        }
        ans += 1LL * dp[i][j][s[x] - '0'][s[x + 1] - '0'] - 1LL;
      }
      cout << ans << " ";
    }
    cout << '\n';
  }
  return 0;
}
