#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MOD = 998244353;
long long n, m, k, q, p, ans, l, r, i, j, x, y, a[500001], b[11][11][11];
vector<long long> c[300001];
vector<long long> v;
long long d[1000001];
bool t[1000001];
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  for (int x = 0; x < 10; x++)
    for (int y = 0; y < 10; y++)
      for (int z = 0; z < 10; z++) {
        bool t[11] = {};
        vector<pair<long long, long long> > v;
        long long o = 0, p = 0, l = y, r = x;
        while (!t[p]) {
          v.push_back(make_pair(p, o));
          t[p] = 1;
          p += r;
          o++;
          p %= 10;
        }
        v.push_back(make_pair(p, o));
        long long mn = 1e10;
        for (int j = 0; j < v.size(); j++) {
          bool tt[11] = {};
          long long p = v[j].first, q = 1e10;
          while (!tt[p]) {
            if (p == z) {
              q -= 1e10;
              break;
            }
            tt[p] = 1;
            q++;
            p += l;
            p %= 10;
          }
          long long u = q + v[j].second - 1;
          if (u > -1 && u < 1e10) mn = min(mn, u);
        }
        b[x][y][z] = mn;
        if (x > y) {
          p = min(b[x][y][z], b[y][x][z]);
          b[x][y][z] = p;
          b[y][x][z] = p;
        }
      }
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      long long ans = 0;
      for (int i = 0; i < s.size() - 1; i++) {
        long long p = s[i + 1] - s[i];
        if (p < 0) p += 10;
        ans += b[x][y][p];
      }
      if (ans >= 1e10 || ans < 0)
        cout << "-1 ";
      else
        cout << ans << " ";
    }
    cout << "\n";
  }
  return 0;
}
