#include <bits/stdc++.h>
const long long INF32 = 1e9;
const long long INF64 = 1e17;
const int RANGE = 1e6 + 5;
using namespace std;
template <class T>
void read(T &Val) {
  T tmp = 0;
  char ch = getchar();
  int flag = 1;
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while ((ch >= '0' && ch <= '9')) {
    tmp = tmp * 10 + ch - '0';
    ch = getchar();
  }
  Val = flag * tmp;
}
long long dp[10][10][10][10];
int used[10][10][10][10];
int data[10];
long long work(int a, int b, int x, int y) {
  if (dp[a][b][x][y] != -1) return dp[a][b][x][y];
  int ans = INF32;
  for (int i = 1; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int tmp = (a + i * x + j * y) % 10;
      if (tmp == b) ans = min(ans, i + j - 1);
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      int tmp = (a + i * x + j * y) % 10;
      if (tmp == b) ans = min(ans, i + j - 1);
    }
  }
  dp[a][b][x][y] = ans;
  dp[a][b][y][x] = ans;
  return ans;
}
int get(int a, int b, int x, int y) {
  if (dp[a][b][x][y]) return dp[a][b][x][y];
}
void solveB() {
  memset(dp, -1, sizeof(dp));
  string s;
  cin >> s;
  int sLen = s.size();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      long long tmp = 0;
      for (int l = 0; l < sLen - 1; l++) {
        long long now = work(s[l] - '0', s[l + 1] - '0', i, j);
        if (now >= INF32) {
          tmp = INF32;
          break;
        }
        tmp += now;
      }
      if (tmp >= INF32)
        cout << -1;
      else
        cout << tmp;
      cout << " ";
    }
    cout << endl;
  }
}
int main() {
  solveB();
  return 0;
}
