#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        int t; cin >> t;
        string s; cin >> s;
        if(t==0&&s=="0")break;
        int p=0;
        for(char c:s){
            p+=c-'0';
        }
        if(p>t){
            printf("error\n");
            continue;
        }
        p=-1;
        int cnt=1;
        int n=s.size();
        vector<int> res;
        vector<int> v;
        for(int i=0;i<(1<<n-1);i++){
            v.clear();
            int sum=0;
            int now=s[0]-'0';
            for(int j=0;j<n-1;j++){
                if((i>>j)&1){
                    v.push_back(now);
                    sum+=now;
                    now=s[j+1]-'0';
                }
                else{
                    now=now*10+s[j+1]-'0';
                }
            }
            sum+=now;
            v.push_back(now);
            if(sum<=t){
                if(p==sum){
                    cnt++;
                }
                else if(sum>p){
                    p=sum;
                    cnt=1;
                    res=v;
                }
            }
        }
        if(cnt>=2){
            printf("rejected\n");
        }
        else{
            printf("%d",p);
            for(int vv:res){
                printf(" %d",vv);
            }
            printf("\n");
        }
    }
}
