#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 2e9, MOD = 1e9 + 7;
const ll INFLL = 1e18;
int dp[10][10][10][10];
void init() {
  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] = INF;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int cnt = 0;
  if (s[0] != '0') {
    cnt++;
    s = '0' + s;
  }
  vector<int> ar;
  for (auto i : s) ar.push_back(i - '0');
  init();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int start = 0; start < 10; start++) {
        for (int k = 1; k <= 10; k++) {
          dp[i][j][start][(start + i * k) % 10] =
              min(dp[i][j][start][(start + i * k) % 10], k);
          dp[i][j][start][(start + j * k) % 10] =
              min(dp[i][j][start][(start + j * k) % 10], k);
        }
        for (int l = 0; l < 10; l++) {
          for (int k = 1; k <= 10; k++) {
            dp[i][j][start][(l + j * k) % 10] =
                min(dp[i][j][start][(l + j * k) % 10], dp[i][j][start][l] + k);
          }
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int ans = 0;
      bool sol = true;
      for (int k = 1; k < ar.size() and sol; k++) {
        if (dp[i][j][ar[k - 1]][ar[k]] == INF)
          sol = false;
        else
          ans += dp[i][j][ar[k - 1]][ar[k]] - 1;
      }
      cout << (sol ? ans + cnt : -1) << ' ';
    }
    cout << '\n';
  }
  return 0;
}
