A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't allowed). Both of these sequences are finite (There are only 83 Right-truncatables, while there are 4260 Left-truncatables).
You need to write a program that accepts a single number as input, and produces the nth right-truncatable prime. However, when the program is read arranged backwards, it should produce the nth left-truncatable prime.
To arrange a program backwards, we split the program into words, then reverse the order of the words. A word can consist of any number of characters.
For example, if the following was your program:
hello world 1234567890
The following would all be allowed as possible backwards arrangements:
Splitting on each character:
0987654321 dlrow olleh
Splitting on whitespace:
1234567890 world hello
Splitting arbitrarily (pipes added for clarity):
hel|lo w|orld 1|23456|7|8|90 908723456orld 1lo whel
When arranging your program backwards, all whitespace must be considered and reversed, just like any other character.
Forward test inputs:
1: 2 2: 3 21: 379 60: 239933 83: 73939133
Backward test inputs:
1: 2 2: 3 39: 647 187: 29173 4260: 357686312646216567629137
Programs should be able to run in a reasonable amount of time (less than a minute)
This is a code-golf, so the program with the fewest bytes wins!