Flandre is not a clever girl, she always puzzled in math problems, and gets bogged deeper and deeper, this day she screamed as usual:" Oh my god, my head is full of one two three, I think my head is becoming bigger, I don't want to calculate A^B anymore!". To stop her from screaming, you have to help her solve his problem: get the last digit of a^b,hard or not? You can do it!
There are several test case. Each contains two integers A(0 <= A <= 6000000) and B(1 <= B <= 6000000).
For each test case, output the last digit of A^B.There is a blank line between two cases.