#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000005;
const int mod = 998244353;
char s[maxn];
int a[55];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 10; y++) {
      for (int i = 0; i <= 10; i++) a[i] = mod;
      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          if ((i == 0) && (j == 0)) continue;
          a[(i * x + j * y) % 10] = min(a[(i * x + j * y) % 10], i + j - 1);
        }
      }
      int ans = 0;
      for (int i = 0; i + 1 < n; i++) {
        if (a[(s[i + 1] - s[i] + 10) % 10] == mod) {
          ans = -1;
          break;
        } else
          ans += a[(s[i + 1] - s[i] + 10) % 10];
      }
      printf("%d ", ans);
      if (y == 9) printf("\n");
    }
  }
  return 0;
}
