Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define rdll(x) scanf("%lld",&x);
int n,m,a,b,c;
bool rui[55][2505];
bool ok[55][55][105];
vector<int>edge[55];
int main(){
	cin>>n>>m>>a>>b>>c;
	rep(i,m){
		int x,y; cin>>x>>y;
		edge[x].pb(y);
	}
	repn(i,n) ok[i][i][0] = 1;
	repn(x,104){
		repn(i,n){
			repn(j,n){
				for(int k=0;k<edge[i].size();k++){
					int to = edge[i][k];
					if(ok[to][j][x-1]) ok[i][j][x] = 1;
				}
			}
		}
	}
	rui[n][0] = 1;
	for(int t=1;t<=n*n;t++){
		for(int v=1;v<=n;v++){
			int mask = 0;
			repn(u,n){
				if(ok[v][u][a] && rui[u][t-1]) mask|=1;
			}
			repn(u,n){
				if(ok[v][u][b] && rui[u][t-1]) mask|=2;
			}
			repn(u,n){
				if(ok[v][u][c] && rui[u][t-1]) mask|=4;
			}
			if(mask==7){
				rui[v][t]=1;
			}
			else if(rui[v][t-1]) rui[v][t] = 1;
		}
		if(rui[1][t]){
			cout<<t<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}
