#include using namespace std; using ll = long long; #define fo(a,b) for(int a=0;a<(b);a++) const int NMAX = 112345; struct Nd { vector e; int opon[2]; int me[2]; } nd[NMAX]; pair qu[10*NMAX]; int qb, qe; int n, m, f, t, s; int main() { scanf("%d%d%d%d%d", &n, &m, &f, &t, &s); fo(i,m) { int x,y; scanf("%d%d", &x, &y); nd[x].e.push_back(nd+y); nd[y].e.push_back(nd+x); } qb=qe=0; nd[t].opon[1] = 1; qu[qb++] = make_pair(nd+t, 1); while(qe!=qb) { Nd * c = qu[qe].first; int round = qu[qe].second + 1; qe++; for(Nd * to : c->e) { if(! to->opon[round%2]) { to->opon[round%2] = round; qu[qb++] = make_pair(to, round); } } } fo(i,n) nd[i].e.push_back(nd+i); qb=qe=0; nd[s].me[1] = 1; qu[qb++] = make_pair(nd+s, 1); while(qe!=qb) { Nd * c = qu[qe].first; int round = qu[qe].second + 1; qe++; for(Nd * to : c->e) { if(! to->me[round%2] && (!to->opon[round%2] || to->opon[round%2]>round)) { to->me[round%2] = round; qu[qb++] = make_pair(to, round); } } } if(!nd[f].me[0] && !nd[f].me[1]) printf("death\n"); else if(!nd[f].me[0]) printf("%d\n", nd[f].me[1]-1); else if(!nd[f].me[1]) printf("%d\n", nd[f].me[0]-1); else printf("%d\n", min(nd[f].me[0], nd[f].me[1])-1); return 0; }