Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,M,a[3],dp[50];
vector<int> G[50];
int inf=1e8;
bool can[101][50][50];
int main(){
	cin>>N>>M>>a[0]>>a[1]>>a[2];
	rep(i,M){
		int v,w;
		cin>>v>>w;
		v--,w--;
		G[v].pb(w);
	}
	rep(i,N) can[0][i][i]=1;
	rep(i,100){
		rep(v,N) for(int u:G[v]) rep(x,N) if(can[i][u][x]) can[i+1][v][x]=1;
	}
	rep(i,N) dp[i]=inf;
	dp[N-1]=0;
	bool update=1;
	while(update){
		update=0;
		rep(i,N){
			int mx=-1;
			rep(j,3){
				int mn=inf;
				rep(v,N){
					if(can[a[j]][i][v]) chmin(mn,dp[v]+1);
				}
				chmax(mx,mn);
			}
			if(mx<dp[i]){
				update=1;
				dp[i]=mx;
			}
		}
	}
	if(dp[0]==inf) puts("IMPOSSIBLE");
	else cout<<dp[0]<<endl;
}