Config History Lookup
Your team's config service never overwrites anything: every change is appended to an audit log as a
record SET key value t, meaning that from second t on, key holds value. The log is written
by a single leader with a monotonic clock, so the times of SET records strictly increase through
the log.
While the log is being written, engineers debugging incidents ask questions of the form
GET key t: "what was key set to at second t?" The answer is the value of the SET record for
key with the largest time that is at most t, or NULL if there is no such record. A query
only sees the records that come before it in the log; it may ask about any time, including
times before the first record or after the last one written so far.
Some keys are hot and change on every deploy, so a key may have a very long history. Answer every query.
Input
The first line contains q (1 ≤ q ≤ 2·10^5), the number of log lines. Each of the next q lines
is one of:
SET key value t: setkeytovaluefrom secondton;GET key t: ask for the value ofkeyat secondt.
Keys are strings of 1 to 20 characters, each a lowercase English letter, a digit, . or _.
Values are strings of 1 to 20 characters, each a lowercase English letter or a digit. All times
satisfy 1 ≤ t ≤ 10^9. The times of the SET lines strictly increase in the order they appear;
times of GET lines are arbitrary and unrelated to each other or to the SET times.
Output
For every GET line, in order, print one line with the answer: the value, or NULL if key had
no value at second t according to the records written before the query.
Notes
In the first example, db.pool is set to 10 at second 5 and to 25 at second 12. A query at
second 12 sees the change made at exactly that second, while a query at second 11 still sees 10,
and a query at second 3 comes before any change, so its answer is NULL.
In the second example, the first query asks about second 100 but is written before the SET at
second 50, so it cannot see it and its answer is NULL. The same query repeated after that SET
returns on.