Input to this problem will begin with a line containing a single integer x indicating the number of datasets. Each data set consists of three components:
- Start line – A single line, "m n" (1 <= m, n <= 20) where m indicates the number of items in the queue and n indicates the number of queue operations.
- Queue items – A line of short (between 1 and 8 characters) alphanumeric names for the items in the queue. Names are unique for a given data set and contain no whitespace.
- Queue operations – n lines of queue operations in the format "starting-position requested-position".