You are given an array of numbers of size N. You need to multiply these numbers and find the remainder when the product of these numbers is divided by a number K.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.

Each testcase contains 3 lines:-

Size of array, N

Elements of the array separated by a space

The number K

**Ouput:**

For each testcase, print the remainder when the product of array elements is divided by K.

**Constraints:**

1<=T<=100

1<=N<=20

1<=A[i]<=10^{20}

1<=K<=20

**Example:**

**Input:**

1

3

4 6 7

3

**Output:**

0

**Explanation:**

4*6*7=168

Now, 168%3=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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

madhursengar24 | 86 |

PiyushPandey4 | 617 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 448 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.