• + 1 comment

    My code is failed for some test cases, It's in python. n=int(input()) m=[] for i in range(n): s=input() l=[] length=len(s) for i in range(1,length+1): for j in range(length-i+1): l.append(s[j:j+i]) m=m+l
    m=set(m) z=sorted(list(m)) for _ in range(int(input())): k=int(input()) if k in range(len(z)+1): print(z[k-1]) else: print("INVALID")