#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
string s;
int dis[10][10];
inline int sol() {
  int ans = 0;
  for (int i = 1; i < s.size(); i++) {
    if (dis[s[i - 1] - '0'][s[i] - '0'] == inf) return -1;
    ans += dis[s[i - 1] - '0'][s[i] - '0'] - 1;
  }
  return ans;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  for (int x = 0; x < 10; x++, printf("\n"))
    for (int y = 0; y < 10; y++) {
      memset(dis, 0x3f, sizeof dis);
      for (int i = 0; i < 10; i++)
        dis[i][(i + x) % 10] = dis[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++)
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      printf("%d ", sol());
    }
}
