#include <bits/stdc++.h>   using namespace std;   const int D = 505;   const int N = 5005;   pair<int, int> pre[D][N];   int ans[D][N];   void solve() {     memset(pre, -1, sizeof(pre));     memset(ans, -1, sizeof(ans));     int d, s;     cin >> d >> s;     queue<pair<int, int> > que;     que.push(pair<int, int>(0, 0));     vector<int> vec;     while (!que.empty()) {       pair<int, int> u = que.front();       que.pop();       if (u.first == 0 && u.second == s) {         pair<int, int> cur = u;         while (!(cur.first == 0 && cur.second == 0)) {           vec.push_back(ans[cur.first][cur.second]);           cur = pre[cur.first][cur.second];         }         break;       }       for (int i = 0; i <= 9; i++) {         pair<int, int> v = pair<int, int>((u.first * 10 + i) % d, u.second + i);         if (v.second <= s && ans[v.first][v.second] == -1) {           ans[v.first][v.second] = i;           pre[v.first][v.second] = u;           que.push(v);         }       }     }     if (!vec.size())       printf( -1 n );     else {       reverse(vec.begin(), vec.end());       for (auto i : vec) putchar(i +  0 );       printf(  n );     }   }   int main() {     solve();     return 0;   }   