#include <bits/stdc++.h>
#pragma GCC omptimize("unroll-loops")
#pragma optimize("SEX_ON_THE_BEACH")
#pragma GCC optimize("no-stack-protector")
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = long double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
ll get_seed(string s) {
  ll ans = 0;
  for (int i = 0; i < s.size(); ++i) ans += s[i];
  return ans;
}
int popcount(int x) { return __builtin_popcount(x); }
ll popcountll(ll x) { return __builtin_popcount(x); }
int way[10][10];
void build(int x, int y) {
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j) way[i][j] = 1e5;
  for (int i = 0; i < 10; ++i) way[i][(i + x) % 10] = way[i][(i + y) % 10] = 1;
  for (int k = 0; k < 10; ++k)
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < 10; ++j)
        way[i][j] = min(way[i][j], way[i][k] + way[k][j]);
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      if (way[i][j] >= (int)(1e5)) way[i][j] = -1;
}
int get_ans(int x, int y, string& s) {
  build(x, y);
  ll ans = 0;
  int curr = 0;
  for (int i = 1; i < s.size(); ++i) {
    if (way[curr][s[i] - '0'] == -1) return -1;
    ans += way[curr][s[i] - '0'] - 1;
    curr = s[i] - '0';
  }
  return ans;
}
void solve(int ii) {
  string s;
  cin >> s;
  for (int x = 0; x < 10; ++x) {
    for (int y = 0; y < 10; ++y) cout << get_ans(x, y, s) << " ";
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; ++i) solve(i);
  return 0;
}
