import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Solution {
public List<Integer> solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
List<Integer> result = new ArrayList<>();
for (int i = 0; i< commands.length; i++){
List<Integer> split = new ArrayList<>();
for (int j =commands[i][0]; j<=commands[i][1];j++){
split.add(array[j-1]);
}
Collections.sort(split);
result.add(split.get(commands[i][2]-1));
}
return result;
}
}