#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string second;
  cin >> second;
  int n = second.size();
  long long int ans[10][10];
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = i; j < 10; j++) {
      priority_queue<pair<long long int, long long int> > pq;
      int steps[10];
      for (long long int k = 0; k < 10; k++) steps[k] = 1e9;
      pq.push({i, 1});
      pq.push({j, 1});
      while (!pq.empty()) {
        int rem = pq.top().first;
        int num = pq.top().second;
        rem %= 10;
        pq.pop();
        if (steps[rem] > num) {
          steps[rem] = num;
          pq.push({(rem + i), (num + 1)});
          pq.push({(rem + j), (num + 1)});
        }
      }
      long long int mn = 0;
      for (long long int k = 1; k < n; k++) {
        int diff = (second[k] - second[k - 1]);
        diff += 10;
        diff %= 10;
        if (steps[diff] == 1e9) {
          mn = -1;
          break;
        } else
          mn += (steps[diff] - 1);
      }
      ans[i][j] = mn;
      ans[j][i] = mn;
    }
  }
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) cout << ans[i][j] << " ";
    cout << "\n";
  }
  cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
