#C7274. Simple Database Simulation

    ID: 51127 Type: Default 1000ms 256MiB

Simple Database Simulation

Simple Database Simulation

You are required to implement a simple key-value database. The database supports two commands:

  • INSERT key value: This command inserts a key with an integer value. If the key already exists, its value is updated to the new value.
  • QUERY key: This command retrieves the value associated with the provided key. If the key does not exist in the database, output NOT FOUND.

The commands are given in order, and you must process them to produce the output of every QUERY command.

inputFormat

The first line of input contains an integer n, representing the number of commands. The following n lines each contain a command in one of the following two formats:

  • INSERT key value
  • QUERY key

outputFormat

For each QUERY command, output the result on a separate line. If the key exists in the database, output its corresponding integer value. Otherwise, output NOT FOUND.

## sample
7
INSERT myKey 123
QUERY myKey
INSERT anotherKey 456
QUERY anotherKey
INSERT myKey 789
QUERY myKey
QUERY nonExistentKey
123

456 789 NOT FOUND

</p>