Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created January 18, 2026 02:08
Show Gist options
  • Select an option

  • Save maehrm/cdb0f95217cc588840872df28cc02266 to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/cdb0f95217cc588840872df28cc02266 to your computer and use it in GitHub Desktop.
N = int(input())
Q = int(input())
boxes = [[] for _ in range(N + 1)]
cards = {}
for _ in range(Q):
t, *q = map(int, input().split())
if t == 1:
i, j = q
boxes[j].append(i)
if i not in cards:
cards[i] = set()
cards[i].add(j)
elif t == 2:
i = q[0]
print(*sorted(boxes[i]))
else:
i = q[0]
print(*sorted(cards[i]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment