#K95007. Taco Tracker
Taco Tracker
Taco Tracker
This problem involves tracking the locations of items based on a series of commands. You are given multiple datasets. Each dataset starts with two integers \(N\) and \(M\), where \(N\) is the total number of items and \(M\) is the number of commands. Following this, there are \(M\) commands which can be of two types:
- MOVE x y: Set the location of item \(x\) to \(y\).
- WHERE x: Query the current location of item \(x\). If the item has not been moved before, the output should be
UNKNOWN
.
The input terminates with a line containing "0 0". Process all datasets sequentially and output the result for every WHERE command.
inputFormat
Input consists of multiple datasets. For each dataset:
- The first line contains two integers (N) and (M), where (N) is the number of items and (M) is the number of commands.
- The next (M) lines each contain a command in one of the following forms: "MOVE x y" or "WHERE x".
The input ends with a line containing "0 0".
outputFormat
For each WHERE command, output the location of the item if it has been moved; otherwise, output "UNKNOWN". Each answer must be printed on a new line.## sample
3 5
MOVE 1 100
MOVE 2 200
WHERE 1
WHERE 2
WHERE 3
0 0
100
200
UNKNOWN
</p>