#include <bits/stdc++.h>
using namespace std;
int matrix[10][10];
void dfs(int a, int cnt, int x, int y, int arr[]) {
  if (arr[a] == -1 || cnt < arr[a]) {
    arr[a] = cnt;
    dfs((a + x) % 10, cnt + 1, x, y, arr);
    dfs((a + y) % 10, cnt + 1, x, y, arr);
  }
}
int add_val(int arr[], string s) {
  int sum = 0;
  char last = '0';
  for (int i = 1; i < s.length(); i++) {
    int num = ((s[i] - last) < 0) ? s[i] - last + 10 : s[i] - last;
    if (arr[num] == -1) return -1;
    sum += arr[num] - 1;
    last = s[i];
  }
  return sum;
}
int main() {
  string s;
  cin >> s;
  int cnt_array[10];
  for (int i = 0; i < int(10); i++)
    for (int j = i; j < 10; j++) {
      fill_n(cnt_array, 10, -1);
      dfs(i, 1, i, j, cnt_array);
      dfs(j, 1, i, j, cnt_array);
      matrix[i][j] = add_val(cnt_array, s);
      matrix[j][i] = matrix[i][j];
    }
  for (int i = 0; i < int(10); i++) {
    for (int j = 0; j < int(10); j++) cout << matrix[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
