#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int dp[10][10][10][10];
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++)
        for (int l = 0; l < 10; l++) {
          dp[i][j][k][l] = INT_MAX;
          for (int t1 = 0; t1 <= 10; t1++) {
            for (int t2 = 0; t2 <= 10; t2++) {
              if ((t1 * i + t2 * j) % 10 == (l - k + 10) % 10 &&
                  (t1 != 0 || t2 != 0)) {
                dp[i][j][k][l] = min(dp[i][j][k][l], t1 + t2);
              }
            }
          }
        }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int ans = 0;
      for (int k = 0; k < s.length() - 1; k++) {
        if (dp[i][j][s[k] - '0'][s[k + 1] - '0'] == INT_MAX) {
          ans = -1;
          break;
        } else {
          ans += max(0, dp[i][j][s[k] - '0'][s[k + 1] - '0'] - 1);
        }
      }
      cout << ans << " ";
    }
    cout << endl;
  }
}
