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<(n); i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define X first
#define Y second

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

const ll INF = 1e9;


int n, m, a, b, c;
ll d[105][105];
vector<int> edge[105];

int main(){
	fill( d[0], d[0]+105*105, INF );
	cin >> n >> m >> a >> b >> c;
	rep(i,m){
		int u, v;
		cin >> u >> v;
		edge[v].pb(u);
	}
	edge[1].pb(0);

	queue<pii> que;
	que.emplace(n,0);
	d[n][0] = 1;
	while( !que.empty() ){
		auto p = que.front();
		//cout << p.X << "," << p.Y << " " << d[p.X][p.Y] << endl;
		que.pop();
		ll f = -1;
		if( d[p.X][a] < INF && d[p.X][b] < INF && d[p.X][c] < INF ){
			f = max(d[p.X][a], max(d[p.X][b], d[p.X][c]) );
			d[p.X][0] = min(d[p.X][0], f);
		}
		for(auto t: edge[p.X]){
			int ni = p.Y + 1;
			if( ni <= 100 && d[t][ni] > d[p.X][p.Y] ){
				d[t][ni] = d[p.X][p.Y];
				que.emplace( t, ni );
			}
			if( f>0 && d[t][1] > f + 1 ){
				d[t][1] = f + 1;
				que.emplace( t, 1 );
			}
		}
	}

	if( d[1][0] == INF ) cout << "IMPOSSIBLE" << endl;
	else cout << d[1][0] << endl;
}