#include <bits/stdc++.h>
const double eps = 1e-8, pi = acos(-1.0);
const int maxS = 1e6 + 13;
const int maxT = 1e3 + 13;
const int MOD = 835672545;
const int base = 19260817;
const int layer = 20;
using namespace std;
inline void read(long long &x) { scanf("%lld", &x); }
inline void read(long long &x, long long &y) {
  read(x);
  read(y);
}
inline void read(long long &x, long long &y, long long &z) {
  read(x, y);
  read(z);
}
inline void read(int &x) { scanf("%d", &x); }
inline void read(int &x, int &y) {
  read(x);
  read(y);
}
inline void read(int &x, int &y, int &z) {
  read(x, y);
  read(z);
}
int n, m, x, y, z, T, kase = 0;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int f[10][10][10][10], inf;
string str;
int main() {
  memset(f, 0x3f, sizeof(f));
  inf = f[0][0][0][0];
  for (int x = 0; x < 10; x++)
    for (int y = 0; y < 10; y++) {
      for (int i = 0; i < 10; i++) {
        f[x][y][i][(i + x) % 10] = 1;
        f[x][y][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++)
            f[x][y][i][j] = min(f[x][y][i][j], f[x][y][i][k] + f[x][y][k][j]);
    }
  cin >> str;
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      int ans = 0;
      if (str[0] != '0') {
        int t = f[x][y][0][str[0] - '0'];
        if (t == inf) {
          printf("-1 ");
          continue;
        } else
          ans = t;
      }
      int i;
      for (i = 1; i < str.length(); i++) {
        int t = f[x][y][str[i - 1] - '0'][str[i] - '0'];
        if (t == inf) {
          printf("-1 ");
          break;
        } else
          ans += t - 1;
      }
      if (i == str.length()) printf("%d ", ans);
    }
    printf("\n");
  }
  return 0;
}
