Can anyone help me out?

Given a keypad as shown in diagram, and an N digit number. List all words which are possible by pressing these numbers.

Input:
The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each testcase contains two lines of input. The first line of each test case is N, N is the number of digits. The second line of each test case contains D[i], N number of digits.

Output:
Print all possible words from phone digits with single space.

Constraints:
1 <= T <= 10
1 <= N <= 10
2 <= D[i] <= 9

Example:
Input:
1
3
2 3 4

Output:
adg adh adi aeg aeh aei afg afh afi bdg bdh bdi beg beh bei bfg bfh bfi cdg cdh cdi ceg ceh cei cfg cfh cfi

Hey Utkarsh, in this problem for each test case you will be provided with no. of digits and the digits pressed on keypad, you just have to print all the possible outputs (i.e the string which can be formed using those digits).
for eg.
input:
1
2
2 3
output:
ad ae af bd be bf cd ce cf

here, 2 => “abc” and 3 => “def”
so if we press 2 3 on keyboard all the possible combinations we can make using “abc” and “def” are { ad ae af bd be bf cd ce cf }.

You can solve this problem using recursion.