#include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int n;
long long int distance(string& s, long long int in, long long int x,
                       long long int y) {
  vector<bool> visited(10, false);
  long long int dis = 0;
  vector<long long int> node(1, s[in] - 48);
  while (!node.empty()) {
    vector<long long int> temp;
    long long int l = node.size();
    for (long long int i = 0; i < l; i++) {
      long long int a1 = (node[i] + x) % 10, a2 = (node[i] + y) % 10;
      if (!visited[a1]) {
        visited[a1] = true;
        if (a1 == s[in + 1] - 48) return dis;
        temp.push_back(a1);
      }
      if (!visited[a2]) {
        visited[a2] = true;
        if (a2 == s[in + 1] - 48) return dis;
        temp.push_back(a2);
      }
    }
    node = temp;
    dis++;
  }
  return -1;
}
long long int sol(vector<vector<long long int>>& dp, string& s, long long int x,
                  long long int y) {
  long long int ans = 0;
  for (long long int in = 0; in < n - 1; in++) {
    if (dp[s[in] - 48][s[in + 1] - 48] == -2)
      dp[s[in] - 48][s[in + 1] - 48] = distance(s, in, x, y);
    if (dp[s[in] - 48][s[in + 1] - 48] == -1) return -1;
    ans += dp[s[in] - 48][s[in + 1] - 48];
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  n = s.length();
  vector<vector<long long int>> ans(10, vector<long long int>(10, 0));
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) {
      vector<vector<long long int>> dp(10, vector<long long int>(10, -2));
      ans[i][j] = sol(dp, s, i, j);
      ans[j][i] = ans[i][j];
    }
  }
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}
