#include <bits/stdc++.h>
using namespace std;
int dp[10][10][10][10];
int odp[10][10];
int main(void) {
  string s;
  cin >> s;
  for (int x = 0; x <= 9; x++) {
    for (int y = 0; y <= 9; y++) {
      for (int a = 0; a <= 9; a++) {
        for (int b = 0; b <= 9; b++) {
          dp[x][y][a][b] = 1e9;
          for (int c = 0; c <= 9; c++) {
            for (int d = 0; d <= 9; d++) {
              if ((x + c * a + d * b) % 10 == y && (c != 0 || d != 0)) {
                dp[x][y][a][b] = min(dp[x][y][a][b], c + d);
              }
            }
          }
        }
      }
    }
  }
  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int i = 0; i < s.size() - 1; i++) {
        if (dp[s[i] - 48][s[i + 1] - 48][a][b] != 1e9) {
          odp[a][b] += dp[s[i] - 48][s[i + 1] - 48][a][b];
        } else {
          odp[a][b] = -1;
          break;
        }
      }
    }
  }
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      if (odp[i][j] != -1)
        printf("%d ", odp[i][j] - s.size() + 1);
      else
        printf("-1 ");
    }
    printf("\n");
  }
  return 0;
}
