#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int mypow(int x, int y) {
    int ret = 1;
    while(y > 0) {
        ret *= x;
        y--;
    }
    return ret;
}
int main() {
    int t, num;
    while(cin >> t >> num, t) {
        vector<vector<vector<int>>> ret(1000000);
        ret[num].push_back({num});

        for(int i=1; i<(1<<5); ++i) {
            int top = 0;
            for(int j=4; j>=0; --j) {
                if((i >> j) % 2 == 1) {
                    top = j;
                    break;
                }
            }
            if(mypow(10, top+1) > num) {
                break;
            }
            int rest = num;
            vector<int> v2;
            int sum=0;
            int prev_b = -1;
            for(int b=0; b<5; ++b) {
                if((i >> b) % 2 == 1) {
                    int tmp = 0;
                    if(prev_b != -1) {
                        tmp = mypow(10, b - prev_b);
                    } else {
                        tmp = mypow(10, b+1);
                    }
                    v2.push_back(rest % tmp); // todo
                    sum += rest % tmp;
                    rest /= tmp;
                    prev_b = b;
                    if(rest == 0) {
                        break;
                    }
                }
            }
            if(rest != 0) {
                v2.push_back(rest);
            }
            sum += rest;
            //cout << "rest = " << rest << "   sum=" << sum << endl;
            //cout << endl;
            //for(auto x : v2) {
            //    cout << x << endl;
            //}
            //cout << endl;
            if(sum == 0) {
                continue;
            }
            ret[sum].push_back(v2);
        }

        bool finded = false;
        for(int i=t; i>=0; --i) {
            if(ret[i].size() >= 2) {
                cout << "rejected" << endl;
                finded = true;
                break;
            } else if(ret[i].size() == 1) {
                finded = true;
                cout << i << " ";
                reverse(ret[i][0].begin(), ret[i][0].end());
                for(int j=0; j<ret[i][0].size()-1; ++j) {
                    cout << ret[i][0][j] << " ";
                }
                cout << ret[i][0][ret[i][0].size()-1] << endl;
                break;
            }
        }
        if(!finded) {
            cout << "error" << endl;
        }
    }
}
