You are given two integers N and P. N represents an integer number, and P represents the power to which N will be raised. You need the determine, if the units digit of the N^{P} will be same as the units digit of N.

**Input:**

The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows. Each test case contains 2 lines:-

The number N

The power P

**Output:**

For each testcase, print 0 if the units digit changes, else print 1

**Constraints:**

1<=T<=100

1<=N<=10^{30}

1<=P<=100

**Example:**

**Input:**

3

2

1

3

5

4

2

**Output:**

1

1

0

**Explanation:**

For testcase 1: 2^{1}=2 so units digit remains same. Therefore, we print 1

For testcase 3: 4^{2}=16 so units digit changes from 4 to 6. Therefore, we print 0

Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

sabka_din_aayega | 317 |

maggiiiii | 248 |

thanuvinu94 | 211 |

Savage_19 | 206 |

Anugrah_kumar | 172 |

Bishnu Dev Panda | 803 |

sabka_din_aayega | 628 |

Anugrah_kumar | 562 |

okayboss | 561 |

maggiiiii | 531 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.