#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1.0) * 4;
const int INF = 1e7 + 9;
long long int ans[11][11];
int tab[11][11][11];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  string str;
  cin >> str;
  for (int i = 0; i < 11; i++)
    for (int j = 0; j < 11; j++)
      for (int k = 0; k < 11; k++) tab[i][j][k] = -1;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++)
          for (int m = 0; m < 10; m++) {
            if (l == 0 && m == 0) continue;
            int x = l * i + m * j;
            x = x % 10;
            if (x == k) {
              if (tab[i][j][k] == -1 || tab[i][j][k] > l + m - 1)
                tab[i][j][k] = l + m - 1;
            }
          }
      }
  for (int i = 0; i < 10; i++)
    for (int j = i; j < 10; j++) {
      int l = str.length();
      long long int tot = 0;
      bool g = true;
      for (int k = 0; k < l - 1; k++) {
        int x = str[k] - 48;
        int y = str[k + 1] - 48;
        int diff = y - x;
        if (diff < 0) diff += 10;
        if (tab[i][j][diff] == -1) {
          g = false;
          break;
        }
        tot += (long long int)tab[i][j][diff];
      }
      if (g)
        ans[i][j] = tot;
      else
        ans[i][j] = -1;
    }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (j < i)
        cout << ans[j][i] << " ";
      else
        cout << ans[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
