You will be given **N** number of strings. You have to find the lexicographically smallest string and the lexicographically largest string among these strings.

**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.** In the next line are **N** space separated strings of lower case Latin letters only.

**Output:**

Corresponding to each test case, in a new line, print the lexicographically smallest string and the lexicographically largest string among the given strings separated by a single space between them.

**Constraints:**

1 ≤ **T** ≤ 100

1 ≤ **N** ≤ 100

1 ≤ **Length of each string** ≤ 40

**Example:**

**Input**

3

3

a ab abc

3

a a b

3

z xy t

**Output**

a abc

a b

t z

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.

hari32147 | 128 |

RaghavaMahanthi | 100 |

AdityaRaj9 | 84 |

AtakanSarıoğlu | 83 |

geetyadav | 82 |

abducodes | 866 |

harshtyagi36 | 432 |

arpit_anshuman | 331 |

vamsikrishna55 | 323 |

sandipbhaumik | 321 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.