#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
int dp[12][12][12][12];
int a[2000100];
int n;
int main() {
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++)
        for (int t = 0; t < 10; t++) {
          dp[i][j][k][t] = INF;
          for (int x = 0; x < 10; x++)
            for (int y = 0; y < 10; y++)
              if (x + y != 0)
                if ((i + k * x + t * y - j) % 10 == 0)
                  dp[i][j][k][t] = min(dp[i][j][k][t], x + y);
        }
  string s;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) a[i] = s[i] - '0';
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int res = 0;
      for (int t = 0; t < n - 1; t++) {
        int x, y;
        x = a[t];
        y = a[t + 1];
        if (dp[x][y][i][j] == INF) {
          res = -1;
          break;
        }
        res = res + dp[x][y][i][j] - 1;
      }
      cout << res;
      if (j < 9)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
