# Introduction:

#    A deletable composite is a composite number with two or more digits
#    that remains composite when any digit is deleted. For example, 104
#    is a deletable composite because 10, 14, and 04 are composite.
#    Note that leading zeros are allowed.
#
#    The following Python 2.7 code computes a list of all deletable composites
#    up to a given bound. It is intended as a supplement for Sequence A225619
#    in the On-line Encyclopedia of Integer Sequences. The sequence was authored
#    by Derek Orr.
#
#    The code for the Sieve of Eratosthenes is copied from
#    http://stackoverflow.com/questions/1023768/sieve-of-atkin-explanation
#    but I cannot find the original author.
#
#    All other code was written by David Radcliffe and is released to the public domain.
#    If you use this code, attribution is appreciated but not required.

from math import sqrt

N = 1000
sqrtN = int(sqrt(N))+1

def sieveOfErat(end):  
  if end < 2: return []  

  #The array doesn't need to include even numbers  
  lng = ((end/2)-1+end%2)  

  # Create array and assume all numbers in array are prime  
  sieve = [True]*(lng+1)  

  # In the following code, you're going to see some funky  
  # bit shifting and stuff, this is just transforming i and j  
  # so that they represent the proper elements in the array.  
  # The transforming is not optimal, and the number of  
  # operations involved can be reduced.  

  # Only go up to square root of the end  
  for i in range(int(sqrt(end)) >> 1):  

    # Skip numbers that aren't marked as prime  
    if not sieve[i]: continue  

    # Unmark all multiples of i, starting at i**2  
    for j in range( (i*(i + 3) << 1) + 3, lng, (i << 1) + 3):  
      sieve[j] = False  

  # Don't forget 2!  
  primes = [2]  

  # Gather all the primes into a list, leaving out the composite numbers  
  primes.extend([(i << 1) + 3 for i in range(lng) if sieve[i]])  

  return primes

primes = sieveOfErat(sqrtN)

# isprime(n) returns True if n is prime, and False if n is not prime.
# The function assumes that the input is an integer.
# If n is greater than N*N but it has no prime factor less than or equal to N,
# then the function will return None, indicating that the function is unable
# to determine if n is prime.

def isprime(n):
    if n <= sqrtN and n in primes:
        return True
    if any(n % p == 0 for p in primes):
        return False
    if n <= N:
        return True

# iscomposite(n) returns True if n is composite, and it returns False if n is prime
# or if n is less than 4. A value of None indicates that the function is unable
# to determine if n is composite.

def iscomposite(n):
    if n < 4 or isprime(n):
        return False
    if n <= N:
        return True

# Generator which returns the numbers obtained by n by deleting one digit.
# For example, deleteOneDigit(123) yields 23, 13, and 12.

def deleteOneDigit(n):
    s = str(n)
    for k in xrange(len(s)):
        yield int(s[:k] + s[k+1:])

# This function returns True if n is a deletable composite number, False otherwise.

def deletableComposite(n):
    return iscomposite(n) and all(iscomposite(d) for d in deleteOneDigit(n))

# List all deletable composites up to N.

print filter(deletableComposite, xrange(10,N+1))
