#include <bits/stdc++.h>
using namespace std;
long long ceildiv(long long one, long long two) {
  if (one % two == 0) {
    return one / two;
  } else {
    return one / two + 1;
  }
}
long long power(long long n, long long pow, long long m) {
  if (pow == 0) return 1;
  if (pow % 2 == 0) {
    long long x = power(n, pow / 2, m);
    return (x * x) % m;
  } else
    return (power(n, pow - 1, m) * n) % m;
}
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long factorial(long long n, long long mod) {
  if (n > 1)
    return (n * factorial(n - 1, mod)) % mod;
  else
    return 1;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
vector<long long> read(long long n) {
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  return a;
}
vector<vector<long long>> adj;
void init(long long n) {
  for (long long i = 0; i <= n; i++) {
    vector<long long> a;
    adj.push_back(a);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long fsr[10][10][10];
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      for (long long k = 0; k < 10; k++) {
        fsr[i][j][k] = 1000000000000000000;
      }
    }
  }
  for (long long digit1 = 0; digit1 < 10; digit1++) {
    for (long long digit2 = 0; digit2 < 10; digit2++) {
      long long dp[155];
      dp[0] = 0;
      if (digit1 == 0 || digit2 == 0) {
        fsr[digit1][digit2][0] = 1;
      }
      for (long long i = 1; i <= 150; i++) {
        dp[i] = 1000000000000000000;
        if (i >= digit1) {
          dp[i] = min(dp[i], dp[i - digit1] + 1);
        }
        if (i >= digit2) {
          dp[i] = min(dp[i], dp[i - digit2] + 1);
        }
        fsr[digit1][digit2][i % 10] = min(fsr[digit1][digit2][i % 10], dp[i]);
      }
    }
  }
  string s;
  cin >> s;
  long long ans[10][10];
  for (long long i = 0; i < 10; i++) {
    for (long long j = 0; j < 10; j++) {
      ans[i][j] = -1;
    }
  }
  for (long long digit1 = 0; digit1 < 10; digit1++) {
    for (long long digit2 = 0; digit2 < 10; digit2++) {
      if (ans[digit2][digit1] != -1) {
        cout << ans[digit2][digit1] << " ";
        continue;
      }
      long long now = 0;
      for (long long i = 0; i < (long long)s.size() - 1LL; i++) {
        long long dif = (s[i + 1] - '0') - (s[i] - '0');
        if (dif < 0) {
          dif += 10;
        }
        if (fsr[digit1][digit2][dif] == 1000000000000000000) {
          now = -1;
          break;
        }
        now += fsr[digit1][digit2][dif] - 1;
      }
      ans[digit1][digit2] = now;
      cout << ans[digit1][digit2] << " ";
    }
    cout << '\n';
  }
}
