#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 55
#define M 2500
#define P 100
#define inf 0x3f3f3f3f
using namespace std;
struct Ahri
{
	int v,n;
}e[M];
int head[N],cnt;
inline void add(int u,int v)
{
	e[++cnt].v=v;
	e[cnt].n=head[u];
	head[u]=cnt;
}
bool f[P+5][N][N];
int dis[N],n,m,A,B,C;
int da[N],db[N],dc[N];
void getf()
{
	int i,j,k,l;
	for(i=1;i<=n;i++)f[0][i][i]=1;
	for(k=1;k<=P;k++)
		for(j=1;j<=n;j++)
			for(i=head[j];i;i=e[i].n)
				for(l=1;l<=n;l++)
					f[k][l][e[i].v]|=(f[k-1][l][j]);
}
queue<int>q;
void bfs()
{
	while(!q.empty())q.pop();
	memset(dis,-1,sizeof dis);
	memset(da,0,sizeof da);
	memset(db,0,sizeof db);
	memset(dc,0,sizeof dc);
	
	int i,u;
	q.push(n),dis[n]=0;
	
	while(!q.empty())
	{
		u=q.front(),q.pop();

		for(i=1;i<=n;i++)if(dis[i]==-1)
		{
			if(!da[i]&&f[A][i][u])da[i]=dis[u]+1;
			if(!db[i]&&f[B][i][u])db[i]=dis[u]+1;
			if(!dc[i]&&f[C][i][u])dc[i]=dis[u]+1;
			if(da[i]&&db[i]&&dc[i])
				dis[i]=max(da[i],max(db[i],dc[i])),q.push(i);
		}
	}
}

int main()
{
//	freopen("test.in","r",stdin);
	int i,j,k;
	scanf("%d%d%d%d%d",&n,&m,&A,&B,&C);
	while(m--)
	{
		scanf("%d%d",&i,&j);
		add(i,j);
	}
	getf();
	bfs();
	if(dis[1]==-1)puts("IMPOSSIBLE");
	else printf("%d\n",dis[1]);
	
	return 0;
}
### Prompt

Please create a solution in Cpp to the following problem:

Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE

### Response

```cpp
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 55
#define M 2500
#define P 100
#define inf 0x3f3f3f3f
using namespace std;
struct Ahri
{
	int v,n;
}e[M];
int head[N],cnt;
inline void add(int u,int v)
{
	e[++cnt].v=v;
	e[cnt].n=head[u];
	head[u]=cnt;
}
bool f[P+5][N][N];
int dis[N],n,m,A,B,C;
int da[N],db[N],dc[N];
void getf()
{
	int i,j,k,l;
	for(i=1;i<=n;i++)f[0][i][i]=1;
	for(k=1;k<=P;k++)
		for(j=1;j<=n;j++)
			for(i=head[j];i;i=e[i].n)
				for(l=1;l<=n;l++)
					f[k][l][e[i].v]|=(f[k-1][l][j]);
}
queue<int>q;
void bfs()
{
	while(!q.empty())q.pop();
	memset(dis,-1,sizeof dis);
	memset(da,0,sizeof da);
	memset(db,0,sizeof db);
	memset(dc,0,sizeof dc);
	
	int i,u;
	q.push(n),dis[n]=0;
	
	while(!q.empty())
	{
		u=q.front(),q.pop();

		for(i=1;i<=n;i++)if(dis[i]==-1)
		{
			if(!da[i]&&f[A][i][u])da[i]=dis[u]+1;
			if(!db[i]&&f[B][i][u])db[i]=dis[u]+1;
			if(!dc[i]&&f[C][i][u])dc[i]=dis[u]+1;
			if(da[i]&&db[i]&&dc[i])
				dis[i]=max(da[i],max(db[i],dc[i])),q.push(i);
		}
	}
}

int main()
{
//	freopen("test.in","r",stdin);
	int i,j,k;
	scanf("%d%d%d%d%d",&n,&m,&A,&B,&C);
	while(m--)
	{
		scanf("%d%d",&i,&j);
		add(i,j);
	}
	getf();
	bfs();
	if(dis[1]==-1)puts("IMPOSSIBLE");
	else printf("%d\n",dis[1]);
	
	return 0;
}
```