#K10481. Interplanetary Message Passing

    ID: 23256 Type: Default 1000ms 256MiB

Interplanetary Message Passing

Interplanetary Message Passing

You are given N planets and M directed communication channels. Each channel is represented as a directed edge from planet u to planet v. A message can be transmitted from a source planet S to a target planet T if and only if there exists a sequence of channels forming a path from S to T.

In mathematical terms, there exists a sequence of planets $$S = u_0 \rightarrow u_1 \rightarrow \cdots \rightarrow u_k = T,$$ which implies that communication is possible.

Your task is to determine whether a message can be sent from planet S to planet T.

inputFormat

The input is read from stdin and structured as follows:

N M
u1 v1
u2 v2
...
up vp
S T

Where:

  • N is the number of planets.
  • M is the number of directed channels.
  • Each of the next M lines contains two integers u and v indicating a channel from planet u to planet v.
  • The last line contains two integers S (source) and T (target).

outputFormat

Output a single line to stdout containing "Yes" if communication from planet S to planet T is possible, and "No" otherwise.## sample

4 4
1 2
2 3
3 4
4 2
1 4
Yes