1978: Breadth-first search of graphs

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:13 解决:5

题目描述

Here is a graph. Its vertices are represented by capital letters. Its serial number starts from A. Please program the breadth-first search and output the vertices starting from B.

输入

there are many cases,for each case,input two integers "m" and "n" to denote the number of vertices and the number of the edges.and then input n lines to represent each edge with two letters(corresponding to two vertices)

输出

output the breadth first search traversal sequence of the graph starting from "B"

样例输入 复制

9 10
A B
A D 
A E
B C
B E
C F
D G
E G
G H
H I

样例输出 复制

BACEDFGHI