Given two array A[0….N-1] and B[0….M-1] of size N and M respectively, representing two numbers such that every element of arrays represent a digit. For example, A[] = { 1, 2, 3} and B[] = { 2, 1, 4 } represent 123 and 214 respectively. The task is to find the sum of both the numbers.

**Input:**

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

Each testcase contains 4 lines:-

size of first array denoted by N

N elements of first array, separated by a space

size of second array denoted by M

M elements of second array, separated by a space

**Output:**

Print the sum of the numbers represented by the arrays.

**Constraints:**

1<=T<=100

2<=N<=9

2<=M<=9

**Example:**

**Input:**

3

2

1 2

2

2 1

4

9 5 4 9

3

2 1 4

3

1 2 3

3

2 1 4

**Output:**

33

9763

337

**Explanation:**

For testcase 1:

N=2, and A[]={1,2}

M=2, and B[]={2,1}

Number represented by first array is 12.

Number represented by second array is 21

Sum=12+21=33

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.