#include <bits/stdc++.h>
using namespace std;
long long d[10][10][10][10];
long long ans[10][10];
int main() {
  string s;
  cin >> s;
  long long arr[s.size()];
  for (long long i = 0; i < 10; ++i) {
    for (long long j = 0; j < 10; ++j) {
      for (long long x = 0; x < 10; ++x) {
        for (long long y = 0; y < 10; ++y) {
          d[i][j][x][y] = 100000000;
          long long f = true;
          for (long long a = 0; a < 11; ++a) {
            for (long long b = 0; b < 11; ++b) {
              if (a > 0 || b > 0) {
                if ((a * x + b * y + i) % 10 == j) {
                  f = false;
                  d[i][j][x][y] = min(a + b - 1, d[i][j][x][y]);
                }
              }
            }
          }
          if (f) {
            d[i][j][x][y] = -100000000;
          }
        }
      }
    }
  }
  for (long long i = 0; i < s.size(); ++i) {
    arr[i] = (long long)(s[i]) - 48;
  }
  for (long long x = 0; x < 10; ++x) {
    for (long long y = 0; y < 10; ++y) {
      for (long long i = 1; i < s.size(); ++i) {
        ans[x][y] += d[arr[i]][arr[i - 1]][x][y];
      }
    }
  }
  if (ans[0][0] < 0) {
    cout << -1 << ' ';
  } else {
    cout << ans[0][0] << ' ';
  }
  for (long long j = 9; j > 0; --j) {
    if (ans[0][j] < 0) {
      cout << -1 << ' ';
    } else {
      cout << ans[0][j] << ' ';
    }
  }
  cout << '\n';
  for (long long i = 9; i > 0; --i) {
    if (ans[i][0] < 0) {
      cout << -1 << ' ';
    } else {
      cout << ans[i][0] << ' ';
    }
    for (long long j = 9; j > 0; --j) {
      if (ans[i][j] < 0) {
        cout << -1 << ' ';
      } else {
        cout << ans[i][j] << ' ';
      }
    }
    cout << '\n';
  }
  return 0;
}
