Reverse Prime

There are a few 7 digit positive numbers whose reverse number is a prime number and less than 106. For example: 1000070, 1000090 and 1000240 are first few reverse prime numbers because all of the numbers are 7 digit numbers whose reverse number is a prime number and less than 106. You have to find out all the 7 digit reverse prime numbers and also its number of prime factors. Prime factors of a positive integer are the prime numbers that divide into that integer exactly, without leaving a remainder. For example, prime factors of 24 are 2, 2, 2 and 3. Input In this problem, youll encounter 2 types of input: Query: This type of input will be formatted like this — ‘q i’. Deletion: This type of input will be formatted like this ‘d reverse_prime’. It is guaranteed that i will be a valid index and reverse_prime will be a valid 7 digit reverse prime number. It is also guaranteed that no two reverse_prime will be same. There will be at most 71000 query lines and 3500 deletion lines in the data set. The program will terminated by EOF. Output For Query type input, you have to calculate the cumulative summation of the number of prime factors of reverse prime numbers from 0-th to i-th index. For Deletion type input, you have to delete reverse_prime from the set and update your summation. No output is required in such cases. Sample Input q0 q1 q2 d 1000070 d 1000090 q0 d 1000240 q0 q1 Sample Output 4 10 16 6 3 7