Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 55
#define INF 1000000000
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,m,a,b,c;
char in[M*2][M][M];
int dis[M];
int max(int x,int y,int z)
{
	return max(max(x,y),z);
}
int main()
{
	int x,y;
	int d1,d2,d3;
	bool flg;
	while(~scanf("%d %d %d %d %d",&n,&m,&a,&b,&c))
	{
		MSET(in, false);
		REP(i,1,m)
		{
			RI(x,y);
			in[1][x][y] = true;
		}

		REP(s,2,100)
		{
			REP(i,1,n)REP(j,1,n)REP(k,1,n)
				if(in[1][i][j] && in[s-1][j][k])
					in[s][i][k] = true;
		}
		
		REP(i,1,n)dis[i]=INF;
		dis[n]=0;

		while(1)
		{
			x=-1;
			flg=false;
			REP(i,1,n)
			{
				d1=d2=d3=INF;

				REP(j,1,n) if(in[a][i][j] && d1>dis[j]) d1=dis[j];
				REP(j,1,n) if(in[b][i][j] && d2>dis[j]) d2=dis[j];
				REP(j,1,n) if(in[c][i][j] && d3>dis[j]) d3=dis[j];

				if(max(d1,d2,d3)+1 < dis[i])
				{
					flg=true;
					dis[i] = max(d1,d2,d3)+1;
				}
			}

			if(!flg) break;
		}

		if(dis[1]==INF) puts("IMPOSSIBLE");
		else printf("%d\n",dis[1]);
	}
	return 0;
}