#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using int64 = long long int;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1 << 28;
const ll MOD = 1000000007LL;
const int T = 10;
ll solve(string &s, int x, int y) {
  vector<vector<int> > dist(T, vector<int>(T, INF));
  for (int i = 0; i < T; i++) {
    chmin(dist[i][(i + x) % 10], 1);
    chmin(dist[i][(i + y) % 10], 1);
  }
  for (int k = 0; k < T; k++) {
    for (int i = 0; i < T; i++) {
      for (int j = 0; j < T; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int N = s.length();
  ll ans = 1 - N;
  for (int i = 0; i + 1 < N; i++) {
    int u = s[i] - '0', v = s[i + 1] - '0';
    if (dist[u][v] == INF) return -1;
    ans += dist[u][v];
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  vector<bool> exist(10);
  for (auto c : s) exist[c - '0'] = true;
  for (int i = 0; i < T; i++) {
    for (int j = 0; j < T; j++) {
      ll v = solve(s, i, j);
      printf("%lld%c", v, " \n"[j + 1 == T]);
    }
  }
  return 0;
}
