#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

int bh[102];
int use_bh[102];
int sub_bh[102];
int wsub_bh[102];

int all_bh_used()
{
    int i=0;
    for(i=0;i<101;i++)
    {
        if(bh[i] > 0)return 0;
    }
    return 1;
}

vector <vector <int> > match2(int height, int position, vector <vector <int> >  vl)
{   
    
    if(bh[height+1] > 0)
    {
        vl[position-1].push_back(height+1);
    }
    if(bh[height] > 0)
    {
        vl[position-1].push_back(height);
    }
    
	return vl;
}

int find(int depth, int ph, int p)
{
    int i;
    if(use_bh[p] > 1)
    {
        for(i=depth;i<=ph+1;i++)
        {
            if(bh[i] > 0)
            {            
                bh[i] -= 1;
                //cout<<"bh["<<i<<"]="<<bh[i]<<endl;
                sub_bh[i] += 1;
                return 1;            
            }
        }
    }
    else
    {
        if(bh[p] > 0)
        {
            bh[p] -= 1;
            sub_bh[p] += 1;
            return 1;
        }
    }
    return 0;
}

class CrossingTheRiver{
	public:
	CrossingTheRiver(){}
	~CrossingTheRiver(){}
	string isItEvenPossible(int waterWidth, int landWidth, vector<int>  blockHeight, int depth);
};

