#include #include #include #include #include using namespace std; typedef long long int ll; #define x first #define y second #define NONE 1234567890 struct Vertex { vector next; vector firstEnemy; ll distance = NONE; Vertex() : firstEnemy(2, NONE) {}; }; int main(){ ll n, m, finish, enemyStart, start, a, b; cin >> n >> m >> finish >> enemyStart >> start; vector graph(n); vector> edges(m); if (start == enemyStart) { cout << "death\n"; return 0; } for (int i=0; i> a >> b; graph[a].next.push_back(b); graph[b].next.push_back(a); edges[i] = {a, b}; } queue> q; graph[enemyStart].firstEnemy[0] = 0; q.push({0, enemyStart}); while (!q.empty()){ ll d = q.front().first; ll v = q.front().second; q.pop(); for (int s: graph[v].next) { if (graph[s].firstEnemy[(d+1) % 2] == NONE) { graph[s].firstEnemy[(d+1) % 2] = d + 1; q.push({d+1, s}); } } } //vstupne su < n, vystupne su n az 2*n-1 vector ourGraph(2*n); for (int i=0; i>(); q.push({0, start}); ourGraph[start].distance = 0; while (!q.empty()) { ll d = q.front().first; ll v = q.front().second; q.pop(); for (int s: ourGraph[v].next) { if (ourGraph[s].distance == NONE && ourGraph[s].firstEnemy[(d+1)%2] > d+1) { ourGraph[s].distance = d + 1; q.push({d+1, s}); } } } if (ourGraph[finish].distance == NONE) { cout << "death\n"; } else { cout << ourGraph[finish].distance << '\n'; } return 0; }