#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      vector<vector<long long>> dist(10, vector<long long>(10, 1e9));
      for (int d = 0; d < 10; d++) {
        int c = (d + x) % 10;
        dist[d][c] = 1;
        c = (d + y) % 10;
        dist[d][c] = 1;
      }
      for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
          for (int j = 0; j < 10; j++) {
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
          }
        }
      }
      int ans = 0;
      int prev = 0;
      for (int i = 1; i < s.size(); i++) {
        int curr = s[i] - '0';
        if (dist[prev][curr] == 1e9) {
          ans = -1;
          break;
        }
        ans += dist[prev][curr];
        prev = curr;
      }
      if (ans == -1)
        cout << ans << " ";
      else
        cout << (ans - (int)s.size() + 1) << " ";
    }
    cout << endl;
  }
  return 0;
}
