Description
Peter is a rich guy and a self-confessed shoe whore - a person who owns a lot of shoes. Any branded shoe you can think of, he definitely has. He even has this huge room solely for his shoe collection at his mansion. Can you imagine that?
The good thing about Peter is, he never forgets to use, if not all, most of his shoes. If it’s time for his lawn tennis game, he uses his sneakers. If it’s time for work, he puts on his Testoni shoes. But the everyday routine of going up and down from his bedroom to the shoe room is making him jaded. So, he bought a shoe rack for his room that will only contain the shoes he’ll be wearing within the day and for the next few days. Sounds handy right?
Not wanting to waste his time going up and down again every few days, he hired you to devise an efficient and time-saving way to replace shoes in his rack with the ones he’ll be using in the next few days from his shoe room. For starters, he gave you an inventory of his shoes S, each uniquely labeled with a letter or a combination of letters in the English Alphabet (e.g. A, AB, ZXX). Then, he shared his weekly schedule tagging the shoes he’ll be wearing for the events.
Let’s look at Peter’s shoe rack. It’s a 5-compartment rack containing shoes a, b, c, d, and e.
| a | b | c | d | e |
From his schedule, the following shoes will be used in order and must be in the rack: a, d, and e. With this data, you don’t need to do anything. All shoes are there.
But what happens if we have the following: x, a, g, b, c, d, c and e. Shoes x and g are not in the rack. Therefore, a pair of shoes has got to be evicted. Question is, which shoe? Remember, evicting means a trip from Peter’s room to the shoe room. How do you minimize eviction then? Now, that is the problem.
Your job now is to show Peter, through a program, that you have the solution.
Input Format
The first line of input contains the number of cases C to handle. The succeeding lines are the C test cases. Each case contains 3 data separated by a semicolon: size of the rack R, R number of shoes S labeled uniquely by the letters of the alphabet and a listing of shoes that will be used by Peter based on his schedule.
Output Format
Your program must display the optimized number of evictions given the input data. Otherwise, display unable to process.
Constraints
0 < R < 50 S > 0