Problem: You are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s.

Input

The first line contains two positive integers d and s (1 ≤ d ≤ 500, 1 ≤ s ≤ 5000) separated by space.

Output

Print the required number or -1 if it doesn't exist.

Examples

Input

13 50


Output

699998


Input

61 2


Output

1000000000000000000000000000001


Input

15 50


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
const int N = 5e3 + 10;
const int inf = 1e9 + 7;
int f[N][501];
int p[N], d, s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> d >> s;
  if (d % 3 == 0 && s % 3) return 0 * puts("-1");
  if (d % 9 == 0 && s % 9) return 0 * puts("-1");
  if (!(9 % d)) {
    if (s % 9) cout << s % 9;
    for (int i = 1; i <= s / 9; ++i) cout << "9";
    exit(0);
  }
  if (s < 2) {
    int exp = 0;
    while (!(d % 10)) d /= 10, ++exp;
    while (!(d % 2)) d /= 2, ++exp;
    while (!(d % 5)) d /= 5, ++exp;
    if (d > 1) return 0 * puts("-1");
    cout << "1";
    for (int i = 1; i <= exp; ++i) cout << "0";
    exit(0);
  }
  for (int i = 0; i <= s; ++i)
    for (int j = 0; j <= d; ++j) f[i][j] = inf;
  f[0][0] = 0;
  for (int i = 0; i <= s; ++i) {
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        q;
    for (int r = 0; r < d; ++r) q.push(pair<int, int>(f[i][r], r));
    while (q.size()) {
      int r = q.top().second;
      int kk = q.top().first;
      q.pop();
      if (kk != f[i][r]) continue;
      int nR = r * 10 % d;
      if (f[i][r * 10 % d] > kk + 1) {
        f[i][r * 10 % d] = kk + 1;
        q.push(pair<int, int>(kk + 1, r * 10 % d));
      }
    }
    for (int r = 0; r < d; ++r)
      for (int k = 1; k < 10; ++k)
        f[i + k][(r * 10 + k) % d] =
            min(f[i + k][(r * 10 + k) % d], f[i][r] + 1);
  }
  if (f[s][0] == inf) return 0 * puts("-1");
  p[0] = 1;
  for (int i = 1; i < N; ++i) p[i] = p[i - 1] * 10 % d;
  int R = 0;
  for (int i = f[s][0] - 1; ~i; --i) {
    while (i >= f[s][R]) {
      cout << "0";
      --i;
    }
    if (i < 0) break;
    for (int j = 1; j < min(s + 1, 10); ++j) {
      int nR = (R - p[i] * j + d * 10) % d;
      if (f[s - j][nR] <= i) {
        cout << j;
        R = nR;
        s -= j;
        break;
      }
    }
  }
}