string CrossingTheRiver::isItEvenPossible(int waterWidth, int landWidth, vector<int>  blockHeight, int depth)
{
	string st;
	vector<vector <int> > vl;
	
	int i=0, s, skip=0;
	int position = 1, ph=0, f=0, land_sum=0, old_ph=0, end_ph=0, f1=0, f2=0;
	int len_block = blockHeight.size();
	
	for (int i = 0; i < waterWidth + landWidth; i++) {
    	vector<int> row; 
    	vl.push_back(row); 
	}
    
    //ini bh
    for(i=0; i<102; i++)
    {
        bh[i] = 0;
        use_bh[i] = 0;
    }
    
    for(i=0;i<len_block;i++)
    {
        bh[blockHeight[i]] += 1;
    }
    
	while(position <= waterWidth + landWidth && 0 == f)
	{
		skip = 0;
        
        if(1 == all_bh_used())
        {
            f = 1;
            break;
        }
        
        
		if(position <= waterWidth)
		{
			ph += depth;
			vl = match2(ph, position, vl);
			if(vl[position-1].size() > 0)
			{
                ph = vl[position-1].back() - depth;
                bh[vl[position-1].back()] -= 1;
                use_bh[vl[position-1].back()] += 1;
                ++position;
			}
			else//vl[position-1].size() == 0
			{
				if(position > 1)
				{
					--position;
                    s = vl[position-1].size();
                    bh[vl[position-1][s-1]] += 1;
                    use_bh[vl[position-1][s-1]] -= 1;
                    vl[position-1].resize(s-1);
					if(s>1)
					{
                        bh[vl[position-1].back()] -= 1;
                        use_bh[vl[position-1].back()] += 1;
						ph = vl[position-1].back() - depth; 
						skip = 1;
                        ++position;
					}
                    
					while(vl[position-1].size() == 0 && 0 == skip)
					{
                        if(position > 1)
						{
							--position;
                            s = vl[position-1].size();
							bh[vl[position-1][s-1]] += 1;
                            use_bh[vl[position-1][s-1]] -= 1;
							vl[position-1].resize(s-1);
							if(s>1)
							{
								bh[vl[position-1].back()] -= 1;
                                use_bh[vl[position-1].back()] += 1;
								ph = vl[position-1].back() - depth; 
								++position;
								break;
							}
						}
						else
						{
							if(vl[position-1].size() > 0)
							{
                                s = vl[position-1].size();
                                bh[vl[position-1][s-1]] += 1;
                                use_bh[vl[position-1][s-1]] -= 1;
                                vl[position-1].resize(s-1);
                                if(s>1)
                                {
                                    bh[vl[position-1].back()] -= 1;
                                    use_bh[vl[position-1].back()] += 1;
                                    ph = vl[position-1].back() - depth; 
                                    ++position;
                                    break;
                                }
							}
							else
							{
								f = 1;
								break;
							}
						}
					}
				}
				else//position == 1
				{
					if(vl[position-1].size() > 1)
					{
						s = vl[position-1].size();
						bh[vl[position-1][s-1]] += 1;
                        use_bh[vl[position-1][s-1]] -= 1;
						vl[position-1].resize(s-1);
                        if(s>1)
						{
							bh[vl[position-1].back()] -= 1;
                            if(bh[vl[position-1].back()] < 0)cout<<"bh8["<<position<<"]="<<bh[vl[position-1].back()]<<endl;
                            use_bh[vl[position-1].back()] += 1;
							ph = vl[position-1].back() - depth; 
							++position;
						}
					}
					else
					{
						f = 1;
						break;
					}
				}
			}	
		}
		else//position > waterWidth 
		{	
            old_ph = ph;
            land_sum = position - waterWidth - 1;
            f1 = 0;
            f2 = 0;
            while(land_sum < landWidth)
            {
                if(0 == bh[ph] && 0 == bh[ph+1])
                {
                    if(use_bh[ph] > 0 && 0 == f1)
                    {
                        if(1 == find(depth, ph, ph))
                        {
                            land_sum += 1;
                            use_bh[ph] -= 1;
                            wsub_bh[ph] += 1;
                        }
                        else f1 = 1;
                    }
                    else if(use_bh[ph+1] > 0 && 0 == f2)
                    {
                        if(1 == find(depth, ph, ph+1))
                        {
                            land_sum += 1;
                            use_bh[ph] -= 1;
                            wsub_bh[ph] += 1;
                            ++ph;
                            f1 = 0;
                            f2 = 0;
                        }
                        else f2 = 1;
                    }
                    else
                    {
                        end_ph = ph;
                        break;
                    }
                }
                else
                {
                    if(bh[ph] > 0)
                    {
                        land_sum += bh[ph];
                        sub_bh[ph] = bh[ph];
                        bh[ph] = 0;
                    }
                    if(bh[ph+1] > 0)
                    {
                        land_sum += bh[ph+1];
                        sub_bh[ph+1] = bh[ph+1];
                        bh[ph+1] = 0;
                        ++ph;
                    }
                }
            }
            
            for(i=depth;i<=end_ph;i++)
            {
                if(sub_bh[i] > 0)
                {
                    bh[i] += sub_bh[i];
                    sub_bh[i] = 0;
                }
                if(wsub_bh[i] > 0)
                {
                    use_bh[i] += wsub_bh[i];
                    wsub_bh[i] = 0;
                }
            }
            
            if(land_sum >= landWidth)
            {
                position = waterWidth + landWidth + 1;
                break;
            }
			else//vl[position-1].size() = 0
            {
               
				if(position > 1)
				{
					--position;
                    
					s = vl[position-1].size();
					bh[vl[position-1][s-1]] += 1;
                    use_bh[vl[position-1][s-1]] -= 1;
					vl[position-1].resize(s-1);
					
					if(s>1)
					{
						bh[vl[position-1].back()] -= 1;
                        use_bh[vl[position-1].back()] += 1;
						if(position > waterWidth)
						{
							ph = vl[position-1].back();	
						}
						else
						{
							ph = vl[position-1].back() - depth;
						}
						++position;
						skip = 1;
					}
					while(vl[position-1].size() == 0 && 0==skip)
					{
						if(position > 1)
						{
							--position;
                            
                            s = vl[position-1].size();
                            bh[vl[position-1][s-1]] += 1;
                            use_bh[vl[position-1][s-1]] -= 1;
                            vl[position-1].resize(s-1);
                            if(s>1)
							{
								bh[vl[position-1].back()] -= 1;
                                use_bh[vl[position-1].back()] += 1;
                                if(position > waterWidth)
								{
									ph = vl[position-1].back();	
								}
								else
								{
									ph = vl[position-1].back() - depth;
								}
								++position;
								break;
							}
						}
						else//while, position==1
						{
							if(vl[position-1].size() > 1)
							{

                                s = vl[position-1].size();
								bh[vl[position-1][s-1]] += 1;
                                use_bh[vl[position-1][s-1]] -= 1;
								vl[position-1].resize(s-1);
								if(s>1)
								{
									bh[vl[position-1].back()] -= 1;
                                    use_bh[vl[position-1].back()] += 1;
									if(position > waterWidth)
									{
										ph = vl[position-1].back();	
									}
									else
									{
										ph = vl[position-1].back() - depth;
									}
									++position;
									break;
								}
							}
							else
							{
								f = 1;
								break;
							}
						}
					}
				}
				else//if position == 1
				{
					if(vl[position-1].size() > 1)
					{
                        s = vl[position-1].size();
                        bh[vl[position-1][s-1]] += 1;
                        use_bh[vl[position-1][s-1]] -= 1;
                        vl[position-1].resize(s-1);

                        if(s>1)
						{
							bh[vl[position-1].back()] -= 1;
                            use_bh[vl[position-1].back()] += 1;
							if(position > waterWidth)
							{
								ph = vl[position-1].back();	
							}
							else
							{
								ph = vl[position-1].back() - depth;
							}
							++position;
						}
					}
					else
					{
						f = 1;
						break;
					}
				}
			}
		}
	}
	if(0 == f)
    {
        st = "POSSIBLE";
    }
	else {
		if (0 == ph)st = "POSSIBLE";
		else
		{
			st = "IMPOSSIBLE";	
		}
	}
	
	return st;
}


