#C2665. Library Management System

    ID: 46006 Type: Default 1000ms 256MiB

Library Management System

Library Management System

You are given a series of transactions for a library. There are \(M\) members and \(B\) books, and \(N\) transactions are performed sequentially. Initially, every book is available, represented by a status of -1.

Each transaction is either:

  • issue X Y — if book \(Y\) is available (status is -1), it is issued to member \(X\).
  • return X Y — if book \(Y\) was issued to member \(X\), it is returned (status becomes -1).

For each test case, after processing all transactions, output the status of every book in order. If a book is issued, output the member ID; if available, output -1.

inputFormat

The first line contains an integer \(T\), the number of test cases. For each test case:

  • The first line contains three integers: \(M\) (number of members), \(B\) (number of books), and \(N\) (number of transactions).
  • The next \(N\) lines each contain a transaction in the format: action X Y, where action is either issue or return, \(X\) is the member ID, and \(Y\) is the book ID (1-indexed).

outputFormat

For each test case, output a single line with \(B\) space-separated integers representing the final status of each book. If a book is issued, output the member ID who has it; if not, output -1.

## sample
1
3 5 7
issue 1 2
issue 2 3
return 1 2
issue 3 2
issue 2 4
return 2 3
issue 1 3
-1 3 1 2 -1