#include <bits/stdc++.h>
using namespace std;
long long INF = 1e9 + 7;
long long MOD = 998244353;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (long long x = 0; x < 10; x++) {
    for (long long y = 0; y < 10; y++) {
      long long ans = 0;
      long long dist[10][10];
      for (long long i = 0; i < 10; i++) {
        for (long long j = 0; j < 10; j++) {
          dist[i][j] = INF;
        }
      }
      for (long long i = 0; i < 10; i++) {
        dist[i][(i + x) % 10] = 1;
        dist[i][(i + y) % 10] = 1;
      }
      for (long long k = 0; k < 10; k++) {
        for (long long i = 0; i < 10; i++) {
          for (long long j = 0; j < 10; j++) {
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
          }
        }
      }
      for (long long i = 0; i < s.size() - 1; i++) {
        ans += dist[s[i] - '0'][s[i + 1] - '0'] - 1;
      }
      if (ans >= INF - 1) {
        ans = -1;
      }
      cout << ans << " ";
    }
    cout << "\n";
  }
}
