spoj question wrong ans

its a easy question,but i am not able to find that testcase for which my code verdict is wrong
help me.
urgent help needed

if __name__=="__main__":
    t = int(raw_input())
    while t:
      a,b = map(int,raw_input().split())
      rem = a%10
      rem1 =b%4
      d =rem
      if b == 0:
          print "1"
          t =t-1
      for i in range(0,rem1-1,1):
          rem = rem *d

      print rem%10

      t =t-1

a = 2
b = 16

thanx buddy