Grafs (2)

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

Input

Input starts with the value of nn and the nn names of the vertices. Then comes the value of mm and follow the mm arcs, made up by the name of two vertices, without repetitions nor autoloops. Then follows a pair of vertices x,yx,y. You can assume that xx and yy belong to the graph.

Output

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

Problem information

Author: Jordi Petit

Generation: 2026-01-25T10:31:41.683Z

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