#include <bits/stdc++.h>
#define fo(i,a,b) for (int i = a;i <= b;i ++)
using namespace std;

const int maxn = 105;
int n,m,step[3],t;
bitset<60> d[maxn][maxn];
int f[maxn];

bool solve() {
    bool flag = false;
    for (int i = 1; i <= n; i++) {
		int wp = 0;
		//if (f[i] < 1 << 29) continue;
		for (int k = 0; k < 3; k++) {
			int js = 1 << 29;
			for (int j = 1; j <= n; j++) {
				if (d[i][step[k]][j]) {
					js = min(js, f[j]);
				}
			}
			wp = max(wp, js + 1);
		}
		if (f[i] > wp) flag = true;
		f[i] = min(f[i], wp);
    }
    return flag;
}

int main() {

	scanf("%d%d%d%d%d",&n,&m,&step[0],&step[1],&step[2]);

	for (int i = 1; i <= m; i++) {
	    int a,b;
	    scanf("%d %d",&a,&b);
	    d[a][1][b]  = 1;
	}

	for (int j = 2; j <= 100; j++)
	    for (int i = 1; i <= n; i++) {
		for (int k = 1; k <= n; k++)
		    if (d[i][1][k]) d[i][j] = d[i][j] | d[k][j - 1];
	    }

	for (int i = 1; i <= n; i++) f[i] = 1 << 29;
	f[n] = 0;

	while (solve() && (++t < n * 3));

	if (t >= n * 3 || f[1] >= 1 << 29) printf("IMPOSSIBLE\n") ;
	else printf("%d\n",f[1]);
	return 0;
}