// Arup Guha
// 2/6/2024
// Soluion to COP 3503 Exam 1 Question 6

import java.util.*;

public class prefixcomposite {

	// Run it.
	public static void main(String[] args) {
		go(0, 0, 5);
	}
	
	//  Prints out all prefix composites where cur is the first k digits that are n digits long.
	public static void go(int cur, int k, int n) {
	
		// Finished filling it. Print.
		if (k == n) {
			System.out.println(cur);
			return;
		}
		
		// Try each digit next, recurse if the resulting prefix is composite.
		for (int i=0; i<10; i++)
			if (!isprime(10*cur+i))
				go(10*cur+i, k+1, n);
	}
	
	// Returns true if n is prime or less than 2.
	public static boolean isprime(int n) {
		
		// Trial division...return false if divisor is found.
		for (int i=2; i*i<=n; i++)
			if (n%i == 0)
				return false;
			
		// If we get here, n<2 or n was prime.
		return true;
	}
}