Given a string consisting of only lowercase English alphabets, your task is to find the smallest palindromic substring.
In case there are multiple palindromic substrings of the same length present, print the lexicographically smallest substring. 
Formally, a substring is a contiguous sequence of characters within a string. So in a string "abcdef", "abc" is a substring whereas "adf" is not a substring.
A palindrome is a word, phrase, or sequence that reads the same backwards as forwards, e.g. madam or mom.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains of two lines of input, two integers.
- First, we have a single integer $N$ which signifies the length of the substring.
- Next, we have a string of length $N$ that only has lowercase English alphabets.

-----Output:-----
For each testcase, output in a single line the shortest palindromic substring.

-----Constraints-----
- $1 \leq T \leq 100$
- $2 \leq N \leq 10^5$

-----Sample Input:-----
2
2
zy
1
cd

-----Sample Output:-----
y
c

-----EXPLANATION:-----
There are only two possibilities. "z" and "y". Since both of them have the same length. We print the lexicographically smaller substring which is y.

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
T = int(input())
for t in range(T):
  N = int(input())
  s = sorted(list(str(input())))
  print(s[0])

for t in range(int(input())):
  n=int(input())
  s=sorted(list(str(input())))
  print(s[0])

T = int(input())
for t in range(T):
  N = int(input())
  s = sorted(list(str(input())))
  print(s[0])

T = int(input())
for t in range(T):
  N = int(input())
  s = sorted(list(str(input())))
  print(s[0])

for _ in range(int(input())):
 n = int(input())
 s = input()
 minn = ord(s[0])
 for i in range(1,n):
  minn = min(ord(s[i]), minn)
  
 print(chr(minn))


t=int(input())
for i in range(t):
 n=int(input())
 s=input()
 s=sorted(s)
 print(s[0])

t=int(input())
for _ in range(t):
 n=int(input())
 s=input()
 print(min(s))
    

    


t = int(input())

for i in range(t):
 l = int(input())
 st = input()
 if st == "":
  print("")
 else:
  minC = st[0]
  for s in st:
   if s < minC:
    minC = s
  print(minC)

# cook your dish here
def palindromeSubStrs(s):
 m = dict()
 n = len(s)

 R = [[0 for x in range(n + 1)] for x in range(2)]

 s = "@" + s + "#"

 for j in range(2):
  rp = 0
  R[j][0] = 0

  i = 1
  while i <= n:

   while s[i - rp - 1] == s[i + j + rp]:
    rp += 1
   R[j][i] = rp
   k = 1
   while (R[j][i - k] != rp - k) and (k < rp):
    R[j][i + k] = min(R[j][i - k], rp - k)
    k += 1
   rp = max(rp - k, 0)
   i += k
 s = s[1:len(s) - 1]
 m[s[0]] = 1
 for i in range(1, n):
  for j in range(2):
   for rp in range(R[j][i], 0, -1):
    m[s[i - rp - 1: i - rp - 1 + 2 * rp + j]] = 1
  m[s[i]] = 1
 ans=[]
 for i in m:
  ans.append(i)
 print(min(ans))

for i in range(int(input())):
 n=int(input())
 s=input()
 palindromeSubStrs(s)


# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 s=input()
 p=list(s)
 p.sort()
 print(p[0])

for i in range(int(input())):
 n=int(input())
 s=list(input())
 s.sort()
 print(s[0])

for _ in range(int(input())):
 n = int(input())
 
 st = [i for i in input()]
 
 print(min(st))

# cook your dish he
t = int(input())
while t>0:
 t-=1
 n = int(input())
 str = input()
 s = []
 for i in range(n):
  s.append(ord(str[i]))
 a = min(s)
 print(chr(a))

# cook your dish here
t=int(input())
rr=[]
for i in range(t):
 n=int(input())
 s=input()
 s=list(s)
 s.sort()
 rr.append(s[0])
for i in rr:
 print(i)

# cook your dish here
test=int(input(""))
for i in range(test):
 n=int(input(""))
 s=input("")
 list(s)
 d=[]
 for i in range(n):
  d.append(s[i])
 print(min(d))

# cook your dish here
t = int(input())
for z in range(t):
 n = int(input())
 s = list(input())
 s.sort()
 print(s[0])

T = int(input())
for _ in range(T):
 n = int(input())
 s = list(input())
 s.sort()
 print(s[0])

# cook your dish here
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 19:08:25 2020

@author: pavan
"""

def palindrome(s): 
 m = dict() 
 n = len(s)
 R = [[0 for x in range(n+1)] for x in range(2)]
 s = "@" + s + "#"
 
 for j in range(2): 
  rp = 0
  R[j][0] = 0
  i = 1
  while i <= n:
   while s[i - rp - 1] == s[i + j + rp]: 
    rp += 1
   R[j][i] = rp 
   k = 1
   while (R[j][i - k] != rp - k) and (k < rp): 
    R[j][i+k] = min(R[j][i-k], rp - k) 
    k += 1
   rp = max(rp - k, 0) 
   i += k
 s = s[1:len(s)-1]
 m[s[0]] = 1
 for i in range(1,n): 
  for j in range(2): 
   for rp in range(R[j][i],0,-1): 
    m[s[i - rp - 1 : i - rp - 1 + 2 * rp + j]] = 1
  m[s[i]] = 1
 print(min(m))
   
for _ in range(int(input())):
 N = int(input())
 s = input()
 palindrome(s)

# n,k = map(int,input().strip().split(" ")) takes two number as input in a     single line
# arr = list(map(int,input().split())) takes an array as a input in a single     line
# arr = [int(input()) for i in range(n)] takes an array as input in different     lines

def solve() :
 n = int(input())
 sr = input()
 print(min(sr))
 
t = int(input())
while t>0 :
 solve()
 t -= 1

# cook your dish here
for _ in range(int(input())):
 n=int(input())
 str1=input()
 str1=sorted(str1)
 print(min(str1))

# cook your dish here
try:
 t=int(input())
 for i in range(t):
  n=int(input())
  strin=input()
  l=list(strin)

  l.sort()
  print(l[0])
except:
 pass


T=int(input())
for i in range(0,T):
 N=int(input())
 word=input()
 min=word[0]
 for j in range (0,N):
  if (word[j]<=min):
   min=word[j]
 print(min)

for i in range(int(input())):
 n=int(input())
 s=input()
 a=set()
 for j in s:
  a.add(j)
 a=list(a)
 a.sort()
 print(a[0])