#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int t, n, sum;
vector<int> ans;
bool r = false;

void dfs(vector<int> v,int n, int d) {
    if (d == 0) {
        int s = 0;
        for (int i = 0; i < v.size(); i++) s += v[i];
        //for (int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << sum << " " << s << endl;
        if (s <= t && s > sum) {
            sum = s;
            ans = v;
            r = false;
        }
        else if (s <= t && s == sum) {
            r = true;
        }
        return;
    }
    
    while (1) {
        int a = n / d;
        int b = n % d;
        //printf("n=%d d=%d a=%d b=%d\n",n,d,a,b);
        vector<int> _v = v;
        _v.push_back(a);
        d /= 10;
        dfs(_v, b, d);
        if (d == 0) break;
    }
}

int main(void){
    while (cin>>t>>n && t && n) {
        sum = -1;;
        vector<int> a;
        int d = 1;
        while (n >= d*10) d *= 10; 
        dfs(a, n, d);
        
        if (r) cout << "rejected" << endl;
        else if (sum == -1) cout << "error" << endl;
        else {
            cout << sum;
            for (int i = 0; i < ans.size(); i++) cout << " " << ans[i];
            cout << endl;
        }
    }
}