using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; static class Program{ const int mod=(int)1e9+7; const int inf=int.MaxValue-1; static List>[] li; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; int n=s[0],m=s[1],k=s[2]; li=new List>[n+1]; for(int i=1;i<=n;i++){li[i]=new List>();} for(int i=0;i(); qu.Enqueue0(1); while(qu.cnt>0){ var e=qu.Dequeue; b[e.d]=true; for(int i = 0;ic[e.d]){ c[li[e.d][i].Item1]=c[e.d]; qu.Enqueue0(li[e.d][i].Item1); } } else{ if(c[li[e.d][i].Item1]>c[e.d]+1){ c[li[e.d][i].Item1]=c[e.d]+1; qu.Enqueue1(li[e.d][i].Item1); } } } } } return c[n]{ public class Dt{ public bool b; public T d; public Dt(bool b,T d){this.b=b;this.d=d;} public override string ToString()=>"b:"+b.ToString()+" d:"+d.ToString(); } private Queue
qu0=new Queue
(),qu1=new Queue
(); public void Enqueue(bool b,T d){ if(b){qu0.Enqueue(new Dt(true,d));} else{qu1.Enqueue(new Dt(false,d));} } public void Enqueue0(T d){qu0.Enqueue(new Dt(true,d));} public void Enqueue1(T d){qu1.Enqueue(new Dt(false,d));} public Dt Dequeue{get{return qu0.Count>0?qu0.Dequeue():qu1.Dequeue();}} public Dt Peek{get{return qu0.Count>0?qu0.Peek():qu1.Peek();}} public int cnt{get{return qu0.Count+qu1.Count;}} } public class Sc{ public int I{get{return int.Parse(Console.ReadLine());}} public long L{get{return long.Parse(Console.ReadLine());}} public double D{get{return double.Parse(Console.ReadLine());}} public string S{get{return Console.ReadLine();}} public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}} public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}} public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}} public string[] Sa{get{return Console.ReadLine().Split();}} public object[] Oa{get{return Console.ReadLine().Split();}} public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}} public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);} public T[] Arr(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i