Link: https://codeforces.com/problemset/problem/46/F

Anyone who solved this problem before please help me. I don't sure I understood the problem's statement so I can't recap its statement, sorry about this.

I don't know how test case 6 has the answer "NO".

Test case 6's input:

```
3 3 3
1 2
2 3
3 1
a 1 1 1
b 2 1 3
c 3 1 2
b 1 1 2
c 2 1 3
a 3 1 1
```

Illustration of initial state:

The black-ink art is the graph and the red number on each edge is its index. The green-ink art is the information of the person: the green string is the name of that person and the small green numbers near it is that person's keys. In the initial state of this test case: person 'a' was at node number 1 and had the only key to open the 1-index edge; person 'b' was at node number 2 and had the only key to open the 3-index edge; person 'c' was at node number 3 and had the only key to open the 2-index edge.

I think the process will happen as follow:

First, 'a' use his key to open edge 1-2.

Next, since edge 1-2 was open, 'b' go to node number 1 and use his key to open edge 3-1.

Finally, 'c' can go to node number 1 and swap his key with 'b'. After this 'b' has the key 2 and 'c' has the key 3. Then, 'c' go to node number 2 and a go to node number 3 to reach the expected state.

That's what I thought and I think the answer for this test case is "YES", but jury's answer is "NO". I don't know where I gone wrong. Please help correcting me!

And here is my submission: https://codeforces.com/contest/46/submission/193789491