#include <bits/stdc++.h>
using namespace std;
long long ara[10][10];
long long cnt[10];
long long dif(long long x, long long y) {
  if (y >= x)
    return y - x;
  else
    return 10 + y - x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i + 1 < s.size(); i++) {
    int d = dif(s[i] - '0', s[i + 1] - '0');
    cnt[d]++;
  }
  for (long long D = 0; D < 10; D++) {
    if (cnt[D] == 0) continue;
    for (long long i = 0; i < 10; i++) {
      for (long long j = 0; j < 10; j++) {
        long long bostu = 2e12;
        for (long long x = 0; x < 10; x++) {
          for (long long y = 0; y < 10; y++) {
            if (x == 0 and y == 0) continue;
            if ((i * x + j * y - D) % 10 == 0) {
              bostu = min(bostu, x + y - 1);
            }
          }
        }
        ara[i][j] += cnt[D] * bostu;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (ara[i][j] >= 2e12)
        cout << "-1 ";
      else
        cout << ara[i][j] << " ";
    }
    cout << endl;
  }
}
