#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 123;
int ans[10][10];
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int a = 0; a < 10; ++a) {
    for (int b = a; b < 10; ++b) {
      vector<int> mn(10, inf);
      for (int x = 0; x < 10; ++x) {
        for (int y = 0; y < 10; ++y)
          if (x || y)
            mn[(a * x + b * y) % 10] = min(mn[(a * x + b * y) % 10], x + y);
      }
      for (int i = 1; i < (int)s.size(); ++i) {
        int tmp = (s[i] - s[i - 1] + 10) % 10;
        if (mn[tmp] != inf)
          ans[a][b] += mn[tmp] - 1;
        else {
          ans[a][b] = -1;
          break;
        }
      }
    }
  }
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j)
      cout << (i <= j ? ans[i][j] : ans[j][i]) << ' ';
    cout << '\n';
  }
  return 0;
}
