fork download
  1. def Power(a, b):
  2. mod = 1000000007
  3.  
  4. if b == 0 or a == 1:
  5. return 1
  6. if b == 1:
  7. return a
  8.  
  9. c = Power(a, int(b / 2))
  10. s = (c * c) % mod
  11.  
  12. if(b % 2 == 1):
  13. s = (s * a) % mod
  14.  
  15. return s
  16.  
  17. for _ in range(int(input())):
  18. a, b = map(int, input().split())
  19. print(Power(a, b))
Success #stdin #stdout 0.02s 9200KB
stdin
1
17027 15425013045
stdout
553464457