#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
struct node {
  int x, y, z;
} pre[1005][N + 5][2];
int a, dg[1005][N + 5][2];
bool vis[1005][N + 5][2];
string solve() {
  const int K = 1000;
  queue<node> q;
  vis[0][K][0] = 1, dg[0][K][0] = -1;
  q.push({0, K, 0});
  while (!q.empty()) {
    int i = q.front().x, j = q.front().y, flg = q.front().z;
    q.pop();
    if (!i && j == K && flg) {
      string ans = "";
      node tmp;
      while (dg[i][j][flg] != -1) {
        if (!ans.empty() || dg[i][j][flg]) ans += (dg[i][j][flg] + '0');
        tmp = pre[i][j][flg];
        i = tmp.x, j = tmp.y, flg = tmp.z;
      }
      return ans;
    }
    for (int d = 0; d <= 9; d++) {
      int x = (i + d * a) / 10;
      int y = (i + d * a) % 10 * a - d + j;
      int z = (flg || d);
      if (y >= 0 && y <= N && !vis[x][y][z])
        vis[x][y][z] = 1, dg[x][y][z] = d, pre[x][y][z] = {i, j, flg},
        q.push({x, y, z});
    }
  }
  return "-1";
}
int main() {
  scanf("%d", &a);
  cout << solve() << endl;
}
