#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll target;
    string s;
    cin>>target>>s;
    vector<ll> pow2(100,1);
    FOR(i,1,100){
      pow2[i]=pow2[i-1]*2;
    }


    while(target>0){
      ll size = s.size()-1;
      ll res = 0;
      ll flag = 2;
      ll res_bit = 0;
      deque<ll> ans;
      FOR(bit,0,pow2[size]){
        ll tmp_res = s[size] - '0';
        ll tmp = 1;
        deque<ll> tmp_ans;
        ll var = tmp_res;
        FOR(i,0,size){
          tmp *= 10;
          if(!(bit&(1<<(size-1-i)))) tmp = 1;
          ll x = s[size-i-1] - '0';
          tmp_res += x*tmp;
          if(tmp == 1){
             tmp_ans.push_back(var);
             var = 0;
          }
          var += x*tmp;
        }
        tmp_ans.push_back(var);


        if(tmp_res<=target){
          if(tmp_res == res) flag = 1;
          if(tmp_res>res){
            res = tmp_res;
            ans = tmp_ans;
            res_bit = bit;
            flag = 0;
          }
        }

      }
      if(flag == 0) {
        cout<<res;
        while(!(ans.empty())){
          cout<<" "<<ans.back();
          ans.pop_back();
        }
        cout<<endl;
      }
      else if(flag == 1) cout<<"rejected"<<endl;
      else cout<<"error"<<endl;

      cin>>target>>s;
    }
}

