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 all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, a, b, c;
bool can[101][50][50];
int dp[50];

int main(){
	cin >> n >> m >> a >> b >> c;
	rep(i, m){
		int x, y; cin >> x >> y; x--; y--;
		can[0][x][y] = 1;
	}
	rep(it, 100) rep(k, n) rep(i, n) rep(j, n){
		if(can[it][i][k] && can[0][k][j]) can[it + 1][i][j] = 1;
	}
	
	rep(it, 101){
		rep(i, n - 1){
			int x = inf, y = inf, z = inf;
			rep(j, n){
				if(can[a - 1][i][j]) x = min(x, dp[j] + 1);
				if(can[b - 1][i][j]) y = min(y, dp[j] + 1);
				if(can[c - 1][i][j]) z = min(z, dp[j] + 1);
			}
			dp[i] = max({dp[i], x, y, z});
		}
	}
	if(dp[0] >= n) cout << "IMPOSSIBLE" << endl; 
	else cout << dp[0] << endl;
	
	return 0;
}