Right most non zero digit
Submissions: 843   Accuracy:

11.34%

  Difficulty: Easy   Marks: 2

You will be given an array A of N non negative integers. Your task is to find the right most non zero digit in the product of array elements.
 

Input:
The first line of input contains a single integer T denoting the number of test cases.
Then T test cases follow. The first line of each test case consists of N, the size of the array. The second line of each test cases consists of N space separated non negative integers which denote the values in the array A.

 

Output:
Corresponding to each test case, in a new line, print the right most non zero digit in the product of the numbers. If there is no right most non zero digit, then print -1.

 

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 100
0 ≤ A[i] ≤ 1010 


 

Example:
Input
1
3 5 6 90909009

Output
7

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.