import Common

main = print $ sum $ take 11 [ n | n <- [10..],
                                       length (takeWhile (==True) [ isPrime x | x <- rfr n ] ) == length (rfr n),
                                       length (takeWhile (==True) [ isPrime x | x <- rfl n ] ) == length (rfl n) ] 


rfl, rfr :: Int -> [Int]
rfl 0 = []
rfl n = n : rfl (foldl (\acc x -> 10*acc + x) 0 (drop 1 (toDigits n)))
rfr 0 = []
rfr n = n : rfr (n `div` 10)
