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

public class TestsGen {
	static int testcount = 0;

	static Random random = new Random(36498732);

	static final int MAXN = 100;

	static Solver solver = new Solver();

	static void write() throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);

		out.close();
	}

	static void writeNext(int len) throws IOException {
		char[] a = new char[len];
		a[0] = (char) (random.nextInt(9) + '1');
		for (int i = 1; i < len; i++) {
			a[i] = (char) (random.nextInt(10) + '0');
		}
		String s = solver.next(new String(a));
		if (s.length() <= MAXN) {
			PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
			System.out.println("Generating test #" + testcount);
			out.println(s);
			out.close();
		}
	}

	static void writeRand(int len) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		char[] a = new char[len];
		a[0] = (char) (random.nextInt(9) + '1');
		for (int i = 1; i < len; i++) {
			a[i] = (char) (random.nextInt(10) + '0');
		}
		out.println(new String(a));
		out.close();
	}

	static void writeString(String s) throws IOException {
		PrintWriter out = new PrintWriter(String.format("%02d", ++testcount));
		System.out.println("Generating test #" + testcount);
		out.println(s.trim());
		out.close();
	}

	public static void main(String[] args) throws IOException {
		while (new File(String.format("%02d.t", testcount + 1)).exists()) {
			testcount++;
		}
		for (int i = 1; i < 12; i++) {
			writeString(Integer.toString(i));
		}
		for (int i = 0; i < 10; i++) {
			writeRand(random.nextInt(MAXN) + 1);
			writeRand(MAXN);
		}
		for (int i = 0; i < 10; i++) {
			writeNext(random.nextInt(MAXN) + 1);
			writeNext(MAXN);
		}
		writeString(repeat("90", 3));
		writeString(repeat("90", MAXN / 2));
		writeString(repeat("90", MAXN / 4) + repeat("0", MAXN / 2));
		writeString(repeat("90", MAXN / 4) + repeat("0", MAXN / 2 - 1));
		writeString(repeat("9", MAXN));
		writeString(repeat("9", MAXN - 1));
		writeString("9898");
		writeString("19910");
		writeString("120987");
		writeString("109995");
		writeString("2532302011291246914913571384281450474389857042095");
		writeString("7076577387593552108683533277646874585819196");
		writeString("949451958919734");
		writeString("51954110796019197");
		writeString("809110581249194");
		writeString("991");
		writeString("5979793792231539040270589090");
	}

	private static String repeat(String string, int i) {
		StringBuilder ret = new StringBuilder();
		while (i-- > 0) {
			ret.append(string);
		}
		return ret.toString();
	}

}

class Solver {
	String next(String s) {
		int n = s.length();
		int[] a = new int[2 * n];
		for (int i = 0; i < n; i++) {
			a[i] = s.charAt(n - i - 1) - '0';
		}

		{
			int i = 0;
			while (a[i] == 9) {
				i++;
			}
			a[i]++;
			for (i--; i >= 0; i--) {
				a[i] = 0;
			}
		}

		int s1 = 0;
		int s2 = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (i % 2 == 0) {
				s1 += a[i];
			} else {
				s2 += a[i];
			}
		}

		int t = Math.abs(s1 - s2);
		int last = 0;
		for (int i = 0; i < 2 * n; i++) {
			if (t == 0) {
				break;
			}
			if ((s1 < s2 && i % 2 == 0) || (s1 > s2 && i % 2 == 1)) {
				if (t >= 9 - a[i]) {
					t -= 9 - a[i];
					a[i] = 9;
					last = i;
				} else {
					a[i] += t;
					t = 0;
					last = i;
				}
			} else {
				if (t > a[i]) {
					t -= a[i];
					a[i] = 0;
					last = i;
				} else {
					a[i] -= t - 1;
					t = 1;
					last = i;
					int j = i + 1;
					while (a[j] == 9) {
						j++;
					}
					if ((j - i) % 2 == 1) {
						a[j]++;
						last = j;
						t = 0;
						continue;
					}
					if (a[i] >= 2) {
						a[i] -= 2;
						a[j]++;
						last = j;
						t = 0;
					}
				}
			}
		}
		int i = last - 1;
		int i2 = i - 1;
		while (i >= 0 && i2 >= 0) {
			int tt = Math.min(a[i], a[i2]);
			a[i] -= tt;
			a[i2] -= tt;
			if (a[i] == 0) {
				i -= 2;
			}
			if (a[i2] == 0) {
				i2 -= 2;
			}
		}
		i = 2 * n - 1;
		while (a[i] == 0) {
			i--;
		}
		String ret = "";
		for (; i >= 0; i--) {
			ret += a[i];
		}
		return ret;
	}

}