#include <bits/stdc++.h>
using namespace std;
ostream& operator<<(ostream& os, const vector<long long int>& arr) {
  for (int i : arr) os << i << ' ';
  os << endl;
  return os;
}
long long int factorial(long long int x) {
  long long int r = 1;
  while (x) {
    r = r * x;
    x--;
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int rec(string second, long long int a, long long int b) {
  long long int dp[10][10];
  map<long long int, long long int> sums;
  for (long long int i = 0; i <= 9; i++) {
    for (long long int j = 0; j <= 9; j++) {
      long long int sum = a * i + b * j;
      if ((i | j) != 0) {
        if (!sums.count(sum)) {
          sums[sum] = i + j - 1;
        } else {
          sums[sum] = min(sums[sum], i + j - 1);
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      dp[i][j] = INT_MAX;
      for (auto k = sums.begin(); k != sums.end(); k++) {
        if ((i + k->first) % 10 == j) {
          dp[i][j] = min(dp[i][j], k->second);
        }
      }
    }
  }
  long long int minimum = 0;
  for (int in = 1; in < second.size(); in++) {
    if (dp[second[in - 1] - '0'][second[in] - '0'] != INT_MAX) {
      minimum += dp[second[in - 1] - '0'][second[in] - '0'];
    } else {
      return -1;
    }
  }
  return minimum;
}
int main() {
  string second;
  cin >> second;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cout << rec(second, i, j) << " ";
    }
    cout << endl;
  }
  return 0;
}
