Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#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],dist[maxn];
bitset<maxn> d[maxn][maxn];

int main()
{
	scanf("%d%d%d%d%d",&n,&m,&step[0],&step[1],&step[2]);
	sort(step,step+3);
	fo(i,1,m)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		d[u][1][v] = 1;
	}
	fo(j,2,step[2])
		fo(i,1,n)
			fo(k,1,n)
				if (d[i][1][k]) d[i][j] = d[i][j] | d[k][j-1];
	fo(i,1,n) dist[i] = 0x7f7f7f7f;
	dist[n] = 0;
	while (1)
	{
		bool flag = 0;
		fo(i,1,n)
		{
			int len = 0;
			fo(k,0,2)
			{
				int tmp = 0x7f7f7f7f;
				fo(j,1,n)
					if (d[i][step[k]][j])
						tmp = min(tmp,dist[j]+1);
				len = max(len,tmp);
			}
			if (len < dist[i])
			{
				dist[i] = len;
				flag = 1;
			}
		}
		if (!flag) break;
	}
	if (dist[1] == 0x7f7f7f7f) puts("IMPOSSIBLE");
	else printf("%d\n",dist[1]);
	return 0;
}