Pizon and Redon are twin brothers. Both of them are quite genius and try to improve their capability by solving different types of mathematical problems specially the ones which are related to numbers and their factors. Just recently they found an interesting thing about factors of a factorial. Pizon first takes a pen and writes some uppercase English alphabets only from 'A' to 'I'. Then its Redon's turn. He represents the alphabets as one integer number where A = 0, B = 1 , ... I = 8. Suppose Pizon wrote "BA" , so Redon represents this as 10 which is an integer. Then they both give their friend Dadon a number which is always a prime and Dadon has to answer the highest power of that prime number that divides the factorials of Redon's integer. For BA , the integer is 10. And let the given number be 2. So Dadon has to print the highest power of 2 that divides 10! ( Ten Factorial ) . Input: ------ Input starts with an integer T (1<=20), denoting the number of test cases. Each case contains an string ( length <=8 ) and an integer ( which is prime & <= 10^7 ). Output: ------- The output is a single integer denoting the highest power. As the answer can be pretty large, Dadon is requested to print it modulo 1000000007. See sample for better understanding. Sample Input ------------ 2 BA 2 BAA 2 Sample Output ------------- Case 1: 8 Case 2: 97

Sifat Siddiqi Shishir

Language |
Time Limit (seconds) |

C | 1.00 |

C++ | 1.00 |

C++14 | 1.00 |

C# | 3.00 |

Go | 3.00 |

Java | 3.00 |

JavaScript | 3.00 |

Objective-C | 3.00 |

Perl | 3.00 |

PHP | 3.00 |

Python | 3.00 |

Python3 | 3.00 |

Ruby | 3.00 |

VB.Net | 3.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | BishalG | Cpp14 | 0.00s |

02 | prantacse14 | Cpp14 | 0.00s |

03 | sayedgkm | Cpp14 | 0.00s |

04 | Masum_ice | Cpp14 | 0.00s |

05 | imranziad | Cpp14 | 0.00s |

06 | akazad_cse13_ruet | Cpp14 | 0.00s |

07 | souravvv | Cpp14 | 0.00s |

08 | codebreaker007 | Cpp14 | 0.00s |

09 | Tanmoy_Datta | Cpp14 | 0.00s |

10 | alhelal_cse | Cpp14 | 0.00s |

11 | Rajib_119 | Cpp14 | 0.00s |

12 | Roll_Number_27 | Cpp14 | 0.00s |

13 | subhashis_cse | Cpp14 | 0.00s |

14 | Protap_Ghose | Cpp14 | 0.00s |

15 | Knight_King | Cpp14 | 0.00s |

16 | Jakir_Hossain_Sust | Cpp14 | 0.00s |

17 | rezaulhsagar | Cpp14 | 0.00s |

18 | shaft | Cpp14 | 0.00s |

19 | aurko96 | Cpp14 | 0.00s |

20 | Puja1409 | Cpp14 | 0.00s |

21 | nurshuvo51 | Cpp14 | 0.00s |

22 | Jisancse | Cpp14 | 0.00s |

23 | adamantium | Cpp14 | 0.00s |

24 | rayhan50001 | Cpp14 | 0.00s |

25 | alif_biswas | Cpp14 | 0.00s |

26 | Mr_adnan | Cpp14 | 0.00s |

27 | nasif2587 | Cpp14 | 0.00s |

28 | haasib | Cpp14 | 0.00s |

29 | Sopto | Cpp14 | 0.00s |

30 | ssavi | Cpp14 | 0.00s |

31 | tariqiitju | Cpp14 | 0.00s |

32 | froghramar | Cpp14 | 0.00s |

33 | SKL12 | Cpp14 | 0.00s |

34 | alien_bd | Cpp14 | 0.00s |

35 | sadia2427 | Cpp14 | 0.00s |

36 | onucsecu | Cpp14 | 0.00s |

37 | KIRIN_36 | Cpp14 | 0.00s |

38 | SakibAlamin | Cpp14 | 0.00s |

39 | _dipu | Cpp14 | 0.00s |

40 | feodorv | C | 0.00s |

41 | shishir09 | Cpp14 | 0.00s |

42 | Ahb_arif | Cpp14 | 0.00s |

43 | Rakib05 | Cpp | 0.00s |

44 | Robbinb1993 | Cpp | 0.00s |

45 | seyedssz | Cpp14 | 0.01s |

46 | smriad | Cpp | 0.01s |

47 | kpretomazi | Cpp | 0.01s |

48 | prodipdatta7 | Cpp14 | 0.01s |

49 | mahmud2690 | Cpp | 0.01s |

50 | abdulmukit | Cpp | 0.01s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(