HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Algorithms and Data Structures > problem:


26. Exponentiation

Volume problems

• 18. Apartments
• 19. Ferris Wheel
• 20. Two Sets
• 21. Distinct Numbers
• 22. Creating Strings
• 23. Apple Division
• 24. Coin Piles
• 25. Josephus Queries
• 26. Exponentiation
• 27. Dice Combinations
• 28. Minimizing Coins
• 29. Coin Combinations I
• 30. Distinct Numbers
• 31. Apartments
• 32. Ferris Wheel
• 33. Concert Tickets
• 34. Maximum Subarray Sum

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Beta

Your task is to efficiently calculate values ab modulo 109+7.
Note that in this task we assume that 00=1.

Input
The first input line contains an integer n : the number of calculations.
After this, there are n lines, each containing two integers a and b .
Output
Print each value ab modulo 109+7 .
Constraints
1≤n≤2⋅105
0≤a,b≤109

Example

Input:
3
3 4
2 8
123 123
Output:
81
256
921450052

Для отправки решений необходимо выполнить вход.

www.contester.ru