#include <bits/stdc++.h>
using namespace std;
const int N = 13, M = 2011111;
int dis[N][N][N][N], val[M], n;
int main() {
  memset(dis, 0x3f, sizeof dis);
  int iNF = dis[1][1][1][2];
  for (int s1 = 0; s1 <= 9; s1++) {
    for (int s2 = 0; s2 <= 9; s2++) {
      for (int i = 0; i <= 9; i++) {
        dis[s1][s2][i][(i + s1) % 10] = 1;
        dis[s1][s2][i][(i + s2) % 10] = 1;
      }
      for (int k = 0; k <= 9; k++)
        for (int i = 0; i <= 9; i++)
          for (int j = 0; j <= 9; j++) {
            if (dis[s1][s2][i][k] + dis[s1][s2][k][j] < dis[s1][s2][i][j])
              dis[s1][s2][i][j] = dis[s1][s2][i][k] + dis[s1][s2][k][j];
          }
    }
  }
  char ch;
  while ((ch = getchar()) != '\n') val[++n] = ch - '0';
  for (int s1 = 0; s1 <= 9; s1++) {
    for (int s2 = 0; s2 <= 9; s2++) {
      int cnt = 0;
      for (int i = 1; i < n; i++) {
        if (dis[s1][s2][val[i]][val[i + 1]] != iNF) {
          cnt += dis[s1][s2][val[i]][val[i + 1]] - 1;
        } else {
          cnt = -1;
          break;
        }
      }
      cout << cnt << " ";
    }
    cout << endl;
  }
  return 0;
}
