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

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

public class digits_mb_brute {
    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];
                        }
                    }
                }
            }
        }
    }

    static boolean increment(char[] t) {
        for (int i = t.length - 1; i >= 0; --i) {
            ++t[i];
            if (t[i] <= '9') {
                return true;
            }
            t[i] = '0';
        }
        return false;
    }

    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');
        }
        char[] t = s.clone();

        String ans = "NO SOLUTION";

        while (increment(t)) {
            int balance = 0;
            int moved = 0;
            for (int i = 0; i < s.length; ++i) {
                balance += nBal[s[i] - '0'][t[i] - '0'];
                moved += nMov[s[i] - '0'][t[i] - '0'];
            }
            if (moved <= 2 * k && balance == 0) {
                ans = String.valueOf(t);
                break;
            }
        }
        return ans;
    }

    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();
    }
}
