#include <bits/stdc++.h>
using namespace std;
const long long N = 12;
long long dp[N][N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      for (long long dif = 0; dif < 10; dif++)
        dp[i][j][dif] = ((long long)(4e18));
      queue<pair<long long, long long> > q;
      q.push({0, 0});
      while (!q.empty()) {
        long long u = q.front().first;
        long long len = q.front().second;
        q.pop();
        for (auto t : {i, j}) {
          long long nxt = (u + t) % 10;
          if (dp[i][j][nxt] > len + 1)
            dp[i][j][nxt] = len + 1, q.push({nxt, len + 1});
        }
      }
    }
  }
  string str;
  cin >> str;
  vector<long long> dif(11);
  for (long long i = 1; i < str.size(); i++) {
    long long a = str[i - 1] - 48;
    long long b = str[i] - 48;
    if (a <= b)
      dif[b - a]++;
    else
      dif[(9 - a) + b + 1]++;
  }
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      long long res = 0;
      for (long long k = 0; k < 10; k++) {
        if (dif[k] > 0 && dp[i][j][k] == ((long long)(4e18))) {
          res = -1;
          break;
        }
        res += dif[k] * (dp[i][j][k] - 1);
      }
      cout << res << " ";
    }
    cout << "\n";
  }
  return 0;
}
