{"trustable":true,"sections":[{"title":"Description","value":{"format":"MD","content":"In a school, a teacher wants to line up $N$ students in a row, with the students numbered from $1\\sim N$. The teacher follows these steps:\n\n1. First, student $1$ is placed in the queue, so there is only him in the queue;\n\n2. Student $2\\sim N$ enters the queue one by one, and student numbered $i$ enters the queue in the following way: the teacher specifies that student numbered $i$ stands to the left or right of a student numbered $1\\sim(i-1)$ (i.e., one of the students who has already entered the queue);\n\n3. Remove $M$ students from the queue, while the positions of the remaining students remain unchanged.\n\nAfter all the students are arranged in the queue according to the above method, the teacher wants to know the numbers of all the students from left to right."}},{"title":"Input","value":{"format":"MD","content":"The first line contains an integer $N$, indicating that there are $N$ students.\n\nThe $2\\sim N$ line and the $i$ line each contain two integers $k,p$, where $k$ is a positive integer less than $i$ and $p$ is either $0$ or $1$. If $p$ is $0$, it means to insert student $i$ to the left of student $k$; if $p$ is $1$, it means to insert to the right.\n\nThe $N+1$ line contains an integer $M$, indicating the number of students to be removed.\n\nThe next $M$ lines each contain a positive integer $x$, indicating that student $x$ is to be removed from the queue. If student $x$ is no longer in the queue, this instruction is ignored."}},{"title":"Output","value":{"format":"MD","content":"A single line containing at most $N$ integers separated by spaces, representing the numbers of all students in the queue from left to right."}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n1 0\n2 1\n1 0\n2\n3\n3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 4 1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"Hint","value":{"format":"MD","content":"**【Sample Explanation】**\n\nInsert student $2$ to the left of student $1$, the queue is now:\n\n`2 1`\n\nInsert student $3$ to the right of student $2$, the queue is now:\n\n`2 3 1` \n\nInsert student $4$ to the left of student $1$, the queue is now:\n\n`2 3 4 1` \n\nRemove student $3$ from the queue, the queue is now:\n\n`2 4 1` \n\nStudent $3$ is no longer in the queue, ignore the last instruction.\n\nFinal queue:\n\n`2 4 1` \n\n**【Data Range】**\n\nFor $20\\%$ data, $1\\leq N\\leq 10$.\n\nFor $40\\%$ data, $1\\leq N\\leq 1000$.\n\nFor $100\\%$ data, $1\u003cM\\leq N\\leq 10^5$."}}]}