#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long counts[11][11];
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      counts[i][j] = -1;
    }
  }
  counts[0][0] = 1;
  for (long long i = 1; i < 10; i++) {
    for (long long j = 1; j < 100; j++) {
      if (j % i == 0) {
        long long temp = j / i;
        long long las = j % 10;
        if (counts[i][las] == -1) counts[i][las] = temp;
      }
    }
  }
  long long n = s.size();
  long long ans[11][11][11];
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      for (long long k = 0; k < 10; k++) {
        ans[i][j][k] = 0;
      }
    }
  }
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      for (long long k = 0; k < 10; k++) {
        long long aa = 1000000000000000007;
        if (counts[i][k] != -1) {
          aa = min(aa, counts[i][k]);
        }
        if (counts[j][k] != -1) {
          aa = min(aa, counts[j][k]);
        }
        for (long long l = 1; l < 10; l++) {
          long long ind = (k - l + 10) % 10;
          if (counts[i][l] != -1 && counts[j][ind] != -1) {
            aa = min(aa, counts[i][l] + counts[j][ind]);
          }
        }
        ans[i][j][k] = aa;
      }
    }
  }
  long long fans[11][11];
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      fans[i][j] = 0;
    }
  }
  for (long long a = 0; a < 10; a++) {
    for (long long b = a; b < 10; b++) {
      for (long long i = 1; i < n; i++) {
        long long val = (s[i] - '0') - (s[i - 1] - '0');
        val = (val + 10) % 10;
        long long aa = ans[a][b][val];
        if (aa != 1000000000000000007) {
          if (fans[a][b] != -1) {
            fans[a][b] += (aa - 1);
            if (a != b) fans[b][a] += (aa - 1);
          }
        } else {
          fans[a][b] = -1;
          fans[b][a] = -1;
        }
      }
    }
  }
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      cout << fans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
