#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr int INF = INT32_MAX;
constexpr int MAXN = 2e6 + 10;
constexpr double eps = 1e-8;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
using Vec = vector<int>;
template <class T>
void Min(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void Max(T &a, T b) {
  if (b > a) a = b;
}
ll N, M, K, T;
string s;
int ans[10][10];
int dp[10][10][10][10];
void Solution() {
  memset(dp, -1, sizeof dp);
  for (int i = (int)(0); i < (int)(10); ++i) {
    for (int j = (int)(i); j < (int)(10); ++j) {
      for (int f = (int)(0); f < (int)(10); ++f) {
        dp[i][j][f][(f + i) % 10] = 1;
        dp[i][j][f][(f + j) % 10] = 1;
        while (true) {
          bool n = false;
          for (int t = (int)(0); t < (int)(10); ++t) {
            if (dp[i][j][f][t] != -1) {
              if (dp[i][j][f][(t + i) % 10] == -1 ||
                  dp[i][j][f][(t + i) % 10] > dp[i][j][f][t] + 1) {
                dp[i][j][f][(t + i) % 10] = dp[i][j][f][t] + 1;
                n = true;
              }
              if (dp[i][j][f][(t + j) % 10] == -1 ||
                  dp[i][j][f][(t + j) % 10] > dp[i][j][f][t] + 1) {
                dp[i][j][f][(t + j) % 10] = dp[i][j][f][t] + 1;
                n = true;
              }
            }
          }
          if (!n) break;
        }
      }
    }
  }
  for (int i = (int)(0); i < (int)(10); ++i) {
    for (int j = (int)(i); j < (int)(10); ++j) {
      ll t = 0;
      for (int k = (int)(1); k < (int)(s.size()); ++k) {
        int a = s[k - 1] - '0';
        int b = s[k] - '0';
        if (dp[i][j][a][b] == -1) {
          t = -1;
          break;
        } else {
          t += dp[i][j][a][b] - 1;
        }
      }
      ans[i][j] = ans[j][i] = t;
    }
  }
  for (int i = (int)(0); i < (int)(10); ++i) {
    for (int j = (int)(0); j < (int)(10); ++j) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  while (cin >> s) {
    Solution();
  }
  return 0;
}
