#include <bits/stdc++.h>
using namespace std;
long long int po(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return po((x * x) % 1000000007, n / 2);
  else
    return (x * po((x * x) % 1000000007, (n - 1) / 2)) % 1000000007;
}
long long int GCD(long long int A, long long int B) {
  if (B == 0)
    return A;
  else
    return GCD(B, A % B);
}
int main() {
  string s;
  cin >> s;
  long long int pa[10][10];
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j) pa[i][j] = 0;
  long long int p = 0;
  for (int i = 0; i < s.length(); ++i) {
    pa[p][s[i] - 48]++;
    p = s[i] - 48;
  }
  if (s[0] == '0') pa[0][0]--;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      long long int dis[10][10];
      for (int i = 0; i < 10; ++i)
        for (int j = 0; j < 10; ++j) dis[i][j] = 1e18;
      for (int k = 0; k < 10; ++k) {
        dis[k][(k + i) % 10] = 1;
        dis[k][(k + j) % 10] = 1;
      }
      for (int k = 0; k < 10; ++k)
        for (int i = 0; i < 10; ++i)
          for (int j = 0; j < 10; ++j)
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      long long int an = 0, f = 0;
      for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
          if (dis[i][j] > 1e17 && pa[i][j] > 0) {
            cout << -1 << " ";
            f = 1;
            break;
          } else if (pa[i][j] > 0)
            an += pa[i][j] * (dis[i][j] - 1);
        }
        if (f) break;
      }
      if (f) continue;
      if (an > 1e17)
        cout << -1 << " ";
      else
        cout << an << " ";
    }
    cout << endl;
  }
}
