#include <bits/stdc++.h>
using namespace std;
string s;
int a[15][15][15][15];
void fun() {
  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++) a[i][j][k][l] = 1000;
  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 c1 = 0; c1 < 15; c1++) {
            for (int c2 = 0; c2 < 15; c2++) {
              if (c1 == 0 && c2 == 0) continue;
              if ((k + c1 * i + c2 * j) % 10 == l) {
                a[k][l][i][j] = min(a[k][l][i][j], c1 + c2);
              }
            }
          }
        }
      }
    }
  }
}
int main() {
  fun();
  cin >> s;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int sum = 0;
      for (int k = 0; k < s.size() - 1; k++) {
        int now = a[s[k] - '0'][s[k + 1] - '0'][i][j];
        if (now == 1000) {
          sum = -1;
          break;
        }
        sum += now - 1;
      }
      if (j < 9) {
        if (sum == -1)
          printf("-1 ");
        else
          printf("%d ", sum);
      } else {
        if (sum == -1)
          printf("-1\n");
        else
          printf("%d\n", sum);
      }
    }
  }
  return 0;
}
