{"raw_statement":[{"iden":"problem statement","content":"We have $N$ boxes numbered $1$ to $N$ that are initially empty, and an unlimited number of blank cards.  \nProcess $Q$ queries in order. There are three kinds of queries as follows.\n\n*   `1 i j` $\\colon$ Write the number $i$ on a blank card and put it into box $j$.\n*   `2 i` $\\colon$ Report all numbers written on the cards in box $i$, **in ascending order**.\n*   `3 i` $\\colon$ Report all box numbers of the boxes that contain a card with the number $i$, **in ascending order**.\n\nHere, note the following.\n\n*   In a query of the second kind, if box $i$ contains multiple cards with the same number, that number should be printed the number of times equal to the number of those cards.\n*   In a query of the third kind, even if a box contains multiple cards with the number $i$, the box number of that box should be printed only once."},{"iden":"constraints","content":"*   $1 \\leq N, Q \\leq 2 \\times 10^5$\n*   For a query of the first kind:\n    *   $1 \\leq i \\leq 2 \\times 10^5$\n    *   $1 \\leq j \\leq N$\n*   For a query of the second kind:\n    *   $1 \\leq i \\leq N$\n    *   Box $i$ contains some cards when this query is given.\n*   For a query of the third kind:\n    *   $1 \\leq i \\leq 2 \\times 10^5$\n    *   Some boxes contain a card with the number $i$ when this query is given.\n*   At most $2 \\times 10^5$ numbers are to be reported.\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$Q$\n$\\mathrm{query}_1$\n$\\mathrm{query}_2$\n$\\vdots$\n$\\mathrm{query}_Q$\n\nHere, $\\mathrm{query}_q$ denotes the $q$\\-th query, which is in one of the following formats:\n\n$1$ $i$ $j$\n\n$2$ $i$\n\n$3$ $i$"},{"iden":"sample input 1","content":"5\n8\n1 1 1\n1 2 4\n1 1 4\n2 4\n1 1 4\n2 4\n3 1\n3 2"},{"iden":"sample output 1","content":"1 2\n1 1 2\n1 4\n4\n\nLet us process the queries in order.\n\n*   Write $1$ on a card and put it into box $1$.\n*   Write $2$ on a card and put it into box $4$.\n*   Write $1$ on a card and put it into box $4$.\n*   Box $4$ contains cards with the numbers $1$ and $2$.\n    *   Print $1$ and $2$ in this order.\n*   Write $1$ on a card and put it into box $4$.\n*   Box $4$ contains cards with the numbers $1$, $1$, and $2$.\n    *   Note that you should print $1$ twice.\n*   Boxes $1$ and $4$ contain a card with the number $1$.\n    *   Note that you should print $4$ only once, even though box $4$ contains two cards with the number $1$.\n*   Boxes $4$ contains a card with the number $2$."},{"iden":"sample input 2","content":"1\n5\n1 1 1\n1 2 1\n1 200000 1\n2 1\n3 200000"},{"iden":"sample output 2","content":"1 2 200000\n1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}