#include <bits/stdc++.h>
using namespace std;
string a;
int x[100];
int sol(int m, int n) {
  for (int i = 0; i <= 10; i++) x[i] = 100;
  for (int i = 0; i <= 10; i++) {
    for (int j = 0; j <= 10; j++) {
      if (i == 0 && j == 0) continue;
      x[(i * m + j * n) % 10] = min(x[(i * m + j * n) % 10], i + j);
    }
  }
  int sum = 0;
  int num;
  for (int i = 1; i < a.length(); i++) {
    num = a[i] - a[i - 1];
    if (num < 0) num += 10;
    if (x[num] == 100) return -1;
    sum += x[num] - 1;
  }
  return sum;
}
int main() {
  cin >> a;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      cout << sol(i, j) << " ";
    }
    cout << endl;
  }
  return 0;
}
