import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int T, N;
    bool input() {
        scanf("%d %d\n", &T, &N);
        return (T != 0 && N != 0);
    }
    void solve() {
        string S = N.to!string;
        int X = cast(int)(S.length);
        int Ans = -1;
        int[] Pat;
        bool Reject;
        void dfs(int index, int[] r) {
            if (index == X) {
                //writeln(r);
                int x = r.reduce!"a + b";
                if (x > T) return;
                if (x > Ans) {
                    Ans = x;
                    Pat = r;
                    Reject = false;
                } else if (x == Ans) {
                    Reject = true;
                }
            }
            for (int i = index + 1; i <= X; i++) {
                string s = S[index .. i];
                //if (s.length > 1 && s[0] == '0') continue;
                dfs(i, r ~ s.to!int);
            }
        }
        dfs(0, []);
        if (Reject) {
            writeln("rejected");
        } else if (Ans < 0) {
            writeln("error");
        } else {
            writefln("%d %(%s %)", Ans, Pat);
        }
    }
    while (input) solve;
}