#include <bits/stdc++.h>
using namespace std;
long long int steps[10][10][10][10];
void cal(long long int x, long long int y, long long int start,
         long long int cnt, long long int cn) {
  if (cnt > 15) return;
  if (cnt != 0) {
    steps[x][y][start][cn] = min(steps[x][y][start][cn], cnt);
  }
  cal(x, y, start, cnt + 1, (cn + x) % 10);
  cal(x, y, start, cnt + 1, (cn + y) % 10);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) {
      for (long long int k = 0; k < 10; k++) {
        for (long long int l = 0; l < 10; l++) {
          steps[i][j][k][l] = 10000;
        }
      }
    }
  }
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) {
      for (long long int k = 0; k < 10; k++) {
        cal(i, j, k, 0, k);
      }
    }
  }
  string str;
  cin >> str;
  for (long long int i = 0; i < 10; i++) {
    for (long long int j = 0; j < 10; j++) {
      bool flag = true;
      long long int ans = 0;
      for (long long int k = 1; k < str.length(); k++) {
        long long int start = str[k - 1] - '0';
        long long int end = str[k] - '0';
        if (steps[i][j][start][end] == 15 || steps[i][j][start][end] == 10000) {
          flag = false;
          break;
        } else {
          ans += steps[i][j][start][end] - 1;
        }
      }
      if (flag) {
        cout << ans << " ";
      } else {
        cout << -1 << " ";
      }
    }
    cout << endl;
  }
}
