#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
long long mod = 998244353;
long long inf = 1e9;
long double eps = 1e-15;
double pi = acos(-1);
ifstream in("input.txt");
ofstream out("output.txt");
int main() {
  int rem[10][10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        rem[i][j][k] = 1e9;
      }
      for (int x = 0; x < 20; x++) {
        for (int y = 0; y < 20; y++) {
          int r = x * i + y * j;
          if (r % 10 == 0) {
            if (r != 0) {
              rem[i][j][r % 10] = min(rem[i][j][r % 10], x + y);
            } else if (i == 0 || j == 0) {
              rem[i][j][0] = 0;
            }
          } else {
            rem[i][j][r % 10] = min(rem[i][j][r % 10], x + y);
          }
        }
      }
      for (int k = 0; k < 10; k++) {
        if (rem[i][j][k] == 1e9) rem[i][j][k] = -1;
      }
    }
  }
  string s;
  cin >> s;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      bool kk = 1;
      int cnt = 0;
      for (int q = 0; q < s.size() - 1; q++) {
        int d = s[q + 1] - s[q];
        d %= 10;
        d += 10;
        d %= 10;
        if (rem[i][j][d] == -1) {
          kk = 0;
          break;
        } else {
          cnt += max(0, rem[i][j][d] - 1);
        }
      }
      if (kk) {
        cout << cnt << " ";
      } else {
        cout << -1 << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
