Longest common prefixSort the queries according to 'r' (Maintain a struct. You will need the original order later while p...