#include <bits/stdc++.h>
using namespace std;
mt19937 myRand(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 myRand64(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string second;
  cin >> second;
  vector<vector<int>> dp(10, vector<int>(10, INF));
  queue<int> q;
  for (int x = 0; x < 10; ++x) {
    for (int y = 0; y < 10; ++y) {
      int ans = 0;
      dp = vector<vector<int>>(10, vector<int>(10, INF));
      for (int i = 0; i < 10; ++i) {
        dp[i][(i + x) % 10] = 1;
        dp[i][(i + y) % 10] = 1;
        q.push((i + x) % 10);
        q.push((i + y) % 10);
        while (!q.empty()) {
          int cur = q.front();
          q.pop();
          int a = (cur + x) % 10;
          int b = (cur + y) % 10;
          if (dp[i][a] > dp[i][cur] + 1) {
            dp[i][a] = dp[i][cur] + 1;
            q.push(a);
          }
          if (dp[i][b] > dp[i][cur] + 1) {
            dp[i][b] = dp[i][cur] + 1;
            q.push(b);
          }
        }
      }
      bool flag = 0;
      for (int i = 0; i + 1 < (int)second.size(); ++i) {
        if (dp[second[i] - '0'][second[i + 1] - '0'] == INF) {
          flag = 1;
          break;
        } else {
          ans += dp[second[i] - '0'][second[i + 1] - '0'] - 1;
        }
      }
      if (flag)
        cout << -1 << ' ';
      else
        cout << ans << ' ';
    }
    cout << '\n';
  }
}
