#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <sstream>
#include <map>

using namespace std;

typedef vector<string> vs;

pair<int,vs> solve(int t, int n){
    stringstream ss;
    ss << n;
    string s = ss.str();
    int l=s.size();
    map<int,vector<vs>> ans;

    if(n <= t)ans[n] = {{s}};
    for(int mask=1;mask<1<<(l-1);mask++){
        vs v = {""};
        v[0] += s[0];
        for(int i=0;i<l-1;i++){
            if(mask>>i & 1) v.push_back("");
            v.back() += s[i+1];
        }
        int sum=0;
        for(int i=0;i<v.size();i++){
            sum += atoi(v[i].c_str());
        }
        if(sum <= t){
            ans[sum].push_back(v);
        }
    }


    if(ans.size()==0) return make_pair(-1,vs{"error"});
    if(ans.rbegin()->second.size()>1) return make_pair(-1,vs{"rejected"});
    return make_pair(ans.rbegin()->first,*ans.rbegin()->second.begin());
}

int main(){
    int t,n;
    while(cin>>t>>n && t){
        auto a = solve(t,n);
        if(a.first!=-1){
            cout << a.first << " ";
            for(int i=0;i<(int)a.second.size();i++){
                cout << a.second[i] << (i+1==a.second.size() ? "\n" : " ");
            }
        }else{
            cout << a.second[0] << endl;
        }
    }
}