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

public class code_aa implements Runnable {

	public static void main(String[] args) {
		new Thread(new code_aa()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	@Override
	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds: " + x
				+ " is not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "code";

	private void solve() throws IOException {
		String digits = "";
		for (int i = 0; i < 10; i++) {
			digits += i;
		}
		for (char c = 'A'; c <= 'Z'; c++) {
			digits += c;
		}
		int k = inBounds(nextInt(), 2, 36, "k");
		int n = nextInt();
		String str = nextToken();
		char[] s = str.toCharArray();
		inBounds(s.length, 1, 100000, "string length");
		myAssert(s.length == n, "string length (" + s.length + ") != " + n);
		for (int i = 0; i < s.length; i++) {
			inBounds(digits.indexOf(s[i]), 0, k - 1, "s[" + i + "] = " + s[i]);
		}
		int[] a = new int[s.length];
		for (int i = 0; i < a.length; i++) {
			a[i] = digits.indexOf(s[i]);
		}
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			sum += a[i];
		}
		int q = 0;
		for (int i = a.length - 1; i >= 0; i--) {
			if (a[i] + 1 < k && 0 <= q - 1
					&& q - 1 <= (a.length - i - 1) * (k - 1)) {
				a[i]++;
				q--;
				int j = a.length - 1;
				while (j > i) {
					a[j] = Math.min(k - 1, q);
					q -= a[j--];
				}
				for (int w = 0; w < a.length; w++) {
					out.print(digits.charAt(a[w]));
				}
				return;
			}
			q += a[i];
		}
		out.println("Impossible");
	}
}
