code converter from java to python
n = int(input())
output = []
strings = []
for _ in range(n):
strings.append(input().strip())
q = int(input())
for _ in range(q):
L,R,K = map(int, input().split())
s = ""
for __ in range(L-1,R):
s += strings[__]
output.append(s[K-1])
print(*sorted(output),sep='\n')