#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

#define INF (1<<29)

int toInt(string s){
  istringstream iss(s);
  int a;
  iss >> a;
  return a;
}

int main(){
  int n;
  string s;
  while(cin >> n >> s){
    if(n == 0 && s == "0") break;
    int ans = -1;
    vector<string> ans2;
    map<int, int> is_found;
    
    for(int i = 0 ; i < (1<<s.size()) ; i++){
      vector<string> tmp;
      int pos = 0;
      int point = 0;
      for(int j = 0 ; j < s.size() ; j++){
	if(j == s.size()-1){
	  string t = s.substr(pos, j-pos+1);
	  tmp.push_back(t);
	  pos = j+1;
	  point += toInt(t);
	}
	
	else if((1<<j) & i){
	  string t = s.substr(pos, j-pos+1);
	  tmp.push_back(t);
	  pos = j+1;
	  point += toInt(t);
	}
      }
      
      is_found[point]++;
      if(point <= n && n-point < n-ans){
	ans = point;
	ans2 = tmp;
      }
      /*
      cout << point << ' ';
      for(int b = 0 ; b < tmp.size() ; b++){
	cout << tmp[b] << ' ';
      }
      cout << endl;
      */
    }
    
    //cout << is_found[ans] << endl;
    bool f = true;
    if(is_found[ans] > 2) f = false;
    
    if(ans == -1) cout << "error" << endl;
    else if(!f){
      cout << "rejected" << endl;
    }
    else{
      cout << ans << ' ';
      for(int i = 0 ; i < ans2.size() ; i++){
	cout << ans2[i];
	if(i != ans2.size()-1) cout << ' ';
	else cout << endl;
      }
    }
  }
  return 0;
}