# Rampaging Primes

Logic Level 4

$$M$$ is the largest $$5$$-digit number and $$N$$ is the smallest $$5$$-digit number that satisfies the following conditions ---

• Each digit of the numbers is a prime digit

• Each successive pairs of digits forms a $$2$$-digit number that is NOT a prime number

• Each of the prime digits must appear at least once in each of the $$5$$-digit numbers

Find $$M-N$$

×