#include <bits/stdc++.h>
using namespace std;
int m[10][10][10][10];
long long ans[10][10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(m, -1, sizeof(m));
  for (int i = 0; i <= 9; ++i) {
    for (int j = 0; j <= 9; ++j) {
      for (int k = 0; k <= 9; ++k) {
        queue<int> q;
        q.push((k + i) % 10);
        q.push((k + j) % 10);
        m[k][(k + i) % 10][i][j] = 0;
        m[k][(k + j) % 10][i][j] = 0;
        while (!q.empty()) {
          int t = q.front();
          q.pop();
          int x = (t + i) % 10;
          int y = (t + j) % 10;
          if (m[k][x][i][j] == -1) {
            q.push(x);
            m[k][x][i][j] = m[k][t][i][j] + 1;
          }
          if (m[k][y][i][j] == -1) {
            q.push(y);
            m[k][y][i][j] = m[k][t][i][j] + 1;
          }
        }
      }
    }
  }
  string a;
  cin >> a;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      long long t = 0;
      for (int k = 0; k < a.size() - 1; ++k) {
        if (m[a[k] - '0'][a[k + 1] - '0'][i][j] == -1) {
          t = -1;
          break;
        }
        t += m[a[k] - '0'][a[k + 1] - '0'][i][j];
      }
      ans[i][j] = t;
    }
  }
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j) cout << ans[i][j] << (j == 9 ? '\n' : ' ');
  return 0;
}
