#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
int n, dp[15][15];
string s;
int solve(int x, int y) {
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 0; i < 10; i++) dp[i][(i + x) % 10] = 1, dp[i][(i + y) % 10] = 1;
  for (int k = 0; k < 10; k++)
    for (int i = 0; i < 10; i++)
      for (int j = 0; j < 10; j++)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (dp[s[i] - '0'][s[i + 1] - '0'] == 0x3f3f3f3f) return -1;
    ans += dp[s[i] - '0'][s[i + 1] - '0'] - 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> s;
  n = s.length();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cout << solve(i, j) << ' ';
    }
    cout << endl;
  }
  return 0;
}
