#include <bits/stdc++.h>
using namespace std;
string s;
int f[15];
int get(int x, int y, int k) {
  int an = 30;
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j <= 9; j++) {
      if (k == 0 && i == 0 && j == 0) continue;
      if ((x * i + y * j) % 10 == k) an = min(an, i + j);
    }
  return an;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int k = 0; k <= 9; k++) f[k] = get(i, j, k);
      f[0] = min(f[0], 10);
      bool z = 1;
      for (auto j : s)
        if (f[j - '0'] == 30) z = 0;
      if (!z)
        cout << -1 << " ";
      else {
        int ans = 0;
        int cur = 0;
        for (auto j : s) {
          int d = ((j - '0') - cur + 10) % 10;
          ans += f[d] - 1;
          cur = j - '0';
        }
        cout << ans - f[0] + 1 << " ";
      }
    }
    cout << '\n';
  }
  return 0;
}
