#include <bits/stdc++.h>
using namespace std;
int steps[11][11][11][11];
void f(int x, int y, int start, int cur, int step) {
  if (step >= 10) return;
  int new_dig = (cur + x) % 10;
  int new_dig2 = (cur + y) % 10;
  steps[x][y][start][new_dig] = min(steps[x][y][start][new_dig], step + 1);
  steps[x][y][start][new_dig2] = min(steps[x][y][start][new_dig2], step + 1);
  f(x, y, start, new_dig, step + 1);
  f(x, y, start, new_dig2, step + 1);
}
int main() {
  string s;
  cin >> s;
  int arr[10][10];
  memset(arr, 0, sizeof arr);
  memset(steps, 10000, sizeof steps);
  for (int i = 0; i < 10; i++) {
    for (int j = i; j < 10; j++) {
      for (int start = 0; start < 10; start++) {
        f(i, j, start, start, -1);
      }
      long long ans = 0;
      for (int jj = 0; jj < s.size() - 1; jj++) {
        int dig1 = s[jj] - '0';
        int dig2 = s[jj + 1] - '0';
        if (steps[i][j][dig1][dig2] >= 10000) {
          arr[i][j] = -1;
        } else
          ans += steps[i][j][dig1][dig2];
      }
      if (arr[i][j] != -1) arr[i][j] = ans;
      arr[j][i] = arr[i][j];
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
