#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int solve(int x, int y, const string &s) {
  vector<vector<int>> d(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    d[i][(i + x) % N] = 1;
    d[i][(i + y) % N] = 1;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (d[i][k] * d[k][j] == 0) continue;
        if (d[i][j] == 0)
          d[i][j] = d[i][k] + d[k][j];
        else
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    int cur = d[s[i] - '0'][s[i + 1] - '0'];
    if (cur == 0) return -1;
    ans += cur - 1;
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  solve(3, 2, s);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << solve(i, j, s) << " ";
    }
    cout << endl;
  }
}
