#include <bits/stdc++.h>
using namespace std;
struct Node {
  int val, dist;
};
int get_int(char c) {
  string s(1, c);
  return stoi(s);
}
int bfs(int i, int j, int s, int e) {
  queue<int> q;
  unordered_map<int, int> dist;
  q.push(s);
  dist[s] = 0;
  int result = 0;
  while (!q.empty()) {
    int n = q.front();
    q.pop();
    int d = dist[n];
    int next = (n + i) % 10;
    if (next == e) return d + 1;
    if (dist.find(next) == dist.end()) {
      q.push(next);
      dist[next] = d + 1;
    }
    next = (n + j) % 10;
    if (next == e) return d + 1;
    if (dist.find(next) == dist.end()) {
      q.push(next);
      dist[next] = d + 1;
    }
  }
  return -1;
}
int main() {
  string a;
  cin >> a;
  int rr[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      rr[i][j] = -2;
    }
  }
  int table[10][10][10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int x = 0; x < 10; x++) {
        for (int y = x; y < 10; y++) {
          table[i][j][x][y] = -2;
        }
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (rr[i][j] != -2) {
        cout << rr[i][j] << " ";
      } else {
        int r = 0;
        for (int k = 0; k < a.size() - 1; k++) {
          int res;
          if (table[(int)a[k] - 48][(int)a[k + 1] - 48][i][j] != -2) {
            res = table[(int)a[k] - 48][(int)a[k + 1] - 48][i][j];
          } else {
            res = bfs(i, j, (int)a[k] - 48, (int)a[k + 1] - 48);
            table[(int)a[k] - 48][(int)a[k + 1] - 48][i][j] = res;
          }
          if (res == -1) {
            r = -1;
            break;
          }
          r += (res - 1);
        }
        rr[i][j] = r;
        rr[j][i] = r;
        cout << r << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
