Problem Description

You will receive q commands: BEGIN, COMMIT, ROLLBACK, SET k v, GET k. Implement nested transactions. GET prints value or NOT FOUND. If COMMIT/ROLLBACK is invalid, output ERROR and stop.

Input Format

First line q. Next q lines commands.

Output Format

Outputs for GET or ERROR.

Sample Test Case

Input:
9 SET a 1 BEGIN SET a 2 GET a ROLLBACK GET a COMMIT BEGIN COMMIT
Output:
2 1 ERROR

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next