import java.io.*; import java.util.*; class P implements Comparable

{ long a,b; P(long x,long y){a=x;b=y;} @Override public int compareTo(P o){ return Long.compare(a,o.a); } } class Main { static final long I=1L<<53; static Mapbank=new HashMap(); static ArrayList[]sky; static int regist(int a,int b){ long v=(long)a<<32|b; Integer c=bank.get(v); if(c!=null)return c; int s=bank.size(); bank.put(v,s); sky[a].add((long)b<<32|s); return s; } static ArrayList[]g; @SuppressWarnings("unchecked") public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n=sc.nextInt(); int m=sc.nextInt(); int k=sc.nextInt(); int s=sc.nextInt(); int t=sc.nextInt(); sky=new ArrayList[n]; Arrays.setAll(sky,x->new ArrayList()); int[]ds=new int[m],es=new int[m]; for(int i=0;inew ArrayList()); for(int i=0;i>>32); long wwh=sky[i].get(j+1); int w=(int)wwh; int wh=(int)(wwh>>>32); g[v].add((long)w<<32|(wh-vh)); g[w].add((long)v<<32|(wh-vh)); } } for(int i=0;iq=new PriorityQueue

(); q.add(new P(0,si)); while(q.size()>0){ P dw=q.poll(); long d=dw.a; int v=(int)dw.b; if(dis[v]<=d)continue; dis[v]=d; for(long e:g[v]){ int w=(int)(e>>>32); long nd=d+(int)e; if(dis[w]<=nd)continue; dis[w]=nd+1; q.add(new P(nd,w)); } } out.println(dis[ti]==I?-1:dis[ti]); out.close(); } // http://codeforces.com/blog/entry/7018 //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; //-----------MyScanner class for faster input---------- public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }