#include <bits/stdc++.h>
using namespace std;
char s[2000010];
int dp[15][15][15];
struct BFS {
  int value;
  int steps;
};
int main() {
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      BFS bfs, bfs1, bfs2;
      bfs.steps = 0;
      bfs.value = 0;
      queue<BFS> item;
      item.push(bfs);
      while (!item.empty()) {
        bfs = item.front();
        item.pop();
        bfs1.value = (bfs.value + i) % 10;
        bfs1.steps = bfs.steps + 1;
        bfs2.value = (bfs.value + j) % 10;
        bfs2.steps = bfs.steps + 1;
        if (dp[i][j][bfs1.value] == 0 || dp[i][j][bfs1.value] > bfs1.steps) {
          dp[i][j][bfs1.value] = bfs1.steps;
          item.push(bfs1);
        }
        if (dp[i][j][bfs2.value] == 0 || dp[i][j][bfs2.value] > bfs2.steps) {
          dp[i][j][bfs2.value] = bfs2.steps;
          item.push(bfs2);
        }
      }
    }
  }
  cin >> s;
  int len = strlen(s);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int ans = 0;
      for (int k = 0; k < len - 1; k++) {
        int num = s[k + 1] - s[k];
        if (num < 0) {
          num += 10;
        }
        if (!dp[i][j][num]) {
          ans = -1;
          break;
        }
        ans += dp[i][j][num] - 1;
      }
      printf("%d ", ans);
    }
    printf("\n");
  }
  return 0;
}
