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>
using namespace std;
const int D = 555, S = 5005;
int lvl[D][S], dp[D][S];
vector<pair<int, int> > a[D * S];
int32_t main() {
  int d, s;
  cin >> d >> s;
  queue<pair<int, int> > Q;
  for (int i = 1; i <= 9 && i <= s; i++) {
    lvl[i % d][i] = 1;
    Q.push(make_pair(i % d, i));
  }
  while (!Q.empty()) {
    int dd, ss;
    tie(dd, ss) = Q.front();
    Q.pop();
    a[lvl[dd][ss]].push_back(make_pair(dd, ss));
    for (int i = 0; i < 10 && ss + i <= s; i++) {
      int dx = (dd * 10 + i) % d, sx = ss + i;
      if (!lvl[dx][sx]) {
        lvl[dx][sx] = lvl[dd][ss] + 1;
        Q.push(make_pair(dx, sx));
      }
    }
  }
  if (!lvl[0][s]) {
    cout << -1 << endl;
    return 0;
  }
  dp[0][s] = 1;
  for (int i = lvl[0][s] - 1; i >= 1; i--) {
    for (auto x : a[i]) {
      int dd, ss;
      tie(dd, ss) = x;
      for (int j = 0; j < 10; j++) {
        int dx = (dd * 10 + j) % d, sx = ss + j;
        dp[dd][ss] |= dp[dx][sx] && (lvl[dx][sx] == lvl[dd][ss] + 1);
      }
    }
  }
  string ans;
  int dd, ss;
  for (int i = 1; i < 10; i++) {
    if (dp[i % d][i]) {
      dd = i % d;
      ss = i;
      ans.push_back(char(i + '0'));
      break;
    }
  }
  while (true) {
    if (dd == 0 && ss == s) break;
    for (int i = 0; i < 10; i++) {
      int dx = (dd * 10 + i) % d, sx = ss + i;
      if (dp[dx][sx] && (lvl[dx][sx] == lvl[dd][ss] + 1)) {
        ans.push_back(i + '0');
        dd = dx;
        ss = sx;
        break;
      }
    }
  }
  cout << ans << endl;
}