#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int T[10][10][10];
  memset(T, -1, sizeof(T));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
          if (x == 0 && y == 0) {
            continue;
          }
          int p = (x * i + y * j) % 10;
          if (T[i][j][p] == -1)
            T[i][j][p] = x + y;
          else
            T[i][j][p] = min(T[i][j][p], x + y);
        }
      }
    }
  }
  vector<vector<int>> ans(10, vector<int>(10, 0));
  vector<vector<bool>> bad(10, vector<bool>(10, false));
  for (int i = 0; i < s.length() - 1; i++) {
    int diff = (s[i + 1] - s[i] + 10) % 10;
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        if (T[j][k][diff] == -1) bad[j][k] = true;
        ans[j][k] += T[j][k][diff] - 1;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (bad[i][j])
        cout << -1 << " ";
      else {
        cout << ans[i][j] << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
