Graphs (1)

Given a directed graph with mm vertices and mm arcs, we wish to know if there is a directed path between two given vertices.

Input

Input starts with nn i mm. Then follow mm pairs u,vu,v, with uvu \ne v, indicating an arc from uu to vv. We have that 0u<n0\le u<n and 0v<n0\le v<n and there are no repeated arcs. Then follows, a pair x,yx,y with 0x<n0\le x<n and 0y<n0\le y <n.

Output

Write “yes” o “no” according to whether there is or not a path from xx to yy.

Problem information

Author: Jordi Petit
Translator: Jordi Petit

Generation: 2026-01-25T11:22:50.547Z

© Jutge.org, 2006–2026.
https://jutge.org