// Задача "Цифровой дисплей"
// Шестая Интернет-олимпиада сезона 2009-2010, усложненный уровень
// Автор задачи: Максим Буздалов, buzdalov@rain.ifmo.ru
// Автор решения: Максим Буздалов, buzdalov@rain.ifmo.ru

import java.io.*;
import java.util.*;

public class digits_mb_wrong3 {
    private static void myAssert(String msg, boolean exp) {
        if (!exp) {
            throw new AssertionError(msg);
        }
    }

    static final String[][] digits = {
        {"+-+","  +","+-+","+-+","+ +","+-+","+-+","+-+","+-+","+-+"},
        {"| |","  |","  |","  |","| |","|  ","|  ","  |","| |","| |"},
        {"+ +","  +","+-+","+-+","+-+","+-+","+-+","  +","+-+","+-+"},
        {"| |","  |","|  ","  |","  |","  |","| |","  |","| |","  |"},
        {"+-+","  +","+-+","+-+","  +","+-+","+-+","  +","+-+","+-+"}
    };
    static final int[][] nMov = new int[10][10];
    static final int[][] nBal = new int[10][10];
    static {
        for (int dFrom = 0; dFrom < 10; ++dFrom) {
            for (int dTo = 0; dTo < 10; ++dTo) {
                for (int line = 0; line < digits.length; ++line) {
                    for (int ch = 0; ch < 3; ++ch) {
                        char from = digits[line][dFrom].charAt(ch);
                        char to = digits[line][dTo].charAt(ch);
                        if ((from == '|' || from == '-') && to == ' ') {
                            ++nMov[dFrom][dTo];
                            --nBal[dFrom][dTo];
                        } else if (from == ' ' && (to == '|' || to == '-')) {
                            ++nMov[dFrom][dTo];
                            ++nBal[dFrom][dTo];
                        }
                    }
                }
            }
        }
    }

    public static String solve(int k, String arg) {
        char[] s = arg.toCharArray();
        myAssert("K is out of bounds", 1 <= k && k <= 100);
        myAssert("String length is out of bounds", 1 <= s.length && s.length <= 100000);
        for (char c : s) {
            myAssert("Illegal character", '0' <= c && c <= '9');
        }

        int n = s.length;
        int k2 = k * 2;
        int[][] dp = new int[n + 1][k2 + 1];
        final int IMPOSSIBLE = k * 2 + 1;
        for (int[] d : dp) {
            Arrays.fill(d, IMPOSSIBLE);
        }
        dp[n][k] = 0;

        for (int i = n - 1; i >= 0; --i) {
            int oldDig = s[i] - '0';
            int[] curr = dp[i];
            int[] prev = dp[i + 1];
            for (int newDig = 0; newDig < 10; ++newDig) {
                for (int bal = Math.max(0, nBal[oldDig][newDig]); bal <= k2 && bal - nBal[oldDig][newDig] <= k2; ++bal) {
                    int newBal = bal - nBal[oldDig][newDig];
                    if (prev[newBal] + nMov[oldDig][newDig] < IMPOSSIBLE) {
                        curr[bal] = Math.min(curr[bal], prev[newBal] + nMov[oldDig][newDig]);
                        if (bal == k && newDig > oldDig && prev[newBal] + nMov[oldDig][newDig] <= k2) {
                            //Found an answer
                            int moved = prev[newBal];
                            s[i] = (char) (newDig + '0');
                            for (int j = i + 1; j < n; ++j) {
                                int od = s[j] - '0';
                                boolean good = false;
                                for (int nd = 0; nd < 10; ++nd) {
                                    int nb = newBal - nBal[od][nd];
                                    if (nb >= 0 && nb <= k2 && dp[j + 1][nb] <= moved) {
                                        s[j] = (char) (nd + '0');
                                        newBal = nb;
                                        moved -= nMov[od][nd];
                                        good = true;
                                        break;
                                    }
                                }
                                if (!good) {
                                    throw new AssertionError("Answer restoring is wrong");
                                }
                            }
                            return String.valueOf(s);
                        }
                    }
                }
            }
        }
        return "NO SOLUTION";
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("digits.in"));
        int k = Integer.parseInt(in.readLine());
        String s = in.readLine();
        in.close();

        PrintWriter out = new PrintWriter("digits.out");
        out.println(solve(k, s));
        out.close();
    }
}
