#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  s.erase(s.begin());
  vector<vector<vector<int>>> dp(10,
                                 vector<vector<int>>(10, vector<int>(10, -1)));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      queue<pair<int, int>> bfs;
      bfs.push({i, 1});
      bfs.push({j, 1});
      dp[i][j][i] = dp[i][j][j] = 1;
      while (!bfs.empty()) {
        pair<int, int> x = bfs.front();
        bfs.pop();
        dp[i][j][x.first] = x.second;
        if (dp[i][j][(x.first + i) % 10] == -1) {
          dp[i][j][(x.first + i) % 10] = x.second + 1;
          bfs.push({(x.first + i) % 10, x.second + 1});
        }
        if (dp[i][j][(x.first + j) % 10] == -1) {
          dp[i][j][(x.first + j) % 10] = x.second + 1;
          bfs.push({(x.first + j) % 10, x.second + 1});
        }
      }
    }
  }
  long long len = s.length();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      long long res = 0;
      int l = 0;
      for (auto &x : s) {
        int k = (((x - '0') - l) + 10) % 10;
        l = x - '0';
        if (dp[i][j][k] == -1) {
          res = -1;
          break;
        }
        res += dp[i][j][k];
      }
      if (res != -1)
        cout << res - len << " ";
      else
        cout << -1 << " ";
    }
    cout << endl;
  }
}
