#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
signed main() {
  string s;
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s;
  long long dp[10][10][10][10];
  for (auto &x : dp)
    for (auto &y : x)
      for (auto &f : y)
        for (auto &s : f) s = INF;
  for (long long x = 0; x < 10; ++x) {
    for (long long y = 0; y < 10; ++y) {
      for (long long f = 0; f < 10; ++f) {
        for (long long s = 0; s < 10; ++s) {
          for (long long kx = 0; kx <= 10; ++kx) {
            for (long long ky = 0; ky <= 10; ++ky) {
              if (kx == 0 && ky == 0) continue;
              if ((f + x * kx + y * ky) % 10 == s)
                dp[x][y][f][s] = min(dp[x][y][f][s], kx + ky - 1);
            }
          }
        }
      }
    }
  }
  long long ans[10][10];
  for (auto &i : ans)
    for (auto &j : i) j = 0;
  for (long long x = 0; x < 10; ++x) {
    for (long long y = 0; y < 10; ++y) {
      for (long long i = 0; i + 1 < s.size(); ++i) {
        if (dp[x][y][s[i] - '0'][s[i + 1] - '0'] == INF) {
          ans[x][y] = -1;
          break;
        }
        ans[x][y] += dp[x][y][s[i] - '0'][s[i + 1] - '0'];
      }
    }
  }
  for (auto &i : ans) {
    for (auto &j : i) cout << j << " ";
    cout << "\n";
  }
  return 0;
}
