#K39102. Shortest Lexicographical Palindromic Subsequence

    ID: 26346 Type: Default 1000ms 256MiB

Shortest Lexicographical Palindromic Subsequence

Shortest Lexicographical Palindromic Subsequence

You are given a string s consisting of lowercase English letters. A subsequence is a sequence that can be derived from the string by deleting zero or more characters without changing the order of the remaining characters. Note that any single character is a palindrome. Therefore, the shortest palindromic subsequence in any string is simply any one character.

Your task is to find the lexicographically smallest character in the string s. Formally, if s is a string, you should output \(\min\{ s_i : 1 \le i \le |s| \}\), where \(|s|\) denotes the length of s.

Input/Output: The input will be provided via stdin and the result should be printed to stdout.

inputFormat

The first line of input contains an integer T (\(1 \le T \le 10^4\)) representing the number of test cases. Each of the following T lines contains a non-empty string s composed of lowercase English letters.

Example:

3
abca
racecar
abcdef

outputFormat

For each test case, output the lexicographically smallest character from the given string on a new line.

Example:

a
a
a
## sample
3
abca
racecar
abcdef
a

a a

</p>