#include<iostream>
#include<cmath>
using namespace std;
int target;

int main(int argc, char *argv[]){
  while(cin >> target, target){
    int card;
    cin >> card;
    int ans = -1, digit = log10(card), bit = 0;

    for (int i = 0; i < 1<<digit; i++) {
      int tmp = card, calc = 0;
      for (int j = digit - 1; j >= 0; j--) {
        if(i&(1<<j)){
          calc += tmp/(int)pow(10, j+1);
          tmp %= (int)pow(10, j+1);
        }
      }
      calc += tmp;
      if(ans < calc && calc <= target){
        // std::cout << "calc:" << calc << std::endl;
        ans = calc;
        bit = i;
      }else if(ans == calc){
        bit = -1;
      }
    }
    if(ans == -1){
      std::cout << "error" << std::endl;
    }else if (bit == -1){
      std::cout << "rejected" << std::endl;
    }else{
      //std::cout << "bit:" << bit << std::endl;
      std::cout << ans << " ";
      for (int i = digit - 1; i >= 0; i--) {
        std::cout << (int)(card/pow(10, i+1));
        card %= (int)pow(10, i+1);
        if(bit&(1<<i))std::cout << " ";
      }
      std::cout << card << std::endl;
    }
  }
  return 0;
}