This page is still under construction.

Parts of this page are still being built. What you see may change.

Bring Them There

Time limit2sMemory limit128 MB

Summary
Find the minimum number of days to send K ships from S to T through an undirected graph where each edge carries at most one ship per day.
Level

Hard8 of 10

Topics
Graph, BFS, Dynamic programming, Shortest path
Solved
No attempts yet

Problem

By the year 3141, humanity has spread across the entire galaxy. Travel between star systems relies on special hypertunnels. To use a hypertunnel you fly your spaceship to a launch point near the source star, activate the hyperjumper, pass through the tunnel, emerge near the destination star, and fly on to the planet you need. The whole trip takes exactly one day.

The system has one limitation: on any given day, each tunnel can carry at most one spaceship. In particular, two ships may never travel through the same tunnel on the same day, not even in opposite directions.

You work in the transportation department of a large corporation. Today you must deliver KK supercomputers from Earth (star system SS) to the planet Eisiem (star system TT). Each supercomputer is so large that it fills an entire spaceship, so one ship can carry only one supercomputer at a time. You have as many spaceships as you need, and a ship may wait at any star system for any number of days. You may use any tunnel whenever you need it, subject only to the one-ship-per-tunnel-per-day rule.

Find the minimum number of days required to deliver all KK supercomputers from SS to TT.

Input

The first line contains five integers NN, MM, KK, SS, TT: the number of star systems, the number of tunnels, the number of supercomputers to deliver, the source star system (Earth), and the destination star system (Eisiem), with 2≤N≤502 \le N \le 50, 1≤M≤2001 \le M \le 200, 1≤K≤501 \le K \le 50, 1≤S,T≤N1 \le S, T \le N, and S≠TS \ne T.

Each of the next MM lines contains two distinct integers describing one tunnel and the two star systems it connects. A tunnel can be traveled in either direction, but only one ship may use it per day. No tunnel connects a star system to itself, and any two star systems are connected by at most one tunnel.

It is guaranteed that at least one route exists from SS to TT.

Output

Print a single integer: the minimum number of days needed to deliver all KK supercomputers from star system SS to star system TT.

Examples1

  1. Example 1

    Input
    6 7 4 1 6
    1 2
    2 3
    3 5
    5 6
    1 4
    4 6
    4 3
    
    Expected output
    4