P with elements from 1 to m.result to store the indices of each query.queries:
a. Iterate through P to find the index of the queried number.
b. Append the index to result.
c. Move the queried number to the front of P by shifting the elements.result list containing the indices of the queries.