// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int MAXN=55;



bool  w[MAXN][MAXN],f[MAXN][MAXN][105];

int vis[MAXN];



int main()

{

    int n,m,len[3];

    scanf("%d%d",&n,&m);

    memset(w,0,sizeof(w));memset(f,0,sizeof(f));memset(vis,0,sizeof(vis));

    for (int i=0;i<3;i++) scanf("%d",&len[i]);

    for (int u,v;m--;)

    {

        scanf("%d%d",&u,&v);

        w[u][v]=true;

    }

    for (int i=1;i<=n;i++)

    {

        f[i][i][0]=true;

        for (int j=1;j<=100;j++)

            for (int k=1;k<=n;k++)

                for (int l=1;l<=n;l++)

                    if (w[l][k]&&f[i][l][j-1])

                        f[i][k][j]=true;

    }

    fill(vis+1,vis+n,INT_MAX);

    for (int now=1;now<=n;now++)

        for (int i=1;i<=n;i++)

            if (vis[i]>now)

            {

                bool flag;

                for (int j=0;j<3;j++)

                {

                    flag=false;

                    for (int k=1;k<=n;k++)

                        if (vis[k]<now&&f[i][k][len[j]])

                        {

                            flag=true;

                            break;

                        }

                    if (!flag) break;

                }

                if (flag)

                {

                    if (i==1)

                    {

                        printf("%d\n",now);

                        return 0;

                    }

                    vis[i]=now;

                }

            }

    puts("IMPOSSIBLE");

    return 0;

}

// Optimized solution to the same problem (faster):
#include <queue>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#define N 55

#define M 2500

#define P 100

#define inf 0x3f3f3f3f

using namespace std;

struct Ahri

{

	int v,n;

}e[M];

int head[N],cnt;

inline void add(int u,int v)

{

	e[++cnt].v=v;

	e[cnt].n=head[u];

	head[u]=cnt;

}

bool f[P+5][N][N];

int dis[N],n,m,A,B,C;

int da[N],db[N],dc[N];

void getf() {

    for(int i = 1; i <= n; i++) f[0][i][i] = 1;



    for(int len = 0; len <= 101; len++) {

        for(int u = 1; u <= n; u++) {

            for(int v = 1; v <= n; v++) {

                if(f[len][u][v]) {

                    for(int p = head[v]; p; p = e[p].n) {

                        int w = e[p].v;

                        f[len + 1][u][w] = 1;

                    }

                }

            }

        }

    }



}

queue<int>q;

void bfs()

{

	while(!q.empty())q.pop();

	memset(dis,-1,sizeof dis);

	memset(da,0,sizeof da);

	memset(db,0,sizeof db);

	memset(dc,0,sizeof dc);

	

	int i,u;

	q.push(n),dis[n]=0;

	

	while(!q.empty())

	{

		u=q.front(),q.pop();



		for(i=1;i<=n;i++)if(dis[i]==-1)

		{

			if(!da[i]&&f[A][i][u])da[i]=dis[u]+1;

			if(!db[i]&&f[B][i][u])db[i]=dis[u]+1;

			if(!dc[i]&&f[C][i][u])dc[i]=dis[u]+1;

			if(da[i]&&db[i]&&dc[i])

				dis[i]=max(da[i],max(db[i],dc[i])),q.push(i);

		}

	}

}



int main()

{

//	freopen("test.in","r",stdin);

	int i,j,k;

	scanf("%d%d%d%d%d",&n,&m,&A,&B,&C);

	while(m--)

	{

		scanf("%d%d",&i,&j);

		add(i,j);

	}

	getf();

	bfs();

	if(dis[1]==-1)puts("IMPOSSIBLE");

	else printf("%d\n",dis[1]);

	

	return 0;

}

// Fastest known solution for this problem: