| Udmurt SU Contest 2011 |
|---|
| Finished |
One fine day Pooh had stumped up to the top of the Forest to see if his friend Christopher Robin was interested in Bears at all. You know, that was the day when Christopher Robin was preparing an Expedition to the North Pole. Christopher Robin asked Pooh to tell the others to get ready and to bring Provisions. Pooh had already alerted Rabbit and now hurried down to Piglet's house.
"Oh! Piglet," said Pooh excitedly, "we're going on an Expotition, all of us, with things to eat. To discover something."
For one moment Piglet was scared by Something, but then he said "if Christopher Robin is coming I don't mind anything." Of course, in case Christopher Robin weren't coming, Piglet won't ever go.
Expotition started at the top of the Forest, where everyone saw all Rabbit's friends-and-relations.
"I didn't ask them," explained Rabbit carelessly. "They just came. They always do. They can march at the end, after Eeyore."
Eeyore began to complain about Rabbit's relations, because in case he wants to sit down for a little rest, he have to brush away some of Rabbit's smaller friends first, which is annoying. Eeyore was really close to refuse the whole Expo.
Now Christopher Robin faced the problem. There are $$$n$$$ persons including himself that are ready to go. And Christopher Robin wants $$$k$$$ of them to go on an Expotition regardless of anything (he knows who are these $$$k$$$ persons). And, trying to please everyone, Christopher Robin wants an Expotition group to be complete: there should be no way to add one or two or more persons in such a way that no one will complain. So, who will finally go to discover the North Pole?
There are two integers on the first line: $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 150\,000$$$, $$$0 \leq m \leq 150\,000$$$). Next $$$m$$$ lines contain complaints of two different kinds. Each complaint consists of three integers $$$t_i$$$, $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i, b_i \leq n$$$, $$$a_i \neq b_i$$$). If $$$t_i = 1$$$ then $$$a_i$$$ won't go on an Expotition if annoying person $$$b_i$$$ is coming. (Christopher Robin failed to remember names of all Rabbit's friends-and-relations, so he just gave everyone a number instead of a name.) And if $$$t_i = 2$$$ then $$$a_i$$$ won't ever go on any adventure without his friend $$$b_i$$$.
Persons are quite friendly, so the number of complaints with $$$t_i = 1$$$ won't exceed $$$40$$$. All pairs $$$(a_i, b_i)$$$ are unique.
Next line contains an integer $$$k$$$ ($$$0 \leq k \leq n$$$). And, if $$$k$$$ is positive, the last line contains $$$k$$$ integers — the persons whom Christopher Robin will surely take on an Expotition.
On the first line output a single integer $$$s$$$ — the number of persons going to discover the North Pole. On the second line output $$$s$$$ integers (separated by spaces, pairwise different) — who are these persons. Feel free to output any answer that is complete. It is guaranteed that at least one answer exists.
3 2 1 1 2 1 2 3 1 3
2 1 3
3 3 2 1 2 2 1 3 1 2 3 0
1 2
| Name |
|---|


