#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<vector<vector<int>>> v(10,
                                vector<vector<int>>(10, vector<int>(10, -1)));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      v[i][j][i] = 0;
      v[i][j][j] = 0;
      vector<set<int>> s(10);
      s[0].insert(i);
      s[0].insert(j);
      int pos = 0;
      while (!s[pos].empty()) {
        for (auto u : s[pos]) {
          if (v[i][j][(u + i) % 10] == -1) {
            s[pos + 1].insert((u + i) % 10);
            v[i][j][(u + i) % 10] = pos + 1;
          }
          if (v[i][j][(u + j) % 10] == -1) {
            s[pos + 1].insert((u + j) % 10);
            v[i][j][(u + j) % 10] = pos + 1;
          }
        }
        pos++;
      }
    }
  }
  string s;
  cin >> s;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int ans = 0;
      bool flag = false;
      for (int k = 0; k < s.length() - 1; k++) {
        int n1 = s[k] - '0';
        int n2 = s[k + 1] - '0';
        int temp;
        if (n2 >= n1) {
          temp = v[i][j][n2 - n1];
        } else {
          temp = v[i][j][n2 - n1 + 10];
        }
        if (temp == -1) {
          flag = true;
          break;
        } else {
          ans += temp;
        }
      }
      if (flag) {
        cout << -1 << " ";
      } else {
        cout << ans << " ";
      }
    }
    cout << '\n';
  }
}
