#include <bits/stdc++.h>
using namespace std;
int path[10][10][10][10];
int ans[10][10];
bool visited[10];
int cpath(int i, int j, int a, int b) {
  queue<pair<int, int> > q;
  for (int k = 0; k < 10; ++k) visited[k] = false;
  if (i != j) {
    q.push(make_pair((a + i) % 10, 1));
    q.push(make_pair((a + j) % 10, 1));
    visited[(a + i) % 10] = true;
    visited[(a + j) % 10] = true;
  } else {
    q.push(make_pair((a + i) % 10, 1));
    visited[(a + i) % 10] = true;
  }
  while (!q.empty()) {
    pair<int, int> e = q.front();
    if (e.first == b) return e.second;
    q.pop();
    if (!visited[(e.first + i) % 10]) {
      q.push(make_pair((e.first + i) % 10, e.second + 1));
      visited[(e.first + i) % 10] = true;
    }
    if (!visited[(e.first + j) % 10]) {
      q.push(make_pair((e.first + j) % 10, e.second + 1));
      visited[(e.first + j) % 10] = true;
    }
  }
  return -1;
}
void print(int i, int j) {
  cout << i << ":" << j << ":" << endl;
  for (int a = 0; a < 10; ++a)
    for (int b = 0; b < 10; ++b) {
      cout << a << "," << b << "->" << path[i][j][a][b] << "  ";
    }
  cout << endl;
}
int main() {
  for (int i = 0; i < 10; ++i) {
    for (int j = i; j < 10; ++j) {
      for (int a = 0; a < 10; ++a) {
        for (int b = 0; b < 10; ++b) {
          path[i][j][a][b] = cpath(i, j, a, b);
        }
      }
    }
  }
  string str;
  cin >> str;
  for (int i = 0; i < 10; ++i) {
    for (int j = i; j < 10; ++j) {
      long long c = 0;
      for (int k = 1; k < str.size(); ++k) {
        int a = str[k - 1] - '0', b = str[k] - '0';
        if (path[i][j][a][b] == -1) {
          c = -1;
          break;
        }
        c += (long long)path[i][j][a][b] - 1;
      }
      ans[i][j] = c;
      ans[j][i] = c;
    }
  }
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}