int main()
{
    CrossingTheRiver cr;
    /*
    int myints[] = {
        5, 9, 41, 7, 5, 7, 8, 3, 6, 16, 16, 81, 6, 6, 17, 5, 15, 5, 13, 5, 63, 10, 14, 5, 12, 69, 5, 6, 7, 9, 64, 14, 11, 4, 7, 3, 14, 7, 13, 96, 4, 92, 33, 97, 45, 4, 55, 7, 16, 7
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(13, 26, b, 2);
    */
    //Possible
    /*
    int myints[] = {
        3,4,4,5,5, 6
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(3, 3, b, 2);
    *///Possible
    /*
    int myints[] = {
        3,4,4,5,6, 6
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(3, 3, b, 2);
    */
    //impossible
    /*
    int myints[] = {
        2, 2, 60, 2, 5, 5, 2, 14, 89, 4, 11, 49, 83, 31, 61, 21, 62, 5, 3, 2, 6, 18, 2, 47, 5
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(11, 2, b, 2);
    *///Possible
    /*
    int myints[] = {
        19, 21, 13, 23, 17, 25, 22, 29, 14, 18, 29, 19, 20, 14, 25, 19, 27, 14, 21, 28, 15, 25, 17, 26, 25, 13, 20, 29, 13, 20, 16, 22, 20, 24, 16, 24, 13, 19, 24, 24, 14, 18, 16, 22, 21
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(35, 10, b, 13);
    */
    //Possible
    /*
    int myints[] = {
        2, 3, 4, 5
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(3, 1, b, 2);
    *///imposible
    
    int myints[] = {
        14, 22, 13, 26, 28, 20, 24, 19, 13, 23, 21, 16, 27, 25, 14, 18, 27, 28, 20, 22, 16, 12, 29, 15, 12, 17, 21, 23, 13, 14, 18, 21, 18, 19, 17, 28
        };
    vector <int> b(myints, myints + sizeof(myints) / sizeof(int));
    cout<<cr.isItEvenPossible(33, 4, b, 11);
    
    //imposible
    //getchar();
    return 0;
}