#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e6 + 5;
const int mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long ans = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }
int n, m, T;
char s[maxn];
vector<int> a[10];
int ans[10][10];
int dp[10][10][10];
int cal(int ss, int tt, int x, int y) {
  int d = (tt + 10 - ss) % 10;
  if (dp[d][x][y] != mod) return dp[d][x][y];
  int res = mod;
  for (int i = 1; i <= a[x].size(); i++) {
    if (a[x][i - 1] == d) res = min(res, i - 1);
    for (int j = 1; j <= a[y].size(); j++) {
      if (a[y][j - 1] == d) res = min(res, j - 1);
      if ((a[x][i - 1] + a[y][j - 1]) % 10 == d) {
        res = min(res, i + j - 1);
      }
    }
  }
  if (res == mod) return dp[d][x][y] = dp[d][y][x] = -1;
  return dp[d][x][y] = dp[d][y][x] = res;
}
int gao(int x, int y) {
  long long Ans = 0;
  for (int i = 2; i <= n; i++) {
    long long temp = cal(s[i - 1] - '0', s[i] - '0', x, y);
    if (temp == -1) return -1;
    Ans += temp;
  }
  return Ans;
}
int main() {
  for (int i = 0; i < 10; i++) {
    for (int j = i;; j += i) {
      a[i].push_back(j % 10);
      if (j % 10 == 0) break;
    }
  }
  cin >> s + 1;
  n = strlen(s + 1);
  for (int i = 0; i <= 9; i++)
    for (int j = 0; j <= 9; j++)
      for (int k = 0; k <= 9; k++) dp[i][j][k] = mod;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j <= i; j++) {
      if (i == 9 && j == 7) {
        int temp = 0;
      }
      ans[i][j] = ans[j][i] = gao(i, j);
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      printf("%d%c", ans[i][j], " \n"[j == 9]);
    }
  }
  return 0;
}
