using System.Collections.Generic;
static void Main(string[] args)
n = int.Parse(Console.ReadLine());
m = int.Parse(Console.ReadLine());
r = int.Parse(Console.ReadLine());
List<int>[] G = new List<int>[n + 1];
List<int> T = new List<int>(n + 1); T.Add(0);
G[i] = new List<int>(); T.Add(0);
u = int.Parse(Console.ReadLine());
v = int.Parse(Console.ReadLine());
G[u].Add(v); G[v].Add(u);
Console.WriteLine("{0}: {1}", i, T[i]);
static void BFS(int n, List<int>[] G, List<int> T, int r)
bool[] used = new bool[n + 1];
Queue<int> Q = new Queue<int>();
for (i = 1; i <= n; i++) used[i] = false;
Q.Enqueue(r); used[r] = true; T[r] = 0;
for(i = 0;i<G[x].Count;i++)
used[y] = true; T[y] = x; Q.Enqueue(y);