ExpertAlgorithms50 points

Detect duplicate card transactions

A bank's fraud team flags a transaction as a possible duplicate when the same account makes a transaction with the same amount within 60 seconds of that account's previous transaction with that amount.

Task: the first line holds n. Each of the next n lines is id account amount seconds (the time in seconds since midnight; lines are in time order). Print the id of every transaction that is a possible duplicate, in input order, one per line. If there are none print None.

Sample test

Input

6
T1 A1 500 100
T2 A1 500 130
T3 A2 500 140
T4 A1 700 150
T5 A1 500 400
T6 A1 500 440

Expected output

T2
T6

Your answer is also checked against 2 hidden tests.

Need a hint?

Remember the last time you saw each (account, amount) pair. Compare the new time with it, then update it.