#include <bits/stdc++.h>
using namespace std;
int f[10][10][10][10], ss[(int)2e6 + 10];
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) ss[i] = s[i] - '0';
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int k = 0; k <= 9; k++) {
        for (int i = 0; i <= 9; i++) {
          for (int j = 0; j <= 9; j++) {
            f[x][y][i][j] = 1e9;
          }
        }
      }
    }
  }
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int i = 0; i <= 9; i++) {
        f[x][y][i][(i + x) % 10] = 1;
        f[x][y][i][(i + y) % 10] = 1;
      }
    }
  }
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int k = 0; k <= 9; k++) {
        for (int i = 0; i <= 9; i++) {
          for (int j = 0; j <= 9; j++) {
            if (f[x][y][i][k] + f[x][y][k][j] < f[x][y][i][j])
              f[x][y][i][j] = f[x][y][i][k] + f[x][y][k][j];
          }
        }
      }
    }
  }
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      long long ans = 0;
      int wr = 0;
      for (int i = 1; i < s.size(); i++) {
        ans += f[x][y][ss[i - 1]][ss[i]] - 1;
        if (f[x][y][ss[i - 1]][ss[i]] >= 1e8) {
          wr = 1;
          break;
        }
      }
      if (wr)
        cout << -1 << ' ';
      else
        cout << ans << ' ';
    }
    cout << endl;
  }
  return 0;
}
