#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long Int;

vector<Int> Graph[100001];
Int DFSPath[100001];
Int pL=0;
Int WentInside[100001];
Int LargestCycleLen[100001];
Int n,m,s,t,f;
Int TFO[100001];

struct tl
{
    Int comefrom;
    Int ver;
    Int dist;
};

tl tail[100001];
Int Train[200001];
Int tL=0;
Int firstwagon;
Int thedistance;
Int thevertex;
Int L;
Int ThePath[100001];

void DFS(Int ver,Int cf)
{
    if (TFO[ver])
    {
        Int cyclelen=pL-WentInside[ver]+1;
        Int i;

        for (i=pL;i>=WentInside[ver];i--)
        {
            if (LargestCycleLen[ DFSPath[i] ]==-1 || LargestCycleLen[ DFSPath[i] ]<cyclelen)
            {
                LargestCycleLen[ DFSPath[i] ]=cyclelen;
            }
        }
        return;
    }

    TFO[ver]=true;
    pL++;
    WentInside[ver]=pL;
    DFSPath[pL]=ver;

    Int i;

    for (i=0;i<Graph[ver].size();i++)
    {
        if (Graph[ver][i]!=cf)
        DFS(Graph[ver][i],ver);
    }

    pL--;
    return;
}

void BFS(Int sver,bool lookingforfinal)
{
    Int uk;
    Int cver,nver;
    Int bestfound,bestdist;
    bool found=false;
    Int d;
    Int i;

    for (i=1;i<=n;i++)
    {
        TFO[i]=false;
    }

    tL=1;
    tail[1].ver=sver;
    tail[1].comefrom=0;
    tail[1].dist=0;
    uk=1;
    TFO[sver]=true;

    while(uk<=tL)
    {
        cver=tail[uk].ver;

        if (lookingforfinal)
        {
            if (cver==f)
            {
                bestfound=uk;
                found=true;
                bestdist=tail[uk].dist;
                break;
            }
        }

        if (LargestCycleLen[cver]>t && !lookingforfinal)
        {
            if (!found)
            {
                found=true;
                bestfound=uk;
                bestdist=tail[uk].dist+LargestCycleLen[cver];
            }
            else
            {
                if (tail[uk].dist+LargestCycleLen[cver]<bestdist)
                {
                    bestdist=tail[uk].dist+LargestCycleLen[cver];
                    bestfound=uk;
                }
            }
        }

        for (i=0;i<Graph[cver].size();i++)
        {
            nver=Graph[cver][i];

            if (cver==s && nver==firstwagon)
            {
                continue;
            }

            if (!TFO[nver])
            {
                TFO[nver]=true;
                tL++;
                tail[tL].dist=tail[uk].dist+1;
                tail[tL].comefrom=uk;
                tail[tL].ver=nver;
            }
        }

        uk++;
    }

    if (!found)
    {
        L=-1;
    }
    else
    {
        L=0;
        cver=bestfound;
        while(cver!=0)
        {
            L++;
            ThePath[L]=tail[cver].ver;
            cver=tail[cver].comefrom;
        }
    }

    thedistance=bestdist;
    thevertex=tail[bestfound].ver;

    return;
}

bool Simulate()
{
    Int i;
    Int d;
    Int ukleft=1,ukright=t;

    for (i=1;i<=n;i++)
    {
        TFO[i]=false;
    }

    for (i=1;i<=t/2;i++)
    {
        d=Train[i];
        Train[i]=Train[ t-i+1 ];
        Train[ t-i+1 ]=d;
    }

    for (i=1;i<=t;i++)
    {
        TFO[ Train[i] ]=true;
    }
    TFO[s]=true;

    for (i=L-1;i>=1;i--)
    {
        TFO[ Train[ukleft] ]=false;
        ukleft++;

        if (TFO[ ThePath[i] ])
        {
            return false;
        }
        else
        {
            TFO[ ThePath[i] ]=true;
            ukright++;
            Train[ukright]=ThePath[i];
        }
    }

    return true;
}

int main()
{
    Int i;
    Int a,b;
    Int totaldistance=0;

    scanf("%lld %lld %lld %lld %lld",&n,&m,&s,&t,&f);

    for (i=1;i<=m;i++)
    {
        scanf("%lld %lld",&a,&b);

        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }

    for (i=1;i<=t;i++)
    {
        scanf("%lld",&Train[i]);
    }

    firstwagon=Train[1];

    for (i=1;i<=n;i++)
    {
        TFO[i]=false;
    }

    for (i=1;i<=n;i++)
    {
        if (!TFO[i])
        {
            DFS(i,0);
        }
    }

    BFS(s,true);

    if (L==-1)
    {
        printf("NO\n");
        return 0;
    }
    else
    {
        if (Simulate())
        {
            printf("%lld\n",thedistance);
        }
        else
        {
            BFS(s,false);

            if (L==-1)
            {
                printf("NO\n");
                return 0;
            }

            totaldistance=totaldistance + thedistance;

            BFS(thevertex,true);

            totaldistance=totaldistance + thedistance;

            if (L==-1)
            {
                printf("NO\n");
                return 0;
            }

            printf("%lld\n",totaldistance);
        }
    }

    return 0;
}
/**
13 15 9 4 1
1 2
1 3
2 4
3 4
4 5
4 6
6 7
7 9
9 8
8 6
7 12
7 13
9 10
9 11
10 11
8 6 4 2
**/
