/*
date 2018-__-__
time:from:  to:
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050226;
/*------------main part------------*/
char s[4][30],p;
struct team
{
	int goal,score,num,win;
	team()
	{
		goal=score=num=win=0;
	}
	char name[30];
};
team t[4];
int game[4];
char s1[30],s2[30];
bool flag;
int t1,t2,p1,p2;
bool cmp(team a,team b)
{
	if(a.score==b.score)
	{
		if(a.win==b.win)
		{
			if(a.goal==b.goal)
			{
				return (strcmp(a.name,b.name) < 0);
			}
			return a.goal>b.goal;
		}
		return a.win>b.win;
	}
	return a.score>b.score;
}
bool cmp1(team a,team b)
{
	return a.num < b.num;
}
int getl(char *str)
{
	for(int i = 0;i<p;i++)
		if(!strcmp(t[i].name,str))
			return i;
	strcpy(t[p++].name,str);
	t[p-1].num=p-1;
	return p-1;
}
int main()
{
	for(int i = 0;i<5;i++)
	{
		cin>>s1>>s2;
		flag=0;
		cin>>t1;
		cin.get();
		cin>>t2;
		p1=getl(s1);p2=getl(s2);
		t[p1].goal+=t1;t[p2].goal+=t2;
		if(t1>t2)
			t[p1].score+=3;
		else if(t1==t2)
		{
			t[p1].score++;
			t[p2].score++;
		}
		else
			t[p2].score += 3;
		t[p1].win += t1 - t2;
		t[p2].win += t2 - t1;
		game[p1]++;
		game[p2]++;
	}
	/*
	for(int i = 0;i<4;i++){
		cout<<t[i].score<<' '<<t[i].win<<' '<<t[i].name<<endl;
	}*/
	char Me[]="BERLAND";
	int me=getl(Me);
	int he;
	for(int i=0;i<4;i++)
		if(game[i] != 3 and i != me)
			he =i;
	int w1=t[me].win,w2=t[he].win,g1=t[me].goal,g2=t[he].goal;
	t[me].score += 3;
	for(int i1 = 1;i1<=20;i1++)
	{
		for(int j1 = 0;j1<20;j1++)
		{
			int i = i1 + j1;
			int j = j1;
			sort(t,t+4,cmp1);
			t[me].goal = g1 + i;
			t[he].goal = g2 + j;
			t[me].win = w1 + i - j;
			t[he].win = w2 + j - i;
			sort(t,t+4,cmp);
			int tmp;
			for(int k=0;k<4;k++)
			{
				if(t[k].num == me)
					tmp=k;
			}
			if(tmp<=1)
			{
				cout<<i<<':'<<j<<endl;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

/// In The Name Of God

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(n);(i)++)
typedef long long ll;

struct team{
    string name;
    int score,goal1,goal2,games;
    int x,y;
    bool operator <(team &p){
        if(p.score!=score)
            return score>p.score;
        if(p.goal1-p.goal2!=goal1-goal2)
            return (goal1-goal2)>(p.goal1-p.goal2);
        if(p.goal1!=goal1)
            return goal1>p.goal1;
        return name<p.name;
    }
};

bool cmp(team q,team p){
    if(p.score!=q.score)
        return q.score>p.score;
    if((p.goal1-p.goal2+p.x-p.y)!=(q.goal1-q.goal2+q.x-q.y))
        return (q.goal1-q.goal2+q.x-q.y)>(p.goal1-p.goal2+p.x-p.y);
    if((p.goal1+p.x)!=(q.goal1+q.x))
        return (q.goal1+q.x)>(p.goal1+p.x);
    return q.name<p.name;
}

team ans[4];
string t1[5],t2[5];
int d1[5],d2[5];
int index[2][5];

map<string,int> mp;

int main(){
    int i,r=1,j,r1,r2;
    ios::sync_with_stdio(false);
    int n,t,tsc;
    REP(i,4){
        ans[i].goal1=0;
        ans[i].goal2=0;
        ans[i].score=0;
        ans[i].games=0;
    }
    REP(i,5){
        cin>>t1[i]>>t2[i];
        scanf("%d:%d",d1+i,d2+i);
        if(mp[t1[i]]==0)
            mp[t1[i]]=r++;
        if(mp[t2[i]]==0)
            mp[t2[i]]=r++;
    }
    REP(i,5){
        index[0][i]=mp[t1[i]]-1;
        index[1][i]=mp[t2[i]]-1;
    }
    REP(i,5){
        ans[index[0][i]].name = t1[i];
        ans[index[0][i]].goal1 +=d1[i];
        ans[index[0][i]].goal2 +=d2[i];
        ans[index[0][i]].games++;

        ans[index[1][i]].name = t2[i];
        ans[index[1][i]].goal1 +=d2[i];
        ans[index[1][i]].goal2 +=d1[i];
        ans[index[1][i]].games++;

        if(d1[i]!=d2[i]){
            if(d1[i]>d2[i]){
                ans[index[0][i]].score += 3;
            }else{
                ans[index[1][i]].score += 3;
            }
        }else{
            ans[index[0][i]].score += 1;
            ans[index[1][i]].score += 1;
        }
    }
    sort(ans,ans+4);
    REP(i,4){
        if(ans[i].name=="BERLAND")
            break;
    }
    if(i<2){
        printf("1:0\n");
        return 0;
    }
    if(ans[i].score+3<ans[1].score){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    REP(j,4){
        if(ans[j].games==2 && ans[j].name!="BERLAND")
            break;
    }
    string ber,ner;
    ber=ans[i].name;
    ner = ans[j].name;
    int x=3000,y=2000,e;
    ans[i].score+=3;
    for(r1=1;r1<100;r1++){//x
        for(r2=0;r2<r1;r2++){//y
            REP(e,4){
                if(ans[e].name==ber){
                    ans[e].x=r1;
                    ans[e].y=r2;
                }
                if(ans[e].name==ner){
                    ans[e].x=r2;
                    ans[e].y=r1;
                }
            }
            sort(ans,ans+4,cmp);
            if(ans[0].name==ber || ans[1].name==ber){
                if((x-y)>(r1-r2)){
                    x=r1;
                    y=r2;
                }
                if((x-y)==(r1-r2) && y>r2){
                    x=r1;
                    y=r2;
                }
            }
        }
    }
    printf("%d:%d\n",x,y);
    return 0;
}

/*
	���������������������������������������x�����x
���������������������������������������ܣܣ���
�������������������������������������������ܣ�
����������������������������������������������
���������������񡡨������������� ������ ��
��������������������������������������������
���������������������ޡ���������������������
�����������������������ܨ�����������������
��������������������������������������������
��������������������������������������
������������������������������������
��������������������������������������
�������������� ��������

*/
/*
����������������
���������������������
�������������������������
��������� . �ܡ����������
����������ȡ����������
���������������������
��������������������
�����������������������
�����������������������
���������������������������
���������������������
���������������������
������������������������
������������������������

	�� ��������������������������������������
���������������������������������������� ����
��������������������������������������������...
��������������������������������������������
��������������������������������������������.
��������������������������������������
�����������������񡡡������������� ��
�������������������������{������������
�����������������������^�m�a����������
�������������������|�z�z���z�z�|����
����������������������������������
����������������������������������
����������������������������������
�����������������z�����|�|�|�����z����

	�ةЩةУ����ܣߣ�����
�ЩةЩب�����������������
�ةЩأ��ܡ�����������������
�ЩبM������������������������
�ةШ������������������񡡡���
�Щب�����������������������������
�ب������������������ܣߣߣߣ�
�Ш�������������������������������
�ب���������������������������
�������������������������������}�{
������������������������������������
������������������������������������ ��
�ب����������������������������������� ��
�Щ���������������������������������������
�ة���������������������������������������
�� �M������ �M�����������������ܡ������� �M
��/�ߣߣߣ����������M��������������������
�ЩةЩةЩأ� ���� �� ������������������ ��
�ةЩةЩةЩ� �ܣߣߣߣܡ������� �������ܩ� ����
������W�i�i�i�i�i�i�i�i�ܡ��� �M�� ������������
�������d�p�p�p�p�p�p�p�p������������������

�q-�r���q-�r�q---�r�q-�r�������q-�r�������q---�r�q�r
�����������������q--�s���������������������������q-�r������
�����t-�s�������t-�r����������������������������������������
�����q-�r�������q-�s�������t--�r�����t--�r��������������
�����������������t--�r���������������������������t-�s���t�s
�t-�s���t-�s�t---�s�t----�s�t----�s�t---�s ��
����������������������������������������������
�j�T�T�j�X�T�r�T�m�T�r�T�j�T���U�T�T�p�T�r�X���X�m�r�X��
�d�T�T�g�U���U�t�T�a�U�U�U�����U�����U���U�t�T�U���U�t�T
�d�T�T�g�U���U�t�T�a�a�U�U�U�U�U�����U���U�X���d�T�g�X��
�m�T�T�p�t�T�a�X�T�r�U�U�d�s�t�p�T�T�p�T�m�t�T�t�T�a�t�T
�T�T�T�j�T�T�s�U���U�U�U�U�����U���X�a�r���T�T�T�p�T�T�T
���T�T�p�T�T���U���U�U�m�m�T���U���U���U�����U���U�� �U��
�T�T�T�m�T�T�T�t�T�a�p�T�T�T���U�t�a���t�a�t�a���U ���^�s
������������������������������������������������������������
�ЩةЩ�-����-��-������-��-�������-�ȡ�
�ةЩة��С���-��-�����򡡩��������𩸩Щ���
-��-��������������������-��-�ء�--��--
�񩦡𩦩�����-��-�������𡡡��񡡣���������

�q�T�T�T�T�T�T�r
�U��� �� �ܡ� �U����������
�U�������t�e���������
�U������ ����� ��
�U�������q�e �������
�U����� ��/ �U���������
�t�T�T�T�T�T�T�s ���������
~����ߡ�*��~���*��~�
��*��~����ߡ�*��~�����
��������������������������������������
�����������v
��������������
���������������������v
���������v��������������
�������������Ϩ���������
�����������v�����v?����
���v�ߨ����������v
�������������������v������������
���������v�ߨ��������v����������
�����������������������v������
�������������������������v��
���������������������������v
�����������������������������v
�������������������������������v
������������������������������������������������������
��㡤��㣮��?���㡤�㣮��?���㡤
��?���㡤��㣮��?���㡤�㣮��?��
����?���㡤��㣮��?������?
__������ __������������?���㡤��
�����n���㡤���n���n���㣮��?��
���������������������������㣮��
�਀�n�������n�����n���n��?���
������������������������������

..�ࡣo����+��?''o?''o�s��o����+��?''o?''o��
�X--�[�X�T-�Y�X-�[�q-�T�r�X�T-�[�����V�[
���V-�_��V�[��^-�_���W�T�s��X�Y��X-�a��
��^-�[����\�`�X-�[��^-�[������
��X-�_�����������q�T�_�������
�\�_�����\�_�����^-�_�\�t�T�s�\�_�\�`�^-�T�_
�ࡣo����+��?''o?''o�s��o����+��?''o?''o��
������������������������������������������������������������
�X�T�T�[�X�[���������������X�[�X�[
�^�[�X�a�U�U�X�T�j�j�j�T�[�U�^�a�d�T�j�j�[
�X�a�^�[�U�^�g�U�U�U�U�d�g�^�[�X�g�U�U�U�U
�^�T�T�a�^�T�m�T�m�T�m�T�a���^�a�^�T�m�T�a

	����������������������������������������������
����������������������������������������������
����������������������������������������������
�������������������������������������������� ��
����������������������������������������������

��������������������������������������������������������
��M ���� �� ���񡡡����� �� ����M ����M
<�� �� ��> ���������� �� �� ���
�� �� �� �� �� �M�������M�� ��������������
������������������������������������������������
 �q�r���������������q�r����
����������������������������
�q�ة�-------�ةبr
��������������������������������
��������������������������������
�����񡡡������������񡡩�
���𡡡��t�ЩЩШs������
�����������t-�s������������
�t--�У�---�ϩ�--�s
�� ���q�r���������q�r��������
�� ���t��----�بs
��������������������������������������������
����..���������������������������ܡ�����
������������������������ܡ���
������ܣߣߣߣߣߣߣߣߣߣ�����
��..�������������������������������ܡ�
��..�ܣ��ܣ��ܣ��ܣ��ܣ��ܣ��ܣ��ܣ�����
��������񡡡��������񡡡����
��������"����������"�������
���񡡣���������������������
���������������������������
�������t�����������������������s
��������������������������
�����������񡡡�������������
��������������������������������������������������������

�������������������
�������������������
�������������������
���������������������
�������������������������
���������������������������
�����������������������������
���������񡡡������񡡡��������
���������������𡡡������������
�������򡡡����������򡡡������
���������������񡡡������������
�����������������������������
���������������������������
�������������������

*/

/*
			  ********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###                 ###           ###           ###
                ...........               #...#               #...#         #...#         #...#
               ##*#######                 #.#.#               #.#.#         #.#.#         #.#.#
            ####*******######             #.#.#               #.#.#         #.#.#         #.#.#
           ...#***.****.*###....          #...#               #...#         #...#         #...#
           ....**********##.....           ###                 ###           ###           ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################              ##################################
#...#......#.##...#......#.##...#......#.##------------------#              #...#......#.##------------------#
###########################################------------------#              ###############------------------#
#..#....#....##..#....#....##..#....#....#####################              #..#....#....#####################
##########################################    #----------#                  ##############    #----------#
#.....#......##.....#......##.....#......#    #----------#                  #.....#......#    #----------#
##########################################    #----------#                  ##############    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#                  #.#..#....#..#    #----------#
##########################################    ############                  ##############    ############
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
using namespace std;
struct team{
   string name;
   int points,Rg,Lg;
};

bool cmp(team x, team y){
   if(x.points>y.points) return true;
   if(y.points>x.points) return false;
   if(x.Rg-x.Lg>y.Rg-y.Lg) return true;
   if(y.Rg-y.Lg>x.Rg-x.Lg) return false;
   if(x.Rg>y.Rg) return true;
   if(y.Rg>x.Rg) return false;
   if(x.name<y.name) return true;
   return false;
}

int score1,score2,i,j;
string name1,name2;
map<string,int> points,Rgoals,Lgoals,num;
char c;
team tab[5];

int main(){
    for(i=0; i<5; ++i){
       cin >> name1 >> name2 >> score1 >> c >> score2;
       Rgoals[name1]+=score1;
       Rgoals[name2]+=score2;
       Lgoals[name1]+=score2;
       Lgoals[name2]+=score1;
       num[name1]++;
       num[name2]++;
       if(score1>score2) points[name1]+=3;
       else
           if(score2>score1) points[name2]+=3;
           else{
                points[name1]+=1;
                points[name2]+=1;
           }
//       cout << name1 << " " << score1 << " " << name2 << " " << score2;
    }

    points["BERLAND"]+=3;

    map<string,int>::iterator it;
    it=points.begin();
    int wsk=0;
    string d;

    while(it!=points.end()){
		if(num[(*it).first]==2 && (*it).first!="BERLAND") d=(*it).first;
		tab[wsk].name=(*it).first;
		tab[wsk].points=points[(*it).first];
		tab[wsk].Rg=Rgoals[(*it).first];
		tab[wsk].Lg=Lgoals[(*it).first];
		++wsk;
		++it;
    }

    int wsk2;

    for(i=1; i<50; ++i)
       for(j=0; j<50; ++j){
          for(int k=0; k<4; ++k){
             if(tab[k].name=="BERLAND") wsk=k;
             if(tab[k].name==d) wsk2=k;
          }
          tab[wsk].Rg+=i+j;
          tab[wsk].Lg+=j;
          tab[wsk2].Rg+=j;
          tab[wsk2].Lg+=i+j;
          sort(tab,tab+4,cmp);
          if(tab[0].name=="BERLAND" || tab[1].name=="BERLAND"){
             cout << i+j << ":" << j << endl;
             return 0;
          }

          for(int k=0; k<4; ++k){
//                  cout << tab[k].name << " " << tab[k].points << " " << tab[k].Rg << " " << tab[k].Lg << endl;
             if(tab[k].name=="BERLAND") wsk=k;
             if(tab[k].name==d) wsk2=k;
          }

          tab[wsk].Rg-=(i+j);
          tab[wsk].Lg-=j;
          tab[wsk2].Rg-=j;
          tab[wsk2].Lg-=(i+j);
       }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;

#define FOR(i,x,y) for(LL i=x; i<=y; i++)
#define REP(i,n) for(LL i=0; i<n; i++)

#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
#define SZ(c) (int)(c).size()

#define pb push_back
#define mp make_pair
#define X first
#define Y second

const double eps = 1.0e-11;
const double pi = acos(-1.0);

struct team {
    int good, fail, points, games;
    string name;
    team() : good(0), fail(0), points(0), games(0) {}
};

bool operator < (const team& t1, const team& t2) {
    if (t1.points != t2.points)
        return t1.points > t2.points;
    if (t1.good - t1.fail != t2.good - t2.fail)
        return t1.good - t1.fail > t2.good - t2.fail;
    if (t1.good != t2.good)
        return t1.good > t2.good;
    return t1.name < t2.name;
}

map <string, team> table;

pair<int, int> best(100, 10);
string oponent;
const string B = "BERLAND";

void Up(int g, int f) {
    map <string, team> table1 = table;
    if (g <= f)
        return;
    table1[B].fail += f, table1[B].good += g;
    table1[oponent].fail += g, table1[oponent].good += f;
    string n1 = B, n2 = oponent;
    int g1 = g, g2 = f;
    if (g1 > g2)
        table1[n1].points += 3;
    if (g1 < g2)
        table1[n2].points += 3;
    if (g1 == g2)
        table1[n1].points += 1, table1[n2].points += 1;
    vector<team> tt;
    for (map<string, team>::iterator it = table1.begin(); it != table1.end(); ++it)
        tt.push_back(it->second);
    SORT(tt);
    if (tt[0].name == B || tt[1].name == B) {
        if (best.first - best.second > g - f)
            best = mp(g, f);
        if (best.first - best.second == g - f && best.second > f)
            best = mp(g, f);
    }
}

int main() {
    REP(i, 5) {
        string n1, n2, score;
        int g1, g2;
        cin >> n1 >> n2 >> score;
        g1 = score[0] - '0';
        g2 = score[2] - '0';
        table[n1].good += g1, table[n1].fail += g2, table[n1].name = n1, table[n1].games++;
        table[n2].good += g2, table[n2].fail += g1, table[n2].name = n2, table[n2].games++;
        if (g1 > g2)
            table[n1].points += 3;
        if (g1 < g2)
            table[n2].points += 3;
        if (g1 == g2)
            table[n1].points += 1, table[n2].points += 1;
    }
    for (map<string, team>::iterator it = table.begin(); it != table.end(); ++it)
        if (it->first != B && it->second.games == 2)
            oponent = it->second.name;

    REP(i, 100)
        REP(j, 100)
            Up(i, j);
    if (best == mp(100, 10)) {
        cout << "IMPOSSIBLE\n";
        return 0;
    }

    cout << best.first << ":" << best.second << endl;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
struct A
{
    string name;
    int score;
    int point;
    int miss;
    int time;
    friend bool operator < (const A &a,const A &b)
    {
        if(a.score!=b.score)
            return a.score>b.score;
        if((a.point-a.miss)!=(b.point-b.miss))
            return a.point-a.miss>b.point-b.miss;
        if(a.point!=b.point)
            return a.point>b.point;
        //return a.name<b.name;
        return strcmp(a.name.data(),b.name.data())<0;
    }
} dui[6],temp[6];
int n;
int addteam(string team)
{
    for(int i=0; i<n; i++)
        if(dui[i].name==team)
            return -1;
    dui[n].name=team;
    dui[n].score=dui[n].miss=dui[n].time=dui[n].point=0;
    n++;
    return n-1;
}
int find1(string a)
{
    for(int i=0; i<n; i++)
        if(dui[i].name==a)
            return i;
}
int main()
{
    //freopen("in.txt","r",stdin);
    string team1,team2;
    int score1,score2,t1,t2;
    char x;
    n=0;
    for(int i=0; i<5; i++)
    {
        cin>>team1>>team2>>score1>>x>>score2;
        addteam(team1);
        addteam(team2);
        t1=find1(team1);
        t2=find1(team2);
        if(score1>score2)
            dui[t1].score+=3;
        else if(score1<score2)
            dui[t2].score+=3;
        else
        {
            dui[t1].score++;
            dui[t2].score++;
        }
        dui[t1].miss+=score2;
        dui[t2].miss+=score1;
        dui[t1].point+=score1;
        dui[t2].point+=score2;
        dui[t1].time++;
        dui[t2].time++;
    }
    bool flag=true;
    sort(dui,dui+n);
    string tempname("BERLAND");
    t1=find1(tempname);
    int m;
    if((dui[t1].score+3<dui[1].score)&&(dui[t1].score+3<dui[0].score))
    {
        flag=false;
        cout<<"IMPOSSIBLE"<<endl;
    }
    if(flag)
    {
        flag=false;
        for(int i=0; i<n; i++)
            if(i!=t1)
                if(dui[i].time<3)
                {
                    m=i;
                    break;
                }
        int min1=100000;
        for(int i=0; i<=100; i++)
        {
            for(int j=i+1; j<=100; j++)
            {
                for(int k=0; k<n; k++)
                    temp[k]=dui[k];
                temp[m].miss+=j;
                temp[t1].miss+=i;
                temp[m].point+=i;
                temp[t1].point+=j;
                if(i==j)
                {
                    temp[m].score++;
                    temp[t1].score++;
                }
                else if(i<j)
                    temp[t1].score+=3;
                sort(temp,temp+n);
                int tp;
                for(int l=0; l<n; l++)
                    if(temp[l].name==tempname)
                    {
                        tp=l;
                        break;
                    }
                if(tp<2)
                    if(j-i<min1)
                    {
                        score1=j;
                        score2=i;
                        min1=j-i;
                        flag=true;
                    }
            }
        }
        if(flag)
            printf("%d:%d\n",score1,score2);
        else
            cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

#include <iostream>
#define FOR(i,a)    for(int i = 0 ;i<a;i++)
#define REP(i,a,b)  for(int i = a;i<b;i++)
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

void solve();

struct a1{
    int x;
    int y;
    int score;
    string s;
    int nom;
};

int main()
{
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    solve();
    return 0;
}

bool  cmp(a1 a,a1 b)
{
    if(a.score > b.score)   return true;
    else if(a.score < b.score)  return false;
    else if(a.x - a.y > b.x - b.y)
        return true;
    else if(a.x - a.y < b.x - b.y)
        return false;
    else if(a.x > b.x)    return true;
    else if(a.x < b.x)  return false;
    else if (a.s < b.s) return true;
    else return false;
    //return true;
}

void solve()
{
    int k = 0;
    a1 a[4];
    FOR(i,5)
    {
        string s1,s2,s3;
        cin>>s1>>s2>>s3;
        int x1,x2;
        x1 = s3[0] - '0';
        x2 = s3[2] - '0';
        bool flag = true;
        FOR(j,k)
        {
            if(s1 == a[j].s)
            {
                a[j].x += x1;
                a[j].y += x2;
                flag = false;
                a[j].nom++;
                if(x1 > x2)   a[j].score += 3;
                else if(x1 == x2) a[j].score += 1;
            }
        }
        if(flag)
        {
            flag = true;
            k++;
            a[k-1].s = s1;
            a[k-1].x = x1;
            a[k-1].y = x2;
            a[k-1].nom = 1;
            if(x1 > x2)   a[k-1].score = 3;
            else if(x1 == x2) a[k-1].score = 1;
            else    a[k-1].score = 0;
        }
        flag = true;
        FOR(j,k)
        {
            if(s2 == a[j].s)
            {
                a[j].x += x2;
                a[j].y += x1;
                flag = false;
                a[j].nom++;
                if(x1 < x2)   a[j].score += 3;
                else if(x1 == x2) a[j].score += 1;
            }
        }
        if(flag)
        {
            flag = true;
            k++;
            a[k-1].s = s2;
            a[k-1].x = x2;
            a[k-1].y = x1;
            a[k-1].nom = 1;
            if(x1 < x2)   a[k-1].score = 3;
            else if(x1 == x2) a[k-1].score = 1;
            else    a[k-1].score = 0;
        }
        else    flag = true;
    }
    string s1,s2;
    s1 = "BERLAND";
    FOR(i,4)    if(a[i].s == "BERLAND") a[i].score += 3;
    FOR(i,4)    if(a[i].nom == 2 && a[i].s != "BERLAND")  s2 = a[i].s;
    int k1 = 1;
    while(k1<100)
    {
        FOR(i,100)
        {
            FOR(j,4)    if(a[j].s == s1) a[j].x += i+k1,a[j].y += i;
            FOR(j,4)    if(a[j].s == s2) a[j].y += i+k1,a[j].x += i;
            sort(a,a+4,cmp);
            if(a[0].s == "BERLAND") {
                cout<<i+k1<<":"<<i<<"\n";
                return;
            }
            else if(a[1].s == "BERLAND")
            {
                cout<<i+k1<<":"<<i<<"\n";
                return;
            }
            else
            {
                FOR(j,4)    if(a[j].s == s1) a[j].x -= (i+k1),a[j].y -= i;
                FOR(j,4)    if(a[j].s == s2) a[j].y -= (i+k1),a[j].x -= i;
            }
        }
        k1++;
    }
    cout<<"IMPOSSIBLE\n";
}

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

using namespace std;

struct S
{
    string name;
    int point, loss,win,jin,ci;
}s[6];

void input()
{
      string a1,a2;
      int b1,b2;
      int c1,c2;
      char d;
      int k = 0;
      for ( int i = 1; i <= 5; ++i )
      {
             cin >> a1 >> a2;
             cin >> b1 >> d >> b2;
             if ( b1 > b2 ) { c1 = 3; c2 = 0; }
             if ( b1 == b2 ) { c1 = 1; c2 = 1; }
             if ( b1 < b2 ) { c1 = 0; c2 = 3; }
             int j;
             for (  j = 1; j <= k; ++j )
                  if ( s[j].name == a1 ) { break;}
             if ( j > k )
             {
                 ++k;
                 s[k].name = a1;
             }
            s[j].point += c1; s[j].loss += b2; s[j].win += b1;
            s[j].ci += 1;
            for (  j = 1; j <= k; ++j )
                  if ( s[j].name == a2 ) { break;}
             if ( j > k )
             {
                 ++k;
                 s[k].name = a2;
             }
              s[j].point += c2; s[j].loss += b1; s[j].win += b2;
              s[j].ci += 1;
      }
      for ( int i = 1; i <= 4; ++i )
          s[i].jin = s[i].win - s[i].loss;
      return;
}

void chang( int a, int b )
{
     S R;
     R = s[a];
     s[a] = s[b];
     s[b] = R;
     return;
}

int main()
{
      for ( int i = 1; i <= 4; ++i )
      {
          s[i].loss = s[i].point = s[i].win = s[i].jin = 0;
          s[i].name = "";
      }
      input();
      for ( int i = 1; i < 4; ++i )
          for ( int j = i + 1; j <= 4; ++j )
          {
                if ( s[i].point < s[j].point ) chang(i,j);
                if ( s[i].point == s[j].point && s[i].jin < s[j].jin ) chang(i,j);
                if ( s[i].point == s[j].point && s[i].jin == s[j].jin && s[i].win < s[j].win ) chang(i,j);
                if ( s[i].point == s[j].point && s[i].jin == s[j].jin && s[i].win == s[j].win && s[i].name > s[j].name ) chang(i,j);
          }
      int k = 0;/*
      for ( int i = 1; i <= 4; ++i )
          cout << s[i].name << "     " << s[i].point << "  " << s[i].jin << "   " << s[i].win << endl;
*/
      for ( int i = 1; i <= 4; ++i )
           if ( s[i].name == "BERLAND" ) { k = i; break; }
       if ( k <= 2 ) cout << "1:0" << endl;
       else
       {
           if ( s[k].point + 3 < s[2].point ) { cout << "IMPOSSIBLE" << endl; return 0; }
           if ( s[k].point + 3 > s[2].point ) { cout << "1:0" << endl; return 0; }
           int res = 0,res2 = 0;
           int h = 1;
           s[k].point += 3;

           while ( 1 )
           {
              for ( int i = 1; i <= 4; ++i )
                 if( s[i].ci == 2 && s[i].name != "BERLAND" ) {h = i; break;}
              for ( int i = 1; i <= 4; ++i )
                 if ( s[i].name == "BERLAND" ) { k = i; break; }
              if ( k == 2 || k == 1 || ( k == 3 && s[k].jin == s[2].jin) )
              {
                while (1)
                {
                   // cout << "^" << endl;
                        for ( int i = 1; i < 4; ++i )
                            for ( int j = i + 1; j <= 4; ++j )
                            {
                                    if ( s[i].point < s[j].point ) chang(i,j);
                                    if ( s[i].point == s[j].point && s[i].jin < s[j].jin ) chang(i,j);
                                    if ( s[i].point == s[j].point && s[i].jin == s[j].jin && s[i].win < s[j].win ) chang(i,j);
                                    if ( s[i].point == s[j].point && s[i].jin == s[j].jin && s[i].win == s[j].win && s[i].name > s[j].name ) chang(i,j);
                            }
                        for ( int i = 1; i <= 4; ++i )
                                if( s[i].ci == 2 && s[i].name != "BERLAND" ) {h = i; break;}
                        for ( int i = 1; i <= 4; ++i )
                                if ( s[i].name == "BERLAND" ) { k = i; break; }
                       if ( k == 2 || k == 1 ) break;
                       else { ++res; ++res2; }
                       if ( h== 2 )
                       {
                           cout << res  << ":" << res2 -1 << endl;
                           return 0;
                        }
                       s[h].win += 1;
                       s[k].win += 1;
                }
                break;
              }
             else ++res;
             s[k].win += 1;
              s[k].jin += 1;
              s[h].jin -= 1;
             for ( int i = 1; i < 4; ++i )
                 for ( int j = i + 1; j <= 4; ++j )
                 {
                   if ( s[i].point < s[j].point ) chang(i,j);
                   if ( s[i].point == s[j].point && s[i].jin < s[j].jin ) chang(i,j);
                   if ( s[i].point == s[j].point && s[i].jin == s[j].jin && s[i].name > s[j].name ) chang(i,j);
                }
           }
           cout << res << ":" << res2 << endl; return 0;
       }
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct team
{
    int f,d,g,n,num;
    char name[25];
}f[4],r[4];
bool cmp(team c,team d)
{
    if(c.f!=d.f)
        return c.f>d.f;
    else if(c.d!=d.d)
        return c.d>d.d;
    else if(c.g!=d.g)
        return c.g>d.g;
    else
        return strcmp(c.name,d.name)==-1;
}
int main()
{
    char a[25],b[25];
    int i,j,k,c,d,m=5,n1,n2,t,bn,tn,tot=0;
    while(m--)
    {
        scanf("%s%s%d:%d",a,b,&c,&d);
        for(i=0,t=0;i<tot;i++)
            if(strcmp(f[i].name,a)==0)
            {
                n1=i;
                t=1;
            }
            if(!t)
            {
                n1=tot;
                strcpy(f[tot].name,a);
                tot++;
            }
        for(i=0,t=0;i<tot;i++)
            if(strcmp(f[i].name,b)==0)
            {
                n2=i;
                t=1;
            }
            if(!t)
            {
                n2=tot;
                strcpy(f[tot].name,b);
                tot++;
            }
        if(c>d)
            f[n1].f+=3;
        else if(c<d)
            f[n2].f+=3;
        else
        {
            f[n1].f++;
            f[n2].f++;
        }
        f[n1].d+=c-d;
        f[n2].d+=d-c;
        f[n1].g+=c;
        f[n2].g+=d;
        f[n1].num++;
        f[n2].num++;
    }
    for(i=0;i<4;i++)
    {
        f[i].n=i;
        if(strcmp(f[i].name,"BERLAND")==0)
            bn=i;
        else if(f[i].num==2)
            tn=i;
    }
    memcpy(r,f,sizeof(f));
    for(k=1,t=0;k<=100;k++)
    {
        for(i=0;i<=100-k;i++)
        {
            j=i+k;
            f[bn].f+=3;
            f[bn].d+=j-i;
            f[tn].d+=i-j;
            f[bn].g+=j;
            f[tn].g+=i;
            sort(f,f+4,cmp);

            if(strcmp(f[1].name,"BERLAND")==0||strcmp(f[0].name,"BERLAND")==0)
            {
                t=1;
                break;
            }
            memcpy(f,r,sizeof(f));
        }
        if(t)
            break;
    }
    if(t)
        printf("%d:%d\n",j,i);
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

#include <cstdio>
#include <sstream>
#include <iostream>

#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <cstring>

#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPI(i,c) for (typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ALL(c) c.begin(), c.end()
#define SZ(x) ((int)(x).size())

#define MP make_pair
#define FF first
#define SS second

#define DB(x) cout << #x << " = " << x << endl;

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int INF = 1 << 30;
const double EPS = 1e-7;

string other;
map<string, int> C;
map<pair<string, string>, pair<int, int> > M;
map<string, int> P, W, L;

bool cmp(string a, string b)
{
    if (P[a] != P[b])
        return P[a] > P[b];

    if (W[a]-L[a] != W[b]-L[b])
        return W[a]-L[a] > W[b]-L[b];

    if (W[a] != W[b])
        return W[a] > W[b];

    return a < b;
}

void calc(map< pair<string, string>, pair<int, int> > T, int x, int y)
{
    T[ MP("BERLAND", other) ] = MP(x, y);

    P.clear();
    W.clear();
    L.clear();

    REPI(k, T)
    {
        if (k->SS.FF > k->SS.SS)
            P[k->FF.FF] += 3;

        if (k->SS.FF < k->SS.SS)
            P[k->FF.SS] += 3;

        if (k->SS.FF == k->SS.SS)
        {
            ++P[k->FF.FF];
            ++P[k->FF.SS];
        }

        W[k->FF.FF] += k->SS.FF;
        L[k->FF.FF] += k->SS.SS;

        W[k->FF.SS] += k->SS.SS;
        L[k->FF.SS] += k->SS.FF;
    }

    vector<string> R;
    REPI(k, P) R.push_back(k->FF);

    sort(ALL(R), cmp);

    //REPI(k, R) cout << *k << " \t  " << P[*k] << "  " << W[*k] << "   " << L[*k] << "\n";

    if (R[0] == "BERLAND" || R[1] == "BERLAND")
    {
        cout << x << ":" << y << "\n";
        exit(0);
    }
}

int main()
{
    REP(i, 5)
    {
        string n1, n2;
        int g1, g2;
        cin >> n1 >> n2 >> g1; getchar(); cin >> g2;
        M[ MP(n1, n2) ] = MP(g1, g2);
        ++C[n1];
        ++C[n2];
    }

    REPI(k, C)
        if (k->SS == 2 && k->FF != "BERLAND")
            other = k->FF;

    for (int d = 1; d <= 27; ++d)
        for (int y = 0; y <= 27; ++y)
        calc(M, y+d, y);

    cout << "IMPOSSIBLE\n";

    return 0;
}// (++UH)++ :: agarwaen

#include<bits/stdc++.h>
using namespace std;
struct Team{
	int score;
	int lost;
	int get;
	string name;
	operator <(const Team &t2)const{
		if(score!=t2.score)return score>t2.score;
		if(get-lost!=t2.get-t2.lost)return (get-lost)>(t2.get-t2.lost);
		if(get!=t2.get)return get>t2.get;
		return name<t2.name;
	}
};
Team tem[4];
int a,b,cnt;
char x[133],y[133];
bool was[4][4];
map<string,int>mp;
map<string,bool>vis;
int main(){
	for(int i=0;i<4;i++)
		tem[i].score=0,
		tem[i].lost=0,
		tem[i].get=0;
	for(int i=0;i<5;i++){
		scanf("%s %s %d:%d",&x,&y,&a,&b);
		if(!vis[x])mp[x]=cnt++,vis[x]=1;
		if(!vis[y])mp[y]=cnt++,vis[y]=1;
		if(a>b)
			tem[mp[x]].score+=3;
		else if(a==b)
			tem[mp[x]].score+=1,
			tem[mp[y]].score+=1;
		else
			tem[mp[y]].score+=3;
		tem[mp[x]].get+=a;
		tem[mp[x]].lost+=b;
		tem[mp[y]].get+=b;
		tem[mp[y]].lost+=a;
		tem[mp[x]].name=x;
		tem[mp[y]].name=y;
		was[mp[x]][mp[y]]=1;
		was[mp[y]][mp[x]]=1;
	}
	//for(int i=0;i<3;i++)
	//	for(int j=i+1;j<4;j++)
	//		cout<<tem[i].name<<' '<<tem[j].name<<' '<<was[i][j]<<endl;
	//for(int i=0;i<4;i++)
	//	cout<<tem[i].score<<' '<<tem[i].get<<' '<<tem[i].lost<<' '<<tem[i].name<<endl;
	int p1=12345,p2=0;
	for(int xx=0;xx<3;xx++)
		for(int yy=xx+1;yy<4;yy++)
			if(was[xx][yy]==0)
			{
				if(tem[yy].name =="BERLAND")swap(xx,yy);
				for(int i=0;i<100;i++)
					for(int j=0;j<i;j++)
					{
						if(i>j)
							tem[xx].score+=3;
						if(i==j)
							tem[xx].score+=1,
							tem[yy].score+=1;
						if(i<j)
							tem[yy].score+=3;
						tem[xx].get+=i;
						tem[xx].lost+=j;
						tem[yy].get+=j;
						tem[yy].lost+=i;
						//sort(tem,tem+4);
						Team tmp[4];
						for(int k=0;k<4;k++)tmp[k]=tem[k];
						sort(tmp,tmp+4);
						if(i==0&&j==1)
							for(int k=0;k<4;k++)
								cout<<tmp[k].score<<' '<<tmp[k].get<<' '<<tmp[k].lost<<' '<<tmp[k].name<<endl;
						for(int k=0;k<2;k++)
							if(tmp[k].name=="BERLAND"){
								if((i-j)<(p1-p2)||(i<p1))
								{
									p1=i,
									p2=j;
								}
	//							else
	//								cout<<i-j<<' '<<p1-p2<<endl;
							}
						//cout<<i<<' '<<j<<endl;
						if(i>j)
							tem[xx].score-=3;
						if(i==j)
							tem[xx].score-=1,
							tem[yy].score-=1;
						if(i<j)
							tem[yy].score-=3;
						tem[xx].get-=i;
						tem[xx].lost-=j;
						tem[yy].get-=j;
						tem[yy].lost-=i;
					}
					if(p1-p2<10000)
						cout<<p1<<':'<<p2;
					else
						cout<<"IMPOSSIBLE";
					return 0;
			}
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
map<string,int> P;
map<string,int> D;
map<string,int> S;
map<string,int> Name;
struct node{
    int x,y,z;
    string name;
    node(int x=0,int y=0,int z=0,string name=""):x(x),y(y),z(z),name(name){}
    bool operator < (const node &a)const{
        if(x==a.x && y==a.y && z==a.z) return name<a.name;
        else if(x==a.x && y==a.y) return z>a.z;
        else if(x==a.x) return y>a.y;
        return x>a.x;
    }
}a[10];
bool pd(string s,string p,int x,int y){
    if(x>y){
        //if(x==2 && y==1) cout<<s<<" "<<p<<endl;
        //if(x==2 && y==1 )printf("%d %d\n",P[s],P[p]);
        P[s]+=3;
        P[p]+=0;
        //if(x==2 && y==1 )printf("%d %d\n",D[s],D[p]);
        D[s]+=x-y;
        D[p]+=y-x;
        //if(x==2 && y==1 )printf("%d %d\n",S[s],S[p]);
        S[s]+=x;
        S[p]+=y;
    }
    int cnt=0;
    for(auto & t : P){
        string tmp=t.first;
        if(tmp=="BERLAND"){
            a[0].x=t.second;
            a[0].y=D[tmp];
            a[0].z=S[tmp];
            a[0].name=tmp;
        } else {
            a[++cnt].x=P[tmp];
            a[cnt].y=D[tmp];
            a[cnt].z=S[tmp];
            a[cnt].name=tmp;
        }
    }
    sort(a,a+cnt+1);
    int f=0;
    if(a[0].name=="BERLAND" || a[1].name=="BERLAND") f=1;
    else f=0;
    if(x>y){
        P[s]-=3;
        P[p]-=0;
        D[s]-=x-y;
        D[p]-=y-x;
        S[s]-=x;
        S[p]-=y;
    }
    if(f) return true;
    return false;
}
string s,p;
int x,y;
int main(){
    for(int i=0;i<5;i++){
        cin>>s>>p;
        scanf("%d:%d",&x,&y);
        Name[s]++;
        Name[p]++;
        if(x>y){
            P[s]+=3;
            P[p]+=0;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        } else if(x==y){
            P[s]+=1;
            P[p]+=1;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        } else if(x<y){
            P[s]+=0;
            P[p]+=3;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        }
    }
    string op;
    for(auto & t : P){
        if(Name[t.first]==2 && t.first!="BERLAND") op=t.first;
    }
    int x,y,f=0,ans=1e9;
    for(int i=0;i<=100;i++){
        for(int j=0;j<i;j++){
            //cout<<i<<" "<<j<<endl;
            if(pd("BERLAND",op,i,j)){
                f=1;
                if(i-j<ans){
                    ans=i-j;
                    f=1;
                    x=i;
                    y=j;
                }
                else if(i-j==ans){
                    f=1;
                    if(j<y){
                        x=i;
                        y=j;
                    }

                }
            }
        }
    }
    if(f) printf("%d:%d\n",x,y);
    else printf("IMPOSSIBLE\n");
    return 0;
}

/*
 * DATE : 2017-05-30
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define Long                    long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long I = (A); I < (B) ; ++ I)
#define REP(i,n)                for( long long i=0 ; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define Di(x)                   long long x;scanf("%d",&x)
#define in(x)                   input(x)
#define in2(x,y)                input(x), input(y)
#define in3(x,y,z)              input(x), input(y),input(z)
#define ins(x)                  scanf("%s",x)
#define ind(x)                  scanf("%lf",&x)
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/Users/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("/Users/matrixcode/Desktop/out.txt","w",stdout)

template<class T > void input(T &x){
    char c = getchar();x = 0;
    for(;(c<48 || c>57);c = getchar());
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1001;

int main() {

	map<string, int> points, count, goals, miss;
	int x,y;
	char a[25], b[25];
	for(int i=0;i<5;i++) {
		scanf("%s%s%d:%d",a,b,&x,&y);
		count[a]++;
		count[b]++;
		if(x > y) points[a]+=3;
		if(x < y) points[b]+=3;
		if(x == y) {
			points[a]++; points[b]++;
		}
		goals[a]+=x; miss[a]+=y;
		goals[b]+=y; miss[b]+=x;
	}

	string at;
	vector<string> teams;

	for(auto &s: count) {
		teams.push_back(s.first);
		if(s.second == 2 && s.first!="BERLAND") {
			at = s.first;
		}
	}

	for(int i=1;i<100;i++) {
		for(int k=0;k<100;k++) {
			int j = i+k;
			goals["BERLAND"] += j; miss["BERLAND"] += k;
			goals[at]+= k; miss[at] += j;
			points["BERLAND"] += 3;
			vector<tuple<int, int, int, string> > u;
			for(auto &s:teams) {
				u.push_back(make_tuple(-points[s],-goals[s]+miss[s],-goals[s],s));
			}
			sort(u.begin(), u.end());
			if(get<3>(u[0]) == "BERLAND" || get<3>(u[1]) == "BERLAND") {
				printf("%d:%d",j,k);
				return 0;
			}
			points["BERLAND"] -= 3;
			goals["BERLAND"] -= j;
			miss["BERLAND"] -= k;
			goals[at] -= k;
			miss[at] -= j;
		}
	}
	printf("IMPOSSIBLE");

}

#include<stdio.h>
#include<string.h>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
map<string,int>ha;
string BD="BERLAND",name[5];
int cpt[5][5],wb[5],ball[5];
int t_wb[5],t_ball[5],flg,diren,cnt[5],t_cnt[5];
int rk[5];
bool cmp(const int& a,const int& b)
{
	if(cnt[a]!=cnt[b])return cnt[a]>cnt[b];
	if(wb[a]!=wb[b])return wb[a]>wb[b];
	if(ball[a]!=ball[b])return ball[a]>ball[b];
	return name[a]<name[b];
}
int find_diren()
{
	int i;
	for(i=2;i<=4;i++)
	if(cpt[1][i]==10)return i;
	return i;
}
int win(int X,int Y)
{
	int i;
	memcpy(t_cnt,cnt,sizeof(cnt));
	memcpy(t_ball,ball,sizeof(ball));
	memcpy(t_wb,wb,sizeof(wb));

	cnt[1]+=3;
	wb[1]+=X-Y;
	ball[1]+=X;

	wb[diren]+=Y-X;
	ball[diren]+=Y;
	for(i=1;i<=4;i++)rk[i]=i;
	sort(rk+1,rk+5,cmp);

 	memcpy(cnt,t_cnt,sizeof(cnt));
	memcpy(ball,t_ball,sizeof(ball));
	memcpy(wb,t_wb,sizeof(wb));

	for(i=1;i<=4;i++)
	if(rk[i]==1)break;
	if(i<=2)return 1;
	return 0;
}
void solv()
{
	int i,dif,y,lmt_dif,lmt_x;
	for(i=1;i<=4;i++)rk[i]=i;
	sort(rk+1,rk+5,cmp);
	for(i=1;i<=4;i++)
	if(rk[i]==1)break;
	if(i<=2){printf("1:0\n");return;}
	else if(cnt[rk[2]]-cnt[1]>3){printf("IMPOSSIBLE\n");}

	lmt_dif=1;lmt_x=1;
	for(i=1;i<=4;i++)
	{
		lmt_dif=max(lmt_dif,ball[i]);
		lmt_x=max(lmt_x,ball[i]);
	}
	lmt_dif+=5;lmt_x+=5;
	for(dif=1;dif<=lmt_dif;dif++)
	for(y=0;y<=lmt_x;y++)
	if(win(dif+y,y)){
		printf("%d:%d\n",dif+y,y);
		return;
	}
}
int main()
{
//	freopen("test","r",stdin);
	int i,j,a,b;
	char T1[22],T2[22];
	string t1,t2;
	ha[BD]=++flg;
	name[1]=BD;
	for(i=1;i<=4;i++)
	for(j=1;j<=4;j++)cpt[i][j]=10;
	for(i=0;i<5;i++)
	{
		scanf("%s%s",T1,T2);
		scanf("%d:%d",&a,&b);
		t1=T1;t2=T2;
		if(ha[t1]==0){ha[t1]=++flg;name[flg]=t1;}
		if(ha[t2]==0){ha[t2]=++flg;name[flg]=t2;}

		wb[ha[t1]]+=a-b;ball[ha[t1]]+=a;
		wb[ha[t2]]+=b-a;ball[ha[t2]]+=b;

		if(a>b){
			cnt[ha[t1]]+=3;
			cpt[ha[t1]][ha[t2]]=1;
			cpt[ha[t2]][ha[t1]]=-1;
		}
		else if(a<b){
			cnt[ha[t2]]+=3;
			cpt[ha[t1]][ha[t2]]=-1;
			cpt[ha[t2]][ha[t1]]=1;
		}
		else{
			cnt[ha[t1]]++;
			cnt[ha[t2]]++;
			cpt[ha[t1]][ha[t2]]=0;
			cpt[ha[t2]][ha[t1]]=0;
		}
	}
	diren=find_diren();
	solv();
	return 0;
}

#include <bits/stdc++.h>
#define vt vector<team>
#define pb push_back
using namespace std;
struct team
{
    string name;
    int goal, miss, score;
    int matches;
    team()
    {
        goal = 0;
        miss = 0;
        score = 0;
        matches = 0;
    }
    void operator =(const team &a)
    {
        name = a.name;
        goal = a.goal;
        miss = a.miss;
        score = a.score;
        matches = a.matches;
    }
    bool operator <(const team &a) const
    {
        if (score == a.score)
        {
            if (goal - miss == a.goal - a.miss)
            {
                if (goal == a.goal)
                {
                    return name < a.name;
                }
                return goal > a.goal;
            }
            return goal - miss > a.goal - a.miss;
        }
        return score > a.score;
    }
    bool operator >(const team &a) const
    {
        return !(*this < a);
    }
};
map<string, team> match;
vt arr, arr2;
int main()
{
    ios::sync_with_stdio(false);
    string a, b;
    int x, y;
    for (int i = 0; i < 5; i++)
    {
        cin >> a >> b;
        team n;
        if (!(match.count(a)))
        {
            n.name = a;
            match[a] = n;
        }
        if (!(match.count(b)))
        {
            n.name = b;
            match[b] = n;
        }
        cin >> x;
        cin.ignore(1);
        cin >> y;
        if (x == y)
        {
            match[a].score++;
            match[b].score++;
        }
        else
            if (x > y)
            {
                match[a].score += 3;
            }
            else
            {
                match[b].score += 3;
            }
        match[a].goal += x;
        match[b].miss += x;
        match[b].goal += y;
        match[a].miss += y;
        match[a].matches++;
        match[b].matches++;
    }
    string miss_team;
    for (auto it : match)
    {
        if (it.second.matches == 3)
        {
            arr.pb(it.second);
        }
        else
        {
            if (it.second.name != "BERLAND")
            {
                miss_team = it.second.name;
            }
        }
    }
    for (int k = 1; k < 100; k++)
    {
        for (int j = 0; j < 100; j++)
        {
            int i = j + k;
            team b_t = match["BERLAND"], m_t = match[miss_team];
            b_t.goal += i;
            b_t.miss += j;
            b_t.score += 3;
            m_t.goal += j;
            m_t.miss += i;
            arr2 = arr;
            arr2.pb(b_t);
            arr2.pb(m_t);
            sort(arr2.begin(), arr2.end());
            if (arr2[0].name == "BERLAND" || arr2[1].name == "BERLAND")
            {
                cout << i << ":" << j << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

struct state {
    int p, s, a;
    string n;
    bool operator<(const state&e) const {
        if (e.p != p)
            return p > e.p;
        if (s - a != e.s - e.a)
            return s - a > e.s - e.a;
        if (e.s != s)
            return s > e.s;
        return n < e.n;
    }
};

vector<state> v;
map<string, int> hs;
string a, b;
vector<string> w;

void add(int x, int y, string &s) {
    if (hs.find(s) == hs.end()) {
        hs[s] = v.size();
        v.push_back(state());
        v.back().n = s;
    }
    int at = hs[s];
    if (x > y)
        v[at].p += 3;
    else if (x == y)
        ++v[at].p;
    v[at].s += x;
    v[at].a += y;
}

bool check(int x, int y, int pos, int ag) {
    vector<state> temp = v;
    temp[pos].p += 3;
    temp[pos].s += x;
    temp[pos].a += y;
    temp[ag].s += y;
    temp[ag].a += x;
    sort(temp.begin(), temp.end());
    return temp[0].n == "BERLAND" || temp[1].n == "BERLAND";
}

int main() {
//  freopen("a", "r", stdin);
    char c;
    for (int i = 0, x, y; i < 5; ++i) {
        cin >> a >> b >> x >> c >> y;
        add(x, y, a);
        add(y, x, b);
        if (a == "BERLAND")
            w.push_back(b);
        else if (b == "BERLAND")
            w.push_back(a);
    }
    int ag = 0;
    map<string, int>::iterator it;
    for (it = hs.begin(); it != hs.end(); ++it)
        if (it->first != "BERLAND" && w[0] != it->first && w[1] != it->first) {
            ag = it->second;
            break;
        }
    assert(ag != -1);
    int pos = hs["BERLAND"];
    int diff = 2e9, x = -1, y = -1;
    for (int i = 1; i <= 100; ++i)
        for (int j = i - 1; j >= 0; --j)
            if (check(i, j, pos, ag)) {
                if (i - j < diff || (i - j == diff && j < y)) {
                    x = i;
                    y = j;
                    diff = i - j;
                }
            }
    if (x == -1)
        puts("IMPOSSIBLE");
    else
        printf("%d:%d\n", x, y);
    return 0;
}

#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <string>

#define oo 1e9
#define pi 3.1415926536
#define all(x) x.begin(),x.end()
#define sorta(x) sort(all(x))
#define sortam(x,comp) sort(all(x),comp)
#define sortd(x) sort(x.rbegin(),x.rend())
#define pb push_back
#define mp make_pair

using namespace std;

struct Rank {
	string name;
	int gf, ga, pnts, pl;
};

bool comp(Rank a, Rank b) {
	return a.pnts > b.pnts || ( a.pnts == b.pnts && a.gf - a.ga > b.gf - b.ga ) || ( a.pnts == b.pnts && a.gf - a.ga == b.gf - b.ga && a.gf > b.gf ) || ( a.pnts == b.pnts && a.gf - a.ga == b.gf - b.ga && a.gf == b.gf && a.name < b.name );
}

void mn(int &resx, int &resy, int x, int y) {
	if(x - y < resx - resy || ( x - y == resx - resy && y < resy )) resx = x, resy = y;
}

int main() {
	map<string, Rank>group;
	map<string, Rank>::iterator gind;
	for(int i = 0; i < 5; i++) {
		string team1, team2, score;
		cin >> team1 >> team2 >> score;
		if(!group.count(team1)) {
			group[team1].name = team1;
			group[team1].gf = 0;
			group[team1].ga = 0;
			group[team1].pnts = 0;
			group[team1].pl = 0;
		}

		if(!group.count(team2)) {
			group[team2].name = team2;
			group[team2].gf = 0;
			group[team2].ga = 0;
			group[team2].pnts = 0;
			group[team2].pl = 0;
		}

		group[team1].pl++;
		group[team1].pnts += score[0] > score[2] ? 3 : score[0] == score[2] ? 1 : 0;
		group[team1].gf += score[0] - '0';
		group[team1].ga += score[2] - '0';
		group[team2].pl++;
		group[team2].pnts += score[0] < score[2] ? 3 : score[0] == score[2] ? 1 : 0;
		group[team2].ga += score[0] - '0';
		group[team2].gf += score[2] - '0';
	}

	Rank fin[4];
	int ind = 0, bind, othind;
	for(gind = group.begin(); gind != group.end(); gind++) {
		fin[ind] = gind->second;
		if(fin[ind].name == "BERLAND") bind = ind;
		else if(fin[ind].pl == 2) othind = ind;
		ind++;
	}

	fin[bind].pnts += 3;
	int resx = -1, resy = -100;
	for(int x = 1; x < 30; x++) {
		for(int y = 0; y < x; y++) {
			for(int i = 0; i < 4; i++) {
				if(fin[i].name == "BERLAND") bind = i;
				else if(fin[i].pl == 2) othind = i;
			}
			fin[bind].gf += x;
			fin[bind].ga += y;
			fin[othind].ga += x;
			fin[othind].gf += y;
			sort(fin, fin + 4, comp);
			if(fin[0].name == "BERLAND" || fin[1].name == "BERLAND") mn(resx, resy, x, y);
			for(int i = 0; i < 4; i++) {
				if(fin[i].name == "BERLAND") bind = i;
				else if(fin[i].pl == 2) othind = i;
			}
			fin[bind].gf -= x;
			fin[bind].ga -= y;
			fin[othind].ga -= x;
			fin[othind].gf -= y;
		}
	}
	resx == -1 ? cout << "IMPOSSIBLE\n" : cout << resx << ":" << resy << endl;
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef vector< int > VI;
typedef vector< string > VS;
typedef pair< int, int > II;
typedef long long LL;
#define FOR(i,b,e) for(int (i)=(int)(b);(i)<(int)(e);++(i))
#define FORIT(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define INF 987654321

typedef pair< string, string > SS;

int main()
{
    map< SS, II > M;
    map< string, int > C;
    FOR(i, 0, 5) {
        string a, b, c;
        cin >> a >> b >> c;
        int x, y;
        sscanf(c.c_str(), "%1d:%1d", &x, &y);
        M[make_pair(a, b)] = make_pair(x, y);
        ++C[a];
        ++C[b];
    }
    string opp;
    for (map< string, int >::iterator it = C.begin(); it != C.end(); ++it)
        if (it->second != 3 && it->first != "BERLAND") { opp = it->first; break; }
    int ansx, ansy;
    int dmin = INF, smin = INF;
    FOR(x, 0, 100)
        FOR(y, 0, x) {
            map< string, int > win;
            map< string, int > score, miss;
            for (map< SS, II >::iterator it = M.begin(); it != M.end(); ++it) {
                string t1 = it->first.first, t2 = it->first.second;
                int s1 = it->second.first, s2 = it->second.second;
                if (s1 > s2) {  win[t1] += 3, win[t2] += 0; }
                else if (s1 == s2) { win[t1] += 1; win[t2] += 1; }
                else if (s1 < s2) { win[t1] += 0; win[t2] += 3; }
                score[t1] += s1, score[t2] += s2;
                miss[t1] += s2, miss[t2] += s1;
            }
            win["BERLAND"] += 3, win[opp] += 0;
            score["BERLAND"] += x, score[opp] += y;
            miss["BERLAND"] += y, miss[opp] += x;
            // check
            VS name;
            VI win1, score1, miss1;
            for (map< string, int >::iterator it = win.begin(); it != win.end(); ++it) {
                name.push_back(it->first);
                win1.push_back(it->second);
                score1.push_back(score[it->first]);
                miss1.push_back(miss[it->first]);
            }
            FOR(i, 0, 4)
                FOR(j, i+1, 4) {
                    bool flag = false;
                    if (win1[i] < win1[j]) flag = true;
                    else if (win1[i] == win1[j]) {
                        if (score1[i]-miss1[i] < score1[j]-miss1[j]) flag = true;
                        else if (score1[i]-miss1[i] == score1[j]-miss1[j]) {
                            if (score1[i] < score1[j]) flag = true;
                            else if (score1[i] == score1[j] && name[i] > name[j]) flag = true;
                        }
                    }
                    if (flag) { swap(name[i], name[j]), swap(win1[i], win1[j]), swap(score1[i], score1[j]), swap(miss1[i], miss1[j]); }
                }
            if (name[0] == "BERLAND" || name[1] == "BERLAND")
                if (dmin > x-y || (dmin == x-y && smin > x)) dmin = x-y, smin = x, ansx = x, ansy = y;
        }
    if (dmin == INF) { cout << "IMPOSSIBLE" << endl; return 0; }
    ostringstream oss;
    oss << ansx << ":" << ansy;
    cout << oss.str() << endl;
    return 0;
}

//#pragma comment(linker, "/STACK:64777216")
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <typeinfo>
#include <set>
#include <cctype>
#include <locale>
#include <utility>
#include <map>
#include <iterator>
#include <valarray>
#include <complex>
#include <sstream>
#include <bitset>
#include <ctime>
#include <list>
#include <numeric>
#include <cstring>
using namespace std;

/*
#include <unordered_map>
#include <unordered_set>
#include <regex>
*/
#define sz size()
#define pb push_back
#define ppb pop_back
#define all(c) (c).begin(), (c).end()
#define sqr(a) (a)*(a)
#define mp make_pair
#define rall(c) (c).rbegin(), (c).rend()
#define rmp reverse_make_pair
#define tre(u) paths[path_num[u]]

typedef vector<int> vint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<vector<int> > vvint;
typedef vector<char> vchar;
typedef vector<vector<int> > graph;
const int INF=~(1<<31);

inline int in() {
    int a;
    scanf("%d", &a);
    return a;
}
template<class T1, class T2>
inline pair<T1, T2> reverse_make_pair(T1 x, T2 y){
    return pair<T1, T2>(y, x);
}
template<class T>
ostream& operator<<(ostream& out, const vector<T> a){
    for(int i = 0; i < (int)a.size(); i++)   out<<a[i]<<' ';
    return out;
}
template<class T>
ostream& operator<<(ostream& out, const set<T> a){
    int i=0;
    while(a.begin ()+i!=a.end ()){
        cout<<*(a.begin ()+i)<<' ';
        ++i;
    }
    return out;
}
double din() {
    double a;
    scanf("%lf", &a);
    return a;
}

ll gcd(ll a, ll b) {
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

const double eps = 1e-6;

int logbin(int a){
    a--;
    int res=1;
    while(a) a>>=1, res<<=1;
    return res;
}
int binpow (int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res *= a;
        a *= a;
        n >>= 1;
    }
    return res;
}
struct treap{
    treap *l,*r;
    int x,y;
    int size;
    treap(int _c){
        l=r=NULL;
        size=1;
        x=_c;
        y=rand();
        recalc();
    }
    void recalc(){
        size=1;
        if(l!=NULL){
            size+=l->size;
        }
        if(r!=NULL){
            size+=r->size;
        }
    }

};
void recalc(treap* &a){
    if(a==NULL) return;
    a->recalc ();
}

/*void merge(treap* &t,treap* l, treap* r){
    if(!l) return (void)(t=r);
    if(!r) return (void)(t=l);
    treap *a=new treap(l->c), *b=new treap(r->c);
    a->l=l->l, a->r=l->r;
    b->l=r->l, b->r=r->r;
    if(b->y > a->y){
        merge(b->l, l, b->l);
        t=b;
    }else{
        merge(a->r, a->r, r);
        t=a;
    }
    recalc (t);
}
void split(treap* v,int x, treap* &l, treap* &r){
    if(!v) return (void)(r=l=0);
    treap *a=new treap(v->c);
    a->l=v->l;
    a->r=v->r;
    a->recalc ();
    if(v->x <= x){
        split(a->r, x, a->r, r);
        l=a;
    }else{
        split(a->l, x, l, a->l );
        r=a;
    }
    recalc(v);
}
*/

/*
vector<vector<pair<int,int> > > g;
vector<int> tin, tout;
int timer;
int n,l;
vector < vector<int> > up;
vector<int> weight;
void dfs (int v, int p = 0) {
    tin[v] = ++timer;
    up[v][0] = p;
    for (int i=1; i<=l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i].first;
        if (to != p)
            dfs (to, v);
    }
    tout[v] = ++timer;
}
bool upper (int a, int b) {
    return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca (int a, int b) {
    if (upper (a, b))  return a;
    if (upper (b, a))  return b;
    for (int i=l; i>=0; --i)
        if (! upper (up[a][i], b))
            a = up[a][i];
    return up[a][0];
}
vector<char> u;
vint deep;
void dfs2(int v,int d=0){
    u[v]=1;
    deep[v]=v++;
    for(int i=0;i<g[v].sz;++i) if(!u[g[v][i]]) dfs(g[v][i],d);
}
*/

/*struct node{
    int k;
    node *con[3];
    int g,i;
    int si;
    node(int _k){
        k = _k;
        g=k;
        i=1;
        si=1;
        con[0] = con[1] = con[2] = NULL;
    }
    void recalc(){
        g=k;
        si=1;
        if(con[0]) g=gcd(g, con[0]->g), si+=con[0]->si;
        if(con[1]) g=gcd(g, con[1]->g), si+=con[1]->si;
    }

};
void recalc(node *a){
    if(a) a->recalc ();
}
node *root;

void zig(node *x, int ch=0){
    node *prt = x->con[2], *xs;
    if(prt->con[1] == x) ch ^= 1;
    xs = x->con[ch^1];
    x->con[2] = prt->con[2];
    prt->con[2] = x;
    x->con[ch^1] = prt;
    prt->con[ch] = xs;
    recalc(prt);
    recalc(x);
}
void splay (node *x){
    if(!x) return;
    if(!x->con[2]) return;
    if(!x->con[2]->con[2]){
        zig(x);
        return;
    }
    //исправить
    zig(x->con[2]);
    zig(x);
    splay(x);
}

inline ll dist(pii a, pii b){
    return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}
*/

int main(){
    //freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //srand(time(NULL));

    vint bals(4,0), wins(4,0), lbals(4,0), mat(4,0);
   map<string, int> m;
   vector<string> nam(4);
   vector<pair<int, pair<int, pair<int, string> > > > al, aal;
   for(int i=0, j=0;i<5;++i){
       string s;
       cin>>s;
       if(m.count (s)==0) m[s]=j++, nam[j-1]=s;

       string ss;
       cin>>ss;
       if(m.count (ss)==0) m[ss]=j++, nam[j-1]=ss;
       int a1,a2;
       scanf("%d:%d",&a1, &a2);
       bals[m[s]]+=a1;
       bals[m[ss]]+=a2;
       lbals[m[s]]+=a2;
       lbals[m[ss]]+=a1;
       if(a1>a2) wins[m[s]]+=3;
       if(a1<a2) wins[m[ss]]+=3;
       if(a1==a2) wins[m[s]]+=1,wins[m[ss]]+=1;
       mat[m[s]]++;
       mat[m[ss]]++;
   }
   for(int i=0;i<4;++i){
          pair<int, pair<int, pair<int, string> > > b;
          if(mat[i]==2) continue;
          b=mp(-wins[i], mp(-(bals[i]-lbals[i]), mp(-bals[i], nam[i])));
          al.push_back (b);
   }
   int ii=-1, jj;
   for(int i=0;i<4;++i){
       if(mat[i]==2){
           if(ii==-1) ii=i;
           else jj=i;
       }
   }
   if(nam[jj]=="BERLAND") swap(ii, jj);
   pii res=mp(-1,-1);
   for(int i=0;i<=70;++i){
       for(int j=0;j<i;++j){
              pair<int, pair<int, pair<int, string> > > b, c;
              b=mp(-(wins[ii]+3), mp(-((bals[ii]+i)-(lbals[ii]+j)), mp(-(bals[ii]+i), nam[ii])));
              c=mp(-(wins[jj]), mp(-((bals[jj]+j)-(lbals[jj]+i)), mp(-(bals[jj]+j), nam[jj])));
              aal=al;
              aal.push_back (b);
              aal.push_back (c);
              sort(all(aal));
              if(aal[0]==b || aal[1]==b){
                  //cout<<i<<' '<<j<<endl;
                  if(res.first==-1){
                      res=mp(i,j);
                  }else{
                      if(res.first-res.second > i-j){
                          res=mp(i,j);
                      }
                      else if(res.first-res.second == i-j){
                          if(res.second > j){
                              res=mp(i,j);
                          }
                      }
                  }
              }
       }
   }
   if(res.first==-1){
       cout<<"IMPOSSIBLE";
   }
   else cout<<res.first<<':'<<res.second<<endl;

    return 0;
}

#pragma comment (linker, "/STACK:214721677")
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <string>
using namespace std;
#define REP(i,n) for (int i=0, _n=(n)-1; i <= _n; ++i)
#define REPD(i,n) for (int i=(n)-1; i >= 0; --i)
#define FOR(i,a,b) for (int i=(a), _b=(b); i <= _b; ++i)
#define FORD(i,a,b) for (int i=(a), _b=(b); i >= _b; --i)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define sz(a) ((int) ((a).size()))
template < class T > T sqr (T a) { return (a) * (a); }
template < class T > T abs (T a) { return (a < 0) ? -(a) : (a); }
const double Pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 1000*1000*1000 + 7;
const double phi = 0.5 + sqrt(1.25);
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <double, double> pdd;

struct team {
    string name;
    int scored,lost,pts,games;

    team() { name = "", scored = 0, lost = 0, pts = 0, games = 0;}
};

int comp (team t1, team t2) {
        if (t1.pts != t2.pts)
            return t1.pts > t2.pts;

        if (t1.scored - t1.lost != t2.scored - t2.lost)
            return t1.scored - t1.lost > t2.scored - t2.lost;

        if (t1.scored != t2.scored)
            return t1.scored > t2.scored;

        return t1.name < t2.name;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    team list[5];
    REP(i, 5)
        list[i] = team();
    int num = 0;
    REP(aksldgjhf, 5) {
        /*string s;
        getline(cin, s);
        int id = s.find(' ');
        string name1 = s.substr(0, id), name2 = "";
        for (int i = id+1; i < sz(s); ++i)
            if (s[i] != ' ')
                name2 += s[i];
            else break;*/

        char asd[210];
        scanf("%s", &asd);
        string name1 = string(asd);
        scanf("%s", &asd);
        string name2 = string(asd);
        scanf("%s", &asd);
        string score = string(asd);
        int a = score[0] - 48, b = score[2] - 48;

        bool found = 0;
        REP(i, 5)
            if (list[i].name == name1) {
                found = 1;
                list[i].scored += a;
                list[i].lost += b;
                if (a == b)
                    list[i].pts += 1;
                else if (a > b)
                    list[i].pts += 3;
                list[i].games++;
            }
        if (!found) {
            int i = num++;
            list[i].name = name1;
            list[i].scored += a;
            list[i].lost += b;
            if (a == b)
                list[i].pts += 1;
            else if (a > b)
                list[i].pts += 3;
            list[i].games++;
        }

        found = 0;
        REP(i, 5)
            if (list[i].name == name2) {
                found = 1;
                list[i].scored += b;
                list[i].lost += a;
                if (a == b)
                    list[i].pts += 1;
                else if (b > a)
                    list[i].pts += 3;
                list[i].games++;
            }
        if (!found) {
            int i = num++;
            list[i].name = name2;
            list[i].scored += b;
            list[i].lost += a;
            if (a == b)
                list[i].pts += 1;
            else if (b > a)
                list[i].pts += 3;
            list[i].games++;
        }
    }

//    REP(i, 4) {cout << list[i].name << " " << list[i].pts << list[i].scored << list[i].lost << endl;}

    sort(list, list + 4, comp);
    int place = 0;
    for (int i = 0; i < 4; ++i)
        if (list[i].name == "BERLAND")
            place = i;

    if (place < 2) {
        printf("1:0\n");
        return 0;
    }
    if (list[place].pts + 3 > list[1].pts) {
        printf("1:0\n");
        return 0;
    }
    if (list[place].pts + 3 < list[1].pts) {
        printf("IMPOSSIBLE");
        return 0;
    }
    int left = 0;
    REP(i, 4)
        if (list[i].games == 2 && list[i].name != "BERLAND")
            left = i;

    list[place].pts += 3;
    int X = 100, Y = 0;
    team tmp[5];
    REP(i, 5)
        tmp[i] = list[i];

    int place_b4 = place, left_b4 = left;
    REP(x, 40)
        REP(y, x) {
            list[place].scored += x, list[place].lost += y;
            list[left].scored += y, list[left].lost += x;
            sort(list, list + 4, comp);

            place = 0;
            for (int i = 0; i < 4; ++i)
                if (list[i].name == "BERLAND") {
                    place = i;
                    break;
                }

            if (place < 2) {
                if (x - y < X - Y) {
                    X = x;
                    Y = y;
                }
                else
                if (x - y == X - Y) {
                    if (y < Y) {
                        X = x;
                        Y = y;
                    }
                }

            }

            REP(i, 5)
                list[i] = tmp[i];
            place = place_b4, left = left_b4;
        }

    printf("%d:%d", X, Y);

    return 0;
}

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define flush fflush(stdout)
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

struct team {
	string name;
	int points;
	int score;
	int miss;
	team() {
		name = "";
		points = score = miss = 0;
	}
	team(string n, int p, int s, int m) {
		name = n;
		points = p;
		score = s;
		miss = m;
	}
	bool operator<(const team &t) const {
		if (points == t.points) {
			int diff1 = score - miss;
			int diff2 = t.score - t.miss;
			if (diff1 == diff2) {
				if (score == t.score)
					return name < t.name;
				return score > t.score;
			}
			return diff1 > diff2;
		}
		return points > t.points;
	}
};

int main() {
	PLAY();

	map<string, team> mp;
	map<string, int> cnt;
	for (int i = 0; i < 5; i++) {
		string team1, team2;
		int score1, score2;
		char tmp;
		cin >> team1 >> team2;
		cin >> score1 >> tmp >> score2;
		cnt[team1]++;
		cnt[team2]++;
		int p1 = 0, p2 = 0;
		if (score1 == score2)
			p1 = p2 = 1;
		else if (score1 > score2) p1 = 3;
		else p2 = 3;
		if (mp.find(team1) == mp.end())
			mp[team1] = team(team1, p1, score1, score2);
		else {
			mp[team1].points += p1;
			mp[team1].score += score1;
			mp[team1].miss += score2;
		}
		if (mp.find(team2) == mp.end())
			mp[team2] = team(team2, p2, score2, score1);
		else {
			mp[team2].points += p2;
			mp[team2].score += score2;
			mp[team2].miss += score1;
		}
	}
	vector<team> v;
	team other;
	for (auto e : cnt)
		if (e.second == 2 && e.first != "BERLAND")
			other = mp[e.first];
	team berland;
	for (auto e : mp) {
		if (e.first == "BERLAND") berland = e.second;
		else if(e.first != other.name) v.push_back(e.second);
	}
	int mnx = 100, mny = 100;
	int mn = INT_MAX;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < i; j++) {
			vector<team> tmp = v;
			int p1 = 3, p2 = 0;
			berland.points += p1;
			berland.score += i;
			berland.miss += j;
			other.points += p2;
			other.score += j;
			other.miss += i;
			tmp.push_back(berland);
			tmp.push_back(other);
			sortva(tmp);
			if (tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") {
				int diff = i - j;
				if (diff <= mn) {
					if (diff == mn) {
						if (j < mny) {
							mnx = i, mny = j;
						}
					}
					else
						mnx = i, mny = j;
					mn = diff;

				}
			}
			berland.points -= p1;
			berland.score -= i;
			berland.miss -= j;
			other.points -= p2;
			other.score -= j;
			other.miss -= i;
		}
	}
	if (mn == INT_MAX)
		cout << "IMPOSSIBLE" << endl;
	else
		cout << mnx << ":" << mny << endl;

	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
typedef long long ll;
#define MAX 35
using namespace std;
#define INF 2147483647
#define inf 1<<30
#define MOD 1000000007
#define EPS 1e-9
#define G 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
bool debug = false;
int n,m, k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};

struct Team {
    string name;
    int point, goal, mg, cou;
    bool operator < (const Team &o) const {
        if (point == o.point) {
            if (goal-mg == o.goal-o.mg) {
                if (goal==o.goal) {
                    return name > o.name;
                }
                return goal<o.goal;
            }
            return goal-mg < o.goal-o.mg;
        }
        return point<o.point;
    }
};
Team t[4];
int cc=0;
int gt(string a) {
    REP(i,cc) if (t[i].name == a) return i;
    t[cc].name=a; cc++;
    return cc-1;
}
void setp(string a, string b, int pa, int pb) {
    int mpa = gt(a), mpb=gt(b);
    if (pa>pb) t[mpa].point+=3;
    else if(pa<pb) t[mpb].point+=3;
    else {t[mpa].point++; t[mpb].point++;}
    t[mpa].goal+=pa; t[mpa].mg+=pb;
    t[mpb].goal+=pb; t[mpb].mg+=pa;
    t[mpa].cou++; t[mpb].cou++;
}
void rsetp(string a, string b, int pa, int pb) {
    int mpa = gt(a), mpb=gt(b);
    if (pa>pb) t[mpa].point-=3;
    else if(pa<pb) t[mpb].point-=3;
    else {t[mpa].point--; t[mpb].point--;}
    t[mpa].goal-=pa; t[mpa].mg-=pb;
    t[mpb].goal-=pb; t[mpb].mg-=pa;
    t[mpa].cou--; t[mpb].cou--;
}
int main(){
    string a,b;
    int pa,pb;
    REP(i,5) {
        cin>>a>>b;
        scanf("%d:%d",&pa,&pb);
        setp(a, b, pa, pb);
    }
    string me = "BERLAND", other;
    REP(i,4) if (t[i].name != me && t[i].cou==2) other=t[i].name;
    for(int d=1;d<100;d++) {
        for(int y=0,x;y<100;y++) {
            x=y+d;
            setp(me, other, x, y);
            sort(t,t+4);
            if (t[2].name==me || t[3].name==me) {
                printf("%d:%d\n",x,y); return 0;
            }
            rsetp(me, other, x, y);
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
map<string,int> P;
map<string,int> D;
map<string,int> S;
map<string,int> Name;
struct node{
    int x,y,z;
    string name;
    node(int x=0,int y=0,int z=0,string name=""):x(x),y(y),z(z),name(name){}
    bool operator < (const node &a)const{
        if(x==a.x && y==a.y && z==a.z) return name<a.name;
        else if(x==a.x && y==a.y) return z>a.z;
        else if(x==a.x) return y>a.y;
        return x>a.x;
    }
}a[10];
bool pd(string s,string p,int x,int y){
    if(x>y){
        P[s]+=3;
        P[p]+=0;
        D[s]+=x-y;
        D[p]+=y-x;
        S[s]+=x;
        S[p]+=y;
    }
    int cnt=0;
    for(auto & t : P){
        string tmp=t.first;
        if(tmp=="BERLAND"){
            a[0].x=t.second;
            a[0].y=D[tmp];
            a[0].z=S[tmp];
            a[0].name=tmp;
        } else {
            a[++cnt].x=P[tmp];
            a[cnt].y=D[tmp];
            a[cnt].z=S[tmp];
            a[cnt].name=tmp;
        }
    }
    sort(a,a+cnt+1);
    int f=0;
    if(a[0].name=="BERLAND" || a[1].name=="BERLAND") f=1;
    else f=0;
    if(x>y){
        P[s]-=3;
        P[p]-=0;
        D[s]-=x-y;
        D[p]-=y-x;
        S[s]-=x;
        S[p]-=y;
    }
    if(f) return true;
    return false;
}
string s,p;
int x,y;
int main(){
    for(int i=0;i<5;i++){
        cin>>s>>p;
        scanf("%d:%d",&x,&y);
        Name[s]++;
        Name[p]++;
        if(x>y){
            P[s]+=3;
            P[p]+=0;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        } else if(x==y){
            P[s]+=1;
            P[p]+=1;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        } else if(x<y){
            P[s]+=0;
            P[p]+=3;
            D[s]+=x-y;
            D[p]+=y-x;
            S[s]+=x;
            S[p]+=y;
        }
    }
    string op;
    for(auto & t : P){
        if(Name[t.first]==2 && t.first!="BERLAND") op=t.first;
    }
    int x,y,f=0,ans=1e9;
    for(int i=0;i<=100;i++){
        for(int j=0;j<i;j++){
            if(pd("BERLAND",op,i,j)){
                f=1;
                if(i-j<ans){
                    ans=i-j;
                    f=1;
                    x=i;
                    y=j;
                }
                else if(i-j==ans){
                    f=1;
                    if(j<y){
                        x=i;
                        y=j;
                    }

                }
            }
        }
    }
    if(f) printf("%d:%d\n",x,y);
    else printf("IMPOSSIBLE\n");
    return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <ctime>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <sstream>
#include <bitset>
#include <complex>
#include <functional>
//#include <unordered_set>
//#include <unordered_map>
//#include <cassert>
#pragma comment(linker, "/STACK:16777216")
#pragma warning(default :4)
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define eps 1e-9
#define INF 1000000001
//#define oo 1000000001
#define oo 0x3F3F3F3F
#define MOD 1000000007
#define cint const int &
#define cll const ll &
#define cull const ull &
#define FOR(i, x) for (int i = 0; i < (int)(x); ++i)
#define CL(x) memset(x, 0, sizeof(x))
#define SINF(x) memset(x, 0x3F, sizeof(x));
#define SVAL(x, y) memset(x, y, sizeof(x))
#define CP(t, f) memcpy(t, f, sizeof(f));
#define FIN freopen("in.txt", "r", stdin);
#define FOUT freopen("out.txt", "w", stdout);
#define y1 ____y1
void dbg() { std::cerr << '\n'; };
template<typename T1> void dbg(T1 x1) { std::cerr << x1 << '\n'; };
template<typename T1, typename T2> void dbg(T1 x1, T2 x2) { std::cerr << x1 << " " << x2 << '\n'; };
template<typename T1, typename T2, typename T3> void dbg(T1 x1, T2 x2, T3 x3) { std::cerr << x1 << " " << x2 << " " << x3 << '\n'; };
const double PI=acos(-1.);
ll Round(double x) { return x<0 ? x-.5 : x+.5; };
using namespace std;
typedef vector<int> VINT;
typedef pair<int, int> PII;
typedef complex<double> Cn;
typedef vector<PII> VPII;
struct Team
{
    string name;
    int score, X, Y, ma;
    Team(string N, int S, int x, int y, int M) : name(N), score(S), X(x), Y(y), ma(M) {};
};
bool operator < (const Team &a, const Team &b)
{
    if (a.score!=b.score) return a.score>b.score;
    if ((a.X-a.Y)!=(b.X-b.Y)) return (a.X-a.Y)>(b.X-b.Y);
    if (a.X!=b.X) return a.X>b.X;
    return a.name<b.name;
}
string BERN="BERLAND", opp;
char s1[111], s2[111];
int c1, c2;
vector<Team> tms;
int gid(string s)
{
    for (int i=0; i<tms.size(); i++)
        if (tms[i].name==s) return i;
    tms.push_back(Team(s, 0, 0, 0, 0));
    return tms.size()-1;
}
void addm(string n1, string n2, int c1, int c2)
{
    int i1=gid(n1), i2=gid(n2);
    if (c1>c2) tms[i1].score+=3;
    if (c1==c2) tms[i1].score+=1, tms[i2].score+=1;
    if (c1<c2) tms[i2].score+=3;
    tms[i1].X+=c1; tms[i1].Y+=c2;
    tms[i2].X+=c2; tms[i2].Y+=c1;
    tms[i1].ma++;
    tms[i2].ma++;
}
int main()
{
    tms.reserve(10);
    FOR(i, 5)
    {
        scanf("%s %s %d:%d\n", s1, s2, &c1, &c2);
        string n1=string(s1, s1+strlen(s1));
        string n2=string(s2, s2+strlen(s2));
        addm(n1, n2, c1, c2);
    }
    for (int i=0; i<tms.size(); i++) if (tms[i].name!=BERN && tms[i].ma<3) opp=tms[i].name;
    for (int d=1; d<200; d++)
        for (int y=0; y<200; y++)
        {
            vector<Team> tmp=tms;
            addm(BERN, opp, y+d, y);
            sort(tms.begin(), tms.end());
            if (gid(BERN)<2)
            {
                printf("%d:%d\n", y+d, y);
                return 0;
            }
            tms=tmp;
        }
    puts("IMPOSSIBLE");
    return 0;
}

# include <stdio.h>
# include <string.h>
# include <string>
# include <iostream>
# include <algorithm>
# include <sstream>
# include <vector>
# include <set>
# include <cmath>
# include <map>
using namespace std;

struct team
{
    string name ;
    int sc , og ;
    int pts , played ;
};

vector <string> getWords(string sen) {

   istringstream iss(sen);
   vector <string> wyn;
   string slowo;
   while (true) {

      iss >> slowo; if (!iss) break;
      wyn.push_back( slowo );
   }
   return wyn;
}

bool cmp ( team a , team b )
{
    if ( a.pts != b.pts ) return a.pts > b.pts ;
    if ( a.sc-a.og != b.sc-b.og ) return a.sc-a.og > b.sc-b.og;
    if ( a.sc != b.sc ) return a.sc > b.sc ;
    return a.name < b.name ;
}

team teams[4] ;
char tmp[111] ;
vector<string>v;
map < string , int> mp ;

void copyteam ( team &a , team &b )
{
    a.name = b.name ;
    a.og = b.og ;
    a.played = b.played ;
    a.pts = b.pts ;
    a.sc = b.sc ;
    return ;
}

int main()
{
    int b=0 ;
    for ( int i=0 ; i<5 ; i++ )
    {
        v.clear();
        for ( int j=0 ; j<3 ; j++ )
        {
            scanf("%s",tmp);
            v.push_back(tmp);
        }
        string num="";
        int n1=-1 , n2=-1 ;
        if ( mp.count(v[0])==0 )    mp[v[0]]=b++;
        if ( mp.count(v[1])==0 )    mp[v[1]]=b++;
        for ( int i=0 ; i<v[2].size() ; i++ )
        {
            if ( v[2][i] == ':' )
            {
                sscanf(num.c_str(),"%d",&n1);
                num="";
                continue ;
            }
            num += v[2][i] ;
        }
        sscanf(num.c_str(),"%d",&n2);
        num="";
        if ( n1 > n2 )
        {
            int ind = mp[ v[0] ] ;
            teams[ ind ].pts += 3 ;
            teams[ ind ].name = v[0] ;
            teams[ ind ].sc += n1 ;
            teams[ ind ].og += n2 ;
            teams[ ind ].played ++;
            int ind2 = mp [ v[1] ] ;
            teams[ ind2 ].name = v[1] ;
            teams[ ind2 ].sc += n2 ;
            teams[ ind2 ].og += n1 ;
            teams[ ind2 ].played ++;
        }
        else if ( n1 < n2 )
        {
            int ind = mp [ v[1] ] ;
            teams[ ind ].pts += 3 ;
            teams[ ind ].name = v[1] ;
            teams[ ind ].sc += n2 ;
            teams[ ind ].og += n1 ;
            teams[ ind ].played ++;
            int ind2 = mp [ v[0] ] ;
            teams[ ind2 ].name = v[0] ;
            teams[ ind2 ].sc += n1 ;
            teams[ ind2 ].og += n2 ;
            teams[ ind2 ].played ++;
        }
        else
        {
            int ind = mp [ v[0] ] , ind2 = mp [ v[1] ] ;
            teams [ ind ].name = v[0] ;
            teams [ ind ].sc += n1 ;
            teams [ ind ].og += n2 ;
            teams [ ind ].pts += 1 ;
            teams [ ind ].played ++;

            teams [ ind2 ].name = v[1] ;
            teams [ ind2 ].sc += n2 ;
            teams [ ind2 ].og += n1 ;
            teams [ ind2 ].pts += 1 ;
            teams [ ind2 ].played ++;
        }
    }
    int ii=0 , jj=0 ;
    sort ( teams , teams+4 , cmp ) ;
    for ( int i=0 ; i<4 ; i++ )
    {
        if ( teams[i].played==2 && teams[i].name != "BERLAND" ) jj = i ;
        else if ( teams[i].played==2 ) ii = i ;
    }

        int d = teams[1].sc-teams[1].og ;
        team tt[4] ;
        for ( int i=0 ; i<4 ; i++ )
            tt[i] = teams[i] ;
        int i ;
        int ansx=-1 , ansy=-1 , diff = 1<<30 ;
        int f = 0 ;
        for ( i=1 ; i<=100; i++ )
        {
            for ( int j=0 ; j<i; j++ )
            {
                copyteam ( teams[ii] , tt[ii] );
                teams[ii].pts += 3 ;
                teams[ii].sc += i ;
                teams[ii].og += j ;
                teams[jj].og += i ;
                teams[jj].sc += j ;
                sort ( teams , teams+4 , cmp );
                if ( teams[0].name=="BERLAND" || teams[1].name=="BERLAND" )
                {
                    if ( i-j <= diff )
                    {
                        if ( i-j == diff )
                            f++ ;
                        else
                            f=0 ;
                        diff = i-j ;
                        ansx = i ;
                        ansy = j ;
                    }
                }
                for ( int i=0 ; i<4 ; i++ )
                    copyteam( teams[i] , tt[i] ) ;
            }
        }
        int yval=1<<30 ;
        if ( f > 1 )
        {
            for ( i=1 ; i<=100; i++ )
            {
                for ( int j=0 ; j<i; j++ )
                {
                    copyteam ( teams[ii] , tt[ii] );
                    teams[ii].pts += 3 ;
                    teams[ii].sc += i ;
                    teams[ii].og += j ;
                    teams[jj].og += i ;
                    teams[jj].sc += j ;
                    sort ( teams , teams+4 , cmp );
                    if ( teams[0].name=="BERLAND" || teams[1].name=="BERLAND" )
                    {
                        if ( i-j == diff )
                        {
                            if ( j < yval )
                            {
                                yval = j ;
                                ansx = i ;
                                ansy = j ;
                            }
                        }
                    }
                    for ( int i=0 ; i<4 ; i++ )
                        copyteam( teams[i] , tt[i] ) ;
                }
            }
        }
        if ( diff == 1<<30 )    printf("IMPOSSIBLE\n");
        else printf("%d:%d\n",ansx,ansy);

}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,int> mpci;
typedef map<int,int> mpii;
typedef map<string,int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
const ll power(int n,int k)
{
	ll t=1;
	rep(i,k)
	  t*=n;
	return t;
}
const string turn2(int n)
{
	string s="";
	while(n!=0)
	{
		s+=(char)(n%2+'0');
		n/=2;
	}
	reverse(s.begin(),s.end());
	return s;
}
const string turn16(int n)
{
	string s="";
	while(n!=0)
	{
		if(n%16>9)
		  s+=(char)('A'+n%16-10);
		else
		  s+=(char)('0'+n%16);
		n/=16;
	}
	reverse(s.begin(),s.end());
	return s;
}
const ll quickpower(int n,int k)
{
	if(k==1)
	  return n;
	if(k%2==1)
	  return n*quickpower(n,k/2)*quickpower(n,k/2);
	else
	  return quickpower(n,k/2)*(quickpower(n,k/2));
}
/*
void merge(int a[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)
	{
	  l[i]=a[i+left];
    }
	for(int i=0;i<n2;i++)
	{
	  r[i]=a[mid+i];
	}
	r[n2]=l[n1]=INF;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++)
	{
		if(l[i]<=r[j])
		{
			a[k]=l[i++];
		}
		else
		{
			a[k]=r[j++];
		}
	}
}
void mergesort(int a[],int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}
int binsearch(int x,int v[],int n)
{
	int low=0,high=n-1;
	int mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(x<v[mid])
		  high=mid-1;
		else
		  if(x>v[mid])
		    low=mid+1;
		  else
		    return mid+1;
	}
	return -1;
}
int partition(int a[],int left,int right)
{
	int p=a[left];
	int i=left;
	int j=right+1;
	for(;;)
	{
		while(a[++i]<p)
		  if(i>=right)
		    break;
		while(a[j--]>p)
		  if(j<=left)
		    break;
		if(i>=j)
		  break;
		else
		  swap(a[i],a[j]);
	}
	if(j>=left)
	  return j;
	swap(a[left],a[j]);
	return j;
}
void quicksort(int a[],int left,int right)
{
	int q;
	while(right>left)
	{
		q=partition(a,left,right);
	    if(n-q+1==k)
	    {
	        cout<<a[q];
	  		exit(0);
		}
		quicksort(a,left,q-1);
		quicksort(a,q+1,right);
	}
}
void dfs(int n)
{
	if(use[n])
	  return;
	use[n]=true;
	cout<<n<<endl;
	for(int i=0;i<v[n].size();i++)
	  dfs(v[n][i]);
}*/
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
struct team
{
	int score;
	int in,out,game;
	string name;
} t[5],g[5];
map<string,int> mp;
vii ans;
bool less1(const team a,const team b)
{
	if(a.score!=b.score)
	{
		return a.score>=b.score;
	}
	else
	{
		if((a.in-a.out)!=(b.in-b.out))
		{
			return (a.in-a.out)>=(b.in-b.out);
		}
		else
		{
			if(a.in!=b.in)
			{
				return a.in>=b.in;
			}
			else
			{
				return a.name<=b.name;
			}
		}
	}
}
bool less2(pii a,pii b)
{
	if((a.first-a.second)!=(b.first-b.second))
	{
		return (a.first-a.second)<=(b.first-b.second);
	}
	else
	{
		if(a.second!=b.second)
		{
			return a.second<=b.second;
		}
	}
}
bool good(int c,int d,int a,int b)
{
	for(int i=1;i<5;i++)
	{
		g[i]=t[i];
	}
	string l=t[a].name;
	g[a].score+=3;
	g[a].in+=c;
	g[a].out+=d;
	g[b].in+=d;
	g[b].out+=c;
	sort(g+1,g+5,less1);
	for(int i=1;i<=2;i++)
	{
		if(g[i].name==l)
		{
			return 1;
		}
	}
	return 0;
}
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int l=1;
  rep(i,5)
  {
  	string a,b;
  	cin>>a>>b;
  	int c,d;
	scanf("%d:%d",&c,&d);
	if(c>d)
	{
		if(!mp[a])
		{
			mp[a]=l;
			t[l].score+=3;
			t[l].in+=c;
			t[l].out+=d;
			t[l].name=a;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[a]].score+=3;
			t[mp[a]].in+=c;
			t[mp[a]].out+=d;
			t[mp[a]].game++;
		}
		if(!mp[b])
		{
			mp[b]=l;
			t[l].in+=d;
			t[l].out+=c;
			t[l].name=b;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[b]].score+=0;
			t[mp[b]].in+=d;
			t[mp[b]].out+=c;
			t[mp[b]].game++;
		}
	}
	if(c==d)
	{
		if(!mp[a])
		{
			mp[a]=l;
			t[l].score+=1;
			t[l].in+=c;
			t[l].out+=d;
			t[l].name=a;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[a]].score+=1;
			t[mp[a]].in+=c;
			t[mp[a]].out+=d;
			t[mp[a]].game++;
		}
		if(!mp[b])
		{
			mp[b]=l;
			t[l].score+=1;
			t[l].in+=d;
			t[l].out+=c;
			t[l].name=b;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[b]].score+=1;
			t[mp[b]].in+=d;
			t[mp[b]].out+=c;
			t[mp[b]].game++;
		}
	}
	if(d>c)
	{
		if(!mp[a])
		{
			mp[a]=l;
			t[l].score+=0;
			t[l].in+=c;
			t[l].out+=d;
			t[l].name=a;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[a]].score+=0;
			t[mp[a]].in+=c;
			t[mp[a]].out+=d;
			t[mp[a]].game++;
		}
		if(!mp[b])
		{
			mp[b]=l;
			t[l].score+=3;
			t[l].in+=d;
			t[l].out+=c;
			t[l].name=b;
			t[l].game++;
			l++;
		}
		else
		{
			t[mp[b]].score+=3;
			t[mp[b]].in+=d;
			t[mp[b]].out+=c;
			t[mp[b]].game++;
		}
	}
  }
  /*for(int i=1;i<=4;i++)
  {
     cout<<t[i].name<<" "<<t[i].score<<" "<<t[i].in<<" "<<t[i].out<<endl;
  }*/
  int a=mp["BERLAND"],b=0;
  for(int i=1;i<=4;i++)
  {
  	if(i!=a&&t[i].game==2)
  	{
  	  b=i;
	  break;
	}
  }
  for(int i=1;i<=30;i++)
    rep(j,i)
    {
    	if(good(i,j,a,b))
    	{
    		ans.pb(pii(i,j));
		}
	}
  /*rep(i,ans.size()/2)
  {
  	cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }*/
  if(ans.size()==0)
  {
  	cout<<"IMPOSSIBLE"<<endl;
  	return 0;
  }
  sort(ans.begin(),ans.end(),less2);
  cout<<ans[0].first<<":"<<ans[0].second<<endl;
  return 0;
}

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
struct Node
{
	string name;
	int score;
	int goals;
	int dif;
	Node()
	{
		name = "";
		score = 0;
		goals = 0;
		dif = 0;
	}
	bool operator < (const Node& node) const
	{
		if (score != node.score) return score > node.score;
		if (dif != node.dif) return dif > node.dif;
		if (goals != node.goals) return goals > node.goals;
		return name < node.name;
	}
};
map<pair<string, string>, pair<int, int>> ms;
bool check()
{
	map<string, Node> mn;
	for (auto& p : ms)
	{
		string s1, s2;
		int x, y;
		tie(s1, s2) = p.first;
		tie(x, y) = p.second;
		if (s1 > s2) continue;
		if (!mn.count(s1)) mn[s1].name = s1;
		if (!mn.count(s2)) mn[s2].name = s2;
		mn[s1].dif += x - y;
		mn[s2].dif += y - x;
		mn[s1].goals += x;
		mn[s2].goals += y;
		if (x > y) mn[s1].score += 3;
		if (x == y) mn[s1].score++, mn[s2].score++;
		if (x < y) mn[s2].score += 3;
	}
	vector<Node> v;
	for (auto& p : mn) v.push_back(p.second);
	sort(v.begin(), v.end());
	if (v[0].name == "BERLAND" || v[1].name == "BERLAND") return true;
	return false;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string key = "BERLAND";
	vector<string> vs;
	map<string, int> cnt;
	for (int i = 0; i < 5; i++)
	{
		string s1, s2;
		int x, y;
		cin >> s1 >> s2;
		scanf("%d:%d", &x, &y);
		ms[{s1, s2}] = { x,y };
		ms[{s2, s1}] = { y,x };
		cnt[s1]++;
		cnt[s2]++;
	}
	for (auto& p : cnt)
	{
		if (p.second == 2)
			vs.push_back(p.first);
	}
	string s1 = vs[0], s2 = vs[1];
	if (s1 != key) swap(s1, s2);
	pair<int, int> ans = { int(INF),int(INF) };
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 0; j < i; j++)
		{
			ms[{s1, s2}] = { i,j };
			ms[{s2, s1}] = { j,i };
			if (check())
			{
				ans = min(ans, { i - j,j });
			}
		}
	}
	if (ans.first == INF) puts("IMPOSSIBLE");
	else printf("%d:%d\n", ans.first + ans.second, ans.second);
	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

int answer = 1000000,x=0,y=0;
typedef pair< string,pair<int,pair<int,int> > > nvm;

bool comp(const nvm &a, const nvm &b){
    if(a.second.first>b.second.first) return true;
    else if(a.second.first==b.second.first){
        int t1 = a.second.second.first - a.second.second.second;
        int t2 = b.second.second.first - b.second.second.second;
        if(t1>t2) return true;
        else if(t1==t2){
            if(a.second.second.first>b.second.second.first) return true;
            else if(a.second.second.first == b.second.second.first) return (a.first<b.first);
        }
    }
    return false;
}
int main(){
    char l;
    int s[2];
    string t[2];
    map< string, pair<int,pair<int,int> > > A;
    map< string, int> Mat;
    for(int i=0;i<5;i++){
        cin >> t[0] >> t[1];
        Mat[t[0]]++;
        Mat[t[1]]++;
        cin >> l; s[0] = l-'0';
        cin >> l>> l;  s[1] = l-'0';
        A[t[0]].second.first += s[0];
        A[t[0]].second.second += s[1];
        A[t[1]].second.first += s[1];
        A[t[1]].second.second += s[0];
        if(s[0]>s[1]) {
            A[t[0]].first += 3;
            A[t[1]].first += 0;
        }
        else if(s[0]==s[1]) {
            A[t[0]].first++;
            A[t[1]].first++;

        }
        else{
            A[t[0]].first+=0;
            A[t[1]].first+=3;
        }

    }

    string _1 = "BERLAND",_2;
    for(auto i = Mat.begin();i!=Mat.end();i++){
        if(i->first!=_1 && i->second==2) {
            _2 = i->first;
            break;
        }

    }
    for(int j=1;j<=100;j++){
        for(int k=j-1;k>=0;k--){
            vector< nvm > B;
            for(auto i = A.begin();i!=A.end();i++){
                if(i->first == _1){
                    pair<int, pair<int,int> > p = i->second;
                    p.first += 3;
                    p.second.first += j;
                    p.second.second += k;
                    B.push_back(make_pair(i->first,p));
                }
                else if(i->first == _2){
                    pair<int, pair<int,int> > p = i->second;
                    p.second.first += k;
                    p.second.second += j;
                    B.push_back(make_pair(i->first,p));
                }
                else {
                    pair<int, pair<int,int> > p = i->second;
                    B.push_back(make_pair(i->first,p));
                }
            }
           // cout << B.size() << endl;
            sort(B.begin(),B.end(),comp );
            if(B[0].first == _1 || B[1].first==_1) {
                if(answer>j-k){
                 answer = j-k;
                 x = j;
                 y = k;

                }else if(answer==j-k){
                  if(y>k){
                    x = j;
                    y = k;

                  }

                }

            }
        }
    }
    if(answer==1000000)
    cout << "IMPOSSIBLE";
    else{
    cout << x << ':' << y;

    }
    return 0;
}

#include<bits/stdc++.h>
#define r "BERLAND"
using namespace std;
int main()
{
map<string,int> defen,jishu,yingqiu,shuqiu;
int x,y,i;char a[28],b[28];
for (i=0;i<5;i++)
  {
  scanf("%s%s%d:%d",a,b,&x,&y);
  jishu[a]++,jishu[b]++;
  if (x>y) defen[a]+=3;
  if (x<y) defen[b]+=3;
  if (x==y) defen[a]++,defen[b]++;
  yingqiu[a]+=x,shuqiu[a]+=y;
  yingqiu[b]+=y,shuqiu[b]+=x;
  }
string nico;
vector<string> duiwu;
for (auto &s:jishu)
  {
  duiwu.push_back(s.first);
  if (s.second==2&&s.first!=r) nico=s.first;
  }
for (i=1;i<100;i++) for (int j=0;j<100;j++)
  {
  int k=i+j;
  yingqiu[r]+=k,shuqiu[r]+=j,defen[r]+=3;
  yingqiu[nico]+=j,shuqiu[nico]+=k;
  vector<tuple<int,int,int,string> > v;
  for (auto &s:duiwu) v.push_back(make_tuple(-defen[s],-yingqiu[s]+shuqiu[s],-yingqiu[s],s));
  sort(v.begin(),v.end());
  if (get<3>(v[0])==r||get<3>(v[1])==r) return printf("%d:%d",k,j),0;
  defen[r]-=3,yingqiu[r]-=k,shuqiu[r]-=j;
  yingqiu[nico]-=j,shuqiu[nico]-=k;
  }
printf("IMPOSSIBLE");
}

#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
string str[5];
int cnt[5]={0},sc[5]={0},num[5]={0},di[5]={0};
map <string,int> mp;
int n;
bool cmp(int x,int y)
{
	if(sc[x]!=sc[y])return sc[x]>sc[y];
	if(di[x]!=di[y])return di[x]>di[y];
    if(num[x]!=num[y])return num[x]>num[y];
    return str[x]<str[y];
}
int main()
{
	int n,m,c=1,ber=0,ot=0;
	string s,t;
	for(int i=0;i<5;i++)
	{
		cin>>s>>t;
		if(!mp.count(s)){
			str[c]=s;
			if(s=="BERLAND")ber=c;
			mp[s]=c;c++;
		}
		if(!mp.count(t)){
			str[c]=t;
			if(t=="BERLAND")ber=c;
			mp[t]=c;c++;
		}
		scanf("%d:%d",&n,&m);
		cnt[mp[s]]++,cnt[mp[t]]++;
		if(n>m)sc[mp[s]]+=3;
		if(n<m)sc[mp[t]]+=3;
		if(n==m)sc[mp[s]]++,sc[mp[t]]++;
		num[mp[s]]+=n,num[mp[t]]+=m;
		di[mp[s]]+=n-m,di[mp[t]]+=m-n;
	}
	for(int i=1;i<5;i++)
	    if(cnt[i]==2&&i!=ber){
	    	ot=i;
	    	break;
		}
	sc[ber]+=3;
	for(int i=1;i<=100;i++)
	    for(int j=0;j<=100;j++){
	    	int a=i+j,b=j;
	    	num[ber]+=a,num[ot]+=j;
	    	di[ber]+=i,di[ot]-=i;
	    	int c=0;
	    	for(int l=1;l<5;l++)if(l!=ber)c+=(int)cmp(ber,l);
	    	if(c>=2){
	    		cout<<a<<':'<<b;
	    		return 0;
			}
	    	num[ber]-=a,num[ot]-=j;
	    	di[ber]-=i,di[ot]+=i;
		}
	cout<<"IMPOSSIBLE";
	return 0;
}

// Problem : C. Football Championship
// Contest : Codeforces Round #126 (Div. 2)
// URL : https://codeforces.com/contest/200/problem/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define range(i, s, t)  for (int (i) = s; (i) <= (int)t; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c;
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
char team1[30], team2[30];
typedef pair <int, int> pii;
const string home = "BERLAND";
typedef pair <string, string> pss;
map <pss, pii> res;
map <string, int> goal;
map <string, int> dif;
map <string, int> score;
set <string> st;
set <string> played;
vector <string> teams;
int main() {
	repn(i, 5) {
		int x, y;
		scanf("%s %s %d:%d", team1, team2, &x, &y);
		string ta(team1), tb(team2);
		if (!st.count(ta)) {
			st.insert(ta);
			teams.pb(ta);
		}
		if (!st.count(tb)) {
			st.insert(tb);
			teams.pb(tb);
		}
		res[mp(ta, tb)] = mp(x, y);
		if (ta == home) played.insert(tb);
		else if (tb == home) played.insert(ta);
		if (x > y) score[ta] += 3;
		else if (x == y) score[ta]++, score[tb]++;
		else score[tb] += 3;
		goal[ta] += x; goal[tb] += y; dif[ta] += x;
		dif[ta] -= y; dif[tb] += y; dif[tb] -= x;
	}
	played.insert("BERLAND");
	sort(teams.begin(), teams.end(), [](string a, string b) {
		if (score[a] != score[b]) return score[a] > score[b];
		if (dif[a] != dif[b]) return dif[a] > dif[b];
		if (goal[a] != goal[b]) return goal[a] > goal[b];
		return a < b;
	});
	if (teams[0] == "BERLAND" || teams[1] == "BERLAND") {
		cout << "1:0" << endl;
		return 0;
	}
	string enemy;
	for (auto x:teams) if (!played.count(x)) {
		enemy = x;
		break;
	}
	//cerr << home << ' ' << enemy << endl;
	int ansx = 300, ansy = 0;
	rep(i, 300)
		rep(j, i) {
			score[home] += 3; goal[home] += i; dif[home] += i; dif[home] -= j;
			goal[enemy] += j; dif[enemy] += j; dif[enemy] -= i;

			sort(teams.begin(), teams.end(), [](string a, string b) {
				if (score[a] != score[b]) return score[a] > score[b];
				if (dif[a] != dif[b]) return dif[a] > dif[b];
				if (goal[a] != goal[b]) return goal[a] > goal[b];
				return a < b;
			});
			if (teams[0] == "BERLAND" || teams[1] == "BERLAND") {
				if (i - j < ansx - ansy) {
					ansx = i;
					ansy = j;
				}
				else if (i - j == ansx - ansy) {
					if (j < ansy) {
						ansx = i;
						ansy = j;
					}
				}
			}
			score[home] -= 3; goal[home] -= i; dif[home] -= i; dif[home] += j;
			goal[enemy] -= j; dif[enemy] -= j; dif[enemy] += i;
		}
	if (ansx == 300 && ansy == 0) puts("IMPOSSIBLE");
	else printf("%d:%d\n", ansx, ansy);
	return 0;
}

#include<bits/stdc++.h>
#define pii pair<int ,int>
#define f first//分数
#define s second//进球数-失球数
using namespace std;
map<string,int>mp;
int a[10][10];
int co;
inline bool better(int x,int y)
{
	pii x2,y2;
	int x3,y3;
	x3=y3=0;
	x2.f=x2.s=y2.f=y2.s=0;
	for(int i=0;i<4;i++)
	{
		if(i==x)continue;
		if(a[x][i]>a[i][x])x2.f+=3;
		if(a[x][i]==a[i][x])x2.f++;
		x2.s+=a[x][i]-a[i][x];
		x3+=a[x][i];
	}
	for(int i=0;i<4;i++)
	{
		if(i==y)continue;
		if(a[y][i]>a[i][y])y2.f+=3;
		if(a[y][i]==a[i][y])y2.f++;
		y2.s+=a[y][i]-a[i][y];
		y3+=a[y][i];
	}
	if(x2.f!=y2.f)return x2.f>y2.f;
	if(x2.s!=y2.s)return x2.s>y2.s;
	if(x3!=y3)return x3>y3;
	return x<y;
}
inline bool check(int x,int y)
{
	a[mp["BERLAND"]][co]=x;
	a[co][mp["BERLAND"]]=y;
	int rank=0;
	for(int i=0;i<4;i++)
	{
		if(i==mp["BERLAND"])continue;
		if(better(i,mp["BERLAND"]))rank++;
	}
	return rank<=1;
}
int main()
{
	bool f[10];
	memset(a,-1,sizeof(a));
	memset(f,false,sizeof(f));
	string s[10],t[10];
	int n[10],m[10];
	for(int i=0;i<5;i++)
	{
		cin>>s[i]>>t[i];
		scanf("%d:%d",&n[i],&m[i]);
	}
	for(int i=0;i<5;i++)mp[s[i]]=mp[t[i]]=0;
	vector<string>v;
	for(__typeof(mp.begin())it=mp.begin();it!=mp.end();it++)v.push_back((it->first));
	sort(v.begin(),v.end());
	for(int i=0;i<4;i++)mp[v[i]]=i;
	for(int i=0;i<5;i++)
	{
		a[mp[s[i]]][mp[t[i]]]=n[i];
		a[mp[t[i]]][mp[s[i]]]=m[i];
		if(s[i]=="BERLAND")f[mp[t[i]]]=true;
		if(t[i]=="BERLAND")f[mp[s[i]]]=true;
	}
	for(int i=0;i<4;i++)
		if(!f[i]&&i!=mp["BERLAND"])
			co=i;
	for(int i=1;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int lc=i+j;
			if(check(lc,j))
			{
				printf("%d:%d",lc,j);
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}
//佛祖保佑，我必Accepted

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#if LOCAL
	#define DO_NOT_SEND
#endif

typedef long long LL;

int IntMaxVal = (int) 1e20;
int IntMinVal = (int) -1e20;
LL LongMaxVal = (LL) 1e20;
LL LongMinVal = (LL) -1e20;

#define FOR(i, a, b) for(int i = a; i < b ; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)

template<typename T> inline void minimize(T &a, T b) { a = std::min(a, b); }
template<typename T> inline void maximize(T &a, T b) { a = std::max(a, b); }

#define all(v) v.begin(),v.end()

using namespace std;

#define endl '\n'
template<typename T> struct argument_type;
template<typename T, typename U> struct argument_type<T(U)> { typedef U type; };
#define next(t, i) argument_type<void(t)>::type i; cin >> i;
#define nextVector(t, v, size) vector< argument_type<void(t)>::type > v(size); { for (int i = 0 ; i < size ; i++) cin >> v[i]; }

#define range(name, start, count) vector<int> name(count); { for (int i = 0 ; i < count ; i++) name[i] = i + start; }

template <typename T1, typename T2> istream& operator >>(istream& is, pair<T1, T2>& s) { is >> s.first >> s.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T> &v) { for (int i = 0 ; i < v.size() ; i++) os << v[i] << ' '; os << endl; return os; }
template <typename T1, typename T2> ostream& operator <<(ostream& s, pair<T1, T2>& t) { s << t.first << ' ' << t.second; return s; }
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

class team {
	public:

	string name;
	int points;
	int gDiff;
	int gFor;
	int games;
};

bool sorter(const team &t1, const team &t2) {
	if (t1.points != t2.points) return t1.points < t2.points;
	if (t1.gDiff != t2.gDiff) return t1.gDiff < t2.gDiff;
	if (t1.gFor != t2.gFor) return t1.gFor < t2.gFor;
	return t1.name > t2.name;
}

int main() {
	srand (time(NULL));
    ios_base::sync_with_stdio(false); cin.tie(NULL);

	vector<team> teams;
	FOR (i, 0, 5) {
		next(string, s1);
		next(string, s2);
		int i1 = 0;
		while (i1 < teams.size() && teams[i1].name != s1) i1++;
		if (i1 == teams.size()) {
			teams.resize(teams.size() + 1);
			teams.back().points = 0;
			teams.back().gDiff = 0;
			teams.back().gFor = 0;
			teams.back().name = s1;
			teams.back().games = 0;
		}
		int i2 = 0;
		while (i2 < teams.size() && teams[i2].name != s2) i2++;
		if (i2 == teams.size()) {
			teams.resize(teams.size() + 1);
			teams.back().points = 0;
			teams.back().gDiff = 0;
			teams.back().gFor = 0;
			teams.back().name = s2;
			teams.back().games = 0;
		}
		next(string, res);
		int g1 = res[0] - '0';
		int g2 = res[2] - '0';
		if (g1 > g2) teams[i1].points += 3;
		else if (g1 < g2) teams[i2].points += 3;
		else {
			teams[i1].points++;
			teams[i2].points++;
		}
		teams[i1].gFor += g1;
		teams[i2].gFor += g2;
		teams[i1].gDiff += g1 - g2;
		teams[i2].gDiff += g2 - g1;
		teams[i1].games++;
		teams[i2].games++;
	}

	auto result  = make_pair(1, make_pair(0, 0));

	string berland = "BERLAND";
	int j1 = 0;
	while (teams[j1].name != berland) j1++;
	int j2 = 0;
	while (teams[j2].name == berland || teams[j2].games == 3) j2++;
	teams[j1].points += 3;

	FOR (x, 0, 100) FOR (y, 0, x) {
		vector<team> teams2(teams);
		teams2[j1].gFor += x;
		teams2[j1].gDiff += x - y;
		teams2[j2].gFor += y;
		teams2[j2].gDiff += y - x;

		sort(all(teams2), sorter);

		if (teams2[2].name == berland || teams2[3].name == berland) {
			minimize(result, make_pair(0, make_pair(x - y, y)));
		}
	}

	if (result.first == 1) cout << "IMPOSSIBLE";
	else cout << result.second.second + result.second.first << ':' << result.second.second;
}

#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
const int INF = 1000000007;

int main(){
    char a[25],b[25];
    int x,y;
    map<string,int> pts,cnt,goal,miss;
    for(int i=0;i<5;i++){
        scanf("%s%s%d:%d",a,b,&x,&y);
        cnt[a]++,cnt[b]++;
        if(x>y) pts[a]+=3;
        if(x<y) pts[b]+=3;
        if(x==y) pts[a]++,pts[b]++;
        goal[a]+=x,miss[a]+=y;
        goal[b]+=y,miss[b]+=x;
    }
    string at;
    vector<string> team;
    for(auto& s:cnt){
        team.push_back(s.first);
        if(s.second==2 && s.first!="BERLAND") at=s.first;
    }
    for(int i=1;i<100;i++){
        for(int k=0;k<100;k++){
            int j=i+k;
            goal["BERLAND"]+=j,miss["BERLAND"]+=k;
            goal[at]+=k,miss[at]+=j;
            pts["BERLAND"]+=3;
            vector<tuple<int,int,int,string>> u;
            for(auto& s:team) u.push_back(make_tuple(-pts[s],-goal[s]+miss[s],-goal[s],s));
            sort(u.begin(),u.end());
            if(get<3>(u[0])=="BERLAND"
            || get<3>(u[1])=="BERLAND") return printf("%d:%d",j,k),0;
            pts["BERLAND"]-=3;
            goal["BERLAND"]-=j,miss["BERLAND"]-=k;
            goal[at]-=k,miss[at]-=j;
        }
    }
    puts("IMPOSSIBLE");
}

#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define All(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)

struct Team
{
	string nam;
	int gro,win,goal,point;
};
map<string,Team> team;
vector<Team> v;
string ano;

inline bool cmp(Team a,Team b)
{
	if(a.point<b.point) return 0; else if(a.point>b.point) return 1;
	if(a.win<b.win) return 0; else if(a.win>b.win) return 1;
	if(a.goal<b.goal) return 0; else if(a.goal>b.goal) return 1;
	if(a.nam<b.nam) return 1; else if(a.nam>b.nam) return 0;
}

int main()
{
	rep(i,5)
	{
		string a,b;int x,y;
		cin>>a>>b;scanf("%d:%d",&x,&y);
		team[a].nam=a;team[b].nam=b;
		team[a].gro++;team[b].gro++;
		team[a].win+=(x-y);team[b].win+=(y-x);
		team[a].goal+=x;team[b].goal+=y;

		if(x>y) team[a].point+=3,team[b].point+=0; else if(x<y) team[b].point+=3,team[a].point+=0;
		else team[a].point++,team[b].point++;
	}

	repv(i,team) v.push_back(i->second);
	sort(All(v),cmp);

	repV(i,v) if(i.gro==2&&i.nam!="BERLAND") {ano=i.nam;break;}

	int x=0,y=0,cx=0,cy=0;
	for(int i=1;i<=1000;i++)
	{
		int m1,m2;
		rep(i,v.size()) if(v[i].nam=="BERLAND") m1=i; else if(v[i].nam==ano) m2=i;

		v[m1].goal++;
		if(i==1) v[m1].point+=3;
		v[m1].win++;v[m2].win--;
		sort(All(v),cmp);
		/*
		repV(i,v) cout<<i.nam<<' '<<i.win<<' '<<i.goal<<' '<<i.point<<endl;
		cout<<endl;
		*/
		if(v[0].nam=="BERLAND"||v[1].nam=="BERLAND") cx=i; else continue;

		vector<Team> V=v;
		for(int j=1;j<i;j++)
		{
			int m1,m2;
			rep(k,V.size()) if(V[k].nam=="BERLAND") m1=k; else if(V[k].nam==ano) m2=k;

			V[m2].goal++;
			V[m1].win--;V[m2].win++;
			sort(All(V),cmp);

			if(V[0].nam=="BERLAND"||V[1].nam=="BERLAND") cy=j;
		}

		if(x==0&&y==0||cx-cy<x-y||cx-cy==x-y&&cy<y) x=cx,y=cy;
	}

	if(x) cout<<x<<':'<<y; else cout<<"IMPOSSIBLE";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
char a[20][50],b[20][40];
string d[20];
int s1[20],s2[20],num[20];
map <string,int> M;
int id;
char boss[]="BERLAND";
int score[10];
int gol[10],mis[10];

bool ok(int y,int x){

	set <int> st;
	for(int i=1;i<=4;i++) st.insert(i);
	st.erase(id);
	// score
	int nn=0;
	for(int i=1;i<=4;i++) {
		if(i==id) continue;
		if(score[id]>score[i]) nn++,st.erase(i);
	}
	if(nn>=2) return 1;

	int mm=0;
	for(int i=1;i<=4;i++) {
		if(i==id) continue;
		if(score[id]<score[i]) mm++,st.erase(i);
	}
	if(mm>=2) return 0;
	// delta
	if(mm==1){
		auto it=st.begin();
		while(it!=st.end()){
			if(gol[*it]-mis[*it]>gol[id]-mis[id]) return 0;
			if(gol[*it]-mis[*it]<gol[id]-mis[id]) {
				st.erase(it);
				if(st.empty()) return 1;
				it=st.begin();
			}
			else it++;
		}
		if(st.empty()) return 1;
		it=st.begin();
		while(it!=st.end()){
			if(gol[*it]>gol[id]) return 0;
			if(gol[*it]<gol[id]) {
				st.erase(it);
				if(st.empty()) return 1;
				it=st.begin();
			}
			else it++;
		}
		if(st.empty()) return 1;
		it=st.begin();
		while(it!=st.end()){
			if(st.empty()) return 1;
			auto it=st.begin();
			if(*it<id) return 0;
			if(*it>id) {
				st.erase(it);
				if(st.empty()) return 1;
				it=st.begin();
			}
			else it++;
		}
	}

	int N=0;
	auto it=st.begin();
	while(it!=st.end()){
		if(st.empty()) return 1;
		if(gol[*it]-mis[*it]>gol[id]-mis[id]) {
			if(N) return 0;
			st.erase(it);
			N++;
			if(st.empty()) return 1;
			it=st.begin();
			continue;
		}
		if(gol[*it]-mis[*it]<gol[id]-mis[id]) {
			st.erase(it);
			if(st.empty()) return 1;
			it=st.begin();
		}
		else it++;
	}
	it=st.begin();
	while(it!=st.end()){
		if(st.empty()) return 1;
		if(gol[*it]>gol[id]) {
			if(N) return 0;
			st.erase(it);
			N++;
			if(st.empty()) return 1;
			it=st.begin();
			continue;
		}
		if(gol[*it]<gol[id]) {
			st.erase(it);
			if(st.empty()) return 1;
			it=st.begin();
		}
		else it++;
	}
	it=st.begin();
	while(it!=st.end()){
		if(st.empty()) return 1;
		auto it=st.begin();
		if(*it<id) {
			if(N) return 0;
			N++;
			st.erase(it);
			if(st.empty()) return 1;
			it=st.begin();
			continue;
		}
		if(*it>id) st.erase(it);
	}
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	for(int i=1;i<=5;i++){
		scanf("%s %s %d:%d",a+i,b+i,s1+i,s2+i);
//		cerr<<s1[i]<<' '<<s2[i]<<endl;
		d[i*2-1]=a[i];
		d[i*2]=b[i];
	}
	int cnt=10;
	sort(d+1,d+cnt+1);
	cnt=unique(d+1,d+cnt+1)-d-1;
	for(int i=1;i<=cnt;i++) M[d[i]]=i;
	id=M[boss];
	for(int i=1;i<=5;i++){
		num[M[a[i]]]++;
		num[M[b[i]]]++;
		if(s1[i]>s2[i]){
			score[M[a[i]]]+=3;
		}
		else if(s1[i]<s2[i]){
			score[M[b[i]]]+=3;
		}
		else {
			score[M[b[i]]]++;
			score[M[a[i]]]++;
		}
		gol[M[a[i]]]+=s1[i];
		mis[M[a[i]]]+=s2[i];
		gol[M[b[i]]]+=s2[i];
		mis[M[b[i]]]+=s1[i];
	}
	int ppp;
	for(int i=1;i<=4;i++){
		if(i==id) continue;
		if(num[i]<3) ppp=i;
	}
	int fl=1;
	int del=1000;
	int ansx=1000,ansy=1000;
	score[id]+=3;
	for(int i=0;i<300;i++){
		for(int j=i+1;j<=300;j++){
			gol[id]+=j;gol[ppp]+=i;
			mis[id]+=i;mis[ppp]+=j;

			if(ok(i,j)){
				fl=0;
				if(del>j-i){
					del=j-i;
					ansx=j;ansy=i;
				}
			}
			gol[id]-=j;gol[ppp]-=i;
			mis[id]-=i;mis[ppp]-=j;
		}
	}
	if(fl) puts("IMPOSSIBLE");
	else printf("%d:%d\n",ansx,ansy);
	return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

char s[20][100];
struct node{
    int a,b,c,i;
    bool operator<(node x)const{
        if (a > x.a)return true;
        else if(a==x.a){
            if (b > x.b) return true;
            else if (b == x.b){
                if (c > x.c) return true;
                else if (c == x.c && strcmp(s[i],s[x.i])==-1)return true;
            }
        }
        return false;
    }
};

int sum[10] = {0};
node f[10];

int main(){
    int i,x,y,first,second,ansx,ansy,m=0,x2;
    char s1[100],s2[100];
    for(i=1;i<=4;++i)f[i].a=f[i].b=f[i].c=0,f[i].i=i;
    for(i=1;i<=5;++i){
        scanf("%s%s%d:%d",s1,s2,&x,&y);
        //puts(s1);
        //puts(s2);
        for(first=1;first<=m;++first)if(strcmp(s[first],s1)==0)break;
        if(first>m){strcpy(s[++m],s1);}
        for(second=1;second<=m;++second)if(strcmp(s[second],s2)==0)break;
        if(second>m){strcpy(s[++m],s2);}
        //printf("%d %s %d %s\n",first,s1,second,s2);
        ++sum[first];  ++sum[second];
        if(x == y){
            f[first].a++;  f[second].a++;
        }else if(x < y){
            f[second].a += 3;
        }else{
            f[first].a += 3;
        }
        f[first].b += x-y;  f[second].b += y-x;
        f[first].c+=x;  f[second].c+=y;
    }
    //for(i=1;i<=m;++i)printf("%d",i),puts(s[i]);
    for(x2=1;x2<=4;++x2)if(strcmp(s[x2],"BERLAND")==0)break;
    //printf("%dx2\n",x2);
    ++sum[x2];
    x = 1;
    while (sum[x]==3)++x;
    //printf("%d  %d\n",x2,x);
    f[x2].a += 3;
    bool flag = false;
    for (ansx=1;ansx<=100;++ansx){
        for (ansy=0;ansx+ansy<200;++ansy){
            for(first=1;f[first].i!=x2;++first);
            for(second=1;f[second].i!=x;++second);
            f[first].b += ansx;  f[second].b -= ansx;
            f[first].c += ansx+ansy;  f[second].c += ansy;
            sort(f+1,f+5);
            //printf("sdf%d %d   ",ansx,ansy);
            //printf("%d %d %d %d\n",f[1].i,f[2].i,f[3].i,f[4].i);
            /*if (ansx == 1 && ansy == 11){
                for(i=1;i<=4;++i)printf("%d %d %d %d\n",f[i].i,f[i].a,f[i].b,f[i].c);
            }*/
            if(f[1].i == x2 || f[2].i == x2){ flag = true; break; }
            for(first=1;f[first].i!=x2;++first);
            for(second=1;f[second].i!=x;++second);
            f[first].b -= ansx;  f[second].b += ansx;
            f[first].c -= ansx+ansy;  f[second].c -= ansy;
        }
        if (flag) break;
    }
    if (!flag) puts("IMPOSSIBLE");
    else printf("%d:%d\n",ansx+ansy,ansy);
    return 0;
}

/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int pt[4],score[4],miss[4];
int player2;
string names[4];
bool cmp(int x,int y){
    if(pt[x]!=pt[y])return pt[x]<pt[y];
    if(score[x]-miss[x]!=score[y]-miss[y])return score[x]-miss[x]<score[y]-miss[y];
    if(score[x]!=score[y])return score[x]<score[y];
    return names[x]>names[y];
}
bool test(int x,int y){
    score[player2]+=y;
    miss[player2]+=x;
    miss[0]+=y;
    score[0]+=x;
    int d[4]={0,1,2,3};
    sort(d,d+4,cmp);
    score[player2]-=y;
    score[0]-=x;
    miss[player2]-=x;
    miss[0]-=y;
    return d[2]==0||d[3]==0;
}
map<string,int>name;
int _id;
int get(string s){
    if(name.count(s))return name[s];
    names[_id+1]=s;
    return name[s]=++_id;
}
int main(){
    names[0]="BERLAND";
    name["BERLAND"]=0;
    int cnt[4]={};
    REP(i,5){
        char s[24],t[24];
        RS(s);
        RS(t);
        int id[2]={get(s),get(t)};
        int x,y;
        scanf("%d:%d",&x,&y);
        cnt[id[0]]++;
        cnt[id[1]]++;
        if(x>y){
            pt[id[0]]+=3;
        }
        else if(x==y){
            pt[id[0]]++;
            pt[id[1]]++;
        }
        else{
            pt[id[1]]+=3;
        }
        score[id[0]]+=x;
        miss[id[0]]+=y;
        score[id[1]]+=y;
        miss[id[1]]+=x;
    }
    REPP(i,1,4){
        if(cnt[i]==2)player2=i;
    }
    pt[0]+=3;
    FOR(i,1,50){
        FOR(j,0,50){
            if(test(i+j,j)){
                printf("%d:%d\n",i+j,j);
                return 0;
            }
        }
    }
    W("IMPOSSIBLE");
    return 0;
}

/*
 *  Created on: Dec 25, 2013
 *      Author: Ghoooo
 */

#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
//#include <windows.h>

using namespace std;

#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((ll)v.size())
#define rep(i,m) for(int i=0;i<(int)(m);++i)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)
#define For(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define reset(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define dot(a,b) ((conj(a)*(b)).X)
#define X real()
#define Y imag()
#define length(V) (hypot((V).X,(V).Y))
#define vect(a,b) ((b)-(a))
#define cross(a,b) ((conj(a)*(b)).imag())
#define normalize(v) ((v)/length(v))
#define rotate(p,about,theta) ((p-about)*exp(point(0,theta))+about)
#define pointEqu(a,b) (comp(a.X,b.X)==0 && comp(a.Y,b.Y)==0)
#define clrq(x) while(!x.empty()) x.pop();
#define clrvv(v) rep(i,sz(v))v[i].clear();

typedef stringstream ss;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef complex<double> point;
typedef pair<point, point> segment;
typedef pair<double, point> circle;
typedef vector<point> polygon;
typedef unsigned long long ull;
typedef long long ll;

const int oo = (int) 1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
struct team{
	int points, forgoals, againstgoals;
	string name;
	team(){points=forgoals=againstgoals=0; name="";}
};
bool operator<(team a, team b){
	if(a.points != b.points) return a.points > b.points;
	if(a.forgoals-a.againstgoals != b.forgoals-b.againstgoals) return a.forgoals-a.againstgoals>b.forgoals-b.againstgoals;
	if(a.forgoals != b.forgoals) return a.forgoals > b.forgoals;
	return a.name < b.name;
}
int main(){
	ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
	map<string, int> dic;
	dic["BERLAND"] = 0;
	string a, b;
	int n, m;
	char c;
	int cnt = 1;
	team teams[4];
	bool playedwith[4] = {0};
	rep(i,5){
		cin >> a >> b;
		if(dic.find(a) == dic.end()) dic[a]=cnt,++cnt;
		if(dic.find(b) == dic.end()) dic[b]=cnt,++cnt;
		cin >> n >> c >> m;

		int t1 = dic[a], t2 = dic[b];
		if(n>m)teams[t1].points+=3;
		else if(n<m)teams[t2].points+=3;
		else teams[t1].points+=1,teams[t2].points+=1;

		teams[t1].forgoals+=n;
		teams[t2].forgoals+=m;

		teams[t1].againstgoals+=m;
		teams[t2].againstgoals+=n;

		teams[t1].name = a;
		teams[t2].name = b;
		if(t1 == 0 || t2 == 0) playedwith[t1]=playedwith[t2]=true;
	}
	string compname = "";
	int idx = 0, idx2;
	rep(i,4)if(playedwith[i]==false)idx2=i,compname=teams[i].name;
	//cout << endl << endl << "remaining match with: " << teams[idx2].name<<endl;

	//sort(teams,teams+4);
	//cout << setw(20) << "NAME" << setw(10) << "points" << setw(10) << "for" << setw(10) << "against" << endl;
	//rep(i,4)
//	cout << setw(20) << teams[i].name << setw(10) << teams[i].points << setw(10) << teams[i].forgoals << setw(10) << teams[i].againstgoals << endl;

		rep(k,4)if(teams[k].name=="BERLAND")idx=k; else if(teams[k].name == compname)idx2=k;
		teams[idx].points+=3;

		int b1=oo,b2=0;
	rep2(i,1,200){

		++teams[idx].forgoals;
		++teams[idx2].againstgoals;
		sort(teams,teams+4);
		rep(k,4)if(teams[k].name=="BERLAND")idx=k; else if(teams[k].name == compname)idx2=k;
		if(idx<=1){
			int val2 = 0;
			int f1 = teams[idx2].forgoals, f2=teams[idx].againstgoals;
			rep2(j,1,i){
				++teams[idx2].forgoals;
				++teams[idx].againstgoals;
				sort(teams,teams+4);
				rep(k,4)if(teams[k].name=="BERLAND")idx=k; else if(teams[k].name == compname)idx2=k;
				if(idx > 1) break;
				++val2;
			}
			teams[idx2].forgoals=f1,teams[idx].againstgoals=f2;
			if(i-val2 < b1-b2) b1=i,b2=val2;
		}
	}
	if(b1!=oo)cout<<b1<<":"<<b2<<endl;
	else
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#define l(s) int(s.size())
#define pb push_back
#define REP(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin())itr=(c).begin();itr!=(c).end();itr++)
string s1[10],s2[10],name[10],score[10];
map <string,int> mp;
int a[10][10];
bool better(int x,int y)
{
	int i;
	int px=0,py=0,mx=0,sx=0,sy=0,my=0;
	REP(i,4)
	{
		if(i!=x)
		{
			if(a[x][i]>a[i][x])
				sx+=3;
			else if(a[x][i]==a[i][x])
				sx++;
			px+=a[x][i];
			mx+=a[i][x];
		}
	}
	REP(i,4)
	{
		if(i!=y)
		{
			if(a[y][i]>a[i][y])
				sy+=3;
			else if(a[y][i]==a[i][y])
				sy++;
			my+=a[i][y];
			py+=a[y][i];
		}
	}
	if(sx!=sy)
		return (sx>sy);
	if(px-mx!=py-my)
		return (px-mx>py-my);
	if(px!=py)
		return (px>py);
	return (x<y);
}
bool check(int x,int y)
{
	int i,c;
	int b=mp["BERLAND"];
	REP(i,4)
		if(i!=b&&a[b][i]==-1)
			c=i;
	a[b][c]=x;
	a[c][b]=y;
	int rank=1;
	REP(i,4)
	{
		if(i!=b&&better(i,b))
			rank++;
	}
	a[b][c]=a[c][b]=-1;
	return (rank<=2);
}
int main()
{
	int d,i,j;
	REP(i,5)
		cin>>s1[i]>>s2[i]>>score[i];
	REP(i,5)
		mp[s1[i]]=mp[s2[i]]=0;
	i=0;
	foreach(mp,itr)
	{
		(itr->second)=i;
		name[i]=(itr->first);
		i++;
	}
	REP(i,4)
		REP(j,4)
			a[i][j]=-1;
	REP(i,5)
	{
		int x=mp[s1[i]],y=mp[s2[i]];
		REP(j,score[i].length())
			if(score[i][j]==':')
				score[i][j]=' ';
		istringstream ss(score[i]);
		ss>>a[x][y]>>a[y][x];
	}
	for(d=1;d<100;d++)
		REP(i,100)
		{
			j=i+d;
			if(check(j,i))
			{
				cout<<j<<':'<<i<<endl;
				return 0;
			}
		}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

//gskhirtladze

#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
#include<queue>
#include<fstream>
#include<string>
#include<stack>

using namespace std;

long long i,j,m,k,l,o,X,Y,aj;
long long mp;
bool b1,b2;
char c;
long long a1,a2;
map <string,long long> fix;

string s1,s2;

struct name
 {
  string s;
  long long n,pla,p,g,d;
  long long ind;
 };

bool operator<(name A,name B)
 {
  return (A.p>B.p || ( A.p == B.p && ( A.n>B.n || ( A.n  == B.n && (A.g>B.g || (A.g == B.g && A.s<B.s))))));
 }

name a[111];
name b[111];

main()
{
 Y=0;
 X=10000000;
 for (i=1;i<=5;i++)
  {
   cin>>s1>>s2;
   if (fix[s1] == 0)
    {
     k++;
     a[k].s=s1;
     fix[s1]=k;
     a[k].ind=k;
    }
   if (fix[s2] == 0)
    {
     k++;
     a[k].s=s2;
     fix[s2]=k;
     a[k].ind=k;
    }
   a[fix[s1]].pla++;
   a[fix[s2]].pla++;
   scanf("%d%c%d",&a1,&c,&a2);
   a[fix[s1]].g+=a1;
   a[fix[s2]].g+=a2;
   a[fix[s1]].d+=a2;
   a[fix[s2]].d+=a1;
   if (a1 == a2)
    {
     a[fix[s1]].p++;
     a[fix[s2]].p++;
    }
   if (a1>a2) a[fix[s1]].p+=3;
   if (a1<a2) a[fix[s2]].p+=3;
  }
 for (i=1;i<=4;i++)
  a[i].n=a[i].g-a[i].d;
 for (i=1;i<=4;i++)
  if (a[i].s == "BERLAND") break;
 a1=i;
 a[a1].p+=3;
 for (i=1;i<=4;i++)
  if (a[i].pla == 2 && i != a1) break;
 a2=i;
 for (i=0;i<=500;i++)
  for (j=i+1;j<=500;j++)
   {
    a[a1].g+=j;
    a[a1].d+=i;
    a[a1].n=a[a1].g-a[a1].d;
    a[a2].g+=i;
    a[a2].d+=j;
    a[a2].n=a[a2].g-a[a2].d;
    for (k=1;k<=4;k++)
     {
      b[k].s=a[k].s;
      b[k].ind=a[k].ind;
      b[k].p=a[k].p;
      b[k].n=a[k].n;
      b[k].g=a[k].g;
      b[k].d=a[k].d;
      b[k].pla=a[k].pla;
     }
    sort(b+1,b+5);
    if (b[1].s == "BERLAND" || b[2].s == "BERLAND")
     {
      if (b[1].s == "BERLAND") aj=1; else aj=2;
      if (j-i < X-Y)
       {
        X=j;Y=i;
       } else
      if (j-i == X-Y)
       {
        if (i<Y)
         {
          Y=i; X=j;
         }
       }
     }
    a[a1].g-=j;
    a[a1].d-=i;
    a[a1].n=a[a1].g-a[a1].d;
    a[a2].g-=i;
    a[a2].d-=j;
    a[a2].n=a[a2].g-a[a2].d;
   }
 if (X > 10000)
  {
   cout<<"IMPOSSIBLE"<<endl;
   return 0;
  }
 cout<<X<<":"<<Y<<endl;
}

#include<bits/stdc++.h>
#define NN 30

using namespace std;
using INT=long long ;

map<string, int> win, los, sco, mp;

const string B="BERLAND";
vector<string>name;

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif

	for(int i=1; i<=5; i++){
		string a, b;
		cin>>a>>b;

		int c, d;
		scanf("%d:%d", &c, &d);
		win[a]+=c, los[a]+=d;
		win[b]+=d, los[b]+=c;
		if(c==d)sco[a]++, sco[b]++;
		else if(c>d)sco[a]+=3;
		else sco[b]+=3;
		if(!mp.count(a))name.push_back(a);
		if(!mp.count(b))name.push_back(b);
		mp[a]++;
		mp[b]++;
	}

	sco[B]+=3;
	int t=0;
	vector<string>res;

	for(int i=0; i<4; i++){
		if(name[i]==B)continue;
		if(sco[name[i]]>=sco[B])res.push_back(name[i]);
		if(sco[name[i]]>sco[B])t++;
	}

	if(res.size()==0){
		puts("1:0");
		return 0;
	}

	for(int i=0; i<=100; i++){
		int x=win[B], y=los[B];

		for(int j=0; j<=100; j++){
			int w=x+i+j, l=y+j, cnt=0;
			for(int k=0; k<res.size(); k++){
				if(sco[res[k]]>sco[B])continue;
				if(mp[res[k]]==3){
					int a=win[res[k]], b=los[res[k]];
					if(a-b<w-l)continue;
					if(a-b>w-l){
						cnt++;
						continue;
					}
					if(w>a)continue;
					if(a>w){
						cnt++;
						continue;
					}
					if(res[k]<B)cnt++;
				}
				if(mp[res[k]]==2){
					int a=win[res[k]], b=los[res[k]];
					a+=j, b+=(i+j);
					if(w-l>a-b)continue;
					if((a-b)>(w-l)){
						cnt++;
						continue;
					}
					if(w>a)continue;
					if(w<a){
						cnt++;
						continue;
					}
					if(res[k]<B)cnt++;
				}
			}

			if(cnt<2-t){
				int c=i+j, d=j;
				c=max(c, d+1);
				printf("%d:%d\n", c, d);
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");

	return 0;
}

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<utility>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
struct team
{
	string name;
	int goal, lost, score, match;
	inline void Set(string n)
	{
		name = n;
		goal = lost = score = 0;
	}
	bool operator < (team &e) const
	{
		if (score != e.score) return score > e.score;
		if (goal-lost != e.goal-e.lost) return goal-lost > e.goal-e.lost;
		if (goal != e.goal) return goal > e.goal;
		return name < e.name;
	}
} w[10], t[10];
inline bool cmp(ii a, ii b)
{
	if (a.first-a.second != b.first-b.second) return a.first-a.second < b.first-b.second;
	return a.second < b.second;
}
map<string, int> m;
vector<ii> ans;
const string me = "BERLAND";
int main(void)
{
	int idx = 0, opp;
	for(int i = 0; i < 5; i++)
	{
		string a, b;
		int c, d;
		cin>>a>>b;
		scanf("%d:%d", &c, &d);
		if (!m.count(a)) m[a] = idx++, w[m[a]].Set(a);
		if (!m.count(b)) m[b] = idx++, w[m[b]].Set(b);
		w[m[a]].goal+=c;
		w[m[a]].lost+=d;
		w[m[b]].goal+=d;
		w[m[b]].lost+=c;
		if (c > d) w[m[a]].score+=3;
		else if (c == d) w[m[a]].score+=1, w[m[b]].score+=1;
		else w[m[b]].score+=3;
		w[m[a]].match++;
		w[m[b]].match++;
	}
	for(int i = 0; i < 4; i++) if (w[i].match == 2 && w[i].name != me) opp = i;
	for(int x = 0; x <= 100; x++)
		for(int y = 0; y <= 100; y++)
		{
			if (x <= y) continue;
			for(int i = 0; i < 4; i++) t[i] = w[i];
			t[m[me]].goal+=x;
			t[m[me]].lost+=y;
			t[opp].goal+=y;
			t[opp].lost+=x;
			if (x > y) t[m[me]].score+=3;
			else if (x == y) t[m[me]].score+=1, t[opp].score+=1;
			else t[opp].score+=3;
			sort(t, t+4);
			if (t[0].name == me || t[1].name == me) ans.push_back(make_pair(x, y));
		}
	if (ans.empty())
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	sort(ans.begin(), ans.end(), cmp);
	cout<<ans[0].first<<':'<<ans[0].second<<endl;
	return 0;
}

//#include <bits/stdc++.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <functional>
#include <map>
#include <ios>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#include <conio.h>
#include <numeric>
#include <list>
#include <windows.h>
#include <cfloat>
#include <climits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double ld;
typedef pair<int,int> pii;
#define ui(n) ((unsigned int)(n))
#define ll(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((double)(n))
#define fixpoint(n) fixed<<setprecision(n)
const int INF=1e9+7;
const ll LINF=1e18;
#define MP make_pair
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define mod 1000000007
#define sz(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
vector<string> team;
int point[4],goal[4],miss[4],res[4][4],match[4];
int find(string s)
{
	for(int i=0;i<team.size();i++)
		if(team[i]==s) return i;
	team.push_back(s);
	return team.size()-1;
}
bool cmp(int x,int y)
{
	if(point[x]!=point[y]) return point[x]>point[y];
	if(goal[x]-miss[x]!=goal[y]-miss[y])
		return goal[x]-miss[x]>goal[y]-miss[y];
	if(goal[x]!=goal[y]) return goal[x]>goal[y];
	return team[x]<team[y];
}
int ok(int a,int b,int x,int y)
{
	goal[a]+=x;
	goal[b]+=y;
	miss[a]+=y;
	miss[b]+=x;
	res[a][b]=x;
	res[b][a]=y;
	vector<int> order;
	for(int i=0;i<4;i++) order.push_back(i);
	sort(order.begin(),order.end(),cmp);
	if(a==order[0]||a==order[1]) return 1;
	goal[a]-=x;
	goal[b]-=y;
	miss[a]-=y;
	miss[b]-=x;
	return 0;
}
int main()
{
	for(int i=0;i<5;i++)
	{
		string A,B,s;
		cin>>A>>B>>s;
		int a=find(A),b=find(B),x=s[0]-'0',y=s[2]-'0';
		if(x>y) point[a]+=3;
		else
			if(x<y) point[b]+=3;
			else point[a]++,point[b]++;
		goal[a]+=x;
		goal[b]+=y;
		miss[a]+=y;
		miss[b]+=x;
		res[a][b]=x;
		res[b][a]=y;
		match[a]++;
		match[b]++;
	}
	int ber=find("BERLAND"),oppo;
	for(int i=0;i<4;i++)
		if(i!=ber&&match[i]<3) oppo=i;
	point[ber]+=3;
	for(int dif=1;dif<=100;dif++)
		for(int y=0;y<=100;y++)
		{
			int x=y+dif;
			if(ok(ber,oppo,x,y))
			{
				cout<<x<<':'<<y<<endl;
				return 0;
			}
		}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout << #x << ": " << x << endl
#define clr(x,v) memset(x, v, sizeof(x))
#define dblout(x) cout << setprecision(x) << fixed;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

struct team
{
    string name;
    int points, scored, missed;
    team(): name(""), points(0), scored(0), missed(0) {}
    team(string name, int points, int scored, int missed): name(name), points(points),
        scored(scored), missed(missed) {}
    const bool operator<(const team &u)const
    {
        // more points first
        if(points != u.points)
            return points > u.points;
        // more scored-missed difference first
        if(scored - missed != u.scored - u.missed)
            return scored - missed > u.scored - u.missed;
        // more goals scored first
        if(scored != u.scored)
            return scored > u.scored;
        // smaller name first
        return name < u.name;
    }
};

void cp()
{
    map<string, team> team_data;
    map<string, int> games_played;
    for(int i = 0; i < 5; i++)
    {
        string a, b, c;
        cin >> a >> b >> c;
        int sa = c[0] - '0', sb = c[2] - '0';
        games_played[a]++, games_played[b]++;

        if(sa < sb)
            swap(sa, sb), swap(a, b);

        int pa = 0, pb = 0;
        if(sa > sb) // team a won
            pa = 3;
        else // draw
            pa = 1, pb = 1;

        team_data[a].points += pa, team_data[a].scored += sa, team_data[a].missed += sb;
        team_data[b].points += pb, team_data[b].scored += sb, team_data[b].missed += sa;
    }

    vector<team> teams;
    for(pair<string, team> u : team_data)
        u.ss.name = u.ff, teams.pb(u.ss);

    string me = "BERLAND", other;
    for(team u : teams)
        if(games_played[u.name] == 2 && u.name != me)
            other = u.name;

    sort(all(teams));

    auto check = [&](int v, int w)
    {
        vector<team> temp = teams;
        for(team &u : temp)
        {
            if(u.name == me)
                u.points += 3, u.scored += v, u.missed += w;
            else if(u.name == other)
                u.missed += v, u.scored += w;
        }

        sort(all(temp));
        // Did i win?
        return (temp[0].name == me || temp[1].name == me);
    };

    pi best = {2000, 1000};

    for(int x = 1; x <= 20; x++)
        for(int y = 0; y < x; y++)
            if(check(x, y))
                if((x - y < best.ff - best.ss) || ((x - y == best.ff - best.ss) && (y < best.ss)))
                    best = {x, y};

    if(best.ff > 20)
        cout << "IMPOSSIBLE\n";
    else
        cout << best.ff << ":" << best.ss << endl;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<string,pair<int,pair<int,int> > > mp;
vector<pair<pair<int,pair<int,int> >,string > > v,tmp;
set<string> name;
vector<string> al;
string teamA,teamB,score;
int solve(int a,int b) {
	if(a>b){
		return 3;
	}else if(a==b){
		return 1;
	}else{
		return 0;
	}
}
bool cmp(pair<pair<int,pair<int,int> >,string >  x,pair<pair<int,pair<int,int> >,string >  y) {
	if(x.first.first!=y.first.first) {
		return x.first.first<y.first.first;
	}
	if(x.first.second.first!=y.first.second.first) {
		return x.first.second.first<y.first.second.first;
	}
	if(x.first.second.second!=y.first.second.second) {
		return x.first.second.second<y.first.second.second;
	}
	return x.second>y.second;
}
int main() {
	for(int i=1;i<=5;i++) {
		cin>>teamA>>teamB>>score;
		name.insert(teamA);
		name.insert(teamB);
		if(teamA=="BERLAND") {
			al.push_back(teamB);
		}
		if(teamB=="BERLAND") {
			al.push_back(teamA);
		}
		int ga=score[0]-'0',gb=score[2]-'0';
		mp[teamA].first+=solve(ga,gb);
		mp[teamA].second.first+=(ga-gb);
		mp[teamA].second.second+=ga;
		mp[teamB].first+=solve(gb,ga);
		mp[teamB].second.first+=(gb-ga);
		mp[teamB].second.second+=gb;
	}
	for(int i=0;i<al.size();i++) {
		name.erase(al[i]);
	}
	name.erase("BERLAND");
	string no=*name.begin();
	for(map<string,pair<int,pair<int,int> > >::iterator it=mp.begin();it!=mp.end();it++) {
		v.push_back(make_pair(it->second,it->first));
	}
	int idm,opp;
	for(int i=0;i<v.size();i++) {
		if(v[i].second=="BERLAND") {
			idm=i;
		}else if(v[i].second==no) {
			opp=i;
		}
	}
	tmp=v;
	sort(v.rbegin(),v.rend());
	int sec=v[1].first.first;
	int ind;
	for(int i=0;i<v.size();i++) {
		if(v[i].second=="BERLAND") {
			ind=i;
			break;
		}
	}
	int mys=v[ind].first.first;
	if(mys+3<sec) {
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	v=tmp;
	for(int i=1;i<100;i++) {
		for(int y=0;y<=100;y++) {
			int x=y+i;
			v[idm].first.first+=solve(x,y);
			v[idm].first.second.first+=i;
			v[idm].first.second.second+=x;
			v[opp].first.first+=solve(y,x);
			v[opp].first.second.first-=i;
			v[opp].first.second.second+=y;
			sort(v.rbegin(),v.rend(),cmp);
			int pos;
			for(int j=0;j<v.size();j++) {
				if(v[j].second=="BERLAND") {
					pos=j;
					break;
				}
			}
			if(pos<=1) {
				cout<<x<<":"<<y<<endl;
				return 0;
			}
			v=tmp;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
#define r "BERLAND"
using namespace std;
int main()
{
map<string,int> defen,jishu,yingqiu,shuqiu;
int x,y,i;char a[28],b[28];
for (i=0;i<5;i++)
  {
  scanf("%s%s%d:%d",a,b,&x,&y);
  jishu[a]++,jishu[b]++;
  if (x>y) defen[a]+=3;
  if (x<y) defen[b]+=3;
  if (x==y) defen[a]++,defen[b]++;
  yingqiu[a]+=x,shuqiu[a]+=y;
  yingqiu[b]+=y,shuqiu[b]+=x;
  }
string nico;
vector<string> duiwu;
for (auto &s:jishu)
  {
  duiwu.push_back(s.first);
  if (s.second==2&&s.first!=r) nico=s.first;
  }
for (i=1;i<100;i++) for (int j=0;j<100;j++)
  {
  int k=i+j;
  yingqiu[r]+=k,shuqiu[r]+=j,defen[r]+=3;
  yingqiu[nico]+=j,shuqiu[nico]+=k;
  vector<tuple<int,int,int,string> > v;
  for (auto &s:duiwu) v.push_back(make_tuple(-defen[s],-yingqiu[s]+shuqiu[s],-yingqiu[s],s));
  sort(v.begin(),v.end());
  if (get<3>(v[0])==r||get<3>(v[1])==r) return printf("%d:%d",k,j),0;
  defen[r]-=3,yingqiu[r]-=k,shuqiu[r]-=j;
  yingqiu[nico]-=j,shuqiu[nico]-=k;
  }
printf("IMPOSSIBLE");
}

#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define fit(ta, a) for(ta::iterator i = a.begin(); i != a.end(); advance(i, 1))
#define rep(i, a, n) for(int i = a; i < n; i++)
#define dec(i, a, n) for(int i = a; i >= n; i--)
#define clr(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define debug printf
#define ler freopen("in","r",stdin)
#define MAXN 101010
typedef long long lint;
using namespace std;

map<string, int>tim;
int n=2;
string vet[20];

int comp(int a, int b, vector<int>pnts, vector<int>s,vector<int>g){
	if(pnts[a]!=pnts[b]) return pnts[a]>pnts[b];
	if(s[a] != s[b]) return s[a] > s[b];
	if(g[a]!=g[b]) return g[a]>g[b];
	return vet[a] < vet[b];
}

int melhor(int x, int y, int px, int py, vector<int>pnts, vector<int>s,vector<int>g){
	int ganha = 0;
	pnts[1]+=3,s[1]+=x-y,g[1]+=x;
	s[2]+=y-x,g[2]+=y;
	int perde = 0;
	rep(i,2,n) if(comp(i,1,pnts,s,g)) perde++;
	if(perde>1) return 0;
	if(px==-1) return 1;
	if(x-y != px-py) return x-y < px-py;
	return y < py;
}

int main(){
	vector<int>pnts(20,0),s(20,0),g(20,0),q(20,0);
	tim["BERLAND"] = 1;
	vet[1] = "BERLAND";
	rep(i,0,5){
		char ta[30], tb[30];
		int pa, pb;
		char c;
		scanf("%s %s %1d %c %1d", ta, tb, &pa, &c, &pb);
		string a(ta), b(tb);
		if(!tim[a]) tim[a] = n++;
		if(!tim[b]) tim[b] = n++;
		q[tim[a]]++, q[tim[b]]++;
		if(pa > pb) pnts[tim[a]]+=3;
		if(pb > pa) pnts[tim[b]]+=3;
		if(pa==pb) pnts[tim[a]]++, pnts[tim[b]]++;
		g[tim[a]] += pa; s[tim[a]] += pa-pb;
		g[tim[b]] += pb; s[tim[b]] += pb-pa;
		vet[tim[a]] = a, vet[tim[b]] = b;
	}
	rep(i,3,n) if(q[i]==2) swap(pnts[i],pnts[2]), swap(q[i],q[2]), swap(g[i],g[2]), swap(s[i],s[2]), swap(vet[i], vet[2]);
	int x = -1, y = -1;
	rep(i,0,30) rep(j,0,i){
		if(melhor(i,j,x,y,pnts,s,g)) x = i, y = j;
	}
	if(x==-1) printf("IMPOSSIBLE\n");
	else printf("%d:%d\n",x,y);
}

#include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
struct aa{int q,m,p;};
aa f[200];
int i,j,p,su,ss1,ss2,t1,t2,sum[200],len;
string ch1,ch2,s[10];
bool da(int t)
{
	if (t==ss1)
		return false;
	if (f[t].p!=f[ss1].p)
		return f[t].p>f[ss1].p;
	if (f[t].m!=f[ss1].m)
		return f[t].m>f[ss1].m;
	if (f[t].q!=f[ss1].q)
		return f[t].q>f[ss1].q;
	return s[t]<s[ss1];
}
int get(string a)
{
	for (int i=1;i<=len;i++)
	if (s[i]==a)
	return i;
	s[++len]=a;
	return len;
}
void read(int &k)
{
	char q;
	for (q=getchar();q<'0'||q>'9';q=getchar());
	k=q-'0';
}
int main()
{
	for (i=1;i<=5;i++)
	{
		cin>>ch1>>ch2;
		ss1=get(ch1);
		ss2=get(ch2);
		sum[ss1]++;
		sum[ss2]++;
		read(t1);
		read(t2);
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
	}
	for (i=1;i<=4;i++)
	if (s[i]=="BERLAND")
		ss1=i;
	else
	if (sum[i]<3)
		ss2=i;
	for (i=1;i<=35;i++)
	for (j=0;j<=35;j++)
	{
		t2=j;
		t1=j+i;
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
		su=0;
		for (p=1;p<=4;p++)
		if (da(p))
			su++;
		if (su<2)
		{
			printf("%d:%d",t1,t2);
			return 0;
		}
		f[ss1].m-=t1-t2;
		f[ss2].m-=t2-t1;
		f[ss1].q-=t1;
		f[ss2].q-=t2;
		if (t1>t2)
			f[ss1].p-=3;
		else
		if (t1<t2)
			f[ss2].p-=3;
		else
		{
			f[ss1].p--;
			f[ss2].p--;
		}
	}
	printf("IMPOSSIBLE");
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

map<string, int> teams;
map<int, string> name;

string inputs[5][3];

int gamesPlayed[6];
int scored[6];
int missed[6];
int points[6];

int tscored[4], tmissed[4], tpoints[4];

int a1;
int a2 = IINF;
int curDiff = IINF;

void check(int res1, int res2, int berlandTeam, int opponentTeam) {
	//res1 is num berland scored

	for (int i = 0; i < 4; i++) {
		tscored[i] = scored[i]; tmissed[i] = missed[i]; tpoints[i] = points[i];
	}

	for (int j = 0; j < 2; j++) {
		int teamID = (j == 0 ? berlandTeam : opponentTeam);

		if (res1 > res2) {
			tpoints[teamID] += 3;
		} else if (res1 == res2) {
			tpoints[teamID]++;
		}

		tscored[teamID] += res1;
		tmissed[teamID] += res2;

		if (j == 0) {
			swap(res1, res2);
		}
	}
	swap(res1, res2);

	vector<pair<int, pair<int, pair<int, string>>>> result;

	for (int i = 0; i < 4; i++) {
		result.pb(mp(-tpoints[i], mp(-(tscored[i] - tmissed[i]), mp(-tscored[i], name[i]))));
	}
	sort(all(result));

	bool good = false;
	for (int i = 0; i < 2; i++) {
		if (result[i].second.second.second == "BERLAND") {
			good = true;
		}
	}

	if (good) {
		int thisDiff = res1 - res2;

		if (thisDiff < curDiff) {
			curDiff = thisDiff;
			a1 = res1; a2 = res2;
		} else if (thisDiff == curDiff) {
			if (res2 < a2) {
				a1 = res1; a2 = res2;
			}
		}
	}
}

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> inputs[i][j];
		}
	}

	int counter = 0;

	//cout << "here " << endl;

	for (int i = 0; i < 5; i++) {
		int res1 = inputs[i][2][0] - '0';
		int res2 = inputs[i][2][2] - '0';

		for (int j = 0; j < 2; j++) {
			if (teams.find(inputs[i][j]) == teams.end()) {
				teams[inputs[i][j]] = counter;
				name[counter] = inputs[i][j];
				counter++;
			}

			int teamID = teams[inputs[i][j]];
			//cout << i << ' ' << j << " teamID is " << teamID << endl;
			gamesPlayed[teamID]++;

			if (res1 > res2) {
				points[teamID] += 3;
			} else if (res1 == res2) {
				points[teamID]++;
			}

			scored[teamID] += res1;
			missed[teamID] += res2;

			if (j == 0) {
				swap(res1, res2);
			}
		}
	}

	//cout << "checked inputs " << endl;

	int berlandTeam = teams["BERLAND"];
	int opponentTeam = -1;

	for (int i = 0; i < 4; i++) {
		if (gamesPlayed[i] == 2 && name[i] != "BERLAND") {
			opponentTeam = i;
		}
	}

	a1 = -1;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < i; j++) {
			check(i, j, berlandTeam, opponentTeam);
		}
	}

	if (a1 == -1) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << a1 << ':' << a2 << endl;
	}
}

//GCD GCD GCD USE GCD IN MATH

#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define MAXN 100005
#define INF 100000000000000
#define sc(i) scanf("%d",&i);
#define pr(i) printf("%d\n",i);
#define mk(i,j) make_pair(i,j);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> iPair;

struct node{
    string name;
    int SG,MG,points=0;
};

bool compareinterval(node a,node b){
    if(a.points!=b.points)
        return a.points<b.points;
    else{
        int d1=a.SG-a.MG;
        int d2=b.SG-b.MG;
        if(d1!=d2)
            return d1<d2;
        else{
            if(a.SG!=b.SG)
                return a.SG<b.SG;
            else
                return (a.name>b.name);
        }
    }
}

map<string,node> mp;
map<string,int> mp1;
int ansx=100,ansy=0;
int main(){
    for(int i=0;i<5;i++){
        string s1,s2,s3;
        cin>>s1>>s2>>s3;
        mp1[s1]++;mp1[s2]++;
        int score=s3[0]-'0';
        int miss=s3[2]-'0';
        if(mp.find(s1)!=mp.end()){
            mp[s1].SG+=score;
            mp[s1].MG+=miss;
        }
        else{
            mp[s1].name=s1;
            mp[s1].SG+=score;
            mp[s1].MG+=miss;
        }
        if(mp.find(s2)!=mp.end()){
            mp[s2].SG+=miss;
            mp[s2].MG+=score;
        }
        else{
            mp[s2].name=s2;
            mp[s2].SG+=miss;
            mp[s2].MG+=score;
        }
        if(score>miss) mp[s1].points+=3;
        else if(score==miss){
            mp[s1].points+=1;
            mp[s2].points+=1;
        }
        else mp[s2].points+=3;
    }

    //now real game starts.
    string str1="BERLAND",str2;
    for(auto e:mp1){
        if(e.S==2 && e.F!="BERLAND")
            str2=e.F;
    }
    // for(auto e:mp){
    //     cout<<e.S.name<<" "<<e.S.SG<<" "<<e.S.MG<<" "<<e.S.points<<endl;
    // }
    for(int i=1;i<=20;i++){
        for(int j=i-1;j>=0;j--){
            bool ok=0;
            map<string,node> copy(mp.begin(),mp.end());
            copy[str1].points+=3;
            copy[str1].SG+=i;copy[str1].MG+=j;
            copy[str2].SG+=j;copy[str2].MG+=i;
            vector<node> vt;
            for(auto e:copy){
                vt.pb(e.S);
                // cout<<e.S.name<<" "<<e.S.SG<<" "<<e.S.MG<<" "<<e.S.points<<endl;
            }
            sort(vt.begin(),vt.end(),compareinterval);
            // if(i==3 && j==1)
            //     for(auto e:vt){
            //         cout<<e.name<<" "<<e.SG<<" "<<e.MG<<" "<<e.points<<endl;
            //     }
            // cout<<endl<<endl;
            // if(i==3 && j==1)
                // cout<<vt[3].name<<" "<<vt[2].name<<" "<<vt[1].name<<" "<<vt[0].name<<endl;
            if((vt[3].name.compare("BERLAND")==0) || (vt[2].name.compare("BERLAND")==0))
                ok=1;
            if(ok){
                // cout<<i<<" "<<j<<endl;
                if(i-j<ansx-ansy){
                    ansx=i;ansy=j;
                }
                else if(i-j==ansx-ansy){
                    if(j<ansy){
                        ansx=i;ansy=j;
                    }
                }
            }
        }
    }
    //now print the answer.
    ansx==100 && ansy==0 ? cout<<"IMPOSSIBLE" : cout<<ansx<<":"<<ansy;
}

#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#pragma GCC optimize(3)
#pragma G++ optimize(3)

#define All(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)

struct Team
{
	string nam;
	int gro,win,goal,point;
};
map<string,Team> team;
vector<Team> v;
string ano;

inline bool cmp(Team a,Team b)
{
	if(a.point<b.point) return 0; else if(a.point>b.point) return 1;
	if(a.win<b.win) return 0; else if(a.win>b.win) return 1;
	if(a.goal<b.goal) return 0; else if(a.goal>b.goal) return 1;
	if(a.nam<b.nam) return 1; else if(a.nam>b.nam) return 0;
}

int main()
{
	rep(i,5)
	{
		string a,b;int x,y;
		cin>>a>>b;scanf("%d:%d",&x,&y);
		team[a].nam=a;team[b].nam=b;
		team[a].gro++;team[b].gro++;
		team[a].win+=(x-y);team[b].win+=(y-x);
		team[a].goal+=x;team[b].goal+=y;

		if(x>y) team[a].point+=3,team[b].point+=0; else if(x<y) team[b].point+=3,team[a].point+=0;
		else team[a].point++,team[b].point++;
	}

	repv(i,team) v.push_back(i->second);
	sort(All(v),cmp);

	repV(i,v) if(i.gro==2&&i.nam!="BERLAND") {ano=i.nam;break;}

	int x=0,y=0,cx=0,cy=0;
	for(int i=1;i<=1000;i++)
	{
		int m1,m2;
		rep(i,v.size()) if(v[i].nam=="BERLAND") m1=i; else if(v[i].nam==ano) m2=i;

		v[m1].goal++;
		if(i==1) v[m1].point+=3;
		v[m1].win++;v[m2].win--;
		sort(All(v),cmp);
		/*
		repV(i,v) cout<<i.nam<<' '<<i.win<<' '<<i.goal<<' '<<i.point<<endl;
		cout<<endl;
		*/
		if(v[0].nam=="BERLAND"||v[1].nam=="BERLAND") cx=i; else continue;

		vector<Team> V=v;
		for(int j=1;j<i;j++)
		{
			int m1,m2;
			rep(k,V.size()) if(V[k].nam=="BERLAND") m1=k; else if(V[k].nam==ano) m2=k;

			V[m2].goal++;
			V[m1].win--;V[m2].win++;
			sort(All(V),cmp);

			if(V[0].nam=="BERLAND"||V[1].nam=="BERLAND") cy=j;
		}

		if(x==0&&y==0||cx-cy<x-y||cx-cy==x-y&&cy<y) x=cx,y=cy;
	}

	if(x) cout<<x<<':'<<y; else cout<<"IMPOSSIBLE";

	return 0;
}

#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
#define V_CIN(v) do{for(int i = 0; i < sz(v); i++) cin >> (v)[i];}while(0)
#define all(c) (c).begin(),(c).end()

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

//BEGIN!!!

//BEGIN!!!

struct RESULTS{
	int pts,diff,goal,cnt,id;
	string name;
};

RESULTS t[4];
vector<string> teams;
int getTeamNum(string name)
{
	vector<string>::iterator it;
	it = find(teams.begin(),teams.end(),name);
	if(it == teams.end()){
		teams.push_back(name);
		int id =(int)teams.size() - 1;
		t[id].name = name;
		return id;
	}else {
		return it - teams.begin();
	}
}

bool cmp(const RESULTS& x,const RESULTS &y){
	if(x.pts != y.pts) return greater<int>()(x.pts,y.pts);
	if(x.diff != y.diff) return greater<int>()(x.diff,y.diff);
	if(x.goal != y.goal) return greater<int>()(x.goal,y.goal);
	return less<string>()(x.name,y.name);
}

int get_opp()
{
	for (int i = 1; i < 4; i++){
		if(t[i].cnt == 2) return i;
	}
	return -1;
}

template<class T>
void f(int a,int b,int t1,int t2,T& team){
	team[t1].goal += a;
	team[t2].goal += b;
	team[t1].diff += a-b;
	team[t2].diff += b-a;
	team[t1].cnt++;
	team[t2].cnt++;
	if(a > b){
		team[t1].pts += 3;
	} else if(a < b){
		team[t2].pts += 3;
	} else {
		team[t1].pts++; team[t2].pts++;
	}
}

bool ok(int goal,int miss,int op){
	vector<RESULTS> r(t,t+4);
	f(goal,miss,0,op,r);
	sort(r.begin(),r.end(),cmp);
	if(r[0].id == 0 || r[1].id == 0) return true;
	else return false;
}

int main()
{
	getTeamNum("BERLAND");

	for (int i = 0; i < 4; i++){
		t[i].id = i;
	}
	for (int i = 0; i < 5; i++){
		char buf1[100],buf2[100];
		int a,b;
		scanf("%s %s %d:%d",buf1,buf2,&a,&b);
		int t1 = getTeamNum(buf1);
		int t2 = getTeamNum(buf2);
		f(a,b,t1,t2,t);
	}

	int op = get_opp();
	for (int i = 1; i < 100; i++){
		for (int j = 0; j < 100; j++){
			if(ok(i + j,j,op)){
				printf("%d:%d\n",i+j,j);
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<string,int> nti;
string itn[4];
bool soort(vector<int> &a, vector<int> &b){
	if (a[1]<b[1]) return true;
	if (b[1]<a[1]) return false;
	if (a[2]-a[3]<b[2]-b[3]) return true;
	if (b[2]-b[3]<a[2]-a[3]) return false;
	if (a[2]<b[2]) return true;
	if (b[2]<a[2]) return false;
	return (itn[a[0]]>itn[b[0]]);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	string a,b,c;
	int ind=2,ai,bi,st,dif,ber;
	nti["BERLAND"]=1;
	itn[0]="BERLAND";
	vector<int> tp(4,0);
	vector< vector<int> > gols(4,vector<int>(4,0));
	for (int i=0;i<4;i++) gols[i][0]=i;
	int five=5;
	while (five--){
		cin>>a>>b>>c;
		if (!(ai=nti[a])){
			itn[ind-1]=a;
			ai=nti[a]=ind++; //xd
		}
		if (!(bi=nti[b])){
			itn[ind-1]=b;
			bi=nti[b]=ind++;
		}
		tp[--ai]++; //xd
		tp[--bi]++;
		if (c[0]>c[2]) gols[ai][1]+=3;
		else if (c[2]>c[0]) gols[bi][1]+=3;
		else {
			gols[ai][1]++;
			gols[bi][1]++;
		}
		gols[ai][2]+=c[0]-'0';
		gols[ai][3]+=c[2]-'0';
		gols[bi][2]+=c[2]-'0';
		gols[bi][3]+=c[0]-'0';
	}
	bool cool=false;
	for (int i=1;i<4;i++){
		if (tp[i]==2){
			st=i;
			break;
		}
	}
	gols[0][1]+=3;
	for (dif=1;dif<=100 && !cool;dif++){
		for (ber=dif;ber<=100 && !cool;ber++){
			vector< vector<int> > fin=gols;
			fin[0][2]+=ber;
			fin[0][3]+=ber-dif;
			fin[st][2]+=ber-dif;
			fin[st][3]+=ber;
			sort(fin.begin(),fin.end(),soort);
			if (fin[2][0]==0 || fin[3][0]==0){
				cool=true;
				cout<<ber<<":"<<ber-dif<<"\n";
			}
		}
	}
	if (!cool) cout<<"IMPOSSIBLE\n";
	return 0;
}

#include<stdio.h>
#include<map>
#include<string.h>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
map<string,int> points;
map<string,int> goals;
map<string,int> misses;
set<string> playedWithBerland;
void parseS(char *t1,char *t2,int p1,int p2)
{
	if(p1>p2)
	{
		points[t1]+=3;
	}
	else if(p2>p1)
	{
		points[t2]+=3;
	}
	else
	{
		points[t1]+=1;
		points[t2]+=1;
	}
	if(!strcmp(t1,"BERLAND"))
	{
		playedWithBerland.insert(t2);
	}

	if(!strcmp(t2,"BERLAND"))
	{
		playedWithBerland.insert(t1);
	}

	goals[t1]+=p1;
	goals[t2]+=p2;
	misses[t1]+=p2;
	misses[t2]+=p1;

}
char s1[100];
char s2[100];
int p1;
int p2;
char s[1000];
struct cntr
{
	string name;
	int points;
	int misses;
	int goals;
};
bool cmp(cntr &c1, cntr &c2)
{
	return c1.points>c2.points ||
		c1.points==c2.points && c1.goals-c1.misses>c2.goals-c2.misses ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals>c2.goals ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals==c2.goals && c1.name<c2.name;

}
bool ifok(vector<cntr> & C)
{
	sort(C.begin(),C.end(),cmp);
	return C[0].name=="BERLAND" || C[1].name=="BERLAND";
}
int main()
{
	for(int i=0;i<5;i++)
	{
		gets(s);
		sscanf(s,"%s %s %d:%d",s1,s2,&p1,&p2);
		parseS(s1,s2,p1,p2);
	}

	string defC;
	for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
	{
		if(it->first!="BERLAND" && playedWithBerland.find(it->first)==playedWithBerland.end())
		{
			defC=it->first;
		}
	}
	points["BERLAND"]+=3;
	vector<pair<int,int> > goodSc;
	for(int dx=1;dx<100;dx++)
	{
		for(int Y=0;Y<100;Y++)
		{
			int X=Y+dx;
			goals[defC]+=Y;
			goals["BERLAND"]+=X;
			misses[defC]+=X;
			misses["BERLAND"]+=Y;
			vector<cntr> C;
			for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
			{
				cntr c1;
				c1.name=it->first;
				c1.misses=misses[it->first];
				c1.goals=goals[it->first];
				c1.points=points[it->first];
				C.push_back(c1);
			}

			if(ifok(C))
			{
				printf("%d:%d",X,Y);
				return 0;
			}
			goals[defC]-=Y;
			goals["BERLAND"]-=X;
			misses[defC]-=X;
			misses["BERLAND"]-=Y;
		}
	}
	printf("IMPOSSIBLE\n");

}

#include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin())itr=(c).begin();itr!=(c).end();itr++)

string s1[10],s2[10],score[10];
map <string,int> mp;
int a[10][10];
string name[10];

bool better(int x,int y)
{
	int i;
	int sx=0,px=0,mx=0,sy=0,py=0,my=0;
	REP(i,4) if(i!=x)
	{
		if(a[x][i]>a[i][x])  sx+=3;
		else if(a[x][i]==a[i][x]) sx++;
		px+=a[x][i];
		mx+=a[i][x];
	}

	REP(i,4) if(i!=y)
	{
		if(a[y][i]>a[i][y]) sy+=3;
		else if(a[y][i]==a[i][y]) sy++;
		py+=a[y][i];
		my+=a[i][y];
	}
	if(sx!=sy) return(sx>sy);
	if(px-mx!=py-my) return(px-mx>py-my);
	if(px!=py) return(px>py);
	return(x<y);
}

bool check(int x,int y)
{
	int i;
	int b=mp["BERLAND"];
	int c;
	REP(i,4) if(i!=b&&a[b][i]==-1) c=i;
	a[b][c]=x;a[c][b]=y;
	int rank=1;
	REP(i,4) if(i!=b&better(i,b)) rank++;
	a[b][c]=a[c][b]=-1;
	return (rank<=2);
}

int main(void)
{
	int d,i,j;
	REP(i,5) cin>>s1[i]>>s2[i]>>score[i];
	REP(i,5) mp[s1[i]]=mp[s2[i]]=0;
	i=0;
	foreach(mp,itr)
	{
		(itr->second)=i;
		//name[i]=(itr->first);
		i++;
	}
	REP(i,4) REP(j,4) a[j][i]=-1;
	REP(i,5)
	{
		int x=mp[s1[i]],y=mp[s2[i]];
		REP(j,score[i].length()) if(score[i][j]==':') score[i][j]=' ';
		istringstream ss(score[i]);
		ss>>a[x][y]>>a[y][x];
	}

	for(d=1;d<100;d++) REP(i,100)
	{
		j=i+d;
		if(check(j,i))
		{
			cout<<j<<":"<<i<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include <bits/stdc++.h>
#define rep(i, j, k) for(ll i = j; i <= k; i++)
#define ll long long
using namespace std;

int n, point[10], dif[10], score[109],game[10], opp;
string s[10];
map <string, int> mp;

bool bigger (int x, int y)
{
	if (point[x] > point[y])
		return 1;
	if (point[x] == point[y])
	{
		if (dif[x] > dif[y])
			return 1;
		if (dif[x] == dif[y])
		{
			if (score[x] > score[y])
				return 1;
			if (score[x] == score[y])
				return s[x] < s[y];
		}
	}
	return 0;
}

int main ()
{
	mp["BERLAND"] = 2;
	s[2] = "BERLAND";
	int cnt = 0;
	rep (i, 1, 5)
	{
		string s1, s2;
		cin >> s1 >> s2;
		if (!mp[s1])
			cnt += 1 + (cnt == 1), mp[s1] = cnt, s[cnt] = s1;
		if (!mp[s2])
			cnt += 1 + (cnt == 1), mp[s2] = cnt, s[cnt] = s2;
		int u, v;
		scanf ("%d:%d", &u, &v);
		if (u > v)
			point[mp[s1]] += 3;
		else
			if (u < v)
				point[mp[s2]] += 3;
			else
				point[mp[s1]] ++, point[mp[s2]]++;
		dif[mp[s1]] += u - v, dif[mp[s2]] += v - u;
		score[mp[s1]] += u, score[mp[s2]] += v;
		game[mp[s1]]++, game[mp[s2]]++;
	}
	rep (i, 1, 4)
		if (game[i] < 3 && i != 2)
			opp = i;
	point[2] += 3;
	int big_ = 0;
	rep (i, 1, 4)
		if (point[i] > point[2])
			big_++;
	if (big_ >= 2)
	{
		printf ("IMPOSSIBLE\n");
		return 0;
	}
	int ans = 0;
	while (1)
	{
		dif[2]++, score[2]++;
		dif[opp]--;
		ans++;
		rep (i, 0, 1000)
		{
			score[2] += i, score[opp] += i;
			int now = 0;
			rep (i, 1, 4)
				if (bigger (i, 2))
					now++;
			if (now <= 1)
			{
				cout << ans + i << ':' << i << endl;
				return 0;
			}
			score[2] -= i;
			score[opp] -= i;
		}
	}
	return 0;
}
/*
AERLAND DERLAND 2:1
DERLAND CERLAND 0:3
CERLAND AERLAND 0:1
AERLAND BERLAND 2:0
DERLAND BERLAND 4:0
*/

#include<bits/stdc++.h>
#define MyTeam "BERLAND"
using namespace std;
map<string,int> ZJQ,JSQ,SC,Cnt;
map<string,bool> Used;
vector<string> Teams;
bool Cmp(string &A,string &B)
{
	if(SC[A]>SC[B])
		return 1;
	if(SC[A]<SC[B])
		return 0;
	if(JSQ[A]>JSQ[B])
		return 1;
	if(JSQ[A]<JSQ[B])
		return 0;
	if(ZJQ[A]>ZJQ[B])
		return 1;
	if(ZJQ[A]<ZJQ[B])
		return 0;
	if(A>B)
		return 0;
	return 1;
}
int main()
{
	for(int i=0;i<5;i++)
	{
		string A,B;
		cin>>A>>B;
		char _;
		int GA,GB;
		cin>>GA>>_>>GB;
		if(!Used[A])
		{
			Teams.push_back(A);
			Used[A]=true;
		}
		if(!Used[B])
		{
			Teams.push_back(B);
			Used[B]=true;
		}
		ZJQ[A]+=GA;
		ZJQ[B]+=GB;
		JSQ[A]-=GB;
		JSQ[B]-=GA;
		JSQ[A]+=GA;
		JSQ[B]+=GB;
		Cnt[A]++;
		Cnt[B]++;
		if(GA==GB)
		{
			SC[A]++;
			SC[B]++;
		}
		else if(GA>GB)
			SC[A]+=3;
		else	SC[B]+=3;
	}
	//sort(Teams.begin(),Teams.end(),Cmp);
	//cout<<Teams[0]<<endl;
	//return 0;
	string Enemy;
	for(int i=0;i<4;i++)
		if(Cnt[Teams[i]]==2&&Teams[i]!=MyTeam)
			Enemy=Teams[i];
	SC[MyTeam]+=3;
	for(int i=1;i<100;i++)
		for(int j=0;j<100;j++)
		{
			JSQ[MyTeam]+=i;
			JSQ[Enemy]-=i;
			ZJQ[MyTeam]+=i+j;
			ZJQ[Enemy]+=j;
			sort(Teams.begin(),Teams.end(),Cmp);
			if(Teams[0]==MyTeam||Teams[1]==MyTeam)
			{
				//for(int k=0;k<4;k++)
				//	cout<<Teams[k]<<":"<<SC[Teams[k]]<<" "<<JSQ[Teams[k]]<<" "<<ZJQ[Teams[k]]<<endl;
				cout<<i+j<<":"<<j<<endl;
				return 0;
			}
			JSQ[MyTeam]-=i;
			JSQ[Enemy]+=i;
			ZJQ[MyTeam]-=i+j;
			ZJQ[Enemy]-=j;
		}
	puts("IMPOSSIBLE");
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <tuple>

using namespace std;

#define double long double
#define int long long
#define make(type, x) type x; cin >> x
#define make2(type, x, y) type x, y; cin >> x >> y
#define make3(type, x, y, z) type x, y, z; cin >> x >> y >> z
#define make4(type, x, y, z, q) type x, y, z, q; cin >> x >> y >> z >> q
#define ALL(x) (x).begin(), (x).end()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(int i = 0; i < (b); ++i)
#define VI vector <int>
#define VVI vector <vector<int>>
#define PII pair<int, int>
#define PPII pair<PII, int>
#define M7 1000000007
#define M9 1000000009

struct team {
	int ochki;
	int raznost;
	int zabitye;
	int propush;
	string name;
};

bool cmp(team a, team b) {
	if (a.ochki != b.ochki) return a.ochki < b.ochki;
	if (a.raznost != b.raznost) return a.raznost < b.raznost;
	if (a.zabitye != b.zabitye) return a.zabitye < b.zabitye;
	return a.name > b.name;
}

bool cmp2(PII a, PII b) {
	if (a.first - a.second < b.first - b.second) return true;
	if (a.first - a.second > b.first - b.second) return false;
	return a.second < b.second;
}

void Solve() {
	vector <tuple <int, int, int, string> > x;
	map <string, int> cnt;
	FOR(5) {
		string team1, team2;
		char a, b, c;
		cin >> team1 >> team2 >> a >> b >> c;
		cnt[team1]++;
		cnt[team2]++;
		x.push_back(make_tuple((a > c ? 3 : a == c ? 1 : 0), a - '0', c - '0', team1));
		x.push_back(make_tuple((a < c ? 3 : a == c ? 1 : 0), c - '0', a - '0', team2));
	}
	vector <team> scor;
	set <string> f;
	FOR(x.size()) {
		team sc = {0, 0, 0, 0, get<3>(x[i])};
		if (f.count(get<3>(x[i]))) continue;
		f.insert(get<3>(x[i]));
		for (int j = 0; j < x.size(); j++) {
			if (get<3>(x[j]) == get<3>(x[i])) {
				sc.ochki += get<0>(x[j]);
				sc.zabitye += get<1>(x[j]);
				sc.propush += get<2>(x[j]);
				sc.name = get<3>(x[j]);
			}
		}
		scor.push_back(sc);
	}
	FOR(scor.size()) scor[i].raznost = scor[i].zabitye - scor[i].propush;
	team berland = { 0, 0, 0, 0, "BERLAND" }, second;
	string second_team_name;
	for (auto cur : cnt) {
		if (cur.second == 2 and cur.first != berland.name) {
			second_team_name = cur.first;
			break;
		}
	}
	vector <team> scorx;
	sort(ALL(scor), cmp);
	set<PII> an;
	if (scor[scor.size() - 2].name == "BERLAND" || scor[scor.size() - 1].name == "BERLAND") an.insert({ 1,0 });
	FOR(scor.size()) {
		if (scor[i].name == "BERLAND") berland = scor[i];
		else if (second_team_name == scor[i].name) second = scor[i];
		else scorx.push_back(scor[i]);
	}
	sort(ALL(scorx), cmp);
	FOR(100) {
		for (int j = 0; j < i; j++) {
			vector<team> scor2 = scorx;
			team berland2 = berland;
			team second2 = second;

			berland2.ochki += 3;
			berland2.zabitye += i;
			berland2.propush += j;
			berland2.raznost = berland2.zabitye - berland2.propush;

			second2.zabitye += j;
			second2.propush += i;
			second2.raznost = second2.zabitye - second2.propush;

			scor2.push_back(berland2);
			scor2.push_back(second2);
			sort(ALL(scor2), cmp);
			if (scor2[scor2.size() - 2].name == berland.name || scor2[scor2.size() - 1].name == berland.name) {
				an.insert({i, j});
			}
		}
	}
	vector <PII> foo(an.size());
	int kk = 0;
	for (PII cur : an) foo[kk++] = cur;
	sort(ALL(foo), cmp2);
	if (foo.size()) cout << foo[0].first << ':' << foo[0].second;
	else cout << "IMPOSSIBLE";

}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
#if  _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	Solve();
	while (!cin.eof()) {
		string s = "_";
		do getline(cin, s);
		while (!cin.eof() && !s.empty());
		if (cin.eof()) return 0;
		FOR(3) cout << endl;
		Solve();
	}
#else
	Solve();
#endif
	return 0;
}

//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
using namespace std;
map<string,int> sco,goa,mis,ch;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string a,b,c;
	for(int i=0;i<5;i++){
		cin>>a>>b>>c;
		int s,t;
		sscanf(c.c_str(),"%d:%d",&s,&t);
		if(s>t)
		sco[a]+=3;
		if(s<t)
		sco[b]+=3;
		if(s==t){
			sco[a]++;
			sco[b]++;
		}
		goa[a]+=s;
		mis[a]+=t;
		goa[b]+=t;
		mis[b]+=s;
		ch[a]++;
		ch[b]++;
	}
	string at="BERLAND",oth;
	for(map<string,int>::iterator it=ch.begin();it!=ch.end();it++)
	if(it->second==2 && it->first!="BERLAND")
	oth=it->first;
	for(int di=1;di<=40;di++){
		for(int y=0;y<=40;y++){
			int x=y+di;
			sco[at]+=3;
			goa[at]+=x;
			mis[at]+=y;
			goa[oth]+=y;
			mis[oth]+=x;
			int cnt=0;
			for(map<string,int>::iterator it=ch.begin();it!=ch.end();it++){
				if(it->first==at)
				continue;
				if(sco[it->first]>sco[at]){
					++cnt;
					continue;
				}
				if(sco[it->first]<sco[at])
				continue;
				int v=(goa[it->first]-mis[it->first]);
				int vm=goa[at]-mis[at];
				if(v>vm){
					++cnt;
					continue;
				}
				if(v<vm)
				continue;
				v=goa[it->first];
				vm=goa[at];
				if(v>vm){
					++cnt;
					continue;
				}
				if(v<vm)
				continue;
				if(it->first<at){
					++cnt;
					continue;
				}
			}
			if(cnt<=1){
				printf("%d:%d\n",x,y);
				return 0;
			}
			goa[at]-=x;
			mis[at]-=y;
			goa[oth]-=y;
			mis[oth]-=x;
			sco[at]-=3;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
struct ii
{
	int sc,jin,mi;
}team[205];
int n,m,i,j,k,ranks,s1,s2,t1,t2,cnt[205],len,mi=1<<25,mx,my;
string ch1,ch2;
vector<string> s;
bool check(int x,int y)
{
	if (x==y)
	{
		return 0;
	}
	if (team[x].sc!=team[y].sc)
	{
		return team[x].sc>team[y].sc;
	}
	if (team[x].mi!=team[y].mi)
	{
		return team[x].mi>team[y].mi;
	}
	if (team[x].jin!=team[y].jin)
	{
		return team[x].jin>team[y].jin;
	}
	return s[x]<s[y];
}
int get(string st)
{
	int i;
	for (i=0;i<s.size();i++)
	{
		if (s[i]==st) return i;
	}
	s.push_back(st);
	return s.size()-1;
}
int main()
{
	for (i=1;i<=5;i++)
	{
		cin>>ch1>>ch2;
		s1=get(ch1);
		s2=get(ch2);
		cnt[s1]++;
		cnt[s2]++;
		scanf("%d:%d:",&t1,&t2);
		team[s1].mi+=t1-t2;
		team[s2].mi+=t2-t1;
		team[s1].jin+=t1;
		team[s2].jin+=t2;
		if (t1>t2) team[s1].sc+=3;
		if (t1<t2) team[s2].sc+=3;
		if (t1==t2)
		{
			team[s1].sc++;
			team[s2].sc++;
		}
	}
	for (i=0;i<=3;i++)
	{
		if (s[i]=="BERLAND")
		{
			s1=i;
		}
		else if (cnt[i]<3)
		{
			s2=i;
		}
	}
	for (i=1;i<=100;i++)
	{
		for (j=0;j<i;j++)
		{
			team[s1].mi+=i-j;
			team[s2].mi+=j-i;
			team[s1].jin+=i;
			team[s2].jin+=j;
			if (i>j) team[s1].sc+=3;
			if (i<j) team[s2].sc+=3;
			if (i==j)
			{
				team[s1].sc++;
				team[s2].sc++;
			}
			ranks=1;
			for (k=0;k<=3;k++)
			{
				if (check(k,s1)) ranks++;
			}
			if (ranks<=2)
			{
				/*cout<<i<<':'<<j;
				return 0;*/
				if (i-j<mi)
				{
					mx=i;
					my=j;
					mi=i-j;
				}
			}
			team[s1].mi-=i-j;
			team[s2].mi-=j-i;
			team[s1].jin-=i;
			team[s2].jin-=j;
			if (i>j) team[s1].sc-=3;
			if (i<j) team[s2].sc-=3;
			if (i==j)
			{
				team[s1].sc--;
				team[s2].sc--;
			}
		}
	}
	if (mi<(1<<24))
	{
		cout<<mx<<':'<<my;
		return 0;
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
char s1[25],s2[25];
map<string,int>mp;//score
map<string,pair<int,int> >mp2;//ball
map<string,int>cnt;
string team;
vector<string>v;
bool cmp(string s,string t){
	if(mp[s]>mp[t])return true;
	else if(mp[s]<mp[t])return false;
	else{
		if(mp2[s].first-mp2[s].second>mp2[t].first-mp2[t].second)return true;
		else if(mp2[s].first-mp2[s].second<mp2[t].first-mp2[t].second)return false;
		else{
			if(mp2[s].first>mp2[t].first)return true;
			else if(mp2[s].first<mp2[t].first)return false;
			else{
				if(s<t)return true;
				else return false;
			}
		}
	}
}
bool check(int x,int y){
	if(x==y){
		mp["BERLAND"]+=1;
		mp[team]+=1;
	}
	else{
		mp["BERLAND"]+=3;
	}
	mp2["BERLAND"].first+=x,mp2["BERLAND"].second+=y;
	mp2[team].first+=y,mp2[team].second+=x;
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<2;i++){
		if(v[i]=="BERLAND"){
			return true;
		}
	}
	if(x==y){
		mp["BERLAND"]-=1;
		mp[team]-=1;
	}
	else{
		mp["BERLAND"]-=3;
	}
	mp2["BERLAND"].first-=x,mp2["BERLAND"].second-=y;
	mp2[team].first-=y,mp2[team].second-=x;
return false;
}
int main(){
	int a,b;
	for(int i=0;i<5;i++){
		scanf("%s%s%d:%d",s1,s2,&a,&b);
		cnt[s1]++,cnt[s2]++;
		v.push_back(s1),v.push_back(s2);
		if(a>b)mp[s1]+=3;
		else if(b>a)mp[s2]+=3;
		else {
			mp[s1]+=1;
			mp[s2]+=1;
		}
		mp2[s1].first+=a,mp2[s1].second+=b;
		mp2[s2].first+=b,mp2[s2].second+=a;
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for(int i=0;i<v.size();i++){
		if(cnt[v[i]]==2&&v[i]!="BERLAND")team=v[i];
	}
	for(int i=1;i<=105;i++)for(int j=0;j<=105;j++){
        if(check(i+j,j)){
            printf("%d:%d",i+j,j);
            return 0;
        }
    }
    printf("IMPOSSIBLE");
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

typedef struct _Data
{
	char name_[30];
	int  score_;
	int  x_;
	int  y_;
	int flag;
}Data;

int search(char *temp, Data *data);
void change(Data *a, Data *b);
void sort(Data *data);

int main()
{
	char temp[50];
	Data data[10] = {0};
	int i, j = 0;

	for (i = 0; i < 5; ++i)
	{
		int a, b, t;
		scanf("%s", temp);
		if ((t = search(temp, data)) != -1)
			a = t;
		else
		{
			a = j++;
			strcpy(data[a].name_, temp);
		}
		scanf("%s", temp);
		if ((t = search(temp, data))!=-1)
			b = t;
		else
		{
			b = j++;
			strcpy(data[b].name_, temp);
		}
		int m, n;
		scanf("%d:%d", &m, &n);
		if (m > n)
			data[a].score_ += 3;
		else if (m == n)
		{
			data[a].score_ += 1;
			data[b].score_ += 1;
		}
		else
			data[b].score_ += 3;
		data[a].flag++;
		data[b].flag++;
		data[a].x_ += m;
		data[b].x_ += n;
		data[a].y_ += n;
		data[b].y_ += m;
	}

	for (i = 1; i < 50; ++i)
	{
		for (j = 0; j <= 50-i; j++)
		{
			int a, b, k1, k2;
			a = j + i, b = j;
			k1=search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			data[k1].score_ += 3;
			data[k1].x_ += a;
			data[k2].x_ += b;
			data[k1].y_ += b;
			data[k2].y_ += a;
			sort(data);
			k1 = search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			if (k1+1 == 1 || k1+1 == 2)
			{
				printf("%d:%d\n", a, b);
				return 0;
			}
			k1 = search("BERLAND", data);
			for (k2 = 0; k2 < 4; ++k2)
				if (data[k2].flag == 2 && strcmp(data[k2].name_, "BERLAND"))
					break;
			data[k1].score_ -= 3;
			data[k1].x_ -= a;
			data[k2].x_ -= b;
			data[k1].y_ -= b;
			data[k2].y_ -= a;
		}
	}
	printf("IMPOSSIBLE");

	return 0;
}

int search(char *temp,Data *data)
{
	int i;

	for (i = 0; i < 4; ++i)
		if (!strcmp(temp, data[i].name_))
			break;
	if (i < 4)
		return i;
	else
		return -1;
}

void sort(Data *data)
{
	int i, j;

	for (i = 0; i < 4; ++i)
	{
		for (j = 0; j < 4 - i; ++j)
		{
			if (data[j].score_ == data[j+1].score_)
			{
				if (data[j].x_ - data[j].y_ == data[j + 1].x_ - data[j + 1].y_)
				{
					if (data[j].x_ == data[j + 1].x_)
					{
						if (strcmp(data[j].name_, data[j + 1].name_) > 0)
							change(&data[j], &data[j + 1]);
					}
					else if(data[j].x_ < data[j + 1].x_)
						change(&data[j], &data[j + 1]);
				}
				else if(data[j].x_ - data[j].y_ < data[j + 1].x_ - data[j + 1].y_)
					change(&data[j], &data[j + 1]);
			}
			else if(data[j].score_ < data[j + 1].score_)
				change(&data[j], &data[j + 1]);
		}
	}
}

void change(Data *a, Data *b)
{
	Data t;

	t = *a;
	*a = *b;
	*b = t;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[50],b[50];
int aa,bb;
struct team{
    char name[50];
    int score;
    int win;
    int goal;
    int match;
}t[4];
int get(char a[]){
    int i;
    for(i=0;i<4;i++){
        if(!t[i].match){
            strcpy(t[i].name,a);
            break;
        }
        else if(strcmp(a,t[i].name)==0) break;
    }
    return i;
}
void insert(char a[],char b[],int aa,int bb){
    int i=get(a);
    t[i].match++;
    int j=get(b);
    t[j].match++;
    t[i].goal+=aa-bb;
    t[i].win+=aa;
    t[j].goal+=bb-aa;
    t[j].win+=bb;
    if(aa>bb) t[i].score+=3;
    else if(bb>aa) t[j].score+=3;
    else t[i].score++,t[j].score++;
}
void insert(int i,int j,int aa,int bb){
    t[i].goal+=aa-bb;
    t[j].goal+=bb-aa;
    t[i].win+=aa;
    t[j].win+=bb;
    if(aa>bb) t[i].score+=3;
    else if(bb>aa) t[j].score+=3;
}
void init(){
    for(int i=0;i<4;i++){
        t[i].win=t[i].match=t[i].goal=t[i].score=0;
        memset(t[i].name,0,sizeof(t[i].name));
    }
}
bool cmp(team a,team b){
    if(a.score!=b.score) return a.score>b.score;
    if(a.goal!=b.goal) return a.goal>b.goal;
    if(a.win!=b.win) return a.win>b.win;
    return strcmp(a.name,b.name)<0;
}
int main(){
    while(~scanf("%s%s%d:%d",a,b,&aa,&bb)){
        init();
        insert(a,b,aa,bb);
        for(int i=0;i<4;i++){
            scanf("%s%s%d:%d",a,b,&aa,&bb);
            insert(a,b,aa,bb);
        }
        int ma=0,mark[2],tail=0;
        team copy[4];
        for(int i=0;i<4;i++){
            copy[i]=t[i];
            //printf("%s %d %d %d\n",t[i].name,t[i].score,t[i].goal,t[i].win);
            if(2*t[i].win-t[i].goal>ma) ma=2*t[i].win-t[i].goal;
            if(t[i].match==2) mark[tail++]=i;
        }
       // printf("%d\n",ma);
        if(strcmp(t[mark[0]].name,"BERLAND")) swap(mark[1],mark[0]);
        bool jud=1;
        for(int i=1;i<=ma&&jud;i++){
            for(int j=0;j+i<=ma&&jud;j++){
                for(int k=0;k<4;k++) t[k]=copy[k];
                insert(mark[0],mark[1],i+j,j);
                sort(t,t+4,cmp);
                //for(int jj=0;jj<4;jj++) printf("%s %d %d\n",t[jj].name,t[jj].score,t[jj].goal);
                if(strcmp(t[0].name,"BERLAND")==0||strcmp(t[1].name,"BERLAND")==0) {
                    printf("%d:%d\n",i+j,j);
                    jud=0;
                }
            }
        }
        if(jud) printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <set>
#include <memory.h>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>
#include <queue>
#include <sstream>
using namespace std;

struct team {
    int pts;
    int g;
    int l;
    string name;
    int played;

    team() : pts(0), g(0), l(0), played(0) {}

} info[4];

map <string,int> t_search;

int getTeam(string &s) {
    map <string,int>::iterator it = t_search.find(s);
    if (it != t_search.end()) return it->second;
    info[t_search.size()].name = s;
    if (s=="BERLAND") info[t_search.size()].pts+=3;
    t_search.insert(make_pair(s,t_search.size()));
    return t_search.size()-1;
}

bool cmp(team& a,team &b) {
    if (a.pts == b.pts) {
        if (a.g-a.l == b.g-b.l) {
            if (a.g == b.g) {
                return a.name < b.name;
            } else {
                return a.g > b.g;
            }
        } else {
            return a.g-a.l > b.g-b.l;
        }
    } else {
        return a.pts > b.pts;
    }
}

int main() {
    string s,t;
    char xt;
    int g1,g2;
    for (int i=0;i<5;i++) {
        cin >> s >> t >> g1 >> xt >> g2;
        int t1 = getTeam(s) , t2 = getTeam(t);
        ++info[t1].played;
        ++info[t2].played;
        info[t1].g+=g1;
        info[t1].l+=g2;
        info[t2].l+=g1;
        info[t2].g+=g2;
        if (g1 == g2) {
            ++info[t1].pts;
            ++info[t2].pts;
        } else if (g1 > g2) {
            info[t1].pts+=3;
        } else
            info[t2].pts+=3;
    }

    for (int diff=1;diff<100;diff++)
        for (int y=0;y<100;y++) {
            int x = diff+y;
            for (int i=0;i<5;i++) {
                if (info[i].played==2) {
                    if (info[i].name == "BERLAND") {
                        info[i].g += x;
                        info[i].l += y;
                    } else {
                        info[i].g += y;
                        info[i].l += x;
                    }
                }
            }
            sort(info,info+4,cmp);
            if (info[0].name == "BERLAND" || info[1].name == "BERLAND") {
                cout << x << ":" << y << endl;
                return 0;
            }
            for (int i=0;i<5;i++) {
                if (info[i].played==2) {
                    if (info[i].name == "BERLAND") {
                        info[i].g -= x;
                        info[i].l -= y;
                    } else {
                        info[i].g -= y;
                        info[i].l -= x;
                    }
                }
            }
        }
        cout << "IMPOSSIBLE";

}

#include <bits/stdc++.h>
#define pb push_back
using namespace std;

vector<string> team;
int score[4],win[4],lose[4],result[4][4],match[4];

int find_i(string s)
{
	for(int i=0;i<team.size();i++) if(team[i]==s) return i;
	team.pb(s);
	return team.size()-1;
}

bool cmp(int x,int y)
{
	if(score[x]!=score[y]) return score[x]>score[y];
	if(win[x]-lose[x]!=win[y]-lose[y]) return win[x]-lose[x]>win[y]-lose[y];
	if(win[x]!=win[y]) return win[x]>win[y];
	return team[x]<team[y];
}

int ok(int a,int b,int x,int y)
{
	win[a]+=x;win[b]+=y;
	lose[a]+=y;lose[b]+=x;
	result[a][b]=x;result[b][a]=y;
	vector<int> order;
	for(int i=0;i<4;i++) order.pb(i);
	sort(order.begin(),order.end(),cmp);
	if(a==order[0]||a==order[1]) return 1;
	win[a]-=x;win[b]-=y;
	lose[a]-=y;lose[b]-=x;
	return 0;
}

int main()
{
	for(int i=0;i<5;i++)
	{
		string A,B;
		int x,y;
		cin>>A>>B;
		int a=find_i(A),b=find_i(B);
		scanf("%d:%d",&x,&y);
		if(x>y) score[a]+=3;
		else if(x<y) score[b]+=3;
		else score[a]++,score[b]++;
		win[a]+=x;win[b]+=y;
		lose[a]+=y;lose[b]+=x;
		result[a][b]=x;result[b][a]=y;
		match[a]++;match[b]++;
	}

	int me=find_i("BERLAND"),good;
	for(int i=0;i<4;i++) if(i!=me&&match[i]<3) good=i;
	score[me]+=3;
	for(int dif=1;dif<100;dif++)
	{
		for(int y=0;y<100;y++)
		{
			if(ok(me,good,dif+y,y))
			{
				cout<<dif+y<<":"<<y<<endl;
				return 0;
			}
		}
	}

	puts("IMPOSSIBLE");
	return 0;
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  eps      0.00000001
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   inf        0x7fffffff
#define    PI        3.1415926535897932384626433832795
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    vi       vector<int>
#define    vd       vector<double>
#define    vvi      vector< vector<int> >
#define    vvll      vector< vector<long long> >
#define    vvpi     vector< vector< pair<int,int> > >
#define    vvpll     vector< vector< pair<long long,long long> > >
#define    vvd      vector< vector<double> >
#define    vs       vector<string>
#define    vvs      vector< vector<string> >
#define     vc        vector<char>
#define     vpi        vector< pair<int ,int> >
#define      pi        pair<int ,int>
#define      pll       pair<long long ,long long>
#define     vpd        vector< pair<double ,double> >
#define     vpll        vector< pair<long long ,long long> >
#define    vll       vector<long long>
#define    dqi        deque< int >
#define     si         set<int>
#define     spi        set< pair<int ,int > >
#define     row          vector< ll >
#define     matrix            vector< row >
#define    lp(i,n)    for(i=0;i<n;i++)
#define     si         set<int>
#define    oo         9000000000000000000
#define   MOD         1000000007
#define    X            real
#define    Y            imag
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define    scani(n)                  scanf("%d",&n)
#define    scanll(n)                  scanf("%I64d",&n)
#define    printi(n)                 printf("%d",n)
#define    printll(n)                 printf("%I64d",n)
#define    scand(n)                  scanf("%lf",&n)
#define    printd(n)                 printf("%lf",n)
#define    scans(n)                  scanf("%s",&n)
#define    prints(n)                 printf("%s",n)
typedef  long long     ll ;
typedef  unsigned long long ull;
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

map<string,int> points,goals,miss,cnt;

int main()
{

   for(int i=0;i<5;i++)
   {
       string s1,s2;
       cin>>s1>>s2;
       int x,y;
       scanf("%d:%d",&x,&y);

       if(x>y)
        points[s1]+=3;
       else if(y>x)
       points[s2]+=3;
       else
        points[s1]+=1,points[s2]+=1;

       goals[s1]+=x;
       miss[s1]+=y;
       goals[s2]+=y;
       miss[s2]+=x;

       cnt[s1]++;
       cnt[s2]++;

   }
   vs v;
   string with;

    for(auto i=cnt.begin();i!=cnt.end();i++)
    {
        v.pb((*i).first);

        if((*i).second==2&&(*i).first!="BERLAND")
            with=(*i).first;
    }

    for(int i=1;i<100;i++)
    {

        for(int k=0;k<100;k++)
        {

          int  p=i+k;

            goals[with]+=k;
            goals["BERLAND"]+=p;
            miss["BERLAND"]+=k;
            miss[with]+=p;
            points["BERLAND"]+=3;

            vector< tuple< int ,int ,int , string > > v1;

            for(int i=0;i<sz(v);i++)
            {
                v1.pb(mt(-points[v[i]],-goals[v[i]]+miss[v[i]],-goals[v[i]],v[i]));

            }

            sort(all(v1));

            if(get<3>(v1[0]) == "BERLAND"||get<3>(v1[1]) =="BERLAND")
              {
                  cout<<p<<":"<<k<<endl;
                  return 0;
              }

             goals[with]-=k;
            goals["BERLAND"]-=p;
            miss["BERLAND"]-=k;
            miss[with]-=p;
            points["BERLAND"]-=3;

        }
    }

    cout<<"IMPOSSIBLE";

    return 0;
}

#include <iostream>
#include <fstream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

#define F cin
#define G cout

int n,tts;
string a,b,c;

map<string,int> ss;

struct team {
	string name;
	int pts,gm,gt,co;
};

team t[6];

bool cmp(team a,team b)
{
	return a.pts != b.pts ? a.pts > b.pts : a.gm-a.gt != b.gm-b.gt ? a.gm-a.gt > b.gm-b.gt : a.gm != b.gm ? a.gm > b.gm : a.name < b.name;
}

void update(string a,string b,string c)
{
	if ( ss.find(a) == ss.end() ) ss[a] = tts++, t[tts-1].name=a;
	if ( ss.find(b) == ss.end() ) ss[b] = tts++, t[tts-1].name=b;

	int s1 = 0,s2 = 0;
	for (int j=0,ok=0;j<int(c.size());++j)
	{
		if ( c[j] == ':' )
		{
			ok = 1;
			continue;
		}
		if ( ok )
			s2 = s2 * 10 + int(c[j]-'0');
		else
			s1 = s1 * 10 + int(c[j]-'0');
	}
	t[ss[a]].co ++, t[ss[b]].co ++;
	t[ss[a]].gm += s1, t[ss[a]].gt += s2;
	t[ss[b]].gm += s2, t[ss[b]].gt += s1;
	t[ss[a]].pts += s1 > s2 ? 3 : s1 == s2 ? 1 : 0;
	t[ss[b]].pts += s2 > s1 ? 3 : s2 == s1 ? 1 : 0;
}

int main()
{
	ios::sync_with_stdio(0);
	#ifndef ONLINE_JUDGE
		ifstream F("p.in");
	#endif

	for (int i=1;i<=5;++i)
	{
		F>>a>>b>>c;
		update(a,b,c);
 	}
 	for (map<string,int>::iterator it=ss.begin();it!=ss.end();++it)
		if ( it->second != ss["BERLAND"] && t[it->second].co < 3 )
			for (int df=1;df<=40;++df)
				for (int i=df;i<=40;++i)
				{
					int j = i-df;
					string a = "BERLAND";
					string b = it->first;

					string c = "";
					if ( i/10 ) c+= (char(i/10)+'0');
					c += (char(i%10)+'0');
					c += ':';
					if ( j/10 ) c+= (char(j/10)+'0');
					c += (char(j%10)+'0');

					//cerr<<"mips "<<a<<' '<<b<<' '<<c<<'\n';

					team t1 = t[ss[a]];
					team t2 = t[ss[b]];
					update(a,b,c);

					vector<team> ts;

					for (int j=0;j<4;++j) ts.push_back(t[j]);
					//for (int j=0;j<4;++j) cerr<<"ts "<<ts[j].name<<' '<<ts[j].pts<<' '<<ts[j].gm<<' '<<ts[j].gt<<'\n';
					sort(ts.begin(),ts.end(),cmp);

					if ( ts[0].name == a || ts[1].name == a )
					{
						G<<c<<'\n';
						return 0;
					}

					t[ss[a]] = t1;
					t[ss[b]] = t2;
				}
	G<<"IMPOSSIBLE\n";
}

#include<bits/stdc++.h>
#define FOR(i,a,b)for(i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(i=0;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
string s1[10],s2[10],score[10];
map<string,int>mp;
string name[10];
int a[10][10];
bool better(int x, int y){
    int n;
    int sx=0,px=0,mx=0,sy=0,py=0,my=0;
    REP(n,4) if(n!=x){
        if(a[x][n]>a[n][x])sx+=3;else if(a[x][n]==a[n][x])sx++;
        px+=a[x][n];
        mx+=a[n][x];
    }
    REP(n,4) if(n!=y){
        if(a[y][n]>a[n][y])sy+= 3;else if(a[y][n]==a[n][y])sy++;
        py+=a[y][n];
        my+=a[n][y];
    }
    //cout<<sx<<endl<<px<<endl<<mx<<endl<<sy<<endl<<py<<endl<<my<<endl;
    if(sx!=sy) return (sx>sy);
    if(px-mx!=py-my)return (px-mx>py-my);
    if(px!=py)return (px>py);
    return (x<y);
}
bool check(int x, int y){
	int n;
    int b=mp["BERLAND"];
    int c;
	int rank=1;
    REP(n,4)if(n!=b&&a[b][n]==-1)c=n;
    a[b][c]=x;a[c][b]=y;
    REP(n,4)if(n!=b&&better(n,b))rank++;
   // cout<<x<<endl<<y<<endl<<rank<<endl<<c<<endl;
    a[b][c]=-1,a[c][b]=-1;
    return (rank<=2);
}
int main(){
	int i,j;
	REP(i,5)
    {
    	cin>>s1[i]>>s2[i]>>score[i];
	}
    REP(i,5)mp[s1[i]]=mp[s2[i]]=0;
    i=0;
    foreach(mp,itr){
        (itr->second)=i;
        name[i]=(itr->first);
        i++;
       // cout<<i<<endl;
    }
    memset(a,-1,sizeof(a));
	REP(i,5){
        int x=mp[s1[i]],y=mp[s2[i]];
        REP(j,score[i].size()) if(score[i][j]==':')score[i][j]=' ';
        istringstream ss(score[i]);
        ss>>a[x][y]>>a[y][x];
    }
    for(int diff=1;diff<100;diff++)
	{
		for(int a=0;a<100;a++){
		int b=a+diff;
		//cout<<b<<endl<<a<<endl<<diff<<endl;
        if(check(b,a)){
        	//cout<<b<<endl<<a<<endl<<diff<<endl;
            cout<<b<<":"<<a<<endl;
            return 0;
        }
    }	}
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

//===============typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<int> si;
typedef map<string, int> msi;
//=================
const  ll MOD=1e9+7;

//=============define
#define inf 10000000
#define cln(a) memset(a,0,sizeof a);
#define clni(a) memset(a,inf,sizeof a);
#define all(x) x.begin(), x.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back
#define sp(c,x) ((c).find(x) != (c).end())  // for set,map
#define vp(c,x) (find(all(c),x) != (c).end())  // for vector
#define uu first
#define vv second
#define fr(i,a,b) for(int i=int(a);i<int(b);++i)
#define nfr(i,a,b) for(int i= int(a);i>=int(b);--i)
#define tc cin>>t ; while(t--)
#define pc()  cout<<"Case "<<cs++<<": "
#define mx (int)1e5+10
#define s2(x,y) int x,y;scanf("%d %d",&x,&y)
#define s2l(x,y) ll x,y;scanf("%lld %lld",&x,&y)
#define s3(x,y,z) int x,y,z;scanf("%d %d %d",&x,&y,&z)
#define s3l(x,y,z) ll x,y,z;scanf("%lld %lld %lld",&x,&y,&z)
#define sc(x) int x; scanf("%d",&x)
#define scl(x) ll x; scanf("%lld",&x)

#define pfs(x) printf("%d ",x)
#define pf(x) printf("%d\n",x)
#define el puts("");
#define getcx() getchar()
#define Fi freopen("inp.txt","r",stdin)
#define rt return 0
#define dbg(x) cerr<<x<<endl
//============functions
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
ll bigmod(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
    if(b&1)
    ans=(ans*a)%MOD;
    a=(a*a)%MOD;
    b>>=1;
    }
    return ans;
}

int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
//int vis[505][505];
//int vis[505]
//string s[505];

char g[10][10];
int dis[10][10];
map<string,int> Mp;
struct P
{
	string name;
	int po,win,lst,cn;

}v[4],b[4];
 bool cmp(P &a,P &b)
{
	if(a.po!=b.po)
		return a.po>b.po;
	if(a.win-a.lst!=b.win-b.lst)
		return a.win-a.lst>b.win-b.lst;
	if(a.win!=b.win)
		return a.win>b.win;
	return a.name<b.name;
}
string S="BERLAND";
bool ok(int x,int y)
{
	int idx=Mp[S];
	int idx2;
	for(int i=0;i<4;i++)
	{
		if(i!=idx && v[i].cn<3)
			idx2=i;
	}
	dbg(v[idx2].name);
	memcpy(b,v,sizeof v);

	b[idx].po+=3;
	b[idx].win+=x;
	b[idx].lst+=y;
	b[idx2].win+=y;
	b[idx2].lst+=x;
	sort(b,b+4,cmp);
	return b[0].name==S || b[1].name==S;
}
int main()
{
	string a,b;
	char c;
	int co=0,x,y;
	fr(i,0,5)
	{
		cin>>a>>b;
		scanf("%d:%d",&x,&y);
		if(Mp.count(a)==0)
		{
			v[co].name=a;
			Mp[a]=co;
			co++;
		}
		if(Mp.count(b)==0)
		{
			v[co].name=b;
			Mp[b]=co;
			co++;
		}

		int X=Mp[a];
		int Y=Mp[b];
		v[Mp[a]].cn++;
		v[Mp[b]].cn++;
		v[X].win+=x;
		v[X].lst+=y;
		v[Y].lst+=x;
		v[Y].win+=y;
		if(x>y)
		{
			v[X].po+=3;
		}
		else if(x<y)
		{
		v[Y].po+=3;
		}
		else{
			v[X].po++;
			v[Y].po++;
		}
	}
		//Mp[a]++,Mp[b]++;
		int mn=100005;

        fr(i,0, 110)
	        fr(j,0, i)
            if (ok(i, j))
                {
                	if(i-j<mn ||(i-j==mn && j<y) )
                	{
                		mn=i-j;
                		x=i,y=j;
                	}
                }
    if (mn == 100005)
        puts("IMPOSSIBLE");
    else
        printf("%d:%d\n", x, y);

	}

//lxrtxdy!
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
map<string,int> mp;
int cnt;
string name[5];
int goal[5],miss[5],point[5],tim[5];
bool cmp(int a,int b)
{
	if(point[a]!=point[b]) return point[a]>point[b];
	if(goal[a]-miss[a]!=goal[b]-miss[b]) return goal[a]-miss[a]>goal[b]-miss[b];
	if(goal[a]!=goal[b]) return goal[a]>goal[b];
	return name[a]<name[b];
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	mp["BERLAND"]=++cnt;
	name[cnt]="BERLAND";
	for(int i=1;i<=5;i++)
	{
		string t1,t2;
		int g1,g2;
		char c;
		cin>>t1>>t2>>g1>>c>>g2;
		if(!mp.count(t1))
		{
			mp[t1]=++cnt;
			name[cnt]=t1;
		}
		if(!mp.count(t2))
		{
			mp[t2]=++cnt;
			name[cnt]=t2;
		}
		if(g1>g2)
			point[mp[t1]]+=3;
		else if(g1==g2)
		{
			point[mp[t1]]++;
			point[mp[t2]]++;
		}
		else
			point[mp[t2]]+=3;
		goal[mp[t1]]+=g1;
		goal[mp[t2]]+=g2;
		miss[mp[t1]]+=g2;
		miss[mp[t2]]+=g1;
		tim[mp[t1]]++;
		tim[mp[t2]]++;
	}
	int enemy;
	for(int i=1;i<=4;i++)
		if(tim[i]==2&&i!=1)
			enemy=i;
	for(int dif=1;dif<=100;dif++)
		for(int y=0;y<=100;y++)
		{
			int x=y+dif;
			point[1]+=3;
			goal[1]+=x;
			goal[enemy]+=y;
			miss[1]+=y;
			miss[enemy]+=x;
			vector<int> v;
			for(int i=1;i<=4;i++)
				v.push_back(i);
			sort(v.begin(),v.end(),cmp);
			if(v[0]==1||v[1]==1)
			{
				cout<<x<<':'<<y<<endl;
				return 0;
			}
			point[1]-=3;
			goal[1]-=x;
			goal[enemy]-=y;
			miss[1]-=y;
			miss[enemy]-=x;
		}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

//orzlxr!//hello

#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<cmath>
#include<set>
#include<map>
#include<string.h>
#include<string>
using namespace std;

map<string, int>g, h, h2, koll;
string ss1, ss2, s="BERLAND";
int g1, g2;
set<string>ss;
bool cmp(string s1, string s2)
{
     if ( g[s1]>g[s2] )
        return 1;

     if ( g[s1]<g[s2] )
        return 0;

     if ( h[s1]-h2[s1]>h[s2]-h2[s2] )
        return 1;

     if ( h[s1]-h2[s1]<h[s2]-h2[s2] )
        return 0;

     if (h[s1]>h[s2])
        return 1;

     if (h[s1]<h[s2])
        return 0;

     if (s1<s2)
        return 1;
     return 0;
}
pair<int, int>otv=make_pair(100000, 1000);
int main ()
{
    for (int i=1;i<=5;i++)
    {
        cin>>ss1>>ss2;
        ss.insert(ss1);
        ss.insert(ss2);
        scanf("%d:%d", &g1, &g2);
        koll[ss1]++;
        koll[ss2]++;
        //cout<<s1<<" "<<s2<<" "<<g1<<" "<<g2<<endl;
        h[ss1]+=g1;
        h[ss2]+=g2;

        h2[ss1]+=g2;
        h2[ss2]+=g1;
        if (g1>g2)
        {
            g[ss1]+=3;
        }
        if (g1==g2)
        {
            g[ss1]++;
            g[ss2]++;
        }
        if (g1<g2)
        {
            g[ss2]+=3;
        }
    }
    string kto;
    for (set<string>::iterator it=ss.begin();it!=ss.end();it++ )
    {
        if ( koll[*it]==2 && *it!=s )
        {
             kto=*it;
        }
       // cout<<*it<<" "<<g[*it]<<" "<<h[*it]<<" "<<h2[*it]<<endl;
    }
    //cout<<kto<<endl;
    for (int i=1;i<100;i++)
        for (int z=0;z<i;z++)
        {
             int kol=0;
             h[s]+=i;
             h2[s]+=z;
             h[kto]+=z;
             h2[kto]+=i;
             g[s]+=3;
             for (set<string>::iterator it=ss.begin();it!=ss.end();it++)
             {
                 if (*it==s)
                    continue;
                 kol+=cmp( s, *it );
             }
             if (kol>=2)
             {
                //cout<<i<<":"<<0<<endl;
                if (i-z<otv.first-otv.second)
                   otv=make_pair(i, z);
                if (i-z==otv.first-otv.second)
                {
                   if (z<otv.second)
                      otv=make_pair(i, z);
                }
                //return 0;
             }
             h[kto]-=z;
             h2[s]-=z;

             h2[kto]-=i;
             h[s]-=i;
             g[s]-=3;
        }
    if (otv.first!=100000)
       cout<<otv.first<<":"<<otv.second<<endl;
       else
    cout<<"IMPOSSIBLE"<<endl;
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) v.erase(unique(ALL(v)),v.end())
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FILL(x,y) memset(x,y,sizeof(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef unsigned int uint;
const string B="BERLAND";
string x;
map<string,int> mp;//记录队伍的比赛情况，也就是打了多少场
stringstream ss;//读入时更方便
struct team
{
    int p;//分数
    int d;//净胜球
    int g;//进球数
    team(int p=0,int d=0,int g=0):p(p),d(d),g(g){};//构造函数
};
map<string,team> t;//t[队名]=队伍情况（结构体）
/*-------The Main Code-------*/

bool Better(string a,string b)//a胜过b
{
    if(t[a].p!=t[b].p)//先比得分
    {
        return t[a].p>t[b].p;
    }
    if(t[a].d!=t[b].d)//再比净胜（球）
    {
        return t[a].d>t[b].d;
    }
    if(t[a].g!=t[b].g)//然后比进球
    {
        return t[a].g>t[b].g;
    }
    return a<b;//最后比名字（字典序）
}

bool check(int a,int b)//最后一场比分为x:y是否可取
{
//  更新状态
    mp[B]++,mp[x]++;
    t[B].d+=a-b,t[x].d+=b-a;
    t[B].g+=a,t[x].g+=b;
    if(a==b)
    {
        t[B].p++,t[x].p++;
    }
    else if(a>b)
    {
        t[B].p+=3;
    }
    else
    {
        t[x].p+=3;
    }
    int rank=1;
    EACH(mp,it)
    {
        if(it->first==B)
        {
            continue;
        }
        rank+=Better(it->first,B);//有一支队伍胜过BERLAND，rank就+1
    }
//  EACH(t,it)
//  {
//      cout<<it->first<<' '<<(it->second).p<<' '<<(it->second).d<<' '<<(it->second).g<<'\n';
//  }
//  进行还原
    mp[B]--,mp[x]--;
    t[B].d-=a-b,t[x].d-=b-a;
    t[B].g-=a,t[x].g-=b;
    if(a==b)
    {
        t[B].p--,t[x].p--;
    }
    else if(a>b)
    {
        t[B].p-=3;
    }
    else
    {
        t[x].p-=3;
    }
    return rank<=2;
}

int main(int argv,char *argc[])
{
    for(int i=0;i<5;i++)
    {
        string s,a,b;
        int ga,gb;
        getline(cin,s);
        for(int i=0;i<s.size();i++)
        {
            if(s[i]==':')
            {
                s[i]=' ';
            }
        }
        ss.clear();
        ss.str(""),ss<<s;
        ss>>a,ss>>b,ss>>ga,ss>>gb;//臭不要脸的stringstream读入，方便一些
//      update
        mp[a]++,mp[b]++;
        t[a].d+=ga-gb,t[b].d+=gb-ga;
        t[a].g+=ga,t[b].g+=gb;
        if(ga==gb)
        {
            t[a].p++,t[b].p++;
        }
        else if(ga>gb)
        {
            t[a].p+=3;
        }
        else
        {
            t[b].p+=3;
        }
    }
    EACH(mp,it)
    {
        if(it->second==2&&it->first!=B)
        {
            x=it->first;
        }
    }
//  EACH(t,it)
//  {
//      cout<<it->first<<' '<<(it->second).p<<' '<<(it->second).d<<' '<<(it->second).g<<'\n';
//  }
//  枚举得分
    for(int d=1;d<=100;d++)
    {
        for(int b=0;b<=100;b++)
        {
            int a=b+d;
            if(check(a,b))
            {
                cout<<a<<":"<<b;
                exit(0);
            }
        }
    }
    cout<<"IMPOSSIBLE";
    return 0;
}//hello

#include <stdio.h>
#include <string.h>
int main(){
	char name[4][21]={"","","",""};
	char name2[21],name3[21];
	int score[4]={0}, miss[4]={0}, goal[4]={0}, count[4]={0};
	int ber=5,i,j,k,l,a,b,bo,coun=5;
	for(i=0;i<5;i++){
		scanf("%s %s %d:%d", name2, name3, &a,&b);
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name2,name[k])==0){
				bo=1;
				goal[k]+=a;
				miss[k]+=b;
				if(a>b)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				if(ber==5){
					if(strcmp(name2,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name2);
			if(a>b)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=a;
			miss[k]+=b;
			count[k]++;
		}
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name3,name[k])==0){
				bo=1;
				if(b>a)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				goal[k]+=b;
				miss[k]+=a;
				if(ber==5){
					if(strcmp(name3,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name3);
			if(b>a)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=b;
			miss[k]+=a;
			count[k]++;
		}
	}
	score[ber]+=3;
	for(i=0;i<4;i++){
		for(j=3;j>i;j--){
			if((score[j]>score[i])||
				(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])||
				(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&goal[i]<goal[j])||
				(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&goal[i]==goal[j]&&strcmp(name[i],name[j])>0)){
				a=score[i];
				score[i]=score[j];
				score[j]=a;
				a=goal[i];
				goal[i]=goal[j];
				goal[j]=a;
				a=miss[i];
				miss[i]=miss[j];
				miss[j]=a;
				strcpy(name2,name[i]);
				strcpy(name[i],name[j]);
				strcpy(name[j],name2);
				a=count[i];
				count[i]=count[j];
				count[j]=a;
			}
		}
	}
	for(i=0;i<4;i++){
		if(strcmp(name[i],"BERLAND")==0)
			ber=i;
		if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
			coun=i;
	}
	if(ber<=1)
		printf("1:0\n");
	else{
		if(score[ber]==score[1]){
			for(k=1;ber>1&&k<51;k++){
				for(l=0;l<51&&ber>1;l++){
					goal[ber]+=(k+l);
					miss[coun]+=(k+l);
					goal[coun]+=l;
					miss[ber]+=l;
					for(i=0;i<4;i++){
						for(j=3;j>i;j--){
							if((score[j]>score[i])||(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])||
								(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&goal[i]<goal[j])||
								(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&goal[i]==goal[j]&&strcmp(name[i],name[j])>0)){
								a=score[i];
								score[i]=score[j];
								score[j]=a;
								a=goal[i];
								goal[i]=goal[j];
								goal[j]=a;
								a=miss[i];
								miss[i]=miss[j];
								miss[j]=a;
								strcpy(name2,name[i]);
								strcpy(name[i],name[j]);
								strcpy(name[j],name2);
								a=count[i];
								count[i]=count[j];
								count[j]=a;
							}
						}
					}
					for(i=0;i<4;i++){
						if(strcmp(name[i],"BERLAND")==0)
							ber=i;
						if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
							coun=i;
					}
					goal[ber]-=(k+l);
					miss[coun]-=(k+l);
					goal[coun]-=l;
					miss[ber]-=l;
				}
			}
			printf("%d:%d\n",k+l-2, l-1);
		}else{
			printf("IMPOSSIBLE\n");
		}
	}
	return 0;
}

#pragma comment(linker, "/STACK:256000000")

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <ctime>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

template<class T>
double sqrt(T x)
{
	return sqrt((double) x);
}

template<class T>
T sqr (T x)
{
	return x*x;
}

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define SZ(x) (int)((x).size())
//#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)

const double PI = acos(-1.0);
const int INF = 1000000000;
const int MOD = 1000000007;

struct team
{
	string name;
	int points, dif,  zab;

	team(){};
	team( string n, int p, int d, int z)
	{
		points = p;
		name = n;
		dif = d;
		zab = z;
	}

	bool operator<(const team o) const
	{
		if ( points < o.points ) return 1;
		if ( points == o.points && dif < o.dif ) return 1;
		if ( points == o.points && dif == o.dif && zab < o.zab ) return 1;
		if ( points == o.points && dif == o.dif && zab == o.zab && name > o.name ) return 1;
		return 0;
	}
};

//#define ONLINE_JUDGE

int main()
{
	double TIME_START = clock();
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif

	string sa,sb;
	int ta,tb;
	char ch;
	map<string, int> points, pro, zab, g;
	for (int x = 0 ; x < 5 ; x++)
	{
		cin >> sa >> sb >> ta >> ch >> tb;
		points[sa] += 0;
		points[sb] += 0;
		if ( ta > tb ) points[sa] += 3;
		if ( ta < tb ) points[sb] += 3;
		if ( ta == tb )
		{
			points[sa] += 1;
			points[sb] += 1;
		}

		zab[sa] += ta;
		zab[sb] += tb;

		pro[sa] += tb;
		pro[sb] += ta;

		g[sa]++;
		g[sb]++;
	}

	int bn, on;

	string Ber("BERLAND");

	vector<team> temp(4), cur;
	int i = 0;
	for ( map<string, int>::iterator it = points.begin() ; it != points.end() ; it++,i++)
	{
		temp[i] = team(it->X, it->Y, zab[it->X] - pro[it->X], zab[it->X]);
		if ( it->X == Ber )
			bn = i;
		else
			if ( g[it->X] == 2 ) on = i;
	}

	pair<int,int> r;
	bool is = 0;

	for (int x = 1 ; x <= 50 ; x++)
	{
		for (int y = 0 ; y < x ; y++)
		{
			cur = temp;

			cur[bn].points += 3;
			cur[bn].zab += x;
			cur[on].zab += y;

			cur[bn].dif += x-y;
			cur[on].dif += y-x;

			sort(cur.begin(), cur.end());

			if ( cur[2].name == Ber || cur[3].name == Ber )
			{
				if ( is == 0 )
				{
					r = mp(x,y);
					is = 1;
				} else
				{
					if ( x-y < r.X - r.Y )
						r = mp(x,y);
					else
						if ( x-y == r.X - r.Y )
							if ( y < r.Y )
								r = mp(x,y);
				}
			}
		}
	}

	if ( is == 0 ) cout<<"IMPOSSIBLE";
	else printf("%d:%d",r.X, r.Y);

	eprintf("\n\n%.15lf\n\n",(double)(clock() - TIME_START)/CLOCKS_PER_SEC);
	return 0;
}

#pragma comment(linker,"/STACK:100000000000")
#include <iostream>
#include <iomanip>
#include <fstream>
#include <set>
#include <algorithm>
#include <vector>
//#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
#include <iterator>

#define FR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,c,n) for(int (i)=(c);(i)<(n);(i)++)
#define REP(it,v,cont) for((cont)::iterator (it)=(v).begin();(it)!=(v).end();++(it))
#define CLR(a,c) memset((a),(c),sizeof (a))
#define ALL(v) (v).begin(),(v).end()
#define VCPRINT(v) for(int iii = 0;iii < (v).size();iii++) cout<<(v)[iii]<<" ";cout<<endl;
#define SETPRINT(v,cont) for((cont)::iterator iiit = (v).begin();iiit != (v).end();iiit++) cout<<*iiit<<" ";cout<<endl;

bool ascending (int i,int j) { return (i<j); }
bool descending (int i,int j) { return (i>j); }

typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLI pair<long long,int>
#define PIL pair<int,long long>
#define PSI pair<string,int>
#define PSS pair<string,string>

using namespace std;

const int DELTA = 31193;
const ull MOD = 1000*1000*1000+7;

struct Team{
	string name;
	int point;
	int zade;
	int khorde;
	int gd;
	int matches;
} Teams[4];

bool comp(const Team& t1,const Team& t2)
{
	if(t1.point > t2.point) return true;
	if(t1.point < t2.point) return false;
	if(t1.gd > t2.gd) return true;
	if(t1.gd < t2.gd) return false;
	if(t1.zade > t2.zade) return true;
	if(t1.zade < t2.zade) return false;
	return t1.name < t2.name;
}

bool tafazolgoalsort(const PII& p1,const PII& p2)
{
	if(p1.first-p1.second != p2.first - p2.second)
		return p1.first-p1.second < p2.first - p2.second;
	return p1.first < p2.first;
}

PII parse(string s)
{
	string s1,s2;
	int x = 0;while(s[x]!=':') x++;
	s1 = s.substr(0,x);
	s2 = s.substr(x+1);
	return PII(atoi(s1.c_str()),atoi(s2.c_str()));
}

int main()
{
	set<string> names;
	pair<pair<string,string>,string> tmp[5];
	FR(i,5)
	{
		string s1,s2,s3;cin>>s1>>s2>>s3;
		tmp[i] = pair<PSS,string>(PSS(s1,s2),s3);
		names.insert(s1);names.insert(s2);
	}
	int i = 0;
	for(set<string>::iterator it = names.begin();it != names.end();it++,i++)
	{
		Teams[i].name = *it;
		Teams[i].zade = Teams[i].khorde = Teams[i].point = Teams[i].gd = Teams[i].matches = 0;
		FR(j,5)
		{
			if(tmp[j].first.first == *it)
			{
				Teams[i].matches++;
				int s1 = parse(tmp[j].second).first,s2 = parse(tmp[j].second).second;
				Teams[i].zade += s1;
				Teams[i].khorde += s2;
				if(s1>s2) Teams[i].point += 3;
				else if (s1 == s2) Teams[i].point += 1;
				Teams[i].gd += s1 - s2;
			}
			if(tmp[j].first.second == *it)
			{
				Teams[i].matches++;
				int s1 = parse(tmp[j].second).second,s2 = parse(tmp[j].second).first;
				Teams[i].zade += s1;
				Teams[i].khorde += s2;
				if(s1>s2) Teams[i].point += 3;
				else if (s1 == s2) Teams[i].point += 1;
				Teams[i].gd += s1 - s2;
			}
		}
	}
	sort(Teams,Teams+4,comp);
	int berInd,othInd;
	string othNam;
	FR(i,4)
	{
		if(Teams[i].name == "BERLAND") berInd = i;
		if(Teams[i].name != "BERLAND" && Teams[i].matches == 2){ othInd = i; othNam = Teams[i].name;}
	}
	if(berInd == 0 || berInd == 1){ cout<<"1:0"<<endl;return 0;}
	if(Teams[berInd].point + 3 < Teams[1].point){cout<<"IMPOSSIBLE"<<endl;return 0;}
	if(Teams[berInd].point + 3 > Teams[1].point){cout<<"1:0"<<endl;return 0;}

	vector<PII> Cand;

	FR(y,100)
	{
		FR(x,100)
		{
			if(x<=y) continue;
			Team tmp[4];
			FR(i,4) tmp[i] = Teams[i];
			tmp[berInd].matches++;
			tmp[berInd].zade+=x;
			tmp[berInd].khorde+=y;
			tmp[berInd].gd+= x-y;
			tmp[berInd].point+=3;

			tmp[othInd].matches++;
			tmp[othInd].khorde+=x;
			tmp[othInd].zade+=y;
			tmp[othInd].gd-= x-y;
			sort(tmp,tmp+4,comp);
			if(tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") Cand.push_back(PII(x,y));
		}
	}
	if(!Cand.size()){cout<<"IMPOSSIBLE"<<endl;}
	sort(Cand.begin(),Cand.end(),tafazolgoalsort);
	cout<<Cand[0].first<<":"<<Cand[0].second<<endl;
}

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <deque>
#include <locale>
#include <queue>
#include <set>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define MX 20000000000000005
using namespace std;
struct Tm{
	string name;
	int fs,wn,ls,bs;
}T[4];
inline bool cmp(Tm a,Tm b){
	if(a.fs>b.fs) return 1;
	if(a.fs<b.fs) return 0;
	int t1=a.wn-a.ls,t2=b.wn-b.ls;
	if(t1>t2) return 1;
	if(t1<t2) return 0;
	if(a.wn>b.wn) return 1;
	if(a.wn<b.wn) return 0;
	return a.name<b.name;
}
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	int i,j,nsz=-1;
	string a,b,c;
	for(i=0;i<5;i++){
		cin>>a>>b>>c;
		int nm1=-1,nm2=-1;
		for(j=0;j<4;j++){
			if(T[j].name==a){
				nm1=j;
			}else if(T[j].name==b){
				nm2=j;
			}
		}
		if(nm1==-1){
			nm1=++nsz;
			T[nsz].name=a;
		}
		if(nm2==-1){
			nm2=++nsz;
			T[nsz].name=b;
		}
		int x,y;
		x=c.substr(0,1)[0]-'0';
		y=c.substr(2,1)[0]-'0';
		T[nm1].ls+=y;
		T[nm2].ls+=x;
		T[nm1].wn+=x;
		T[nm2].wn+=y;
		T[nm1].bs++;
		T[nm2].bs++;
		if(x>y){
			T[nm1].fs+=3;
		}else if(x<y){
			T[nm2].fs+=3;
		}else{
			T[nm1].fs++;
			T[nm2].fs++;
		}
	}
	sort(T,T+4,cmp);
//	for(i=0;i<4;i++) cout<<T[i].name<<"          "<<T[i].fs<<" "<<T[i].wn<<" "<<T[i].ls<<" "<<T[i].bs<<endl;
//	if(T[0].name=="BERLAND"||T[1].name=="BERLAND"){
//		cout<<"IMPOSSIBLE"<<endl;
//		return 0;
//	}
	int ws=0,bt;
	for(i=0;i<4;i++){
		if(T[i].name=="BERLAND") ws=i;
		else if(T[i].bs<3) bt=i;
	}
//	cout<<bt<<endl;
	if(T[ws].fs+3<T[1].fs){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	int y=0,ppp=0,x=-1;
	T[ws].fs+=3;
	int tx,ty=-1;
	while(++ppp<99){
//		cout<<y<<endl;
//		for(i=0;i<4;i++) cout<<T[i].name<<"          "<<T[i].fs<<" "<<T[i].wn<<" "<<T[i].ls<<" "<<T[i].bs<<endl;
//		cout<<endl;
//		system("pause");
//		while(T[1].name!="BERLAND"&&T[0].name!="BERLAND"){
			for(i=0;i<4;i++){
				if(T[i].name=="BERLAND") ws=i;
				else if(T[i].bs<3) bt=i;
			}
			T[ws].wn++;
			T[bt].ls++;
			sort(T,T+4,cmp);
			y++;
//		}
		y=max(y,1);
		tx=0;
		if(T[1].name=="BERLAND"||T[0].name=="BERLAND"){
			Tm Tt[4];
			Tt[0]=T[0];
			Tt[1]=T[1];
			Tt[2]=T[2];
			Tt[3]=T[3];
			tx=0;
			while((Tt[1].name=="BERLAND"||Tt[0].name=="BERLAND")&&tx<y){
				for(i=0;i<4;i++){
					if(Tt[i].name=="BERLAND") ws=i;
					else if(Tt[i].bs<3) bt=i;
				}
//				cout<<bt<<endl;
				Tt[ws].ls++;
				Tt[bt].wn++;
				sort(Tt,Tt+4,cmp);
				tx++;
//				for(i=0;i<4;i++) cout<<T[i].name<<"          "<<T[i].fs<<" "<<T[i].wn<<" "<<T[i].ls<<" "<<T[i].bs<<endl;
//				cout<<endl;
//				system("pause");
			}
			tx--;
//			cout<<y<<"  "<<tx<<"       "<<ty<<"  "<<x<<endl;
//			system("pause");
			tx=max(0,tx);
			if(ty==-1){
				x=tx;
				ty=y;
				continue;
			}
			if(y-tx<ty-x){
				x=tx;
				ty=y;
			}
		}
	}
	cout<<ty<<':'<<x<<endl;
	return 0;
	#ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
}

#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

#define REP(i,n)    for(int i=1;i<=(n);++i)
#define FOR(i,n)    for(int i=0;i<(n);++i)
#define FORE(i,e,n) for(int i=(e);i<(n);++i)
#define FORF(it, v) for(typeof((v).begin()) it=(v).begin();it!=(v).end();++it)

#define out(v) cout<<(v)<<endl
#define _(A,v) memset(A,v,sizeof(A))
#define all(A)  (A).begin(), (A).end()
#define pb push_back
#define mp make_pair

#define ull long long

struct team {
	int points;
	string name;
	int goals, misseds;
	int games;
	team(int p = 0, string n = "", int g = 0, int m = 0, int gs = 0) {
		points = p;
		name = n;
		goals = g;
		misseds = m;
		games = 0;
	}
	bool operator<(const team &b) const {
			// up
		if(points > b.points) return true;
			// down
		if(points < b.points) return false;
			// equal points, get diff
		int dif_a = goals - misseds;
		int dif_b = b.goals - b.misseds;
		if(dif_a > dif_b) return true;
		if(dif_a < dif_b) return false;
			// equal diff
		if(goals > b.goals) return true;
		if(goals < b.goals) return false;
			// equal goals
		return name < b.name;
	}
};

void copy_t(team src[5], team dest[5]) {
	FOR(i, 5) dest[i] = src[i];
}

int main() {
	/*freopen("d.in",  "r", stdin);
	freopen("d.out", "w", stdout);*/

	string name_x, name_y;
	int x, y;
	set<string> teams;
	set<team> table;
	string game[2][5];
	int result[2][5];
	char final[50];

	FOR(i, 5) {
		cin>>name_x>>name_y>>final;
		result[0][i] = atoi(strtok(final, ":"));
		result[1][i] = atoi(strtok(0, ":"));
		game[0][i] = name_x;
		game[1][i] = name_y;
		teams.insert(name_x);
		teams.insert(name_y);
	}
	FORF(it, teams) {
		name_x = *it;
		team t;
		t.name = name_x;
		FOR(i, 5) {
				// local
			if(game[0][i] == name_x) {
					// win
				if(result[0][i] > result[1][i]) {
					t.points += 3;
				}	// draw
				else if(result[0][i] == result[1][i]) {
					t.points += 1;
				}
					// update goals
				t.goals += result[0][i];
				t.misseds += result[1][i];
				t.games++;
			}	// away
			else if(game[1][i] == name_x) {
					// win
				if(result[1][i] > result[0][i]) {
					t.points += 3;
				}	// draw
				else if(result[1][i] == result[0][i]) {
					t.points += 1;
				}
					// update goals
				t.goals += result[1][i];
				t.misseds += result[0][i];
				t.games++;
			}
		}
		table.insert(t);
	}
	team standing[5], tmp[5];
	int pos_x = -1, pos_y = -1;
	int p = 0;
	FORF(it, table) {
		if((*it).games == 2) {
			if(pos_x == -1) pos_x = p;
			else pos_y = p;
		}
		standing[p++] = *it;
	}
	copy_t(standing, tmp);
	sort(tmp, tmp + 4);

	int bi = -1, bj, min_dif = 1000000;
	if(tmp[pos_x].name == "BERLAND") {
		for(int i = 0; i <= 18; ++i)
		for(int j = i - 1; j >= 0; --j) {
			copy_t(standing, tmp);
				// win
			tmp[pos_x].points += 3;
			tmp[pos_x].goals += i;
			tmp[pos_x].misseds += j;
			tmp[pos_y].goals += j;
			tmp[pos_y].misseds += i;
			sort(tmp, tmp + 4);
			if(tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") {
				if(i - j < min_dif) {
					bi = i;
					bj = j;
					min_dif = i - j;
				}
			}
		}
	} else {
		for(int i = 0; i <= 18; ++i)
		for(int j = i - 1; j >= 0; --j) {
			copy_t(standing, tmp);
				// win
			tmp[pos_y].points += 3;
			tmp[pos_y].goals += i;
			tmp[pos_y].misseds += j;
			tmp[pos_x].goals += j;
			tmp[pos_x].misseds += i;
			sort(tmp, tmp + 4);
			if(tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") {
				if(i - j < min_dif) {
					bi = i;
					bj = j;
					min_dif = i - j;
				}
			}
		}
	}
	if(bi == -1)
		out("IMPOSSIBLE");
	else {
		cout << bi << ":" << bj << endl;
	}
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
struct Info
{
    string name;
    int score, goals, fails;
    Info(string s)
    {
        name = s;
        score = goals = fails = 0;
    }
    Info()
    {
        name = "";
        score = goals = fails = 0;
    }
};
map<string, Info> q;

vector<Info> teams;

bool operator <(Info a, Info b)
{
    return (a.score < b. score || (a.score == b.score && a.goals - a. fails < b.goals - b.fails) ||
        (a.score == b.score && a.goals - a. fails == b.goals - b.fails && a.goals < b.goals) ||
        (a.score == b.score && a.goals - a. fails == b.goals - b.fails && a.goals == b.goals && a.name > b.name));
}

int main()
{
    vector<string> temp1;
    for (int i = 0; i < 5; ++i)
    {
        string team1, team2;
        int s1, s2;
        cin >> team1 >> team2 >> s1;
        getchar();
        cin >> s2;
        if (q.count(team1) == 0)
            q.insert(make_pair(team1, Info(team1)));
        if (q.count(team2) == 0)
            q.insert(make_pair(team2, Info(team2)));
        if (s1 > s2)
            q[team1].score += 3;
        if (s1 == s2)
        {
            q[team1].score += 1;
            q[team2].score += 1;
        }
        if (s2 > s1)
            q[team2].score += 3;
        q[team1].goals += s1;
        q[team1].fails += s2;
        q[team2].fails += s1;
        q[team2].goals += s2;
        if (team1 == "BERLAND")
            temp1.push_back(team2);
        if (team2 == "BERLAND")
            temp1.push_back(team1);
    }
    string other;
    for (map<string, Info>::iterator it = q.begin(); it != q.end(); ++it)
    {
        teams.push_back(it->second);
        bool found = false;
        for (int i = 0; i < 2; ++i)
            if (temp1[i] == it->first)
                found = true;
        if (!found && it->first != "BERLAND")
            other = it->first;
    }
    int idx1, idx2;
    for (int i = 0; i < 4; ++i)
    {
        if (teams[i].name == "BERLAND")
            idx1 = i;
        if (teams[i].name == other)
            idx2 = i;
    }
    vector<Info> temp(4);
    teams[idx1].score += 3;
    pair<int, int> res = make_pair(1E9, 1E8);
    for (int x = 1; x <= 100; ++x)
        for (int y = 0; y < x; ++y)
        {
            for (int i = 0; i < 4; ++i)
            {
                temp[i].score = teams[i].score;
                temp[i].goals = teams[i].goals;
                temp[i].fails = teams[i].fails;
                temp[i].name = teams[i].name;
            }
            temp[idx1].goals += x;
            temp[idx1].fails += y;
            temp[idx2].fails += x;
            temp[idx2].goals += y;
            sort(temp.begin(), temp.end());
            if (temp[2].name == "BERLAND" || temp[3].name == "BERLAND")
                if ((x - y < res.first - res.second) || (x - y == res.first - res.second && y < res.second))
                    res = make_pair(x, y);
        }
    if (res.first > 1E8)
        cout << "IMPOSSIBLE";
    else
        cout << res.first << ':' << res.second;
}

//#pragma comment(linker,"/STACK:128000000")
#include <cstdio>
#include <memory>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <complex>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef short int si;
typedef unsigned short int usi;
typedef long double ld;
typedef pair<short,short> pss;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(x,y,z) for(int x=(y),e##x=(z);x<e##x;x++)
#define all(x) (x).begin(),(x).end()
#define movmax(A,B) {if(A<(B)) A=(B);}
#define movmin(A,B) {if(A>(B)) A=(B);}

const double PI=acos(-1.0);
template<class T> T SQR(const T &a){return a*a;}

struct match
{
	int f;
	int s;
	int zab;
	int pr;
	match(){}
	match(int f0,int s0,int z,int p)
	{
		f=f0;
		s=s0;
		zab=z;
		pr=p;
	}
};

int Point[4]={0};
int Goal[4]={0};
int Prop[4]={0};

bool cmp(int a,int b)
{
	if (Point[a]!=Point[b])
		return Point[a]>Point[b];
	if (Goal[a]-Prop[a]!=Goal[b]-Prop[b])
		return Goal[a]-Prop[a]>Goal[b]-Prop[b];
	if (Goal[a]!=Goal[b])
		return Goal[a]>Goal[b];
	return a<b;
}

int place(match M[6],int team)
{
	rep(i,0,4)
		Goal[i]=Point[i]=Prop[i]=0;
	rep(i,0,6)
	{
		Goal[M[i].f]+=M[i].zab;
		Prop[M[i].f]+=M[i].pr;
		Goal[M[i].s]+=M[i].pr;
		Prop[M[i].s]+=M[i].zab;
		if (M[i].zab==M[i].pr)
		{
			Point[M[i].f]++;
			Point[M[i].s]++;
		}
		else if (M[i].zab>M[i].pr)
			Point[M[i].f]+=3;
		else
			Point[M[i].s]+=3;
	}
	int A[4]={0,1,2,3};
	sort(A,A+4,cmp);
	rep(i,0,4)
		if (A[i]==team)
			return i;
}

void getMatch(match M[6])
{
	char F[6][1000],S[6][1000];
	vector<string> vec;
	map<string,int> games;
	rep(i,0,5)
	{
		scanf(" %s %s %d:%d",F[i],S[i],&M[i].zab,&M[i].pr);
		vec.push_back(F[i]);
		vec.push_back(S[i]);
		games[F[i]]++;
		games[S[i]]++;
	}
	sort(all(vec));
	vec.resize(unique(all(vec))-vec.begin());
	string curr;
	rep(i,0,4)
		if (vec[i]!="BERLAND" && games[vec[i]]<3)
			curr=vec[i];
	map<string,int> mp;
	rep(i,0,4)
		mp[vec[i]]=i;
	rep(i,0,5)
	{
		M[i].f=mp[F[i]];
		M[i].s=mp[S[i]];
	}
	M[5].f=mp["BERLAND"];
	M[5].s=mp[curr];
}

void run()
{
	match M[6];
	getMatch(M);
	int x=-1,y=-1;
	rep(i,1,100)
		rep(j,0,i)
		{
			M[5].zab=i;
			M[5].pr=j;
			int pl=place(M,M[5].f);
			if (pl<=1 && (x==-1 || i-j<x-y  || i-j==x-y && j<y))
			{
				x=i;
				y=j;
			}
		}
	if (x==-1)
		printf("IMPOSSIBLE\n");
	else
		printf("%d:%d\n",x,y);
}

int main()
{
#ifdef _MONYURA_
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	time_t beg=clock();
#endif
	run();
#ifdef _MONYURA_
	printf("================\n");
	printf("Time: %.3lf s.\n",(clock()-beg)/double(CLOCKS_PER_SEC));
#endif
	return 0;
}

/*

*/

/*
 * File:   main.cpp
 * Author: Anton Boytsov
 *
 * Created on 24 Июнь 2012 г., 21:28
 */

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

struct team {
    string name;
    int pts, gs, gf;

    team(string name) : name(name), pts(0), gs(0), gf(0) {
    };

    void score(int goals) {
        gs += goals;
    }

    void unscore(int goals) {
        gf += goals;
    }

    void make_points(int points) {

        pts += points;

    }

};

bool cmp(team a, team s) {

    if (a.pts > s.pts)
        return true;
    if (a.pts == s.pts) {

        if (a.gs - a.gf > s.gs - s.gf)
            return true;
        if (a.gs - a.gf == s.gs - s.gf) {

            if (a.gs > s.gs)
                return true;
            if (a.gs == s.gs) {

                if (a.name < s.name)
                    return true;
                else
                    return false;

            } else
                return false;

        } else
            return false;

    } else
        return false;

}

vector<team> ts;

void addscore(int s1, int s2, string t, string u) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t) {
            ts[i].score(s1);
            ts[i].unscore(s2);
        }
        if (ts[i].name == u) {
            ts[i].score(s2);
            ts[i].unscore(s1);
        }
    }
}

void addteam(string t) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t)
            return;
    }
    ts.push_back(team(t));

}

void addpts(int points, string t) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t) {
            ts[i].make_points(points);
            return;
        }
    }

}

void outteams() {
    cout << "table:" << endl;
    for (int i = 0; i < 4; i++) {
        cout << ts[i].name << " pts: " << ts[i].pts << " gs:" << ts[i].gs << " gf:" << ts[i].gf << endl;
    }
}

map<string, int> played;
char t[100], u[100];

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    for (int i = 0; i < 5; i++) {
        memset(t, 0, sizeof (t));
        memset(u, 0, sizeof (u));
        int s1, s2;
        scanf("%s %s %d:%d", t, u, &s1, &s2);
        addteam(string(t));
        addteam(string(u));
        addscore(s1, s2, string(t), string(u));
        if (s1 > s2) {
            addpts(3, string(t));
        } else if (s1 == s2) {
            addpts(1, string(t));
            addpts(1, string(u));
        } else {
            addpts(3, string(u));
        }
        played[string(t)]++;
        played[string(u)]++;
    }

    string p;
    for (map<string, int>::iterator it = played.begin(); it != played.end(); it++) {
        if (it->second == 2 && it->first != "BERLAND") {
            p = it->first;
            break;
        }
    }
    //cout << p << endl;

    sort(ts.begin(), ts.end(), cmp);
    addpts(3, "BERLAND");
    for (int d = 1; d < 100; d++) {

        for (int j = 0; j < 100; j++) {

            addscore(j + d, j, "BERLAND", p);
            sort(ts.begin(), ts.end(), cmp);
            //outteams();
            if (ts[0].name == "BERLAND" || ts[1].name == "BERLAND") {
                cout << j + d << ":" << j << endl;
                return 0;
            }
            addscore(-(j + d), -j, "BERLAND", p);
        }

    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

//lxrtxdy!
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
map<string,int> mp;
int cnt;
string name[5];
int goal[5],miss[5],point[5],tim[5];
bool cmp(int a,int b)
{
	if(point[a]!=point[b]) return point[a]>point[b];
	if(goal[a]-miss[a]!=goal[b]-miss[b]) return goal[a]-miss[a]>goal[b]-miss[b];
	if(goal[a]!=goal[b]) return goal[a]>goal[b];
	return name[a]<name[b];
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	mp["BERLAND"]=++cnt;
	name[cnt]="BERLAND";
	for(int i=1;i<=5;i++)
	{
		string t1,t2;
		int g1,g2;
		char c;
		cin>>t1>>t2>>g1>>c>>g2;
		if(!mp.count(t1))
		{
			mp[t1]=++cnt;
			name[cnt]=t1;
		}
		if(!mp.count(t2))
		{
			mp[t2]=++cnt;
			name[cnt]=t2;
		}
		if(g1>g2)
			point[mp[t1]]+=3;
		else if(g1==g2)
		{
			point[mp[t1]]++;
			point[mp[t2]]++;
		}
		else
			point[mp[t2]]+=3;
		goal[mp[t1]]+=g1;
		goal[mp[t2]]+=g2;
		miss[mp[t1]]+=g2;
		miss[mp[t2]]+=g1;
		tim[mp[t1]]++;
		tim[mp[t2]]++;
	}
	int enemy;
	for(int i=1;i<=4;i++)
		if(tim[i]==2&&i!=1)
			enemy=i;
	for(int dif=1;dif<=100;dif++)
		for(int y=0;y<=100;y++)
		{
			int x=y+dif;
			point[1]+=3;
			goal[1]+=x;
			goal[enemy]+=y;
			miss[1]+=y;
			miss[enemy]+=x;
			vector<int> v;
			for(int i=1;i<=4;i++)
				v.push_back(i);
			sort(v.begin(),v.end(),cmp);
			if(v[0]==1||v[1]==1)
			{
				cout<<x<<':'<<y<<endl;
				return 0;
			}
			point[1]-=3;
			goal[1]-=x;
			goal[enemy]-=y;
			miss[1]-=y;
			miss[enemy]-=x;
		}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

//orzlxr!

#include <bits/stdc++.h>

using namespace std;

struct node{
    int point;
    string nam;
    int id;
    int x;
    int y;
    bool operator < (const node & a)const{
        if(a.point==point)
        {
            if(a.x-a.y==x-y)
            {
                if(x!=a.x)return x>a.x;
                else return nam<a.nam;
            }
            else return x-y>a.x-a.y;
        }
        else return point>a.point;
    }
}t[5], tmp[5];
map<string, int>mp;
int book[6];
int f(int x, int y, int o, int e){
    int i;
    for(i=1; i<=4; i++){
        tmp[i]=t[i];
    }
    tmp[o].point+=3;
    tmp[o].x+=x, tmp[e].y+=x;
    tmp[o].y+=y, tmp[e].x+=y;
    sort(tmp+1, tmp+5);
    if(tmp[1].id==o || tmp[2].id==o)return true;
    return false;
}

int main(){
    string a, b;
    int x, y, t1, t2;
    int cnt=0;
    for(int i=1; i<=5; i++){
        cin>>a>>b;
        scanf("%d:%d", &x, &y);
        if(!mp[a]){
            t1=mp[a]=++cnt;
        }
        else t1=mp[a];
        if(!mp[b]){
            t2=mp[b]=++cnt;
        }
        else t2=mp[b];
        t[t1].nam=a, t[t2].nam=b;
        t[t1].id=t1, t[t2].id=t2;
        t[t1].x+=x, t[t1].y+=y;
        t[t2].x+=y, t[t2].y+=x;
        if(x>y)t[t1].point+=3;
        else if(x==y)t[t1].point++, t[t2].point++;
        else t[t2].point+=3;
        if(a=="BERLAND" || b=="BERLAND")book[t1]=book[t2]=1;
    }
    int e, o;
    for(int i=1; i<=4; i++)if(!book[i])e=i;
    for(int i=1; i<=4; i++)if(i==mp["BERLAND"])o=i;

    int l=0, r=0;
    for(int i=0; i<=100; i++)
    {
        for(int j=0; j<i; j++)
        {
            if(f(i, j, o, e) && ((l==r && l==0) ||( (i-j)<(l-r) ||(i-j==(l-r) && j<r))))
            {
                l=i, r=j;
            }
        }
    }
    if(l!=0)printf("%d:%d\n", l, r);
    else printf("IMPOSSIBLE\n");
}

#include <stdio.h>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

struct dado
{
    string nome;
    int gol;
    int saldo;
    int pts;
    int jogos;
};

dado team[20];
map<string, int> mapa;

bool comp(dado a, dado b)
{
    if(a.pts!=b.pts) return a.pts>b.pts;
    if(a.saldo!=b.saldo) return a.saldo>b.saldo;
    if(a.gol!=b.gol) return a.gol>b.gol;
    return a.nome<b.nome;
}

int rank()
{
    int resp;
    dado ate[10];
    for(int i=1; i<=4; i++)
    {
        ate[i]=team[i];
    }
    sort(&ate[1], &ate[5], comp);
    /*for(int i=1; i<=4; i++)
    {
        printf("%d time=%s pts=%d gol=%d saldo=%d\n", i, ate[i].nome.c_str(), ate[i].pts, ate[i].gol, ate[i].saldo);
    }*/
    for(int i=1; i<=4; i++)
    {
        if(ate[i].nome=="BERLAND")
        {
            resp=i;
        }
    }
    return resp;
}

int check()
{
    int resp;
    dado ate[10];
    for(int i=1; i<=4; i++)
    {
        ate[i]=team[i];
    }
    sort(&ate[1], &ate[5], comp);
    /*for(int i=1; i<=4; i++)
    {
        printf("%d time=%s pts=%d gol=%d saldo=%d\n", i, ate[i].nome.c_str(), ate[i].pts, ate[i].gol, ate[i].saldo);
    }*/
    for(int i=1; i<=4; i++)
    {
        if(ate[i].nome=="BERLAND")
        {
            resp=i;
        }
    }
    if(ate[resp].saldo>=ate[2].saldo) return 1;
    else return 0;
}

int main()
{
    //char c='9';
    char tmp[100];
    string s1, s2;
    int t1, t2, p, q;
    int ind, rival;
    int cont=0;
    ind=0; rival=0;
    int aux1, aux2;
    for(int i=0; i<5; i++)
    {
        scanf(" %s", tmp);
        s1=string(tmp);
        //printf("%s\n", s1.c_str());
        if(mapa.find(s1)==mapa.end())
        {
            cont++;
            mapa[s1]=cont;
            team[cont].jogos=0;
            team[cont].gol=0;
            team[cont].saldo=0;
            team[cont].pts=0;
            team[cont].nome=s1;
            t1=cont;
        }
        else
        {
            t1=mapa[s1];
        }
        scanf(" %s", tmp);
        s2=string(tmp);
        //printf("%s\n", s2.c_str());
        if(mapa.find(s2)==mapa.end())
        {
            cont++;
            mapa[s2]=cont;
            team[cont].jogos=0;
            team[cont].gol=0;
            team[cont].saldo=0;
            team[cont].pts=0;
            team[cont].nome=s2;
            t2=cont;
        }
        else
        {
            t2=mapa[s2];
        }
        scanf("%d:%d ", &aux1, &aux2);
        team[t1].jogos++;
        team[t1].gol+=aux1;
        team[t1].saldo+=(aux1-aux2);
        team[t2].jogos++;
        team[t2].gol+=aux2;
        team[t2].saldo+=(aux2-aux1);
        if(aux1>aux2)
        {
            team[t1].pts+=3;
        }
        else if(aux1<aux2)
        {
            team[t2].pts+=3;
        }
        else
        {
            team[t1].pts+=1;
            team[t2].pts+=1;
        }
    }
    sort(&team[1], &team[5], comp);
    /*for(int i=1; i<=4; i++)
    {
        printf("%d time=%s pts=%d gol=%d saldo=%d jogos=%d\n", i, team[i].nome.c_str(), team[i].pts, team[i].gol, team[i].saldo, team[i].jogos);
    }*/
    for(int i=1; i<=4; i++)
    {
        if(team[i].nome=="BERLAND")
        {
            ind=i;
        }
    }
    for(int i=1; i<=4; i++)
    {
        if(team[i].jogos==2 && i!=ind)
        {
            rival=i;
        }
    }
    //printf("%d %d\n", ind, rival);
    //casos pos partida
    team[ind].pts+=3;
    if(ind==1 || ind==2) printf("1:0\n");
    else if(team[ind].pts>team[2].pts) printf("1:0\n");
    else if(team[ind].pts<team[2].pts) printf("IMPOSSIBLE\n");
    else
    {
        p=1;
        team[ind].gol++;
        team[ind].saldo++;
        team[rival].saldo--;
        while(check()==0)
        {
            //printf("oi");
            team[ind].gol++;
            team[ind].saldo++;
            team[rival].saldo--;
            p++;
        }
        q=0;
        while(rank()>2)
        {
            team[ind].gol++;
            team[rival].gol++;
            q++;
        }
        printf("%d:%d\n", p+q, q);
    }
    return 0;
}

#include <cstdlib>
#include <iostream>
#include <stack>
#include <cstring>
#include <cmath>
#include <string>
#include <stdio.h>
#include <map>
#include <queue>
#include <list>
#include <vector>
#include <algorithm>

#define EPS 1e-8

const long MAX=1000;

typedef __int64 LONG;

using namespace std;

struct str
{
    string name;
    int point;
    int goal;
    int bad;
    int game;
} mas[4];

void sort()
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3-i;j++)
        {
            if(mas[j+1].point<mas[j].point)
            {
                str t=mas[j+1];
                mas[j+1]=mas[j];
                mas[j]=t;
            }
            else if(mas[j+1].point==mas[j].point)
            {
                if(mas[j+1].goal-mas[j+1].bad<mas[j].goal-mas[j].bad)
                {
                    str t=mas[j+1];
                    mas[j+1]=mas[j];
                    mas[j]=t;
                }
                else if(mas[j+1].goal-mas[j+1].bad==mas[j].goal-mas[j].bad)
                {
                    if(mas[j+1].goal<mas[j].goal)
                    {
                        str t=mas[j+1];
                        mas[j+1]=mas[j];
                        mas[j]=t;
                    }
                    else if(mas[j+1].goal==mas[j].goal)
                    {
                        if(mas[j+1].name.compare(mas[j].name)>0)
                        {
                            str t=mas[j+1];
                            mas[j+1]=mas[j];
                            mas[j]=t;
                        }
                    }
                }
            }
        }
    }
}

int main(int argc, char *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    for(int i=0;i<5;i++)
    {
        string team1,team2,S;
        int ind_t1=-1,ind_t2=-1;
        int ind=-1;
        int g1,g2;
        cin>>team1>>team2;
        for(int i=0;i<4;i++) if(mas[i].name==team1) ind_t1=i;
        if(ind_t1==-1)
        {
            for(int i=0;i<4;i++)
            {
                if(mas[i].name=="")
                {
                    ind_t1=i;
                    mas[i].name=team1;
                    break;
                }
            }
        }
        for(int i=0;i<4;i++) if(mas[i].name==team2) ind_t2=i;
        if(ind_t2==-1)
        {
            for(int i=0;i<4;i++)
            {
                if(mas[i].name=="")
                {
                    ind_t2=i;
                    mas[i].name=team2;
                    break;
                }
            }
        }
        cin>>S;
        for(int i=0;i<S.size();i++) if(S[i]==':') ind=i;
        int t=1;
        g1=0;
        for(int i=ind-1;i>=0;i--)
        {
            g1+=t*(S[i]-'0');
            t*=10;
        }
        g2=0;
        t=1;
        for(int i=ind+1;i<S.size();i++)
        {
            g2+=t*(S[i]-'0');
            t*=10;
        }
        if(g1>g2) mas[ind_t1].point+=3;
        else if(g1==g2)
        {
            mas[ind_t1].point+=1;
            mas[ind_t2].point+=1;
        }
        else mas[ind_t2].point+=3;
        mas[ind_t1].goal+=g1;
        mas[ind_t2].goal+=g2;
        mas[ind_t1].bad+=g2;
        mas[ind_t2].bad+=g1;
        mas[ind_t1].game++;
        mas[ind_t2].game++;
    }
    sort();
    int ind=-1;
    int op=-1;
    for(int i=0;i<4;i++)
    {
        if(mas[i].name=="BERLAND") ind=i;
        if(mas[i].game==2 && mas[i].name!="BERLAND") op=i;
    }
    if(mas[2].point-mas[ind].point>3)
    {
        cout<<"IMPOSSIBLE";
        return 0;
    }
    mas[ind].point+=3;
    int g1=1000,g2=0;
    for(int i=1;i<100;i++)
    {
        for(int j=0;j<i;j++)
        {
            sort();
            for(int k=0;k<4;k++)
            {
                if(mas[k].name=="BERLAND") ind=k;
                if(mas[k].game==2 && mas[k].name!="BERLAND") op=k;
            }
            mas[ind].goal+=i;
            mas[ind].bad+=j;
            mas[op].goal+=j;
            mas[op].bad+=i;
            sort();
            for(int k=0;k<4;k++)
            {
                if(mas[k].name=="BERLAND") ind=k;
                if(mas[k].game==2 && mas[k].name!="BERLAND") op=k;
            }
            if(ind>=2)
            {
                if((i-j)<(g1-g2) )
                {
                    g1=i;
                    g2=j;
                }
                else if((i-j)==(g1-g2))
                {
                    if(i<g1)
                    {
                        g1=i;
                        g2=j;
                    }
                }
            }
            mas[ind].bad-=j;
            mas[ind].goal-=i;
            mas[op].goal-=j;
            mas[op].bad-=i;
        }
    }
    cout<<g1<<":"<<g2;
    return EXIT_SUCCESS;
}

#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
string t[4];
map <string,int> nrt;
int gm[4],gp[4],nrp[4],nrm[4];
bool ok[4];
int ec[4],sol1=2000000000,sol2;

inline bool Sortare(int A,int B)
{
	if(nrp[A]==nrp[B])
	{
		if((gm[A]-gp[A])==(gm[B]-gp[B]))
		{
			if(gm[A]==gm[B])
			{
				if(t[A].compare(t[B])<=0)
					return true;
				return false;
			}
			return gm[A]>gm[B];
		}
		return (gm[A]-gp[A])>(gm[B]-gp[B]);
	}
	return nrp[A]>nrp[B];
}

int main()
{
	int i,j,g1,g2,ind;
	bool gasit;
	string s[2],aux;
	t[0]="BERLAND";
	ok[0]=true;
	for(i=1;i<=5;i++)
	{
		cin>>s[0]>>s[1]>>aux;
		g1=0;
		j=0;
		while(aux[j]!=':')
			g1=g1*10+aux[j++]-'0';
		j++;
		g2=0;
		while(j<aux.size() && '0'<=aux[j] && aux[j]<='9')
			g2=g2*10+aux[j++]-'0';
		gasit=false;
		if(s[0].compare(t[0])==0 && s[0].size()==t[0].size())
		{
			gm[0]+=g1;
			gp[0]+=g2;
			if(g1>g2)
				nrp[0]+=3;
			if(g1==g2)
				nrp[0]++;
			gasit=true;
		}
		if(!gasit)
		{
			if(nrt[s[0]]==0)
			{
				j=1;
				while(ok[j]==true)
					j++;
				nrt[s[0]]=j;
				ok[j]=true;
				t[j]=s[0];
			}
			ind=nrt[s[0]];
			gm[ind]+=g1;
			gp[ind]+=g2;
			nrm[ind]++;
			if(g1>g2)
				nrp[ind]+=3;
			if(g1==g2)
				nrp[ind]++;
			gasit=true;
		}
		gasit=false;
		if(s[1].compare(t[0])==0 && s[1].size()==t[0].size())
		{
			gm[0]+=g2;
			gp[0]+=g1;
			if(g1<g2)
				nrp[0]+=3;
			if(g1==g2)
				nrp[0]++;
			gasit=true;
		}
		if(!gasit)
		{
			if(nrt[s[1]]==0)
			{
				j=1;
				while(ok[j]==true)
					j++;
				nrt[s[1]]=j;
				ok[j]=true;
				t[j]=s[1];
			}
			ind=nrt[s[1]];
			gm[ind]+=g2;
			gp[ind]+=g1;
			nrm[ind]++;
			if(g1<g2)
				nrp[ind]+=3;
			if(g1==g2)
				nrp[ind]++;
			gasit=true;
		}
		s[0].clear();
		s[1].clear();
		aux.clear();
	}
	for(i=1;i<4;i++)
	{
		if(nrm[i]==2)
			ind=i;
	}
	nrp[0]+=3;
	for(i=0;i<4;i++)
		ec[i]=i;
	for(g1=0;g1<100;g1++)
	{
		for(g2=0;g2<g1;g2++)
		{
			gm[0]+=g1;
			gp[0]+=g2;
			gm[ind]+=g2;
			gp[ind]+=g1;
			sort(ec,ec+4,Sortare);
			if(ec[0]==0 || ec[1]==0)
			{
				if((g1-g2)<(sol1-sol2))
				{
					sol1=g1;
					sol2=g2;
				}
				else
				{
					if((g1-g2)==(sol1-sol2))
					{
						if(g2<sol2)
						{
							sol1=g1;
							sol2=g2;
						}
					}
				}
			}
			gm[0]-=g1;
			gp[0]-=g2;
			gm[ind]-=g2;
			gp[ind]-=g1;
		}
	}
	if(sol1==2000000000)
		cout<<"IMPOSSIBLE\n";
	else
		cout<<sol1<<":"<<sol2<<"\n";
	return 0;
}

/* DOAN Minh Quy
** mquy.doan@gmail.com
** problem: Codeforces 200 C. Football Championship
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int64 long long
#define MAXN 100111
typedef pair<int,int> ii;
/*----------------------------------*/
map<string,int> goal,score,diff;
set<string> ex,xx;
vector<string> team;
bool mycmp(string a,string b){
    if ( score[a] != score[b] ){
        return score[a] > score[b];
    }
    if ( diff[a] != diff[b] ){
        return diff[a] > diff[b];
    }
    if ( goal[a] != goal[b] ){
        return goal[a] > goal[b];
    }
    return a < b;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    #endif
    char ff[22],ss[22],line[100],*token;
    int fc,sc;
    string bl = "BERLAND", op ;
    for(int i = 0 ; i < 5 ; i++){
        gets(line);
        token = strtok(line," :");
        strcpy(ff,token);
        token = strtok(NULL," :");
        strcpy(ss,token);
        token = strtok(NULL," :");
        fc = atoi(token);
        token = strtok(NULL," :");
        sc = atoi(token);
        //-------------------------
        if ( ex.find(ff) == ex.end() ){
            ex.insert(ff);
            team.push_back(ff);
        }
        if ( ex.find(ss) == ex.end() ){
            ex.insert(ss);
            team.push_back(ss);
        }
        if ( fc > sc ){
            score[ff] += 3;
        }else if ( fc == sc ){
            score[ff] += 1;
            score[ss] += 1;
        }else{
            score[ss] += 3;
        }
        goal[ff] += fc , goal[ss] += sc;
        diff[ff] += fc - sc , diff[ss] += sc - fc;
        if ( strcmp(ff,bl.c_str()) == 0 ){
            xx.insert(ss);
        }
        if ( strcmp(ss,bl.c_str()) == 0 ){
            xx.insert(ff);
        }
    }
    xx.insert(bl);

    for(int i = 0 ; i < team.size() ; i++){
        if ( xx.find(team[i]) == xx.end() ){
            op = team[i];
        }
    }
    sort(team.begin(),team.end(),mycmp);
    int curr = score[bl] + 3;
    if ( curr < score[team[1]] ){
        puts("IMPOSSIBLE");
    }else{
        int v1 , v2 , a1 = 100,a2  = 0;
        for(v1 = 20 ; v1 > 0 ; v1--){
            for( v2 = v1-1 ; v2 >= 0 ; v2-- ) {
                if ( v1 > v2 ){
                    score[bl] += 3;
                }else if ( fc == sc ){
                    score[bl] += 1;
                    score[op] += 1;
                }else {
                    score[op] += 3;
                }
                goal[bl] += v1 , goal[op] += v2;
                diff[bl] += v1 - v2 , diff[op] += v2 - v1;
                sort(team.begin(),team.end(),mycmp);
                if ( team[0] == bl || team[1] == bl ){
                    if ( v1-v2 < a1 - a2 || (v1-v2 == a1-a2 && v2 < a2)){
                        a1 = v1; a2 = v2;
                    }
                }
                if ( v1 > v2 ){
                    score[bl] -= 3;
                }else if ( fc == sc ){
                    score[bl] -= 1;
                    score[op] -= 1;
                }else {
                    score[op] -= 3;
                }
                goal[bl] -= v1 , goal[op] -= v2;
                diff[bl] -= v1 - v2 , diff[op] -= v2 - v1;
            }
        }
        printf("%d:%d\n",a1,a2);
    }
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <set>
//#include "print.hpp"

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;

const static int inf = 10000000;
const static int mod = 1000000007;

map<string, int> id;
map<int, string> rid;

int reg(const string& s) {
  if(id.count(s) == 0) {
    int sz = id.size();
    id[s] = sz;
    rid[sz] = s;
  }
  return id[s];
}

int p[4];
int get[4];
int lost[4];
int play[4];
int b;
int o;

void check(int ss, int tt, int u1, int u2, int dir) {
  if(u1 > u2) {
    p[ss] += 3 * dir;
  }else if(u1 < u2) {
    p[tt] += 3 * dir;
  }else {
    p[ss] += dir;
    p[tt] += dir;
  }

  get[ss] += u1*dir;
  get[tt] += u2*dir;
  lost[ss] += u2*dir;
  lost[tt] += u1*dir;
  play[ss] += dir;
  play[tt] += dir;
}

bool comp(int i, int j) {
  if(p[i] != p[j]) {
    return p[i] < p[j];
  }
  if(get[i] - lost[i] != get[j] - lost[j]) {
    return get[i] - lost[i] < get[j] - lost[j];
  }
  if(get[i] != get[j]) {
    return get[i] < get[j];
  }
  return rid[i] > rid[j];
}

bool test(int cur1, int cur2, int now1, int now2) {
  vector<int> rank(4);
  rep(i, 4) {
    rank[i] = i;
  }
  sort(all(rank), comp);

  if(rank[0] == b || rank[1] == b) {
    return false;
  }

  if(cur1 == -1) {
    return true;
  }

  if(cur1 - cur2 != now1 - now2) {
    return cur1 - cur2 > now1 - now2;
  }
  return cur2 > now2;
}

int main(){
  memset(p, 0, sizeof(p));
  memset(get, 0, sizeof(get));
  memset(lost, 0, sizeof(lost));
  memset(play, 0, sizeof(play));
  rep(i, 5) {
    string s, t, u; cin >> s >> t >> u;
    int ss = reg(s);
    int tt = reg(t);
    int u1 = u[0]-'0';
    int u2 = u[2]-'0';
    check(ss, tt, u1, u2, 1);
  }

  b = id["BERLAND"];
  rep(i, 4) {
    if(play[i] == 2 && i != b) {
      o = i;
      break;
    }
  }

  int ans1 = -1;
  int ans2 = -1;

  rep(i, 100) {
    for(int j = 0; j < i; ++j) {
      check(b, o, i, j, 1);
      if(test(ans1, ans2, i, j)) {
	ans1 = i;
	ans2 = j;
      }
      check(b, o, i, j, -1);
    }
  }

  if(ans1 == -1) {
    cout << "IMPOSSIBLE" << endl;
  }else {
    cout << ans1 << ":" << ans2 << endl;
  }

  return 0;
}

/*
 * File:   main.cpp
 * Author: vovan
 *
 * Created on 18 Июнь 2012 г., 13:35
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <math.h>
#include <set>
#include <map>
#include <string.h>
using namespace std;

struct tim{
public:
    int och,golza,golpro,count;
    string name;
    void change(int a,int b){
        if(a>b) och+=3;
        else if(a==b) och+=1;
        golza+=a;
        golpro+=b;
        count++;
    }
    tim(string s=""){
        och=0;golza=0;golpro=0;count=0;name=s;
    }
};

int myFind(vector<tim> &v,string s1){
    for(int i=0;i<v.size();i++){
        if(v[i].name==s1){
            return i;
        }
    }
    return -1;
}

int cmp(tim a1,tim a2){
    if(a1.och>a2.och){return 1;}else{if(a1.och==a2.och){if(a1.golza-a1.golpro > a2.golza-a2.golpro){return 1;}else{if(a1.golza-a1.golpro == a2.golza-a2.golpro){if(a1.golza>a2.golza){return 1;}else{if(a1.golza==a2.golza){if(strcmp(a1.name.c_str(),a2.name.c_str())>0){return -1;}else{return 1;}}}}}}}return -1;}
int main(int argc, char** argv) {
    string s1, s2;
    int a1, a2;
    char zn;
    tim tmp;
    vector<tim> v;
    for (int i = 0; i < 5; i++) {
        cin >> s1 >> s2 >> a1 >> zn >> a2;
        int k=myFind(v,s1);
        if(k==-1){
            tim tmp(s1);
            tmp.change(a1,a2);
            v.push_back(tmp);
        }else{
            v[k].change(a1,a2);
        }
        k=myFind(v,s2);
        if(k==-1){
            tim tmp(s2);
            tmp.change(a2,a1);
            v.push_back(tmp);
        }else{
            v[k].change(a2,a1);
        }
    }

    int y=myFind(v,"BERLAND");

    tim tmp1,tmp2;
    int index=-1;
    for(int i=0;i<4;i++){
        if(v[i].count==2 &&v[i].name!="BERLAND"){
            index=i;
        }
    }
    int min=0;int max=111111110;
            for(int j=1;j<=100;j++){
               for(int i=j-1;i>=0;i--){

                tmp1=v[y];
                v[y].change(j,i);
                tmp2=v[index];
                v[index].change(i,j);
                int c=0;
                for(int k=0;k<4;k++){
                    if(v[k].name!="BERLAND"){
                        if(cmp(v[k],v[y])<0){
                            c++;
                        }
                    }
                }
                if(c>=2){
                    if(j-i<max-min){
                        min=i;
                        max=j;
                    }else{
                        if(j-i==max-min){
                            if(j<max){
                               min=i;
                               max=j;
                            }
                        }
                    }
                    v[y]=tmp1;
                    v[index]=tmp2;
                }else{
                    v[y]=tmp1;
                    v[index]=tmp2;
                }
            }
        }
    if(min==0 && max==111111110){
           cout<<"IMPOSSIBLE";
    }else{
        cout<<max<<":"<<min;
    }
    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

struct Data
{
    string name;
    int score, goal, miss;
    int p;
} tmp[4];

bool cmp1(Data A, Data B) { return A.name < B.name; }

bool cmp2(Data A, Data B) { return A.p < B.p; }

bool cmp3(Data A, Data B)
{
    if (A.score != B.score)
        return A.score > B.score;
    if ((A.goal-A.miss) != (B.goal-B.miss))
        return (A.goal-A.miss) > (B.goal-B.miss);
    if (A.goal != B.goal)
        return A.goal > B.goal;
    return A.name < B.name;
}

int main()
{
    string n[5][2];
    char g[5][2];
    map<string, int> Map;
    int inx = 0;
    for (int i = 0; i < 5; i++)
    {
        cin>>n[i][0]>>n[i][1];
        cin>>g[i][0]>>g[i][1]>>g[i][1];
        if (Map.count(n[i][0]) == 0)
        {
            Map.insert(make_pair(n[i][0], inx));
            tmp[inx++].name = n[i][0];
        }
        if (Map.count(n[i][1]) == 0)
        {
            Map.insert(make_pair(n[i][1], inx));
            tmp[inx++].name = n[i][1];
        }
    }

    sort(tmp, tmp + 4, cmp1);
    Map.clear();
    for (int i = 0; i < 4; i++)
    {
        Map.insert(make_pair(tmp[i].name, i));
        tmp[i].p = i;
        tmp[i].score = tmp[i].goal = tmp[i].miss = 0;
    }

    int op[4] = {0, 0, 0, 0};
    op[Map.find("BERLAND")->second] = 1;
    for (int i = 0; i < 5; i++)
    {
        int left = Map.find(n[i][0]) -> second;
        int right = Map.find(n[i][1]) -> second;
        if (n[i][0] == "BERLAND")
            op[Map.find(n[i][1])->second] = 1;
        if (n[i][1] == "BERLAND")
            op[Map.find(n[i][0])->second] = 1;
        if (g[i][0] == g[i][1])
        {
            tmp[left].score += 1;
            tmp[left].goal += (g[i][0] - '0');
            tmp[left].miss += (g[i][1] - '0');
            tmp[right].score += 1;
            tmp[right].goal += (g[i][1] - '0');
            tmp[right].miss += (g[i][0] -'0');
        }
        else if (g[i][0] < g[i][1])
        {
            tmp[left].goal += (g[i][0] - '0');
            tmp[left].miss += (g[i][1] - '0');
            tmp[right].score += 3;
            tmp[right].goal += (g[i][1] - '0');
            tmp[right].miss += (g[i][0] - '0');
        }
        else
        {
            tmp[left].score += 3;
            tmp[left].goal += (g[i][0] - '0');
            tmp[left].miss += (g[i][1] - '0');
            tmp[right].goal += (g[i][1] - '0');
            tmp[right].miss += (g[i][0] - '0');
        }
    }

    int mine = Map.find("BERLAND")->second;
    int opp;
    for (int i = 0; i < 4; i++)
        if (op[i] == 0) opp = i;

    for (int k = 1; k <= 100; k++)
    for (int i = 1; i <= 100; i++)
    {
        for (int j = i-1; i-j <= k && j >= 0 ; j--)
        {
            sort(tmp, tmp + 4, cmp2);

            tmp[mine].score += 3;
            tmp[mine].goal += i;
            tmp[mine].miss += j;
            tmp[opp].goal += j;
            tmp[opp].miss += i;
            sort(tmp, tmp + 4, cmp3);
            if (tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND")
            {
                cout<<i<<":"<<j<<endl;
                return 0;
            }
            sort(tmp, tmp + 4, cmp2);

            tmp[mine].score -= 3;
            tmp[mine].goal -= i;
            tmp[mine].miss -= j;
            tmp[opp].goal -= j;
            tmp[opp].miss -= i;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<string>
#include<vector>
using namespace std;
struct STT{
    int points , a , b , ord;
}arr[10];
bool operator <(const STT&A , const STT&B){
    if(A.points==B.points){
        if(A.a-A.b == B.a-B.b){
            if(A.a==B.a){
                return A.ord>B.ord;
            }
            return A.a<B.a;
        }
        return A.a-A.b < B.a-B.b;
    }
    else return A.points<B.points;
}
map<string,int> score , ON , OFF , ord , played;
string str1 , str2 ;
int a,b , idx , idx2;
map<string,int>::iterator it;
vector<STT>v;
int FIND(){
    for(int i=0;i<4;i++)
        if(v[i].ord==idx) return i+1;
}
char c;
int main(){
    for(int j=1;j<=5;j++){
        cin>>str1>>str2>>a>>c>>b;
        played[str1]++; played[str2]++;
        if(a<b){
            swap(a,b);
            str1.swap(str2);
        }
        if(a==b){
            score[str1]++;
            score[str2]++;
        }
        else{
            score[str1]+=3;
            score[str2]+=0;
        }
        ON[str1]+=a; OFF[str1]+=b;
        ON[str2]+=b; OFF[str2]+=a;
    }
    int n=0;

    for(it=score.begin();it!=score.end();it++){
        arr[++n].points=it->second;
        arr[n].a=ON[it->first];
        arr[n].b=OFF[it->first];
        arr[n].ord=n; ord[it->first]=n;
        if(played[it->first]==2){
            if(it->first.compare("BERLAND")==0) idx=n;
            else idx2=n;
        }

    }
    //if(idx==4 || idx==6)
    //cout<<idx<<' '<<idx2<<endl;

    for(int j=1;j<=100;j++){
        v.clear();
        for(int i=1;i<=4;i++) v.push_back(arr[i]);
        for(int i=0;i<4;i++){
            if(v[i].ord==idx)
                v[i].points+=3 , v[i].a+=j;
            if(v[i].ord==idx2) v[i].b+=j;
        }
        sort(v.begin(),v.end());
      //  cout<<j<<' '<<FIND()<<endl;
        if(FIND()==3 || FIND()==4){
            printf("%d:%d\n",j,0);
            return 0;
        }
    }
   // reverse(arr+1,arr+1+n);
  /*  for(int j=1;j<=n;j++) cout<<arr[j].ord<<' '<<arr[j].points<<' '<<arr[j].a<<' '<<arr[j].b<<endl;
    if(arr[4].ord==ord["BERLAND"] || arr[3].ord==ord["BERLAND"]){
        puts("0:0");
        return 0;
    }

    if(arr[3].points-3>points){
        puts("IMPOSSIBLE");
        return 0;
    }
    if(points+1 > arr[3].points){
        puts("0:0");
        return 0;
    }
    //cout<<points<<' '<<idx<<endl;
    if(points+1 == arr[3].points){
        int dif=(arr[3].a-arr[3].b)-(arr[idx].a-arr[idx].b);
        if(dif==0){
            dif=max(0,arr[3].a-arr[idx].a);
            printf("%d:%d\n",dif,dif);
            return 0;
        }
    }
    if(points+3 > arr[3].points){
        puts("1:0");
        return 0;
    }

    if(points+3 == arr[3].points){
        int dif=(arr[3].a-arr[3].b)-(arr[idx].a-arr[idx].b);
        dif++;
        printf("%d:%d\n",dif,0);
        return 0;
    }*/
    puts("IMPOSSIBLE");

}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <string.h>
#include <map>
#define M 2005
#define For(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
map<string, int>cap;
string s1, s2;
int a, b;
int enter[5];
//int score[5];
//int dscore[5];
//int sscore[5];
string s3, s4;

struct Node {
    bool ok;
    int score, dscore, sscore;
} q[5], qq[5];

int cmp(Node a, Node b) {
    if (a.score == b.score && a.dscore == b.dscore && a.sscore == b.sscore) {
        if(s3.size()==s4.size())
            return s3>s4;
        return s3>s4;
    }
    if (a.score == b.score && a.dscore == b.dscore) {
        return a.sscore > b.sscore;
    }
    if (a.score == b.score) {
        return a.dscore > b.dscore;
    }
    return a.score > b.score;
}

bool judge(int x, int y, int f, int t) {

    For(i, 0, 4) {
        qq[i] = q[i];
    }
    qq[f].dscore += x - y;
    qq[t].dscore += y - x;
    qq[f].sscore += x;
    qq[t].sscore += y;
    For(i, 0, 4)
    qq[i].ok = false;
    qq[f].ok = 1;
    sort(qq, qq + 4, cmp);

    For(i, 0, 4) {
        if (qq[i].ok) {
            if (i < 2) {
                return 1;
            } else
                return 0;
        }
    }
}
string ss[5];
int main(int argc, char** argv) {
    int cnt = 0;
    memset(enter, 0, sizeof (enter));
    int f;

    For(i, 0, 5) {
        q[i].dscore = q[i].score = q[i].sscore = 0;
    }

    For(i, 0, 5) {
        cin >> s1 >> s2;
        scanf("%d:%d", &a, &b);
        if (cap.find(s1) == cap.end()) {
            cap[s1] = cnt;
            ss[cnt]=s1;
            enter[cnt]++;
            cnt++;

        } else {
            enter[cap[s1]]++;
        }
        if (cap.find(s2) == cap.end()) {
            cap[s2] = cnt;
            enter[cnt]++;
            ss[cnt]=s2;
            cnt++;

        } else {
            enter[cap[s2]]++;
        }
        q[cap[s1]].dscore += a - b;
        q[cap[s2]].dscore += b - a;
        q[cap[s1]].sscore += a;
        q[cap[s2]].sscore += b;
        if (a > b) {
            q[cap[s1]].score += 3;
        } else if (a == b) {
            q[cap[s1]].score++;
            q[cap[s2]].score++;
        } else {
            q[cap[s2]].score += 3;
        }
        if (s1 == "BERLAND") {
            f = cap[s1];
            s3 = s1;
        }
        if (s2 == "BERLAND") {
            f = cap[s2];
            s3 = s2;
        }

    }
    int t;

    For(i, 0, 4) {
        if (i != f && enter[i] % 2 == 0) {
            t = i;
        }
    }
    q[f].score += 3;
    cnt = 0;

//    For(i, 0, 4) {
//        if (i != f) {
//            if (q[i].score > f) {
//                cnt++;
//            }
//        }
//    }
//    if (cnt >= 2) {
//        printf("IMPOSSIBLE\n");
//        return 0;
//    }
//    cnt = 0;
//
//    For(i, 0, 4) {
//        if (i != f) {
//            if (q[i].score < f) {
//                cnt++;
//            }
//        }
//    }
//    if (cnt >= 2) {
//        printf("1:0\n");
//        return 0;
//    }
    s4=ss[t];
    For(i, 1, 50) {

        For(j, 0, 50) {
            if (judge(i + j, j, f, t)) {
                printf("%d:%d\n", i + j, j);
                return 0;
            }
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const string my_team="BERLAND";
struct Team
{
	string name;//名字
	int score;//得分
	int jsq;//净胜球
	int jqs;//进球数
	int bss;//比赛场次
	Team()
	{
		name="NULL",score=0,jsq=0,jqs=0,bss=0;
	}
	void AddMatch(int b,int c)//得分,净胜球,进球数
	{
		if(b>0)
			score+=3;
		else if(b==0)
			score+=1;
		jsq+=b;
		jqs+=c;
		bss++;
	}
	bool operator < (Team x)
	{
		if(score!=x.score)
			return score<x.score;
		if(jsq!=x.jsq)
			return jsq<x.jsq;
		if(jqs!=x.jqs)
			return jqs<x.jqs;
		return name>x.name;
	}
};
Team pTeam[4];
int GetTeam(string name)
{
	for(int i=0;i<4;i++)
	{
		if(pTeam[i].name=="NULL")
		{
			pTeam[i].name=name;
			return i;
		}
		if(pTeam[i].name==name)
		{
			return i;
		}
	}
}
int main()
{
	string t1,t2;
	char c;
	int s1,s2;
	int my,enemy;
	Team temp[4];
	for(int i=0;i<5;i++)
	{
		cin>>t1>>t2>>s1>>c>>s2;
		pTeam[GetTeam(t1)].AddMatch(s1-s2,s1);
		pTeam[GetTeam(t2)].AddMatch(s2-s1,s2);
	}
	for(int i=0;i<4;i++)
	{
		if(pTeam[i].bss==2&&pTeam[i].name==my_team)
			my=i;
		else if(pTeam[i].bss==2)
			enemy=i;
	}
	for(int i=1;i<50;i++)
	{
		for(int j=0;j<i;j++)
		{
			memcpy(temp,pTeam,sizeof(pTeam));
			temp[my].AddMatch(i-j,i);
			temp[enemy].AddMatch(j-i,j);
			sort(temp,temp+4);
			if(temp[2].name==my_team||temp[3].name==my_team)
			{
				cout<<i<<":"<<j<<endl;
				return 0;
			}
		}
	 }
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <complex>
#include <numeric>
#include <valarray>
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i(0),_n(n);i<_n;++i)
#define repi(i,a,b) for(int i(a),_b(b);i<_b;++i)
template<class T> int len(const T&c){return (int)c.size();}
typedef long long ll;
#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
#define mem(x,a) memset(x,a,sizeof(x))
template<class T> void cmin(T &a,T b){if(b<a) a=b;}
template<class T> void cmax(T &a,T b){if(b>a) a=b;}
#define inf (1<<29)

class team{
	public:
	int goal,missed,points,played;
	string name;
	bool operator < (team o1) const{
		if(points!=o1.points)return points>o1.points;
		if((goal-missed)!=(o1.goal-o1.missed))return (goal-missed)>(o1.goal-o1.missed);
		if(goal!=o1.goal)return goal>o1.goal;
		return name<o1.name;
	}
};

map<string,int> msi;
string s1,s2;
char ch;
int o1,o2,t1,t2,cnt,w1,w2;

int main(){
	vector<team> teams(5);
	rep(i,5){
		cin>>s1>>s2>>o1>>ch>>o2;
			t1=msi[s1];
			if(!t1){
				msi[s1]=t1=++cnt;
				teams[t1].name=s1;
			}
			t2=msi[s2];
			if(!t2){
				msi[s2]=t2=++cnt;
				teams[t2].name=s2;
			}
			teams[t1].played+=1;
			teams[t2].played+=1;
			teams[t1].goal+=o1;
			teams[t2].goal+=o2;
			teams[t2].missed+=o1;
			teams[t1].missed+=o2;
			if(o1>o2){
				teams[t1].points+=3;
			}
			else if(o1<o2){
				teams[t2].points+=3;
			}
			else {
				teams[t1].points+=1;
				teams[t2].points+=1;
			}
	}
	sort(teams.begin()+1,teams.end());

	rep(i,4){
		if(teams[i+1].name=="BERLAND")w1=i+1;
		else if(teams[i+1].played==2)w2=i+1;
	}

	vector<team> temp;

	int dif=inf;
	int last;
	rep(i,100){
		rep(j,i){
			temp=teams;
			temp[w1].goal+=i;
			temp[w2].goal+=j;
			temp[w1].missed+=j;
			temp[w2].missed+=i;
			if(i>j)temp[w1].points+=3;
			else{
				temp[w1].points+=1;
				temp[w2].points+=1;
			}
			sort(temp.begin()+1,temp.end());

			if(temp[1].name=="BERLAND"||temp[2].name=="BERLAND"){
				if(dif>(i-j)){
					dif=i-j;
					t1=i;
					t2=j;
					last=j;
				}
				if(dif==(i-j)&&last>j){
					t1=i;
					t2=j;
					last=j;
				}

			}

		}
	}

	if(dif==inf){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<t1<<":"<<t2<<endl;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<queue>
#include<string>
#include<iostream>
#include<map>
#define N 1100
#define CC(x,y) memset(x,y,sizeof(x))
#define inf 0x7ffffff
#define ll long long
#define eps 1e-6
#define M 110000
using namespace std;
map<string,int>q;
struct node
{
    int a,b,c,d,t;
    string s;
}f[10];
int i,j,k,m,n,x,y,z,x1;
char st[100];
string s,s1;
int ok(int m)
{
    f[x1].c++;
    f[z].d++;
    int k=0;
    for (int i=1;i<=4;i++)
    {
        if (i==x1)continue;
        if (f[i].a>f[x1].a){k++;continue;}
        if (f[i].a==f[x1].a)
        {
            int x=f[i].c-f[i].d;
            int y=f[x1].c-f[x1].d;
            if (x>y){k++;continue;}
            if (x<y)continue;
            if (f[i].c>f[x1].c){k++;continue;}
            if (f[i].s.compare(f[x1].s)>0){k++;continue;}
        }
    }
    if (k>=2)return 0;else return 1;
}
int main()
{
    //freopen("in.txt","r",stdin);
    j=1;
    for (int i=1;i<=5;i++)
    {
        cin>>s>>s1;
        if (q[s]==0)q[s]=j,j++,f[j].s=s;
        if (q[s1]==0)q[s1]=j,j++,f[j].s=s1;
        scanf("%d:%d",&x,&y);
        int x1=q[s],y1=q[s1];
        f[x1].t++,f[y1].t++;
        {
            f[x1].c+=x,f[x1].d+=y;
            f[y1].c+=y,f[y1].d+=x;
        }
        if (x>y)f[x1].a+=3;
        else if (x==y)f[x1].a++,f[y1].a++;
         else f[y1].a+=3;
        getchar();
    }
    s="BERLAND";
    x1=q[s];
    for (i=1;i<=4;i++)
    {
        if (f[i].t==2&&i!=x1)break;
    }
    z=i;
    int flag=0;
    int t=0;
    f[x1].a+=3;
    for (int i=1;i<=50;i++)
    {
        if (ok(i)){flag=1;t=i;break;}
    }
    if (flag)printf("%d:0\n",t);
     else printf("IMPOSSIBLE\n");
    return 0;
}

#include <cstdlib>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

	int i, j, k, idx, idx_b, idx_o;
	string line[5][3];
	string name[5];

	int game[6][4];

bool is_b_1st_or_2nd(int game[6][4], int idx_b){
	int i;
	int point[4], diff[4], score[4], hoge[4];

	for(i = 0; i < 4; i++) point[i] =  score[i] = diff[i] = 0;

	for(i = 0; i < 6; i++){
		if(game[i][2] > game[i][3]) point[game[i][0]] += 3;
		else if(game[i][2] < game[i][3]) point[game[i][1]] += 3;
		else{ point[game[i][0]]++; point[game[i][1]]++; }

		diff[game[i][0]] += game[i][2] - game[i][3];
		diff[game[i][1]] += game[i][3] - game[i][2];
		score[game[i][0]] += game[i][2];
		score[game[i][1]] += game[i][3];
	}

	for(i = 0; i < 4; i++) hoge[i] = 10000000 * point[i] + 10000 * (diff[i] + 500) + 10 * score[i] + (4 - i);
	sort(hoge, hoge + 4);

		cout << "-----" << endl;
		for(i = 0; i < 4; i++) cout << i << ":" << name[i] << endl;
		cout << endl;
		cout << "opponent:" << name[idx_o] << endl;
		cout << endl;

		for(i = 0; i < 6; i++) cout << game[i][0] << game[i][1] << game[i][2] << game[i][3] << endl;
		for(i = 0; i < 4; i++) cout << hoge[i] << endl;

	return (hoge[2] % 10 == (4 - idx_b) || hoge[3] % 10 == (4 - idx_b));
}

int main(){

	for(i = 0; i < 5; i++){
		string name1, name2, score;
		cin >> name1 >> name2 >> score;
		line[i][0] = name1;
		line[i][1] = name2;
		line[i][2] = score;
	}

	idx = 0;
	for(i = 0; i < 5; i++){
		for(j = 0; j < 2; j++){
			for(k = 0; k < idx; k++) if(line[i][j] == name[k]) break;
			if(k == idx){
				idx++;
				name[k] = line[i][j];
			}
		}
	}
	sort(name, name + 4);
	for(i = 0; i < 4; i++) if(name[i] == "BERLAND") idx_b = i;

	for(i = 0; i < 5; i++){
		for(j = 0; j < 4; j++){
			if(name[j] == line[i][0]) game[i][0] = j;
			if(name[j] == line[i][1]) game[i][1] = j;
		}
		game[i][2] = line[i][2][0] - '0';
		game[i][3] = line[i][2][2] - '0';
	}

	int count[4] = {0, 0, 0, 0};
	for(i = 0; i < 5; i++){
		count[game[i][0]]++;
		count[game[i][1]]++;
	}
	for(i = 0; i < 4; i++){
		if(count[i] == 2 && i != idx_b) idx_o = i;
	}
	game[5][0] = idx_b;
	game[5][1] = idx_o;

	for(i = 1; i <= 100; i++){
		for(j = 0; j < 100 - i; j++){
			game[5][2] = i + j;
			game[5][3] = j;
			if(is_b_1st_or_2nd(game, idx_b)){
				cout << i + j << ":" << j << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
string t[4];
map <string,int> nrt;
int gm[4],gp[4],nrp[4],nrm[4];
bool ok[4];
int ec[4],sol1=2000000000,sol2;

inline bool Sortare(int A,int B)
{
	if(nrp[A]==nrp[B])
	{
		if((gm[A]-gp[A])==(gm[B]-gp[B]))
		{
			if(gm[A]==gm[B])
			{
				if(lexicographical_compare(t[A].begin(),t[A].end(),t[B].begin(),t[B].end()))
					return true;
				return false;
			}
			return gm[A]>gm[B];
		}
		return (gm[A]-gp[A])>(gm[B]-gp[B]);
	}
	return nrp[A]>nrp[B];
}

int main()
{
	int i,j,g1,g2,ind;
	bool gasit;
	string s[2],aux;
	t[0]="BERLAND";
	ok[0]=true;
	for(i=1;i<=5;i++)
	{
		cin>>s[0]>>s[1]>>aux;
		g1=0;
		j=0;
		while(aux[j]!=':')
			g1=g1*10+aux[j++]-'0';
		j++;
		g2=0;
		while(j<aux.size() && '0'<=aux[j] && aux[j]<='9')
			g2=g2*10+aux[j++]-'0';
		gasit=false;
		if(s[0].compare(t[0])==0 && s[0].size()==t[0].size())
		{
			gm[0]+=g1;
			gp[0]+=g2;
			if(g1>g2)
				nrp[0]+=3;
			if(g1==g2)
				nrp[0]++;
			gasit=true;
		}
		if(!gasit)
		{
			if(nrt[s[0]]==0)
			{
				j=1;
				while(ok[j]==true)
					j++;
				nrt[s[0]]=j;
				ok[j]=true;
				t[j]=s[0];
			}
			ind=nrt[s[0]];
			gm[ind]+=g1;
			gp[ind]+=g2;
			nrm[ind]++;
			if(g1>g2)
				nrp[ind]+=3;
			if(g1==g2)
				nrp[ind]++;
			gasit=true;
		}
		gasit=false;
		if(s[1].compare(t[0])==0 && s[1].size()==t[0].size())
		{
			gm[0]+=g2;
			gp[0]+=g1;
			if(g1<g2)
				nrp[0]+=3;
			if(g1==g2)
				nrp[0]++;
			gasit=true;
		}
		if(!gasit)
		{
			if(nrt[s[1]]==0)
			{
				j=1;
				while(ok[j]==true)
					j++;
				nrt[s[1]]=j;
				ok[j]=true;
				t[j]=s[1];
			}
			ind=nrt[s[1]];
			gm[ind]+=g2;
			gp[ind]+=g1;
			nrm[ind]++;
			if(g1<g2)
				nrp[ind]+=3;
			if(g1==g2)
				nrp[ind]++;
			gasit=true;
		}
		s[0].clear();
		s[1].clear();
		aux.clear();
	}
	for(i=1;i<4;i++)
	{
		if(nrm[i]==2)
			ind=i;
	}
	nrp[0]+=3;
	for(i=0;i<4;i++)
		ec[i]=i;
	for(g1=0;g1<100;g1++)
	{
		for(g2=0;g2<g1;g2++)
		{
			gm[0]+=g1;
			gp[0]+=g2;
			gm[ind]+=g2;
			gp[ind]+=g1;
			sort(ec,ec+4,Sortare);
			if(ec[0]==0 || ec[1]==0)
			{
				if((g1-g2)<(sol1-sol2))
				{
					sol1=g1;
					sol2=g2;
				}
				else
				{
					if((g1-g2)==(sol1-sol2))
					{
						if(g2<sol2)
						{
							sol1=g1;
							sol2=g2;
						}
					}
				}
			}
			gm[0]-=g1;
			gp[0]-=g2;
			gm[ind]-=g2;
			gp[ind]-=g1;
		}
	}
	if(sol1==2000000000)
		cout<<"IMPOSSIBLE\n";
	else
		cout<<sol1<<' '<<sol2<<"\n";
	return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

struct t{
	string name;
	int o,z,p,km;
};

string s1,s2;
char c;
int g1,g2,t1,t2;

t team[4],tmp[4];

vector <PII> v;

int fs(string s)
{
	forn(i,4)
		if((team[i].name==s)||(team[i].name==""))
			return i;
}

bool cmp(t a, t b)
{
	if(a.o==b.o)
	{
		if(a.z-a.p==b.z-b.p)
		{
			if(a.z==b.z)
				return a.name<b.name;
			return a.z>b.z;
		}
		return a.z-a.p>b.z-b.p;
	}
	return a.o>b.o;
}

int main()
{
	freopen("z.in", "rt", stdin);
	freopen("z.out", "wt", stdout);
	cout << setiosflags(ios::fixed) << setprecision(10);

	forn(i,5)
	{
		cin >>s1>>s2>>g1>>c>>g2;
		t1=fs(s1);
		team[t1].name=s1;
		team[t1].km++;
		team[t1].z+=g1;
		team[t1].p+=g2;

		t2=fs(s2);
		team[t2].name=s2;
		team[t2].km++;
		team[t2].z+=g2;
		team[t2].p+=g1;

		if(g1>g2)
			team[t1].o+=3;
		if(g2>g1)
			team[t2].o+=3;
		if(g1==g2)
		{
			team[t1].o++;
			team[t2].o++;
		}
	}

	t1=fs("BERLAND");
	team[t1].o+=3;
	forn(i,4)
		if((team[i].km==2)&&(team[i].name!="BERLAND"))
			t2=i;

	for(int i=1; i<200; i++)
		for(int j=i-1; j>=0; j--)
		{
			team[t1].z+=i;
			team[t1].p+=j;
			team[t2].z+=j;
			team[t2].p+=i;

			forn(k,4)
				tmp[k]=team[k];
			sort(tmp,tmp+4,cmp);

			forn(k,2)
				if(tmp[k].name=="BERLAND")
				{
					cout <<i<<":"<<j;
					return 0;
				}
			team[t1].z-=i;
			team[t1].p-=j;
			team[t2].z-=j;
			team[t2].p-=i;
		}
	cout <<"IMPOSSIBLE";
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define DEBUG(x) cout << #x ":" << x << " "
map<string, int> teamMap;
map<int, string> idMap;
struct Team
{
    int id, point, missed, scored;
    Team(int i = 0, int p = 0, int m = 0, int s = 0) : id(i), point(p), missed(m), scored(s) {}
    bool operator<(const Team &x) const
    {
        return (point == x.point ? (scored-missed == x.scored-x.missed ? (scored == x.scored ? id < x.id : scored < x.scored) : scored-missed < x.scored-x.missed) : point < x.point);
    }
    Team operator+=(const Team &x)
    {
        if (id != x.id)
            return (*this);
        point += x.point;
        missed += x.missed;
        scored += x.scored;
        return (*this);
    }
} teams[4];
int cnt[4];
void rebulidMap()
{
    int i = 0;
    /* cout << "Before\n";
    for (auto it=teamMap.begin();it!=teamMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (auto it=idMap.begin();it!=idMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    } */
    decltype(idMap) tempIdMap(idMap);
    for (auto it = teamMap.begin(); it != teamMap.end(); it++)
    {
        it->second = i++;
        idMap[it->second] = it->first;
    }
    int tempCnt[4];
    Team tempTeams[4];
    memcpy(tempCnt, cnt, sizeof(cnt));
    memcpy(tempTeams, teams, sizeof(teams));
    for (int i = 0; i < 4; i++)
    {
        cnt[i] = tempCnt[teamMap[tempIdMap[i]]];
        teams[i] = tempTeams[teamMap[tempIdMap[i]]];
        teams[i].id = i;
    }
    /* cout << "After\n";
    for (auto it=teamMap.begin();it!=teamMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (auto it=idMap.begin();it!=idMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (int i=0;i<4;i++)
    {
        cout << cnt[i] << endl;
    } */
}
int getOpponent()
{
    int t;
    for (int i = 0; i < 4; i++)
    {
        if (cnt[i] < 3 && teamMap["BERLAND"] != i)
        {
            t = i;
            break;
        }
    }
    for (int i = 0; i < 4; i++)
    {
        if (teams[i].id == t)
        {
            return i;
        }
    }
}
int getRealIdById(int id, Team *teams)
{
    for (int i = 0; i < 4; i++)
    {
        if (teams[i].id == id)
        {
            return i;
        }
    }
}
int main()
{
    teamMap.clear();
    // freopen("debug.txt","w",stdout);
    for (int i = 0; i < 4; i++)
    {
        teams[i].id = i;
    }
    for (int i = 0; i < 5; i++)
    {
        string s1, s2;
        int x, y;
        cin >> s1 >> s2;
        scanf("%d:%d", &x, &y);
        int px = (x == y ? 1 : x > y ? 3 : 0);
        int py = (x == y ? 1 : 3 - px);
        //team 1
        int id = teamMap.size();
        if (teamMap.count(s1) == 0)
        {
            teamMap[s1] = id;
            idMap[id] = s1;
        }
        teams[teamMap[s1]] += Team(teamMap[s1], px, y, x);
        cnt[teamMap[s1]]++;
        //team 2
        id = teamMap.size();
        if (teamMap.count(s2) == 0)
        {
            teamMap[s2] = id;
            idMap[id] = s2;
        }
        teams[teamMap[s2]] += Team(teamMap[s2], py, x, y);
        cnt[teamMap[s2]]++;
    }
    rebulidMap();
    teams[teamMap["BERLAND"]] += Team(teamMap["BERLAND"], 3);
    int oid = getOpponent();
    sort(teams, teams + 4);
    /* for (int i = 0; i < 4; i++)
    {
        DEBUG(teams[i].id);
        DEBUG(teams[i].point);
        DEBUG(teams[i].missed);
        DEBUG(teams[i].scored);
        cout << endl;
    } */
    if (getRealIdById(teamMap["BERLAND"], teams) >= 2)
    {
        cout << "1:0" << endl;
        return 0;
    }
    // cout << oid << " "<<teamMap["BERLAND"] <<endl;
    int i = 1;
    while (i<1e2)
    {
        for (int j = i - 1; j >= 0; j--)
        {
            Team tempTeams[4];
            memcpy(tempTeams, teams, sizeof(teams));
            tempTeams[getRealIdById(teamMap["BERLAND"], tempTeams)] += Team(teamMap["BERLAND"], 0, j, i);
            tempTeams[getRealIdById(oid, tempTeams)] += Team(oid, 0, i, j);
            sort(tempTeams, tempTeams + 4);
            if (getRealIdById(teamMap["BERLAND"], tempTeams) >= 2)
            {
                cout << i << ":" << j << endl;
                return 0;
            }
            /* cout << i << " " << j << endl;
            for (int i = 0; i < 4; i++)
            {
                DEBUG(tempTeams[i].id);
                DEBUG(tempTeams[i].point);
                DEBUG(tempTeams[i].missed);
                DEBUG(tempTeams[i].scored);
                cout << endl;
            } */
        }
        i++;
    }
    cout << "IMPOSSIBLE" <<endl;
    return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
//#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

struct team
{
	string s;
	int o,z,d;
};

bool cmp(team a, team b)
{
	if(a.o==b.o)
	{
	    if(a.d==b.d)
	    {
	    	if(a.z==b.z)
	    	{
	    		a.s>b.s;
	    	}
	    	return a.z>b.z;
	    }
		return a.d>b.d;
	}
	return a.o>b.o;
}

map <string,int> mp;
int k=0;
string s1,s2;
int d1,d2;
char c;

team a[4];
int p[4];

inline void add()
{
	forn(i,4)
	{
		if(a[i].s==s1)
        {
           	a[i].z++;
            a[i].d++;
        }
           if(a[i].s==s2)
           	a[i].d--;
    }
}

int main()
{
//	freopen("z.in", "rt", stdin);
//	freopen("z.out", "wt", stdout);

	forn(i,5)
	{
		cin >>s1>>s2>>d1>>c>>d2;
		if(mp.find(s1)==mp.end())
		{
			mp[s1]=k;
			a[k].s=s1;
			k++;
		}
		if(mp.find(s2)==mp.end())
		{
			mp[s2]=k;
			a[k].s=s2;
			k++;
		}

		p[mp[s1]]++;
		p[mp[s2]]++;

		a[mp[s1]].z+=d1;
		a[mp[s1]].d+=d1-d2;
		a[mp[s2]].z+=d2;
		a[mp[s2]].d+=d2-d1;

		if(d1>d2)
			a[mp[s1]].o+=3;
		if(d2>d1)
			a[mp[s2]].o+=3;
		if(d1==d2)
		{
			a[mp[s1]].o+=1;
			a[mp[s2]].o+=1;
		}
	}

	s1="BERLAND";
	p[mp[s1]]++;
	forn(i,4)
		if(p[i]==2)
			s2=a[i].s;

	int s=1;
	a[mp[s1]].o+=3;
	add();

 	while(1)
	{
		sort(a,a+4,cmp);
		if((a[0].s==s1)||(a[1].s==s1))
		{
			cout <<s<<":0";
			return 0;
		}
		s++;
	    add();

		if(s>311)
		{
			cout <<"IMPOSSIBLE";
			return 0;
		}
	}
	return 0;
}

/* DOAN Minh Quy
** mquy.doan@gmail.com
** problem:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int64 long long
#define MAXN 100111
typedef pair<int,int> ii;
/*----------------------------------*/
map<string,int> goal,score,diff;
set<string> ex,xx;
vector<string> team;
bool mycmp(string a,string b){
    if ( score[a] != score[b] ){
        return score[a] > score[b];
    }
    if ( diff[a] != diff[b] ){
        return diff[a] > diff[b];
    }
    if ( goal[a] != goal[b] ){
        return goal[a] > goal[b];
    }
    return a < b;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    #endif
    char ff[22],ss[22],line[100],*token;
    int fc,sc;
    string bl = "BERLAND", op ;
    for(int i = 0 ; i < 5 ; i++){
        gets(line);
        token = strtok(line," :");
        strcpy(ff,token);
        token = strtok(NULL," :");
        strcpy(ss,token);
        token = strtok(NULL," :");
        fc = atoi(token);
        token = strtok(NULL," :");
        sc = atoi(token);
        //-------------------------
        if ( ex.find(ff) == ex.end() ){
            ex.insert(ff);
            team.push_back(ff);
        }
        if ( ex.find(ss) == ex.end() ){
            ex.insert(ss);
            team.push_back(ss);
        }
        if ( fc > sc ){
            score[ff] += 3;
        }else if ( fc == sc ){
            score[ff] += 1;
            score[ss] += 1;
        }else{
            score[ss] += 3;
        }
        goal[ff] += fc , goal[ss] += sc;
        diff[ff] += fc - sc , diff[ss] += sc - fc;
        if ( strcmp(ff,bl.c_str()) == 0 ){
            xx.insert(ss);
        }
        if ( strcmp(ss,bl.c_str()) == 0 ){
            xx.insert(ff);
        }
    }
    xx.insert(bl);

    for(int i = 0 ; i < team.size() ; i++){
        if ( xx.find(team[i]) == xx.end() ){
            op = team[i];
        }
    }
    sort(team.begin(),team.end(),mycmp);
    int curr = score[bl] + 3;
    if ( curr < score[team[1]] ){
        puts("IMPOSSIBLE");
    }else{
        int v1 = 1 , v2 = 0;
        while(true){
            if ( v1 > v2 ){
                score[bl] += 3;
            }else if ( fc == sc ){
                score[bl] += 1;
                score[op] += 1;
            }else {
                score[op] += 3;
            }
            goal[bl] += v1 , goal[op] += v2;
            diff[bl] += v1 - v2 , diff[op] += v2 - v1;
            sort(team.begin(),team.end(),mycmp);
            if ( team[0] == bl || team[1] == bl ){
                break;
            }
//          printf("%d v\n",v1);
//          for(int i = 0 ; i< team.size() ; i++){
//              cout << team[i] << " " << score[team[i]] <<" " << diff[team[i]] << " " << goal[team[i]] << endl;
//          }
//          puts("");
            if ( v1 > v2 ){
                score[bl] -= 3;
            }else if ( fc == sc ){
                score[bl] -= 1;
                score[op] -= 1;
            }else {
                score[op] -= 3;
            }
            goal[bl] -= v1 , goal[op] -= v2;
            diff[bl] -= v1 - v2 , diff[op] -= v2 - v1;
            if ( v2 ) --v2 ;
            else ++v1;
        }
        printf("%d:%d\n",v1,v2);
    }
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
    map<string,int> id;
    map<string,int> partite;
    vector<pair < pair<int,pair<int,int> >,string> > dp(4,{{0,{0,0}},""});
    int totale=0;
    int golDaFare=0;
    int index;
bool my_compare(pair < pair<int,pair<int,int> >,string> a,pair < pair<int,pair<int,int> >,string> b)
{
    if(a.first.first>b.first.first)
        return true;
    else if(a.first.first<b.first.first)
        return false;
    if(a.first.second.first>b.first.second.first)
        return true;
    else if(a.first.second.first<b.first.second.first)
        return false;
    if(a.first.second.second>b.first.second.second)
        return true;
    else if(a.first.second.second<b.first.second.second)
        return false;
    if(a.second<b.second)
        return true;
    else if(a.second>b.second)
        return true;
}
int main()
{
    string s;
    string b;
    int as=1;
    for(int i=0;i<5;i++){
        char app;
        cin>>s;
        cin>>b;
        partite[s]++;
        partite[b]++;
        if(id[s]==0){
            id[s]=as;
            dp[as-1].second=s;
            as++;
        }
        if(id[b]==0){
            id[b]=as;
            dp[as-1].second=b;
            as++;
        }
        int primo,secondo;
        cin>>primo;
        cin>>app;
        cin>>secondo;
        dp[id[s]-1].first.second.second+=primo;
        dp[id[s]-1].first.second.first+=primo-secondo;
        dp[id[b]-1].first.second.second+=secondo;
        dp[id[b]-1].first.second.first+=secondo-primo;
        if(primo>secondo)
            dp[id[s]-1].first.first+=3;
        else if(secondo>primo)
            dp[id[b]-1].first.first+=3;
        else
        {
            dp[id[s]-1].first.first++;
            dp[id[b]-1].first.first++;
        }
    }
    sort(dp.begin(),dp.end(),&my_compare);
    int index=0,contro=0;
    for(int i=0;i<4;i++)
    {
        if(partite[dp[i].second]<3&&dp[i].second!="BERLAND")
        {
            contro=i;
        }
        else if(dp[i].second=="BERLAND")
            index=i;
    }
    vector<pair < pair<int,pair<int,int> >,string> > app(4);
    bool trovato=false;
    int appi=0,app2=0;
    int att=1e9,att2;
    for(int j=1;j<=100;j++)
    {
        for(int i=0;i<j;i++)
        {
            app=dp;
            app[index].first.first+=3;
            app[index].first.second.first+=(j-i);
            app[index].first.second.second+=j;
            app[contro].first.second.first+=(i-j);
            app[contro].first.second.second+=i;
            sort(app.begin(),app.end(),&my_compare);
            for(int k=0;k<4;k++)
            {
                if(app[k].second=="BERLAND"&&k<2)
                {
                    trovato=true;
                    appi=j;
                    app2=i;
                }
            }
        }
        if(trovato)
        {
            if(appi-app2<att-att2)
            {
                att=appi;
                att2=app2;
            }
        }

    }
    if(trovato)
    {
        cout<<att<<":"<<att2<<endl;
        return 0;
    }
    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <algorithm>
#include <limits.h>
#include <map>
#include <iterator>
#include <set>

using namespace std;

#define pb push_back
#define SIZE(x) (int)x.size()

#ifdef LOCAL
ifstream in("in.txt");
#else
istream &in = cin;
#endif

struct data {
	int p,g,s;
	string name;
};
bool cmp(data a,data b)
{
	if(a.p<b.p) return true;
	if(a.p>b.p) return false;
	if(a.g<b.g) return true;
	if(a.g>b.g) return false;
	if(a.s<b.s) return true;
	if(a.s>b.s) return false;
	return a.name>b.name;
}

set<string> names;
map<string,int> p;
map<string,int> s;
map<string,int> l;
map<string,bool> m;
vector<data>d;
int me,opp;

int main()
{
	for(int i=0;i<5;++i)
	{
		string s1,s2;
		int p1,p2;char tmp;
		in>>s1>>s2>>p1>>tmp>>p2;
		m[s1+s2]=true;m[s2+s1]=true;
		names.insert(s1);names.insert(s2);
		if(p1>p2) {p[s1]+=3;p[s2]+=0;}
		else if(p2>p1) {p[s1]+=0;p[s2]+=3;}
		else {p[s1]+=1;p[s2]+=1;}
		s[s1]+=p1;s[s2]+=p2;
		l[s1]+=p2;l[s2]+=p1;
	}
	set<string>::iterator it;
	for(it=names.begin();it!=names.end();++it)
	{
		data tmp;
		tmp.name=(*it);
		tmp.p=p[(*it)];
		tmp.g=s[(*it)]-l[(*it)];
		tmp.s=s[(*it)];
		d.push_back(tmp);
	}
	sort(d.begin(),d.end(),cmp);
	reverse(d.begin(),d.end());
	for(int i=0;i<d.size();++i)
	{
		if(d[i].name.compare("BERLAND")==0) me=i;
		if(d[i].name!="BERLAND"&&m["BERLAND"+d[i].name]==0) opp=i;
	}
	for(int i=0;i<200;++i)
	{
		for(int j=i-1;j>=0;--j)
		{
			vector<data>nd=d;
			nd[me].p+=3;nd[me].g+=(i-j);nd[me].s+=i;
			nd[opp].g+=j-i;nd[opp].s+=j;
			sort(nd.begin(),nd.end(),cmp);
			reverse(nd.begin(),nd.end());
			if(nd[0].name.compare("BERLAND")==0||nd[1].name.compare("BERLAND")==0)
			{
				cout <<i<<":"<<j<<endl;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

//ITNOG
#include<bits/stdc++.h>

using namespace std;

const int maxN = 300000 + 10;
map<string, int> po;
map<string, int> go;
map<string, int> res;
map<string, int> pl;

bool cmp(string a, string b)
{
    if(po[a] < po[b]) return true;
    else if(po[a] > po[b]) return false;

    if(res[a] < res[b]) return true;
    else if(res[a] > res[b]) return false;

    if(go[a] < go[b]) return true;
    else if(go[a] > go[b]) return false;

    return (a < b);
}
main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    vector<string> v;
    for(int i = 0; i < 5; i ++)
    {
	  string s, d, t; cin >> s >> d >> t;
	  int x = t[0] - '0', y = t[2] - '0';
	  if(x == y) po[s] ++, po[d] ++, go[s] += x, go[d] += x;
	  if(x < y)
	  {
		po[d] += 3;
		go[s] += x, go[d] += y;
		res[s] += x - y, res[d] += y - x;
	  }
	  if(x > y)
	  {
		po[s] += 3;
		go[s] += x, go[d] += y;
		res[s] += x - y, res[d] += y - x;
	  }
	  pl[s] ++; pl[d] ++;
	  v.push_back(s); v.push_back(d);
    }

    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());

    string op;
    for(int i = 0; i < 4; i ++)
	  if(pl[v[i]] == 2 && v[i] != "BERLAND") op = v[i];

    string r = "BERLAND";
    po[r] += 3;
    //cout << res["BERLAND"] << endl;
    for(int i = 1; i <= 100; i ++)
    {
	  go[r] ++; res[r] ++; res[op] --;

	  sort(v.begin(), v.end(), cmp);
	  if(r == v[2] || r == v[3]) { cout << i << ":0" << endl; return 0; }
    }

    cout << "IMPOSSIBLE"  << endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct aa{int di,t;string s;};
int i,t1,t2,a1,a2,len,j;
aa f[10];
string ch1,ch2,at="BERLAND";
bool compare (aa a,aa b)
{
	if (a.t!=b.t)
		return a.t>b.t;
	return a.s==at;
}
void read(int &k)
{
		char t;
		for (t=getchar();!('0'<=t&&t<='9');t=getchar());
		k=0;
		for (;'0'<=t&&t<='9';t=getchar())
			k=k*10+t-'0';
}
int main()
{
	for (i=1;i<=5;i++)
	{
		cin>>ch1;
		while (ch1[0]<=32)
			cin>>ch1;
		cin>>ch2;
		t1=0;t2=0;
		for (j=1;j<=len;j++)
		if (f[j].s==ch1)
			t1=j;
		if (!t1)
			f[t1=++len].s=ch1;
		for (j=1;j<=len;j++)
		if (f[j].s==ch2)
			t2=j;
		if (!t2)
			f[t2=++len].s=ch2;
		read(a2);
		read(a1);
		if (a1>a2)
		{
			f[t1].t+=3;
			f[t2].di+=3;
		}
		else
		if (a1<a2)
		{
			f[t2].t+=3;
			f[t1].di+=3;
		}
		else
		{
			f[t1].t++;
			f[t2].t++;
			f[t1].di++;
			f[t2].di++;
		}
	}
	sort(f+1,f+len+1,compare);
	if (f[1].s==at)
		printf("%d:%d",f[1].t,f[1].di);
	else
	if	(f[2].s==at)
		printf("%d:%d",f[2].t,f[2].di);
	else
		cout<<"IMPOSSIBLE";
}

/**
 * ID: ping128
 * LANG: C++
 */

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <math.h>
#include <algorithm>
#include <map>
#include <string.h>

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;
typedef pair<PII,int>PII2;

string a, b;
int s1, s2;

map<string, int> M;

struct node {
    int c;
    string name;
    int p, s, m;
} team[4];

int cnt = 0;

int cmp2(struct node a, struct node b) {
    if(a.p != b.p)
        return a.p > b.p;
    if(a.s - a.m != b.s - b.m)
        return a.s - a.m > b.s - b.m;
    if(a.s != b.s)
        return a.s > b.s;
    return (a.name).compare(b.name);
}

bool win(int a, int b, string c, int aa, int bb, string cc) {
    if(a - b > aa - bb) return true;
    if(a - b < aa - bb) return false;
    if(a > aa) return true;
    if(a < aa) return false;
    if(c.compare(cc) < 0) return true;
    return false;
}

int main() {

    for(int i = 0; i < 5; i++ ) {
        cin >> a >> b;
        scanf("%d:%d", &s1, &s2);
        if(M.find(a) == M.end()) {
            M[a] = cnt++;
        }
        if(M.find(b) == M.end()) {
            M[b] = cnt++;
        }
        team[M[a]].name = a;
        team[M[b]].name = b;
        team[M[a]].s += s1;
        team[M[b]].s += s2;
        team[M[a]].m += s2;
        team[M[b]].m += s1;
        team[M[a]].c++;
        team[M[b]].c++;
        if(s1 == s2) {
            team[M[a]].p++;
            team[M[b]].p++;
        } else if(s1 > s2) {
            team[M[a]].p += 3;
        } else {
            team[M[b]].p += 3;
        }
    }

    sort(team, team + 4, cmp2);

    if(team[0].name.compare("BERLAND") == 0 || team[1].name.compare("BERLAND") == 0) {
        cout << "1:0" << endl;
    } else {
        int ind;
        if(team[2].name.compare("BERLAND") == 0) ind = 2;
        else ind = 3;

        if(team[1].p - team[ind].p > 3) cout << "IMPOSSIBLE" << endl;
        else if(team[1].p - team[ind].p < 3) cout << "1:0" << endl;
        else {
            // find opponent
            int ind2;
            for(int i = 0; i < 4; i++ ) {
                if(i != ind && team[i].c == 2) {
                    ind2 = i;
                    break;
                }
            }
            int ind3;
            for(int i = 1; i < 4; i++ ) {
                if(i != ind && i != ind2) {
                    ind3 = i;
                    break;
                }
            }
            int aaa = 10000, bbb = 0;
            for(int x = 1; x < 30; x++ ) {
                for(int y = x - 1; y >= 0; y-- ) {
                    if(win(team[ind].s + x, team[ind].m + y, team[ind].name, team[ind2].s + y, team[ind2].m + x, team[ind2].name)
                    && win(team[ind].s + x, team[ind].m + y, team[ind].name, team[ind3].s, team[ind3].m, team[ind3].name)) {
                        if(x - y < aaa - bbb || ( x - y == aaa - bbb && y < bbb)) {
                            aaa = x;
                            bbb = y;
                        }
                    }
                }
            }
            cout << aaa << ":" << bbb << endl;
        }
    }
return 0;
}

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
typedef __int64 LL;

map<string,int> mm;
struct Node{
	string name;
	int sign,cs;
	int point,x,y;
	Node(){
		name = "";
		sign = cs = point = x = y = 0;
	}
};
bool comp(const Node & t1,const Node & t2)
{
	if(t1.point != t2.point)  //分数
	{
		return t1.point > t2.point;
	}
	if(t1.x - t1.y != t2.x - t2.y)  //进球 - 输出
	{
		return t1.x - t1.y > t2.x - t2.y;
	}
	if(t1.x != t2.x)   //进球
	{
		return t1.x > t2.x;
	}
	return t1.name < t2.name;
}
Node mat[10],mat2[10];
int main()
{
	char ns1[100],ns2[100];
	int i,j,g1,g2,nt,p1,p2,st,or,dit;
	string dist = "BERLAND";
	string s1,s2,ts;
	nt = 1;
	for(i = 0;i < 5;i ++)
	{
		scanf("%s%s%d:%d",ns1,ns2,&g1,&g2);
		s1 = ns1;
		s2 = ns2;
		if(mm[s1] == 0)
		{
			mat[nt-1].name = s1;
			mm[s1] = nt ++;
		}
		p1 = mm[s1] - 1;
		mat[p1].sign = p1;
		mat[p1].cs ++;
		mat[p1].x += g1;
		mat[p1].y += g2;
		if(mm[s2] == 0)
		{
			mat[nt-1].name = s2;
			mm[s2] = nt ++;
		}
		p2 = mm[s2] - 1;
		mat[p2].sign = p2;
		mat[p2].cs ++;
		mat[p2].x += g2;
		mat[p2].y += g1;
		if(g1 > g2)
			mat[p1].point += 3;
		else if(g1 < g2) mat[p2].point += 3;
		else mat[p1].point += 1,mat[p2].point += 1;
	}
	nt --;
	sort(mat,mat+nt,comp);
	for(i = 0;i < nt;i ++)
	{
		if(mat[i].name == dist)
			break;
	}
	st = i;
	dit = mat[i].sign;
	for(i = 0;i < nt;i ++)
		if(mat[i].cs  == 2 && i != st)
		{
			or = i;
			break;
		}
	if(mat[st].point + 3 < mat[1].point)
	{
		printf("IMPOSSIBLE\n");
	}else{
		for(i = 1;i < 30;i ++)
		{
			for(j = 0;j < 30;j ++)
			{
				memcpy(mat2,mat,sizeof(mat));
				mat2[st].point += 3; mat2[st].x += i+j;
				mat2[st].y += j;
				mat2[or].x += j; mat2[or].y += i+j;
				sort(mat2,mat2+nt,comp);
				if(mat2[0].sign == dit || mat2[1].sign == dit)
				{
					break;
				}
			}
			if(j < i) break;
		}
		printf("%d:%d\n",i+j,j);
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <iomanip>
#include <queue>
using namespace std;
const int inf = 1e9+7;
map<string,int> m,m1,m2,m3;
string s,s1;
int beer,beer1;
int en,en1;
struct pl
{
    int  x,y,z,q;
};
void ssort(pl a[])
{
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<4;j++)
        {
            if(a[j].x > a[j-1].x)
            {
                swap(a[j],a[j-1]);
            }
            if(a[j].x == a[j-1].x && a[j].y > a[j-1].y)
            {
                swap(a[j],a[j-1]);
            }
            if(a[j].x == a[j-1].x && a[j].y == a[j-1].y && a[j].z > a[j-1].z)
            {
                swap(a[j],a[j-1]);
            }
            if(a[j].x == a[j-1].x && a[j].y == a[j-1].y && a[j].z == a[j-1].z
               && a[j].q < a[j-1].q)
            {
                swap(a[j],a[j-1]);
            }
        }
    }
}
pl a[10],aaa[10];
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","rt",stdin);
        freopen("output.txt","wt",stdout);
    #endif
    for(int i=0;i<5;i++)
    {
        int x,y;
        cin >> s >> s1;
        scanf("%d:%d",&x,&y);
        m[s] += x>y?3:(x == y ? 1 : 0);
            m[s1] += x<y?3:(x == y ? 1 : 0);
        m1[s] += x-y;
            m1[s1] += y-x;
        m2[s] += x;
            m2[s1] += y;
        m3[s]++;
            m3[s1]++;
    }
    int t = 0;
    map<string,int>::iterator ii=m1.begin();
    map<string,int>::iterator iii=m2.begin();
    map<string,int>::iterator iiii=m3.begin();
    for(map<string,int>::iterator i=m.begin();i!=m.end();i++)
    {
        a[t].x = i->second;
        a[t].y = ii->second;
        a[t].z = iii->second;
        a[t].q = t;
        if(i->first == "BERLAND") {beer = t;ii++;iii++;iiii++;t++;continue;}
            if(iiii->second != 3)
            {
                en = t;
            }
        ii++;
            iii++;
                iiii++;
        t++;
    }
    ssort(a);
    for(int i=0;i<4;i++)
    {
        if(a[i].q == beer)
        {
            beer1 = i;
        }
        if(a[i].q == en)
        {
            en1 = i;
        }
    }
    if(beer1 == 0 || beer1 == 1)
    {
        cout << "0:0" << endl;
        exit(0);
    }else
    {
        int ans_x=0,ans_y=0;
        for(int i=1;i<10000;i++)
        {
            for(int i=0;i<4;i++)
            {
                aaa[i].x = a[i].x;
                aaa[i].y = a[i].y;
                aaa[i].z = a[i].z;
                aaa[i].q = a[i].q;
            }
                aaa[beer1].x += 3;
                    aaa[beer1].y += i;
                        aaa[beer1].z += i;
                aaa[en1].y -= i;
                ssort(aaa);
            if(aaa[0].q == beer || aaa[1].q == beer)
            {
                cout << i << ":0" << endl;
                    exit(0);
            }
         /*   for(int i=0;i<4;i++)
            {
                cout << aaa[i].x <<" " << aaa[i].y <<" " << aaa[i].z <<" " << aaa[i].q << endl;
            }
            cout <<" -------- " << endl; */
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define All(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)

struct Team
{
	string nam;
	int gro,win,goal,point;
};
map<string,Team> team;
vector<Team> v;
string ano;

inline bool cmp(Team a,Team b)
{
	if(a.point<b.point) return 0; else if(a.point>b.point) return 1;
	if(a.win<b.win) return 0; else if(a.win>b.win) return 1;
	if(a.goal<b.goal) return 0; else if(a.goal>b.goal) return 1;
	if(a.nam<b.nam) return 1; else if(a.nam>b.nam) return 0;
}

int main()
{
	rep(i,5)
	{
		string a,b;int x,y;
		cin>>a>>b;scanf("%d:%d",&x,&y);
		team[a].nam=a;team[b].nam=b;
		team[a].gro++;team[b].gro++;
		team[a].win+=(x-y);team[b].win+=(y-x);
		team[a].goal+=x;team[b].goal+=y;
		if(x>y) team[a].point+=3,team[b].point+=0; else if(x<y) team[b].point+=3,team[a].point+=0;
		else team[a].point++,team[b].point++;
	}

	repv(i,team) v.push_back(i->second);
	sort(All(v),cmp);

	repV(i,v) if(i.gro==2&&i.nam!="BERLAND") {ano=i.nam;break;}
//	cout<<ano<<endl;
//	repV(i,v) cout<<i.nam<<' '<<i.win<<' '<<i.goal<<' '<<i.gro<<' '<<i.point<<endl;
	int x=0,y=0,cx=0,cy=0;
	for(int i=1;i<1000;i++)
	{
		int m1,m2;
		rep(i,v.size()) if(v[i].nam=="BERLAND") m1=i; else if(v[i].nam==ano) m2=i;

		int t1,t2=v[m1].point,t3,t4,t5=v[m2].goal;

		v[m1].goal++;t1=v[m1].goal;
		if(i==1) v[m1].point+=3,t2+=3;
		v[m1].win++;v[m2].win--;t3=v[m1].win;t4=v[m2].win;
		sort(All(v),cmp);
		/*
		repV(i,v) cout<<i.nam<<' '<<i.win<<' '<<i.goal<<' '<<i.point<<endl;
		cout<<endl;
		*/
		if(v[0].nam=="BERLAND"||v[1].nam=="BERLAND") cx=i; else continue;

		for(int j=1;j<i;j++)
		{
			int m1,m2;
			rep(k,v.size()) if(v[k].nam=="BERLAND") m1=k; else if(v[k].nam==ano) m2=k;

			v[m2].goal++;
			v[m1].win--;v[m2].win++;
			sort(All(v),cmp);

			if(v[0].nam=="BERLAND"||v[1].nam=="BERLAND") cy=j;
		}

		v[m1].goal=t1;
		v[m1].point=t2;
		v[m1].win=t3;v[m2].win=t4;
		v[m2].goal=t5;

		if(x==0&&y==0||cx-cy<x-y||cx-cy==x-y&&cy<y) x=cx,y=cy;
	}

	if(x) cout<<x<<':'<<y; else cout<<"IMPOSSIBLE";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
struct info
{
  int go_w,go_m,point,play;
  string name;

};
struct in
{
  int po,pos;
};
bool my(in a,in b)
{
  if(a.po>b.po);
}
bool my2(info a,info b)
{
    if(a.point>b.point)
        return 1;
    else if(a.point==b.point)
    {
  if((a.go_w-a.go_m)>(b.go_w-b.go_m))
    return 1;
     else if((a.go_w-a.go_m)==(b.go_w-b.go_m))
    {
     if(a.go_w>b.go_w)return 1;
     else if(a.go_w==b.go_w)
     {
         return a.name<b.name;
     }
     }
    }
    return 0;
}
int main()
{
   map<string,int>team;
   int cou=0;
   info lis[10];
   for(int i=1;i<=5;i++)
   {
        lis[i].go_w=lis[i].go_m=lis[i].point=0,lis[i].play=0;
   }
   for(int i=1;i<=5;i++)
   {
        string a, b;int go_1,go_2;
        cin>>a>>b;
        scanf("%d:%d",&go_1,&go_2);
       if(team[a]==0)team[a]=++cou;
       if(team[b]==0)team[b]=++cou;
        int d=team[a];
        lis[d].name=a;
        int e=team[b];
        lis[e].name=b;
        if(go_1==go_2)
            lis[d].point+=1,lis[e].point+=1;
        if(go_1>go_2)
            lis[d].point+=3;
        else lis[e].point+=3;
      lis[d].go_w+=go_1,lis[d].go_m+=go_2,lis[d].play++;
      lis[e].go_w+=go_2,lis[e].go_m+=go_1,lis[e].play++;
   }
   int c=team["BERLAND"];
    vector<in>li;
    int paisi;
    for(int i=1;i<=4;i++)
    {
        info te=lis[i];
        if(te.play==2 && te.name!="BERLAND")
            paisi=i;
    }
         vector<info>tea;
     for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
      info temp=tea[1];
    if(temp.point>lis[c].point+3)
    {
         puts("IMPOSSIBLE");return 0;
    }
    else if(temp.point<lis[c].point+3)
    {
      puts("1:0");return 0;
    }
   int x=0,y=0;
   int ca=0;
   while(1)
   {
       //cout<<"pafd\n";
       vector<info>tea;
    for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
     info temp=tea[0],temp2 =tea[1];
     if(temp.name=="BERLAND" || temp2.name=="BERLAND")
     {
        cout<<x<<":"<<y;
        return 0;
     }
     lis[c].go_w++;
     lis[paisi].go_m++;
     if(ca==0)lis[c].point+=3;
     ca++;
     x++;
   }
   return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define DEBUG(x) cout << #x ":" << x << " "
map<string, int> teamMap;
map<int, string> idMap;
struct Team
{
    int id, point, missed, scored;
    Team(int i = 0, int p = 0, int m = 0, int s = 0) : id(i), point(p), missed(m), scored(s) {}
    bool operator<(const Team &x) const
    {
        return (point == x.point ? (scored-missed == x.scored-x.missed ? (scored == x.scored ? id > x.id : scored < x.scored) : scored-missed < x.scored-x.missed) : point < x.point);
    }
    Team operator+=(const Team &x)
    {
        if (id != x.id)
            return (*this);
        point += x.point;
        missed += x.missed;
        scored += x.scored;
        return (*this);
    }
} teams[4];
int cnt[4];
void rebulidMap()
{
    int i = 0;
    /* cout << "Before\n";
    for (int i=0;i<4;i++)
    {
        cout << cnt[i] << endl;
    }
    for (auto it=teamMap.begin();it!=teamMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (auto it=idMap.begin();it!=idMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    } */
    decltype(teamMap) tempTeamMap(teamMap);
    int tempCnt[4];
    Team tempTeams[4];
    memcpy(tempCnt, cnt, sizeof(cnt));
    memcpy(tempTeams, teams, sizeof(teams));
    for (auto it = teamMap.begin(); it != teamMap.end(); it++,i++)
    {
        it->second = i;
        idMap[it->second] = it->first;
    }
    for (int i=0;i<4;i++)
    {
        cnt[i]=tempCnt[tempTeamMap[idMap[i]]];
        teams[i]=tempTeams[tempTeamMap[idMap[i]]];
        teams[i].id=i;
    }
   /*  cout << "After\n";
    for (auto it=teamMap.begin();it!=teamMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (auto it=idMap.begin();it!=idMap.end();it++)
    {
        cout << (it->first) << " "<< (it->second) << endl;
    }
    for (int i=0;i<4;i++)
    {
        cout << cnt[i] << endl;
    }  */
}
int getOpponent()
{
    for (int i = 0; i < 4; i++)
    {
        if (cnt[i] < 3)
        {
            return i;
        }
    }
}
int getRealIdById(int id, Team *teams)
{
    for (int i = 0; i < 4; i++)
    {
        if (teams[i].id == id)
        {
            return i;
        }
    }
}
int main()
{
    teamMap.clear();
    // freopen("debug.txt","w",stdout);
    for (int i = 0; i < 4; i++)
    {
        teams[i].id = i;
    }
    for (int i = 0; i < 5; i++)
    {
        string s1, s2;
        int x, y;
        cin >> s1 >> s2;
        scanf("%d:%d", &x, &y);
        int px = (x == y ? 1 : x > y ? 3 : 0);
        int py = (x == y ? 1 : 3 - px);
        //team 1
        int id = teamMap.size();
        if (teamMap.count(s1) == 0)
        {
            teamMap[s1] = id;
            idMap[id] = s1;
        }
        teams[teamMap[s1]] += Team(teamMap[s1], px, y, x);
        cnt[teamMap[s1]]++;
        //team 2
        id = teamMap.size();
        if (teamMap.count(s2) == 0)
        {
            teamMap[s2] = id;
            idMap[id] = s2;
        }
        teams[teamMap[s2]] += Team(teamMap[s2], py, x, y);
        cnt[teamMap[s2]]++;
    }
    rebulidMap();
    teams[teamMap["BERLAND"]] += Team(teamMap["BERLAND"], 3);
    cnt[teamMap["BERLAND"]]=3;
    int oid = getOpponent();
    sort(teams, teams + 4);
    /* for (int i = 0; i < 4; i++)
    {
        DEBUG(teams[i].id);
        DEBUG(teams[i].point);
        DEBUG(teams[i].missed);
        DEBUG(teams[i].scored);
        cout << endl;
    } */
    // cout << oid << " "<<teamMap["BERLAND"] <<endl;
    int i = 1;
    while (i<1e2)
    {
        for (int j = i - 1; j >= 0; j--)
        {
            Team tempTeams[4];
            memcpy(tempTeams, teams, sizeof(teams));
            tempTeams[getRealIdById(teamMap["BERLAND"], tempTeams)] += Team(teamMap["BERLAND"], 0, j, i);
            tempTeams[getRealIdById(oid, tempTeams)] += Team(oid, 0, i, j);
            sort(tempTeams, tempTeams + 4);
            /* cout << i << " " << j << endl;
            for (int i = 0; i < 4; i++)
            {
                DEBUG(tempTeams[i].id);
                DEBUG(tempTeams[i].point);
                DEBUG(tempTeams[i].missed);
                DEBUG(tempTeams[i].scored);
                cout << endl;
            } */
            if (getRealIdById(teamMap["BERLAND"], tempTeams) >= 2)
            {
                cout << i << ":" << j << endl;
                return 0;
            }
        }
        i++;
    }
    cout << "IMPOSSIBLE" <<endl;
    return 0;
}

/* DOAN Minh Quy
** mquy.doan@gmail.com
** problem:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int64 long long
#define MAXN 100111
typedef pair<int,int> ii;
/*----------------------------------*/
map<string,int> goal,score,diff;
set<string> ex,xx;
vector<string> team;
bool mycmp(string a,string b){
    if ( score[a] != score[b] ){
        return score[a] > score[b];
    }
    if ( diff[a] != diff[b] ){
        return diff[a] > diff[b];
    }
    if ( goal[a] != goal[b] ){
        return goal[a] > goal[b];
    }
    return a < b;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    #endif
    char ff[22],ss[22],line[100],*token;
    int fc,sc;
    string bl = "BERLAND", op ;
    for(int i = 0 ; i < 5 ; i++){
        gets(line);
        token = strtok(line," :");
        strcpy(ff,token);
        token = strtok(NULL," :");
        strcpy(ss,token);
        token = strtok(NULL," :");
        fc = atoi(token);
        token = strtok(NULL," :");
        sc = atoi(token);
        //-------------------------
        if ( ex.find(ff) == ex.end() ){
            ex.insert(ff);
            team.push_back(ff);
        }
        if ( ex.find(ss) == ex.end() ){
            ex.insert(ss);
            team.push_back(ss);
        }
        if ( fc > sc ){
            score[ff] += 3;
        }else if ( fc == sc ){
            score[ff] += 1;
            score[ss] += 1;
        }else{
            score[ss] += 3;
        }
        goal[ff] += fc , goal[ss] += sc;
        diff[ff] += fc - sc , diff[ss] += sc - fc;
        if ( strcmp(ff,bl.c_str()) == 0 ){
            xx.insert(ss);
        }
        if ( strcmp(ss,bl.c_str()) == 0 ){
            xx.insert(ff);
        }
    }
    xx.insert(bl);

    for(int i = 0 ; i < team.size() ; i++){
        if ( xx.find(team[i]) == xx.end() ){
            op = team[i];
        }
    }
    sort(team.begin(),team.end(),mycmp);
    int curr = score[bl] + 3;
    if ( curr < score[team[1]] ){
        puts("IMPOSSIBLE");
    }else{
        int v1 = 0 , v2 = 10;
        while(true){
            if ( v1 > v2 ){
                score[bl] += 3;
            }else if ( fc == sc ){
                score[bl] += 1;
                score[op] += 1;
            }else {
                score[op] += 3;
            }
            goal[bl] += v1 , goal[op] += v2;
            diff[bl] += v1 - v2 , diff[op] += v2 - v1;
            sort(team.begin(),team.end(),mycmp);
            if ( team[0] == bl || team[1] == bl ){
                break;
            }
//          printf("%d v\n",v1);
//          for(int i = 0 ; i< team.size() ; i++){
//              cout << team[i] << " " << score[team[i]] <<" " << diff[team[i]] << " " << goal[team[i]] << endl;
//          }
//          puts("");
            if ( v1 > v2 ){
                score[bl] -= 3;
            }else if ( fc == sc ){
                score[bl] -= 1;
                score[op] -= 1;
            }else {
                score[op] -= 3;
            }
            goal[bl] -= v1 , goal[op] -= v2;
            diff[bl] -= v1 - v2 , diff[op] -= v2 - v1;
            if ( v2 ) --v2 ;
            else ++v1;
        }
        printf("%d:%d\n",v1,v2);
    }
    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define maxn 100005
#define inf 0xfffffff
using namespace std;
char str1[20], str2[20];
struct node {
	int s, w, l;
	int g;
	char name;
}arr[5];
queue<int> que;
int book[5];
bool cmp(node a, node b)
{
	if (a.s != b.s) return a.s > b.s;
	if (a.g != b.g) return a.g > b.g;
	return a.name < b.name;
}
int main()
{
	int x, y;
	for (int i = 1; i <= 5; i++) {
		scanf("%s%s%d:%d", str1, str2, &x, &y);
		if (i == 1) {
			if (x > y) arr[1].s += 3, arr[1].w += x, arr[1].l += y, arr[4].l += x, arr[4].w += y;
			else if (x == y) arr[1].s++, arr[4].s++;
			else arr[4].s += 3, arr[4].w += y, arr[4].l += x, arr[1].l += y, arr[1].w += x;
		}
		else if (i == 2) {
			if (x > y) arr[4].s += 3, arr[4].w += x, arr[4].l += y, arr[3].l += x, arr[3].w += y;
			else if (x == y) arr[4].s++, arr[3].s++;
			else arr[3].s += 3, arr[3].w += y, arr[3].l += x, arr[4].l += y, arr[4].w += x;
		}
		else if (i == 3) {
			if (x > y) arr[3].s += 3, arr[3].w += x, arr[3].l += y, arr[1].l += x, arr[1].w += y;
			else if (x == y) arr[3].s++, arr[1].s++;
			else arr[1].s += 3, arr[1].w += y, arr[1].l += x, arr[3].l += y, arr[3].w += x;
		}
		else if (i == 4) {
			if (x > y) arr[1].s += 3, arr[1].w += x, arr[1].l += y, arr[2].l += x, arr[2].w += y;
			else if (x == y) arr[1].s++, arr[2].s++;
			else arr[2].s += 3, arr[2].w += y, arr[2].l += x, arr[1].l += y, arr[1].w += x;
		}
		else {
			if (x > y) arr[4].s += 3, arr[4].w += x, arr[4].l += y, arr[2].l += x, arr[2].w += y;
			else if (x == y) arr[4].s++, arr[2].s++;
			else arr[2].s += 3, arr[2].w += y, arr[2].l += x, arr[4].l += y, arr[4].w += x;
		}
	}
	for (int i = 1; i <= 4; i++) {
		arr[i].g = arr[i].w - arr[i].l;
		arr[i].name = 'A' + i - 1;
	}
	sort(arr + 1, arr + 5, cmp);
	int tmp;
	for (int i = 1; i <= 4; i++) {
		if (arr[i].name == 'B') {
			tmp = i;
			break;
		}
	}
	int cnt = 0;
	for (int i = 1; i < tmp; i++) {
		if (arr[i].s - arr[tmp].s > 3) cnt++;
	}
	if (cnt >= 2) {
		printf("IMPOSSIBLE\n");
	}
	else {
		int b = 0;
		arr[tmp] . s += 3;
		while (true) {
			if (tmp <= 2) break;
			b++;
			for (int i = 1; i <= 4; i++) {
				if (arr[i].name == 'B') {
					arr[i].g++;
				}
				if (arr[i].name == 'C') {
					arr[i].g--;
				}
			}
			sort(arr + 1, arr + 5, cmp);
			for (int i = 1; i <= 4; i++)
				if (arr[i].name == 'B') tmp = i;
		}
		//for (int i = 1; i <= 4; i++)
			//cout << arr[i].s << ' ' << arr[i].g << ' ' << arr[i].name << endl;
		printf("%d:0\n", b);
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
#define all(A)             A.begin(), A.end()
#define rall(A)            A.rbegin(), A.rend()
#define mem(A, B)          memset(A, B, sizeof A)
#define sorta(A)           sort(all(A))
#define sortd(A)           sort(rall(A))
#define sortf(A, F)        sort(all(A), F)
#define PI                 (acos(0.) * 2)
#define eps                .000000001
#define oo                 1000000000
template<class T1, class T2> inline void remax(T1& A, T2 B){ if(A < B)A = B; }
template<class T1, class T2> inline void remin(T1& A, T2 B){ if(A > B)A = B; }
ll Gcd(ll a, ll b){ if(!a || !b)return a + b; while(a %= b ^= a ^= b ^= a);  return b; }
ll Power(ll base, ull power){ ll ret = 1; while(power){ if(power & 1)ret *= base; power >>= 1; base *= base; } return ret; }
ll PowerMod(ll base, ull power, ll mod){ if(!power)return 1 % mod; if(power & 1)return (base * PowerMod(base, power - 1, mod)) % mod; return PowerMod((base * base) % mod, power >> 1, mod); }
FILE *Input = stdin;

struct team{
	int points;
	int in;
	int out;
	int ind;
	team(){
		points = in = out = 0;
	}
	const bool operator <(const team &rhs)const{
		if(points != rhs.points)return points > rhs.points;
		if(in - out != rhs.in - rhs.out)return in - out > rhs.in - rhs.out;
		if(in != rhs.in)return in > rhs.in;
		return ind < rhs.ind;
	}
};
struct group{
	team arr[4];
	group(){
		for(int i = 0; i < 4; ++i)
			arr[i].ind = i;
	}
	void f(){
		sort(arr, arr + 4);
	}
};
inline void run(){
	map<string, int> mp;
	char s1[5][21];
	char s2[5][21];
	int arr1[5];
	int arr2[5];
	group g;
	int a, b, p = ~0;
	for(int i = 0; i < 5; ++i)
		scanf("%s%s%d:%d", s1 + i, s2 + i, arr1 + i, arr2 + i);
	for(int i = 0; i < 5; ++i){
		string x = s1[i];
		if(mp.find(x) == mp.end())mp[x] = 0;
		x = s2[i];
		if(mp.find(x) == mp.end())mp[x] = 0;
	}
	for(map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it)
		it->second = ++p;
	for(int i = 0; i < 4; ++i){
		int x = 0;
		for(int j = 0; j < 5; ++j)
			if(mp[s1[j]] == i || mp[s2[j]] == i)++x;
		if(x == 2)
			if(mp["BERLAND"] == i)a = i;
			else b = i;
	}
	for(int i = 0; i < 5; ++i){
		int ind1 = mp[s1[i]];
		int ind2 = mp[s2[i]];
		if(arr1[i] > arr2[i])++++++g.arr[ind1].points;
		else if(arr1[i] < arr2[i])++++++g.arr[ind2].points;
		else++g.arr[ind1].points, ++g.arr[ind2].points;
		g.arr[ind1].in += arr1[i];
		g.arr[ind1].out += arr2[i];
		g.arr[ind2].in += arr2[i];
		g.arr[ind2].out += arr1[i];
	}
	++++++g.arr[a].points;
	for(int i = 1; i <= 50; ++i){
		group gg = g;
		gg.arr[a].in += i;
		gg.arr[b].out += i;
		gg.f();
		if(gg.arr[0].ind == a || gg.arr[1].ind == a){
			g = gg;
			for(int j = i - 1; ~j; --j){
				gg = g;
				gg.arr[a].out += j;
				gg.arr[b].in += j;
				gg.f();
				if(gg.arr[0].ind == a || gg.arr[1].ind == a)return (void)printf("%d:%d\n", i, j);
			}
		}
	}
	puts("IMPOSSIBLE");
}
int main(){
	#ifdef LOCAL
	Input = freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	while(!feof(Input)){
		run();
		puts("");
	}
	printf("\n\ntime: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
	#else
	run();
	#endif
	return 0;
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  eps      0.00000001
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   inf        0x7fffffff
#define    PI        3.1415926535897932384626433832795
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    vi       vector<int>
#define    vd       vector<double>
#define    vvi      vector< vector<int> >
#define    vvll      vector< vector<long long> >
#define    vvpi     vector< vector< pair<int,int> > >
#define    vvpll     vector< vector< pair<long long,long long> > >
#define    vvd      vector< vector<double> >
#define    vs       vector<string>
#define    vvs      vector< vector<string> >
#define     vc        vector<char>
#define     vpi        vector< pair<int ,int> >
#define      pi        pair<int ,int>
#define      pll       pair<long long ,long long>
#define     vpd        vector< pair<double ,double> >
#define     vpll        vector< pair<long long ,long long> >
#define    vll       vector<long long>
#define    dqi        deque< int >
#define     si         set<int>
#define     spi        set< pair<int ,int > >
#define     row          vector< ll >
#define     matrix            vector< row >
#define    lp(i,n)    for(i=0;i<n;i++)
#define     si         set<int>
#define    oo         9000000000000000000
#define   MOD         1000000007
#define    X            real
#define    Y            imag
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define    scani(n)                  scanf("%d",&n)
#define    scanll(n)                  scanf("%I64d",&n)
#define    printi(n)                 printf("%d",n)
#define    printll(n)                 printf("%I64d",n)
#define    scand(n)                  scanf("%lf",&n)
#define    printd(n)                 printf("%lf",n)
#define    scans(n)                  scanf("%s",&n)
#define    prints(n)                 printf("%s",n)
typedef  long long     ll ;
typedef  unsigned long long ull;
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

map< string ,pair<int ,pi> > mb;
map<string, int> vis;

int main()
{

    vector< pair<  pair<  pair<int ,int>  ,int  > , string > > v;

    for(int i=0;i<5;i++)
    {

        string st1,st2;
        int s1,s2;

        cin>>st1>>st2;

        if(st1=="BERLAND")
            vis[st2]=1;
        if(st2=="BERLAND")
            vis[st1]=1;

        scanf("%d:%d",&s1,&s2);

        mb[st1].first+=s1;
        mb[st1].second.first+=s2;

        if(s1>s2)
            mb[st1].second.second+=3;
        else if(s1==s2)
        {
            mb[st1].second.second+=1;
            mb[st2].second.second+=1;
        }
        else
            mb[st2].second.second+=3;

        mb[st2].first+=s2;
        mb[st2].second.first+=s1;

    }

    for(auto i=mb.begin();i!=mb.end();i++)
    {
        string st=(*i).first;
        int go=(*i).second.first;
        int miss=(*i).second.second.first;
        int points=(*i).second.second.second;

        v.pb(mp(mp(mp(points,go-miss),go),st));

    }

    sort(all(v));
    pi mi=mp(1000000000,1000000000);

    string name="BERLAND";
   int miss=mb[name].second.first;
   int  goals=mb[name].first;
   int points=mb[name].second.second;
 //cout<<miss<<" "<<goals<<" "<<points<<endl;

for(int x=1;x<=150;x++)
{
    int cnt=0;

     goals+=x;

     int diff=goals-miss;

     points+=3;

  int cr,cntt;
  for(int j=0;j<sz(v);j++)
 {
     if(v[j].second==name||vis[v[j].second]==1)
        continue;

     v[j].first.first.second-=x;

    cnt=0;

    cr=0;
    cntt=0;
    for(int i=0;i<sz(v);i++)
    {
        int d=v[i].first.first.second;
        int go=v[i].first.second;
        string nm=v[i].second;
        int pt=v[i].first.first.first;

        if(nm==name)
            continue;

  //  if(x==5)
//cout<<nm<<" "<<d<<" "<<go<<" "<<pt<<endl<<goals<<" p= "<<points<<" "<<diff<<endl;
        if(pt>points)
        cnt++;
        else if(pt==points&&d>diff)
        cnt++;
        else if(pt==points&&d==diff&&go>goals)
        {
           int  f=go-goals;
              cr+=f;
             goals+=f;
           cntt++;
           if(pt==points&&d==diff&&go==goals&&nm<name)
                goals++,cr++;
        }
        else if(pt==points&&d==diff&&go==goals&&nm<name)
                goals++,cr++,cntt++;

    }

    if(cnt+cntt<=1)
    {

        mi=min(mi,min(mp(x,-0),mp(x+cr,-cr)));

    }
    else if(cnt<=1)
    {
        mi.first=x+cr;
        mi.second=cr*-1;

    }

    goals-=cr;

    v[j].first.first.second+=x;

  }

    goals-=x;

    diff=goals-miss;
     points-=3;

}

   if(mi.first==1000000000)
    cout<<"IMPOSSIBLE";
   else
    cout<<mi.first<<":"<<mi.second*-1;

    }

#include<stdio.h>
#include<map>
#include<string.h>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
map<string,int> points;
map<string,int> goals;
map<string,int> misses;
set<string> playedWithBerland;
void parseS(char *t1,char *t2,int p1,int p2)
{
	if(p1>p2)
	{
		points[t1]+=3;
	}
	else if(p2>p1)
	{
		points[t2]+=3;
	}
	else
	{
		points[t1]+=1;
		points[t2]+=2;
	}
	if(!strcmp(t1,"BERLAND"))
	{
		playedWithBerland.insert(t2);
	}

	if(!strcmp(t2,"BERLAND"))
	{
		playedWithBerland.insert(t1);
	}

	goals[t1]+=p1;
	goals[t2]+=p2;
	misses[t1]+=p2;
	misses[t2]+=p1;

}
char s1[100];
char s2[100];
int p1;
int p2;
char s[1000];
struct cntr
{
	string name;
	int points;
	int misses;
	int goals;
};
bool cmp(cntr &c1, cntr &c2)
{
	return c1.points>c2.points ||
		c1.points==c2.points && c1.goals-c1.misses>c2.goals-c2.misses ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals>c2.goals ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals==c2.goals && c1.name<c2.name;

}
bool ifok(vector<cntr> & C)
{
	sort(C.begin(),C.end(),cmp);
	return C[0].name=="BERLAND" || C[1].name=="BERLAND";
}
int main()
{
	for(int i=0;i<5;i++)
	{
		gets(s);
		sscanf(s,"%s %s %d:%d",s1,s2,&p1,&p2);
		parseS(s1,s2,p1,p2);
	}

	string defC;
	for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
	{
		if(it->first!="BERLAND" && playedWithBerland.find(it->first)==playedWithBerland.end())
		{
			defC=it->first;
		}
	}
	points[defC]+=0;
	points["BERLAND"]+=3;
	vector<pair<int,int> > goodSc;
	for(int dx=1;dx<100;dx++)
	{
		for(int Y=0;Y<100;Y++)
		{
			int X=Y+dx;
			goals[defC]+=Y;
			goals["BERLAND"]+=X;
			misses[defC]+=X;
			misses["BERLAND"]+=Y;
			vector<cntr> C;
			for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
			{
				cntr c1;
				c1.name=it->first;
				c1.misses=misses[it->first];
				c1.goals=goals[it->first];
				c1.points=points[it->first];
				C.push_back(c1);
			}

			if(ifok(C))
			{
				printf("%d:%d",X,Y);
				return 0;
			}
			goals[defC]-=Y;
			goals["BERLAND"]-=X;
			misses[defC]-=X;
			misses["BERLAND"]-=Y;
		}
	}
	printf("IMPOSSIBLE\n");

}

/*
 * File:   main.cpp
 * Author: Anton Boytsov
 *
 * Created on 24 Июнь 2012 г., 21:28
 */

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

struct team {
    string name;
    int pts, gs, gf;

    team(string name) : name(name), pts(0), gs(0), gf(0) {
    };

    void score(int goals) {
        gs += goals;
    }

    void unscore(int goals) {
        gf += goals;
    }

    void make_points(int points) {

        pts += points;

    }

};

bool cmp(team a, team s) {

    if (a.pts < s.pts)
        return false;
    if (a.pts == s.pts) {

        if (a.gs - a.gf < s.gs - s.gf)
            return false;
        if (a.gs - a.gf == s.gs - s.gf) {

            if (a.gs < s.gs)
                return false;
            if (a.gs == s.gs) {

                if (a.name < s.name)
                    return false;
                else
                    return true;

            } else
                return true;

        } else
            return true;

    } else
        return true;

}

vector<team> ts;

void addscore(int s1, int s2, string t, string u) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t) {
            ts[i].score(s1);
            ts[i].unscore(s2);
        }
        if (ts[i].name == u) {
            ts[i].score(s2);
            ts[i].unscore(s1);
        }
    }
}

void addteam(string t) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t)
            return;
    }
    ts.push_back(team(t));

}

void addpts(int points, string t) {

    for (int i = 0; i < ts.size(); i++) {
        if (ts[i].name == t) {
            ts[i].make_points(points);
            return;
        }
    }

}

void outteams() {
    cout << "table:" << endl;
    for (int i = 0; i < 4; i++) {
        cout << ts[i].name << " pts: " << ts[i].pts << " gs:" << ts[i].gs << " gf:" << ts[i].gf << endl;
    }
}

map<string, int> played;
char t[100], u[100];

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    for (int i = 0; i < 5; i++) {
        memset(t, 0, sizeof (t));
        memset(u, 0, sizeof (u));
        int s1, s2;
        scanf("%s %s %d:%d", t, u, &s1, &s2);
        addteam(string(t));
        addteam(string(u));
        addscore(s1, s2, string(t), string(u));
        if (s1 > s2) {
            addpts(3, string(t));
        } else if (s1 == s2) {
            addpts(1, string(t));
            addpts(1, string(u));
        } else {
            addpts(3, string(u));
        }
        played[string(t)]++;
        played[string(u)]++;
    }

    string p;
    for (map<string, int>::iterator it = played.begin(); it != played.end(); it++) {
        if (it->second == 2 && it->first != "BERLAND") {
            p = it->first;
            break;
        }
    }
    //cout << p << endl;

    sort(ts.begin(), ts.end(), cmp);
    for (int i = 0; i < 1000; i++) {

        addscore(i, 0, "BERLAND", p);
        if (!i) {
            addpts(1, "BERLAND");
            addpts(1, p);
        } else {
            addpts(3, "BERLAND");
        }
        sort(ts.begin(), ts.end(), cmp);
        //outteams();
        if (ts[0].name == "BERLAND" || ts[1].name == "BERLAND") {
            cout << i << ":0" << endl;
            return 0;
        }
        addscore(-i, 0, "BERLAND", p);
        if (!i) {
            addpts(-1, "BERLAND");
            addpts(-1, p);
        } else {
            addpts(-3, "BERLAND");
        }

    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
//#define int long long
const int maxN = 100*1000 + 5;
const int mod = 1000*1000*1000 + 7;
map<string, int> sc, po, ne;
main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    for(int i = 0; i < 5; i ++)
    {
	  string t1, t2; int g1, g2; char c;
	  cin >> t1 >> t2 >> g1 >> c >> g2;

	  if(g1 > g2) sc[t1] += 3;
	  else if(g1 < g2) sc[t2] += 3;
	  else sc[t1] ++, sc[t2] ++;

	  po[t1] += g1; po[t2] += g2;
	  ne[t1] += g2; ne[t2] += g1;
    }
    int score = sc["BERLAND"] , pos = po["BERLAND"], neg = ne["BERLAND"];
    sc.erase((map<string, int>::iterator)sc.begin());
    pair<string, int> x = *sc.rbegin();
    if(score + 2 >= x.second) { cout << "1:0" << endl; return 0; }
    if(score + 3 < x.second) { cout << "IMPOSSIBLE" << endl; return 0; }
    //cout << pos << ' ' << neg << endl;
    cout << max(po[x.first] - ne[x.first] - (pos - neg), 1) << ":0" << endl;
    return 0;
}

// --------------------------- Codeforces Round #126
#define INVCICLE(i,a,b,c) for(int i = (a); i >= (b); i -= (c))
#define CICLE(i,a,b,c) for(int i=(a); i<=(b); i += (c))
using namespace std;
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>

bool RecCMPCADS(const char * SOLP, const char * SOLQ, int p, int q, int pos)
{
 if(SOLP[pos] == 0) return true;
 if(SOLQ[pos] == 0) return false;
 if(SOLP[pos] == SOLQ[pos])
 return RecCMPCADS(SOLP,SOLQ,p,q,pos+1);
 return SOLP[pos] < SOLQ[pos];
}

struct str
{
 int L, P, G, GP, GR; char C[25];
 bool operator <(const str& S) const
 {
  if(P < S.P) return false; if(P > S.P) return true;
  if(GP-GR < S.GP-S.GR) return false; if(GP-GR > S.GP-S.GR) return true;
  if(GP < S.GP) return false; if(GP > S.GP) return true;
  return RecCMPCADS(C,S.C,L,S.L,0);
 }
};

str T[7];
str CT[7];
char teamname1[30];
char teamname2[30];
int number, gop, gor;

int GetPOS(char* teamname)
{
 CICLE(p,1,number,1)
 if(0 == strcmp(teamname,T[p].C)) return p;
 number++; T[number].GP = T[number].GR = T[number].P = T[number].G = 0;
 strcpy(T[number].C, teamname); T[number].L = strlen(teamname); return number;
}

int main()
{
 number  = 0;
 CICLE(p,1,5,1)
 {
  scanf("%s%s%d:%d",&teamname1,&teamname2,&gop,&gor);
  int pos1 = GetPOS(teamname1);
  T[pos1].GP += gop; T[pos1].GR += gor; T[pos1].G++;
  if(gop > gor) T[pos1].P += 3; if(gop == gor) T[pos1].P += 1;
  int pos2 = GetPOS(teamname2);
  T[pos2].GP += gor; T[pos2].GR += gop; T[pos2].G++;
  if(gop < gor) T[pos2].P += 3; if(gop == gor) T[pos2].P += 1;
 }
 sort(T+1,T+number+1); int posc, posb = GetPOS("BERLAND");
 //CICLE(p,1,number,1) printf("%s %d %d %d %d\n",T[p].C,T[p].P,T[p].GP,T[p].GR,T[p].G);
 CICLE(p,1,number,1) if(p != posb && T[p].G == 2) posc = p;
 //printf("PARTIDO entre %s y %s\n",T[posb].C,T[posc].C);

 if(posb < 3) { printf("0:0"); return 0; }
 if(T[posb].P+3 < T[2].P) { printf("IMPOSSIBLE"); return 0; }
 if(T[posb].P+3 > T[2].P) { printf("1:0"); return 0; }

 int mdif = T[posb].GP - T[posb].GR;
 int cdif = T[2].GP - T[2].GR;
 if(mdif >= cdif) { printf("1:0"); return 0; }
 //printf("NO DEFINIDO AUN\n",T[posb].C,T[posc].C);

 int dif = cdif - mdif; //para igualar diferencia...
 if(T[posb].GP+dif > T[2].GP) { if(posc == 2) printf("%d:0",dif); else printf("%d:%d",dif,dif-1); return 0; }
 if(T[posb].GP+dif == T[2].GP && RecCMPCADS(T[posb].C,T[2].C,T[posb].L,T[2].L,0)) { if(posc == 2) printf("%d:0",dif); else printf("%d:%d",dif,dif-1); return 0; }
 { if(posc == 2) printf("%d:0",dif+1); else printf("%d:%d",dif+1,dif); return 0; }
}

#include <cstdlib>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

bool is_b_1st_or_2nd(int game[6][4], int idx_b){
	int i;
	int point[4], diff[4], score[4], hoge[4];

	for(i = 0; i < 4; i++) point[i] =  score[i] = diff[i] = 0;

	for(i = 0; i < 6; i++){
		if(game[i][2] > game[i][3]) point[game[i][0]] += 3;
		else if(game[i][2] < game[i][3]) point[game[i][1]] += 3;
		else{ point[game[i][0]]++; point[game[i][1]]++; }

		diff[game[i][0]] += game[i][2] - game[i][3];
		diff[game[i][1]] += game[i][3] - game[i][2];
		score[game[i][0]] += game[i][2];
		score[game[i][1]] += game[i][3];
	}

	for(i = 0; i < 4; i++) hoge[i] = 1000000 * point[i] + 1000 * (diff[i] + 500) + 10 * score[i] + i;
	sort(hoge, hoge + 4);
	return (hoge[2] % 10 == idx_b || hoge[3] % 10 == idx_b) ;
}

int main(){
	int i, j, k, idx, idx_b, idx_o;
	string line[5][3];
	string name[5];

	int game[6][4];

	for(i = 0; i < 5; i++){
		string name1, name2, score;
		cin >> name1 >> name2 >> score;
		line[i][0] = name1;
		line[i][1] = name2;
		line[i][2] = score;
	}

	idx = 0;
	for(i = 0; i < 5; i++){
		for(j = 0; j < 2; j++){
			for(k = 0; k < idx; k++) if(line[i][j] == name[k]) break;
			if(k == idx){
				idx++;
				name[k] = line[i][j];
			}
		}
	}
	sort(name, name + 4);
	for(i = 0; i < 4; i++) if(name[i] == "BERLAND") idx_b = i;

	for(i = 0; i < 5; i++){
		for(j = 0; j < 4; j++){
			if(name[j] == line[i][0]) game[i][0] = j;
			if(name[j] == line[i][1]) game[i][1] = j;
		}
		game[i][2] = line[i][2][0] - '0';
		game[i][3] = line[i][2][2] - '0';
	}

	int count[4] = {0, 0, 0, 0};
	for(i = 0; i < 5; i++){
		count[game[i][0]]++;
		count[game[i][1]]++;
	}
	for(i = 0; i < 4; i++){
		if(count[i] == 2 && i != idx_b) idx_o = i;
	}
	game[5][0] = idx_b;
	game[5][1] = idx_o;

	for(i = 1; i <= 100; i++){
		for(j = 0; j < 100 - i; j++){
			game[5][2] = i + j;
			game[5][3] = j;
			if(is_b_1st_or_2nd(game, idx_b)){
				cout << i + j << ":" << j << endl;
				return 0;
			}
		}
	}
	/*
	for(i = 0; i < 4; i++){
		cout << i << ":" << name[i] << endl;
	}
	cout << endl;
	cout << "opponent:" << name[idx_o] << endl;
	cout << endl;

	for(i = 0; i < 5; i++){
		cout << game[i][0] << game[i][1] << game[i][2] << game[i][3] << endl;
	}

	is_b_1st_or_2nd(game, idx_b);
	*/
}

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#define LL long long
#define Pr pair<int,int>
#define fread(ch) freopen(ch,"r",stdin)
#define fwrite(ch) freopen(ch,"w",stdout)

using namespace std;
const int INF = 0x3f3f3f3f;
const int msz = 10000;
const int mod = 1e9+7;
const double eps = 1e-8;

struct Team
{
	int a,b,c;
};

map <string,int> mp;
Team team[4];
char a[111],b[111];
char name[4][111];
int aa,bb;
int cnt[4];

bool cal(int aa,int bb,int id1,int id2)
{
	team[id1].c += aa;
	team[id2].c += bb;
	team[id1].b += (aa-bb);
	team[id2].b += (bb-aa);
	if(aa > bb)
	{
		team[id1].a += 3;
	}
	else if(aa == bb)
	{
		team[id1].a += 1;
		team[id2].a += 1;
	}
	else
	{
		team[id2].a += 3;
	}

	int f = 0;
	for(int i = 1; i < 4; ++i)
	{
		if(team[i].a > team[id1].a) f++;
		else if(team[i].b > team[id1].b) f++;
		else if(team[i].c > team[id1].c) f++;
		else if(strcmp(name[i],name[id1]) < 0) f++;
	}

	//printf("%d %d\n",aa,bb);
	//for(int i = 0; i < 4; ++i)
	//{
	//	printf("%s %d %d %d\n",name[i],team[i].a,team[i].b,team[i].c);
	//}
	//puts("----------");
	if(f <= 1) return true;

	team[id1].c -= aa;
	team[id2].c -= bb;
	team[id1].b -= (aa-bb);
	team[id2].b -= (bb-aa);
	if(aa > bb)
	{
		team[id1].a -= 3;
	}
	else if(aa == bb)
	{
		team[id1].a -= 1;
		team[id2].a -= 1;
	}
	else
	{
		team[id2].a -= 3;
	}

	//printf("%d %d\n",aa,bb);
	//for(int i = 0; i < 4; ++i)
	//{
	//	printf("%s %d %d %d\n",name[i],team[i].a,team[i].b,team[i].c);
	//}
	//puts("----------");

	return false;
}

int main()
{
	//fread("");
	//fwrite("");

	int tp = 0;
	team[tp].a = team[tp].b = team[tp].c = 0;
	mp["BERLAND"] = tp++;
	strcpy(name[0],"BERLAND");
	int id1,id2;
	memset(cnt,0,sizeof(cnt));

	for(int i = 0; i < 5; ++i)
	{
		scanf("%s%s%d:%d",a,b,&aa,&bb);
		if(!mp.count(a))
		{
			mp[a] = tp;
			team[tp].a = team[tp].b = team[tp].c = 0;
			strcpy(name[tp],a);
			tp++;
		}

		if(!mp.count(b))
		{
			mp[b] = tp;
			team[tp].a = team[tp].b = team[tp].c = 0;
			strcpy(name[tp],b);
			tp++;
		}

		id1 = mp[a];
		id2 = mp[b];

		team[id1].c += aa;
		team[id2].c += bb;
		team[id1].b += (aa-bb);
		team[id2].b += (bb-aa);
		if(aa > bb)
		{
			team[id1].a += 3;
		}
		else if(aa == bb)
		{
			team[id1].a += 1;
			team[id2].a += 1;
		}
		else
		{
			team[id2].a += 3;
		}
		cnt[id1]++;
		cnt[id2]++;
	}

	id1 = 0;
	for(int i = 1; i < 4; ++i)
	{
		if(cnt[i] == 2)
		{
			id2 = i;
			break;
		}
	}

	for(int dis = 1; dis <= 1000000; ++dis)
	{
		int y = 0;
			if(cal(y+dis,y,id1,id2))
			{
				printf("%d:%d\n",y+dis,y);
				return 0;
			}
	}
	puts("IMPOSSIBLE");

	return 0;
}

#include <cstdlib>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

	int i, j, k, idx, idx_b, idx_o;
	string line[5][3];
	string name[5];

	int game[6][4];

bool is_b_1st_or_2nd(int game[6][4], int idx_b){
	int i;
	int point[4], diff[4], score[4], hoge[4];

	for(i = 0; i < 4; i++) point[i] =  score[i] = diff[i] = 0;

	for(i = 0; i < 6; i++){
		if(game[i][2] > game[i][3]) point[game[i][0]] += 3;
		else if(game[i][2] < game[i][3]) point[game[i][1]] += 3;
		else{ point[game[i][0]]++; point[game[i][1]]++; }

		diff[game[i][0]] += game[i][2] - game[i][3];
		diff[game[i][1]] += game[i][3] - game[i][2];
		score[game[i][0]] += game[i][2];
		score[game[i][1]] += game[i][3];
	}

	for(i = 0; i < 4; i++) hoge[i] = 10000000 * point[i] + 10000 * (diff[i] + 500) + 10 * score[i] + (4 - i);
	sort(hoge, hoge + 4);

		cout << "-----" << endl;
		for(i = 0; i < 4; i++) cout << i << ":" << name[i] << endl;
		cout << endl;
		cout << "opponent:" << name[idx_o] << endl;
		cout << endl;

		for(i = 0; i < 6; i++) cout << game[i][0] << game[i][1] << game[i][2] << game[i][3] << endl;
		for(i = 0; i < 4; i++) cout << hoge[i] << endl;

	return (hoge[2] % 10 == (4 - idx_b) || hoge[3] % 10 == (4 - idx_b));
}

int main(){

	for(i = 0; i < 5; i++){
		string name1, name2, score;
		cin >> name1 >> name2 >> score;
		line[i][0] = name1;
		line[i][1] = name2;
		line[i][2] = score;
	}

	idx = 0;
	for(i = 0; i < 5; i++){
		for(j = 0; j < 2; j++){
			for(k = 0; k < idx; k++) if(line[i][j] == name[k]) break;
			if(k == idx){
				idx++;
				name[k] = line[i][j];
			}
		}
	}
	sort(name, name + 4);
	for(i = 0; i < 4; i++) if(name[i] == "BERLAND") idx_b = i;

	for(i = 0; i < 5; i++){
		for(j = 0; j < 4; j++){
			if(name[j] == line[i][0]) game[i][0] = j;
			if(name[j] == line[i][1]) game[i][1] = j;
		}
		game[i][2] = line[i][2][0] - '0';
		game[i][3] = line[i][2][2] - '0';
	}

	int count[4] = {0, 0, 0, 0};
	for(i = 0; i < 5; i++){
		count[game[i][0]]++;
		count[game[i][1]]++;
	}
	for(i = 0; i < 4; i++){
		if(count[i] == 2 && i != idx_b) idx_o = i;
	}
	game[5][0] = idx_b;
	game[5][1] = idx_o;

	for(i = 1; i <= 100; i++){
		for(j = 0; j < 100 - i; j++){
			game[5][2] = i + j;
			game[5][3] = j;
			if(is_b_1st_or_2nd(game, idx_b)){
				cout << i + j << ":" << j << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

//kAc
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);

#define ALL(x) x.begin(), x.end()
#define fr(x, E) for (__typeof(E.begin()) x = E.begin(); x != E.end(); x++)
#define MP make_pair
#define PB push_back
#define FR first
#define SC second
#define ERR cerr << "ERROR" << endl
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PIII pair<PII, int>
#define PDI pair<double, int>
#define PID pair<int, double>
#define SZ(a) (int)((a).size())
#define VEC vector
#define STR string
#define ISS istringstream
#define OSS ostringstream
#define CLR(a, b) memset(a, b, sizeof(a))
#define gmin(a, b) { if (b < a) a = b; }
#define gmax(a, b) { if (b > a) a = b; }

using namespace std;

map<string,int> S;

int now = 0;
int find(string s) {
    if (S.count(s) == 0) return S[s] = now++;
    return S[s];
}

struct data {
       int pt,abb,goa; string name;
       data() { pt = abb = goa = 0; }
       friend bool operator < (data a,data b) {
              if (a.pt != b.pt) return a.pt < b.pt;
              if (a.abb != b.abb) return a.abb < b.abb;
              if (a.goa != b.goa) return a.goa < b.goa;
              return a.name > b.name;
       }
}team[4];

int cnt[4]; PII ans[1000001]; int Tot = 0;
bool cmp(PII a,PII b) {
     if (a.FR - a.SC != b.FR - b.SC) return a.FR - a.SC < b.FR - b.SC;
     return a.SC < b.SC;
}

string s1,s2;
int main() {
	freopen("temp.in","r",stdin); freopen("temp.out","w",stdout);
   CLR(cnt,0);
    for (int i = 1; i <= 5; i++) {
               int x,y;
        cin >> s1 >> s2; scanf("%d%*c%d\n", &x,&y);
        int ta = find(s1), tb = find(s2); ++cnt[ta]; ++cnt[tb];
        team[ta].name = s1; team[tb].name = s2;
        if (x == y) { team[ta].pt ++; team[tb].pt++; }
        if (x < y) { team[tb].pt += 3; } if (x > y) team[ta].pt += 3;
        team[ta].abb += x - y; team[tb].abb += y - x;
        team[ta].goa += x; team[tb].goa += y;
    }
    int res,man = S["BERLAND"];
    for (int i =0; i <= 3; i++) if (i != man && cnt[i] < 3) { res = i; break ; }
	for (int f1 = 1; f1 <= 100; f1++) for (int f2 = 0; f2 <= f1 + 1; f2++){

                  data tA = team[man], tB = team[res];
        team[man].abb += f1 - f2; team[res].abb += f2 - f1;
        team[man].goa += f1; team[res].goa += f2;
        if (f1 == f2) { ++team[man].pt; ++team[res].pt; }
        if (f1 < f2) team[res].pt+=3; if (f1>f2) team[man].pt+=3;
        data t[4]; for (int i = 0; i <= 3; i++) t[i] = team[i];
        sort(t,t + 4);
        if (find(t[2].name) == man || find(t[3].name) == man) {
            ans[++Tot] = MP(f1,f2);
        }
        team[man] = tA; team[res] = tB;
    }
    if (Tot == 0) { printf("IMPOSSIBLE\n"); return 0; }
    sort(ans + 1,ans + Tot + 1,cmp);
    printf("%d:%d\n",ans[1].FR,ans[1].SC);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
struct aa{int q,m,p;};
aa f[200];
int i,j,p,su,ss1,ss2,t1,t2,sum[200],len;
string ch1,ch2,s[10];
bool da(int t)
{
	if (t==ss1)
		return false;
	if (f[t].p!=f[ss1].p)
		return f[t].p>f[ss1].p;
	if (f[t].m!=f[ss1].m)
		return f[t].m>f[ss1].m;
	if (f[t].q!=f[ss1].q)
		return f[t].q>f[ss1].q;
	return s[t]<s[ss1];
}
int get(string a)
{
	for (int i=1;i<=len;i++)
	if (s[i]==a)
	return i;
	s[++len]=a;
	return len;
}
void read(int &k)
{
	char q;
	for (q=getchar();q<'0'||q>'9';q=getchar());
	k=q-'0';
}
int main()
{
	for (i=1;i<=5;i++)
	{
		cin>>ch1>>ch2;
		ss1=get(ch1);
		ss2=get(ch2);
		sum[ss1]++;
		sum[ss2]++;
		read(t1);
		read(t2);
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
	}
	for (i=1;i<=4;i++)
	if (s[i]=="BERLAND")
		ss1=i;
	else
	if (sum[i]<3)
		ss2=i;
	for (i=-j;i<=35;i++)
	for (j=0;j<=35;j++)
	if (i+j!=0)
	{
		t2=j;
		t1=j+i;
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
		su=0;
		for (p=1;p<=4;p++)
		if (da(p))
			su++;
		if (su<2)
		{
			printf("%d:%d",t1,t2);
			return 0;
		}
		f[ss1].m-=t1-t2;
		f[ss2].m-=t2-t1;
		f[ss1].q-=t1;
		f[ss2].q-=t2;
		if (t1>t2)
			f[ss1].p-=3;
		else
		if (t1<t2)
			f[ss2].p-=3;
		else
		{
			f[ss1].p--;
			f[ss2].p--;
		}
	}
	printf("IMPOSSIBLE");
}

#include <stdio.h>
#include <string.h>
int main()
{
	char name[4][21]={"","","",""};
	char name2[21],name3[21];
	int score[4]={0}, miss[4]={0}, goal[4]={0}, count[4]={0};
	int ber=5,i,j,k,l,a,b,bo,berb,coun=5;
	for(i=0;i<5;i++){
		scanf("%s %s %d:%d", name2, name3, &a,&b);
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name2,name[k])==0){
				bo=1;
				goal[k]+=a;
				miss[k]+=b;
				if(a>b)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				if(ber==5){
					if(strcmp(name2,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name2);
			if(a>b)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=a;
			miss[k]+=b;
			count[k]++;
		}
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name3,name[k])==0){
				bo=1;
				if(b>a)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				goal[k]+=b;
				miss[k]+=a;
				if(ber==5){
					if(strcmp(name3,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name3);
			if(b>a)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=b;
			miss[k]+=a;
			count[k]++;
		}
	}
	score[ber]+=3;
	for(i=0;i<4;i++){
		for(j=3;j>i;j--){
			if((score[j]>score[i])||(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])){//||(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&strcmp(name[i],name[j])>0)){
				a=score[i];
				score[i]=score[j];
				score[j]=a;
				a=goal[i];
				goal[i]=goal[j];
				goal[j]=a;
				a=miss[i];
				miss[i]=miss[j];
				miss[j]=a;
				strcpy(name2,name[i]);
				strcpy(name[i],name[j]);
				strcpy(name[j],name2);
				a=count[i];
				count[i]=count[j];
				count[j]=a;
				if(strcmp(name[i],"BERLAND")==0)
					ber=i;
				else if(strcmp(name[j],"BERLAND")==0)
					ber=j;
				if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
					coun=i;
				else if(count[j]==2&&strcmp(name[j],"BERLAND")!=0)
					coun=j;
			}
		}
	}
	if(ber<=1)
		printf("1:0\n");
	else{
		if(score[ber]==score[1]){
			for(k=1;ber>1&&k<51;k++){
				for(l=0;ber>1&&l<k;l++){
						goal[ber]+=k;
						miss[coun]+=k;
						miss[ber]+=l;
						goal[coun]+=l;
						for(i=0;i<4;i++){
							for(j=3;j>i;j--){
								if((score[j]>score[i])||(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])){//||(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&strcmp(name[i],name[j])>0)){
									a=score[i];
									score[i]=score[j];
									score[j]=a;
									a=goal[i];
									goal[i]=goal[j];
									goal[j]=a;
									a=miss[i];
									miss[i]=miss[j];
									miss[j]=a;
									strcpy(name2,name[i]);
									strcpy(name[i],name[j]);
									strcpy(name[j],name2);
									a=count[i];
									count[i]=count[j];
									count[j]=a;
									if(strcmp(name[i],"BERLAND")==0)
										ber=i;
									else if(strcmp(name[j],"BERLAND")==0)
										ber=j;
									if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
										coun=i;
									else if(count[j]==2&&strcmp(name[j],"BERLAND")!=0)
										coun=j;
								}
							}
						}
						goal[ber]-=k;
						miss[coun]-=k;
						miss[ber]-=l;
						goal[coun]-=l;
				}
			}
			if(ber>1)
				printf("IMPOSSIBLE\n");
			else
				printf("%d:%d\n",k-1, l-1);
		}else{
			printf("IMPOSSIBLE\n");
		}
	}
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <string.h>
#include <map>
#define M 2005
#define For(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
map<string, int>cap;
string s1, s2;
int a, b;
int enter[5];
//int score[5];
//int dscore[5];
//int sscore[5];
string s3, s4;

struct Node {
    bool ok;
    int score, dscore, sscore;
} q[5], qq[5];

int cmp(Node a, Node b) {
    if (a.score == b.score && a.dscore == b.dscore && a.sscore == b.sscore) {
//        if(s3.size()==s4.size())
            For(i,0,s3.size()){
                if(s3[i]>s4[i])
                    return 1;
                if(s3[i]<s4[i])
                    return 0;
            }
    }
    if (a.score == b.score && a.dscore == b.dscore) {
        return a.sscore > b.sscore;
    }
    if (a.score == b.score) {
        return a.dscore > b.dscore;
    }
    return a.score > b.score;
}

bool judge(int x, int y, int f, int t) {

    For(i, 0, 4) {
        qq[i] = q[i];
    }
    qq[f].dscore += x - y;
    qq[t].dscore += y - x;
    qq[f].sscore += x;
    qq[t].sscore += y;
    For(i, 0, 4)
    qq[i].ok = false;
    qq[f].ok = 1;
    sort(qq, qq + 4, cmp);

    For(i, 0, 4) {
        if (qq[i].ok) {
            if (i < 2) {
                return 1;
            } else
                return 0;
        }
    }
}
string ss[5];
int main(int argc, char** argv) {
    int cnt = 0;
    memset(enter, 0, sizeof (enter));
    int f;

    For(i, 0, 5) {
        q[i].dscore = q[i].score = q[i].sscore = 0;
    }

    For(i, 0, 5) {
        cin >> s1 >> s2;
        scanf("%d:%d", &a, &b);
        if (cap.find(s1) == cap.end()) {
            cap[s1] = cnt;
            ss[cnt]=s1;
            enter[cnt]++;
            cnt++;

        } else {
            enter[cap[s1]]++;
        }
        if (cap.find(s2) == cap.end()) {
            cap[s2] = cnt;
            enter[cnt]++;
            ss[cnt]=s2;
            cnt++;

        } else {
            enter[cap[s2]]++;
        }
        q[cap[s1]].dscore += a - b;
        q[cap[s2]].dscore += b - a;
        q[cap[s1]].sscore += a;
        q[cap[s2]].sscore += b;
        if (a > b) {
            q[cap[s1]].score += 3;
        } else if (a == b) {
            q[cap[s1]].score++;
            q[cap[s2]].score++;
        } else {
            q[cap[s2]].score += 3;
        }
        if (s1 == "BERLAND") {
            f = cap[s1];
            s3 = s1;
        }
        if (s2 == "BERLAND") {
            f = cap[s2];
            s3 = s2;
        }

    }
    int t;

    For(i, 0, 4) {
        if (i != f && enter[i] % 2 == 0) {
            t = i;
        }
    }
    q[f].score += 3;
    cnt = 0;

//    For(i, 0, 4) {
//        if (i != f) {
//            if (q[i].score > f) {
//                cnt++;
//            }
//        }
//    }
//    if (cnt >= 2) {
//        printf("IMPOSSIBLE\n");
//        return 0;
//    }
//    cnt = 0;
//
//    For(i, 0, 4) {
//        if (i != f) {
//            if (q[i].score < f) {
//                cnt++;
//            }
//        }
//    }
//    if (cnt >= 2) {
//        printf("1:0\n");
//        return 0;
//    }
    s4=ss[t];
    For(i, 1, 50) {

        For(j, 0, 50) {
            if (judge(i + j, j, f, t)) {
                printf("%d:%d\n", i + j, j);
                return 0;
            }
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

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

class match {
	public:
		int one;
		int two;
		match(int a, int b){
			one = a;
			two = b;
		}
};

bool weaker(int a, int b, int* difference, int* shots, std::string* teams){
	if(difference[a] < difference[b]){
		return true;
	}
	if(difference[a] > difference[b]){
		return false;
	}
	if(shots[a] < shots[b]){
		return true;
	}
	if(shots[a] > shots[b]){
		return false;
	}
	if(teams[a] > teams[b]){
		return true;
	}
	return false;
}
/*
int find_min(std::vector<int> vect, int* difference, int* shots, std::string* teams){
	int weakest = 0;
	for(int i = 0; i < vect.size(); ++i){
		if(weaker(i, weakest, difference, shots, teams)){
			weakest = i;
		}
	}
	return weakest;
}
*/
int find_next_to_min(std::vector<int> vect, int* difference, int* shots, std::string* teams){
	if(vect.size() == 1){
		return 0;
	}

	int next;
	int weakest = 0;

	if(weaker(0, 1, difference, shots, teams)){
		next = 1;
	} else {
		next = 0;
	}
	for(int i = 0; i < vect.size(); ++i){
		if(weaker(i, weakest, difference, shots, teams)){
			next = weakest;
			weakest = i;
		}
	}
	return next;
}

int main(){
	int score[4] = {3, 0, 0, 0};
	int difference[4] = {0, 0, 0, 0};
	int shots[4] = {0, 0, 0, 0};
	int played_matches[4] = {0, 0, 0, 0};
	std::string teams[4];

	teams[0] = "BERLAND";

	std::vector< std::vector< match > > table(4);
	for(int i = 0; i < 4; i++)
    {
		table[i].resize(4, match(0, 0));
	}

	std::string team1;
	std::string team2;
	std::string count_string;
	int count1;
	int count2;

	int filled = 1;
	for(int i = 0; i < 5; i++){
		std::cin >> team1 >> team2 >> count_string;

		int walker = 0;
		while(!(count_string[walker] == ':')){
			walker++;
		}

		count1 = atoi(count_string.substr(0, walker).c_str());
		count2 = atoi(count_string.substr(walker + 1, count_string.size() - walker - 1).c_str());

		//std::cout << "evaluated counters" << std::endl;
		if(filled < 4){
			bool first_exists = false;
			bool second_exists = false;
			for(int i = 0; i < filled; i++){
				if(teams[i] == team1){
					first_exists = true;
				}
				if(teams[i] == team2){
					second_exists = true;
				}
			}
			//std::cout << "before ifs" << std::endl;
			if( (!first_exists) && (!second_exists) ){
				teams[filled] = team1;
				teams[filled + 1] = team2;
				filled += 2;
			} else if( (first_exists) && (!second_exists) ){
				teams[filled] = team2;
				filled++;
			} else if( (!first_exists) && (second_exists) ){
				teams[filled] = team1;
				filled++;
			} else {
				//ok!
			}
			//std::cout << "after ifs" << std::endl;
		}

		int team_counter_1 = 0;
		int team_counter_2 = 0;
		while( !(teams[team_counter_1] == team1) ){
			team_counter_1++;
		}
		while( !(teams[team_counter_2] == team2) ){
			team_counter_2++;
		}
		//std::cout << "found place in table" << std::endl;
		table[team_counter_1][team_counter_2] = match(count1, count2);
		table[team_counter_2][team_counter_1] = match(count2, count1);

		if(count1 > count2){
			score[team_counter_1] += 3;
		} else if (count1 == count2){
			score[team_counter_1] += 1;
			score[team_counter_2] += 1;
		} else {
			score[team_counter_2] += 3;
		}
		played_matches[team_counter_1]++;
		played_matches[team_counter_2]++;

		difference[team_counter_1] += (count1 - count2);
		difference[team_counter_2] += (count2 - count1);

		shots[team_counter_1] += count1;
		shots[team_counter_2] += count2;

		//std::cout << "filled table" << std::endl;
	}

	int opponent = 1;
	while(played_matches[opponent] != 2){
		opponent++;
	}

	int place_guarantee = 1;
	for(int i = 1; i < 4; i++){
		if(score[0] <= score[i]){
			place_guarantee++;
		}
	}
	int place_best = 1;
	for(int i = 1; i < 4; i++){
		if(score[0] < score[i]){
			place_best++;
		}
	}

	if(place_guarantee <= 2){
		std::cout << "1:0" << std::endl;
	} else if(place_best > 2){
		std::cout << "IMPOSSIBLE" << std::endl;
	} else {
		/*
		std::cout << "Difference = " << difference[0] << "__" << difference[1] << "__" << difference[2] << "__" << difference[3] << std::endl;
		std::cout << "Shots = " << shots[0] << "__" << shots[1] << "__" << shots[2] << "__" << shots[3] << std::endl;
		*/
		int teams_behind_by_score = 4 - place_guarantee;
		int teams_ahead_by_score = place_best - 1;

		int mydifference = difference[0];
		int myshots = shots[0];
		int myscore = score[0];

		int amount_teams_to_beat = 2 - teams_behind_by_score;
		std::vector<int> teams_to_beat;
		if(score[1] == myscore){
			teams_to_beat.push_back(1);
		}
		if(score[2] == myscore){
			teams_to_beat.push_back(2);
		}
		if(score[3] == myscore){
			teams_to_beat.push_back(3);
		}

		int difference_in_match = 0;
		int shots_in_match = 0;

		if(teams_to_beat.size() == 1){

			difference_in_match = difference[teams_to_beat[0]] - mydifference;
			if(teams[0] < teams[teams_to_beat[0]]){
				shots_in_match = shots[teams_to_beat[0]] - myshots;
			} else {
				shots_in_match = shots[teams_to_beat[0]] - myshots + 1;
			}
		} else {
			//int weakest_team = find_min(teams_to_beat, difference, shots, teams);
			int almost_weakest_team = find_next_to_min(teams_to_beat, difference, shots, teams);

			difference_in_match = difference[teams_to_beat[almost_weakest_team]] - mydifference;
			if(teams[0] < teams[teams_to_beat[almost_weakest_team]]){
				shots_in_match = shots[teams_to_beat[almost_weakest_team]] - myshots;
			} else {
				shots_in_match = shots[teams_to_beat[almost_weakest_team]] - myshots + 1;
			}
		}

		int goals_given = std::max(difference_in_match, shots_in_match);
		int goals_taken = goals_given - difference_in_match;

		std::cout << goals_given << ":" << goals_taken << std::endl;

	}
}

#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <fstream>
#include <list>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define _DEBUG
#define vec vector
#define pb push_back
#define en '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pull;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef long double ld;
typedef unsigned int ui;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vi2;
typedef vector<vector<ll>> vll2;
typedef vector<vector<ll>> matrix;
typedef vec<vec<vec<int>>> vi3;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

const int inf = 2000000000;
const ll linf = 5000000000000000000;
const ld LDINF = 2e18;
template<typename T> void print(vector<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << ' ';
    cout << en;
}

template<typename T> void print(deque<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cout << a[i] << ' ';
    cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
    for (int i = 0; i < a.size(); i++)
    {
        for (int j = 0; j < a[i].size(); j++)
            cout << a[i][j] << ' ';
        cout << en;
    }
}

template <typename T> void input(vector<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
    for (int i = 0; i < a.size(); i++)
        cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
    for (int i = 0; i < a.size(); i++)
        for (int j = 0; j < a[i].size(); j++)
            cin >> a[i][j];
}

ll mod = 1e9 + 7;

ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    else
        return gcd(b, a % b);
}

map<string, int> perehod;
int ber_pos, another_pos;
struct team{
    string name;
    int goal = 0, win = 0;
};

vec<team> teams;

bool cmp(team &a, team &b){
    if(a.win != b.win)
        return a.win > b.win;
    if(a.goal != b.goal)
        return a.goal > b.goal;
    return a.name < b.name;
}

bool check(int plus1, int plus2){
    vec<team> mem = teams;
    mem[ber_pos].goal += plus1;
    mem[ber_pos].win += 4;
    mem[another_pos].goal += plus2;
    sort(all(mem), cmp);
    if(mem[0].name == "BERLAND" || mem[1].name == "BERLAND")
        return true;
    return false;
}

void solve(){
    map<string, int> cnt;
    string team1, team2;
    map<string, int> win, goal;
    win["BERLAND"] = 0;
    for0(i, 5){
        cin >> team1 >> team2;
        cnt[team1]++;
        cnt[team2]++;
        win[team1] = win[team1];
        win[team2] = win[team2];
        char ch;
        ll score1, score2;
        cin >> score1 >> ch >> score2;
        if(score1 == score2){
            win[team1]++;
            win[team2]++;
        }
        if(score1 > score2){
            win[team1] += 4;
        }
        if(score2 > score1){
            win[team2] += 4;
        }
        goal[team1] += score1 - score2;
        goal[team2] += score2 - score1;
    }
    for(auto elem : win){
        team kek;
        kek.name = elem.first;
        kek.win = elem.second;
        kek.goal = goal[kek.name];
        teams.push_back(kek);
    }
    sort(all(teams), cmp);
    ll dif = inf, y = inf;
    for(int i = 0; i < teams.size(); i++){
        perehod[teams[i].name] = i;
        if(teams[i].name == "BERLAND")
            ber_pos = i;
        else if(cnt[teams[i].name] == 2)
            another_pos = i;
    }
    int ans1, ans2;
    for(int i = 1; i <= 100; i++){
        for(int j = 0; j < i; j++){
            int plus = i - j;
            if(!check(plus, -plus))
                continue;
            if(plus < dif){
                ans1 = i, ans2 = j;
                dif = plus;
                y = j;
            }
            else if(plus == dif){
                if(j < y){
                    ans1 = i, ans2 = j;
                    y = j;
                }
            }
        }
    }
    if(dif == inf){
        cout << "IMPOSSIBLE";
        return;
    }
    cout << ans1 << ':' << ans2;

}

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("input.txt", "r", stdin);
#endif
    // freopen("graph.in", "r", stdin);
    // freopen("graph.out", "w", stdout);

    int tst = 1;
    // cin >> tst;
    while(tst--)
        solve();
}

#include <iostream>
#include <cstdio>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

struct team
{
    string name;
    int score, goaldiffs, totalgoals;

    team(){name = ""; score = 0; goaldiffs = 0; totalgoals = 0;}

    bool operator<(const team& other) const
    {
        if (score < other.score) return true;
        else if (score == other.score)
        {
            if (goaldiffs < other.goaldiffs) return true;
            else if (goaldiffs == other.goaldiffs)
            {
                if (totalgoals < other.totalgoals) return true;
                else if (totalgoals == other.totalgoals)
                {
                    if (name > other.name) return true;
                    else return false;
                }
                else return false;
            }
            else return false;
        }
        else return false;
    }
}teams[4];

string missing;
map<string, pair<int, int> > M;
map<string, int> points;
map<string, int> cnt;

inline bool won(int i, int j)
{
    int cnt = 0;
    for (map<string, pair<int, int> >::iterator it = M.begin(); it != M.end(); it++)
    {
        string name = (*it).first;
        int goalx = (*it).second.first, goaly = (*it).second.second;

        if (name == "BERLAND") {goalx += i; goaly += j;}
        else if (name == missing) {goaly += i; goalx += j;}

        teams[cnt].score = points[name];
        teams[cnt].name = name;
        teams[cnt].goaldiffs = goalx - goaly;
        teams[cnt].totalgoals = goalx;

        cnt++;
    }

    sort(teams, teams + 4);

    if (teams[2].name == "BERLAND" || teams[3].name == "BERLAND") return true;
    else return false;
}

int main()
{
    cin.sync_with_stdio(0);

    for (int i = 0; i < 5; i++)
    {
        string name1, name2, score;
        cin >> name1 >> name2 >> score;

        cnt[name1]++;
        cnt[name2]++;

        int scores_first = score[0] - '0', scores_second = score[2] - '0';

        pair<int, int> pii = M[name1];
        pii.first += scores_first;
        pii.second += scores_second;
        M[name1] = pii;

        pii = M[name2];
        pii.first += scores_second;
        pii.second += scores_first;
        M[name2] = pii;

        if (scores_first > scores_second) points[name1] += 3;
        else if (scores_second > scores_first) points[name2] += 3;
        else {points[name1]++; points[name2]++;}
    }

    for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); it++) if ((*it).second == 2 && (*it).first != "BERLAND")
        missing = (*it).first;

    points["BERLAND"] += 3;

    for (int i = 1; i <= 1000; i++)
        for (int j = i - 1; j >= 0; j--) if (won(i, j))
        {
            cout << i << ":" << j << endl;
            return 0;
        }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

/*
 * Author:  xioumu
 * Created Time:  2012-6-25 0:02:45
 * File Name: c.cpp
 * solve: c.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
const double esp = 1e-8;
const int maxn = 1007;
typedef long long ll;
char name[200][200];
int m;
struct node{
    int p, in, out, id;

}a[200];
bool operator < (const node &a, const node &b) {
    if(a.p != b.p) return a.p > b.p;
    else if(a.in - a.out != b.in - b.out) return (a.in - a.out) > (b.in - b.out);
    else if(a.in != b.in) return a.in > b.in;
    else return strcmp(name[a.id], name[b.id]) < 0;
}
int find(char *s){
    for(int i = 1; i <= m; i++)
        if(strcmp(s, name[i]) == 0 )
            return i;
    m++;
    strcpy(name[m], s);
    return m;
}
int v[6] = {0};
int main(){
    char s1[200], s2[200];
    int d1, d2;
    m = 0; memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(int t = 1; t <= 5; t++){
        scanf("%s %s %d:%d", s1, s2, &d1, &d2);
       //printf("%s %s %d:%d\n",s1, s2, d1, d2);
        int h1 = find(s1);
        int h2 = find(s2);
        if(d1 > d2){
            a[h1].p += 3;
        }
        else if(d1 == d2){
            a[h1].p++;
            a[h2].p++;
        }
        else a[h2].p += 3;

        a[h1].in += d1;
        a[h1].out += d2;
        a[h2].in += d2;
        a[h2].out += d1;
        v[h1]++;
        v[h2]++;
        a[h1].id = h1;
        a[h2].id = h2;
        //printf("%d %d\n",h1, h2);
    }
    //printf("%d %d\n", a[1].p, a[2].p);
    int s = find("BERLAND"), t;
    for(int i = 1; i <= 4; i++)
        if(v[i] < 3 && s != i)
            t = i;
    node oldh = a[s], oldw = a[t];
    //sort(a + 1, a + 5);
    {
        int ans1 = -1, ans2 = -1;
        for(int i = 1; i <= 100; i++)
            for(int j = i; j <= 100; j++){
                node h = oldh;
                h.p += 3;
                h.in += j;
                h.out += j - i;
                node w = oldw;
                w.in += j - i;
                w.out += j;
                if(i == 1 && j == 1){
                    printf("%d %d %d\n", h.p, h.in, h.out);
                }
                if(h < w){
                    ans1 = j;
                    ans2 = j - i;
                    int ok = 0;
                    for(int i = 1; i <= 4; i++)
                        if(a[i] < h && i != s && i != t)
                            ok++;
                        else if(i == t)
                            if(w < h)
                                ok++;
                    if( ok < 2)
                        goto end;
                }
            }
end:;
        if(ans1 == 100 || ans1 == -1) printf("IMPOSSIBLE\n");
        else printf("%d:%d\n", ans1, ans2);
    }
    return 0;
}

#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
string str[5];
int cnt[4]={0},sc[4]={0},num[4]={0},di[4]={0};
map <string,int> mp;
int n;
bool cmp(int x,int y)
{
	if(sc[x]!=sc[y])return sc[x]>sc[y];
	if(di[x]!=di[y])return di[x]>di[y];
    if(num[x]!=num[y])return num[x]>num[y];
    return str[x]>str[y];
}
int main()
{
	int c=1,ber=0;
	string s,t;
	for(int i=0;i<5;i++)
	{
		cin>>s>>t;
		if(!mp.count(s))
		{
			str[c]=s;
			if(s=="BERLAND")
			    ber=c;
			mp[s]=c;
			c++;
		}
		if(!mp.count(t))
		{
			str[c]=t;
			if(t=="BERLAND")
			    ber=c;
			mp[t]=c;
			c++;
		}
		int n,m;
		scanf("%d:%d",&n,&m);
		cnt[mp[s]]++,cnt[mp[t]]++;
		if(n>m)
		    sc[mp[s]]+=3;
		if(n<m)
		    sc[mp[t]]+=3;
		if(n==m)
		    sc[mp[s]]++,sc[mp[t]]++;
		num[mp[s]]+=n,num[mp[t]]+=m;
		di[mp[s]]+=n-m,di[mp[t]]+=m-n;
	}
	int ot;
	for(int i=1;i<5;i++)
	    if(cnt[i]==2&&i!=ber)
	    {
	    	ot=i;
	    	break;
		}
	//for(int i=1;i<5;i++)
	    //cout<<str[i]<<' '<<cnt[i]<<' '<<sc[i]<<' '<<num[i]<<' '<<di[i]<<endl;
	sc[ber]+=3;
	for(int i=1;i<=100;i++)
	    for(int j=0;j<=100;j++)
	    {
	    	int a=i+j,b=j;
	    	num[ber]+=a,num[ot]+=j;
	    	di[ber]+=i,di[ot]-=i;
	    	int c=0;
	    	for(int l=1;l<5;l++)
	    	    if(l==ber)
	    	        continue;
	    	    else
	    	        c+=(int)cmp(ber,l);
	    	if(c>=2)
	    	{
	    		cout<<a<<':'<<b;
	    		return 0;
			}
	    	num[ber]-=a,num[ot]-=j;
	    	di[ber]-=i,di[ot]+=i;
		}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include<bits/stdc++.h>

using namespace std;
char s1[25],s2[25];
map<string,int>mp;//score
map<string,pair<int,int> >mp2;//ball
map<string,int>cnt;
string team;
vector<string>v;
bool cmp(string s,string t){
	if(mp[s]>mp[t])return true;
	else if(mp[s]<mp[t])return false;
	else{
		if(mp2[s].first-mp2[s].second>mp2[t].first-mp2[t].second)return true;
		else if(mp2[s].first-mp2[s].second<mp2[t].first-mp2[t].second)return false;
		else{
			if(mp2[s].first>mp2[t].first)return true;
			else if(mp2[s].first<mp2[t].first)return false;
			else{
				if(s<t)return true;
				else return false;
			}
		}
	}
}
bool check(int x,int y){
	if(x==y){
		mp["BERLAND"]+=1;
		mp[team]+=1;
	}
	else{
		mp["BERLAND"]+=3;
	}
	mp2["BERLAND"].first+=x,mp2["BERLAND"].second+=y;
	mp2[team].first+=y,mp2[team].second+=x;
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<2;i++){
		if(v[i]=="BERLAND"){
			return true;
		}
	}
	if(x==y){
		mp["BERLAND"]-=1;
		mp[team]-=1;
	}
	else{
		mp["BERLAND"]-=3;
	}
	mp2["BERLAND"].first-=x,mp2["BERLAND"].second-=y;
	mp2[team].first-=y,mp2[team].second-=x;
return false;
}
int main(){
	int a,b;
	for(int i=0;i<5;i++){
		scanf("%s%s%d:%d",s1,s2,&a,&b);
		cnt[s1]++,cnt[s2]++;
		v.push_back(s1),v.push_back(s2);
		if(a>b)mp[s1]+=3;
		else if(b>a)mp[s2]+=3;
		else {
			mp[s1]+=1;
			mp[s2]+=1;
		}
		mp2[s1].first+=a,mp2[s1].second+=b;
		mp2[s2].first+=b,mp2[s2].second+=a;
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for(int i=0;i<v.size();i++){
		if(cnt[v[i]]==2&&v[i]!="BERLAND")team=v[i];
	}
	for(int i=0;i<=105;i++)for(int j=1;j<=105;j++){
        if(check(j,i)){
            printf("%d:%d",j,i);
            return 0;
        }
    }
    printf("IMPOSSIBLE");
	return 0;
}

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

class match {
	public:
		int one;
		int two;
		match(int a, int b){
			one = a;
			two = b;
		}
};

bool win(int a, int b, int* score, int* difference, int* shots, std::string* teams){
	if(score[a] > score[b]){
		return true;
	}
	if(score[a] < score[b]){
		return false;
	}
	if(difference[a] > difference[b]){
		return true;
	}
	if(difference[a] < difference[b]){
		return false;
	}
	if(shots[a] > shots[b]){
		return true;
	}
	if(shots[a] < shots[b]){
		return false;
	}
	if(teams[a] < teams[b]){
		return true;
	}
	return false;
}

int main(){
	int score[4] = {3, 0, 0, 0};
	int difference[4] = {0, 0, 0, 0};
	int shots[4] = {0, 0, 0, 0};
	std::string teams[4];

	teams[0] = "BERLAND";

	std::vector< std::vector< match > > table(4);
	for(int i = 0; i < 4; i++)
    {
		table[i].resize(4, match(0, 0));
	}

	std::string team1;
	std::string team2;
	std::string count_string;
	int count1;
	int count2;

	int filled = 1;
	for(int i = 0; i < 2; i++){
		std::cin >> team1 >> team2 >> count_string;

		int walker = 0;
		while(!(count_string[walker] == ':')){
			walker++;
		}

		count1 = atoi(count_string.substr(0, walker).c_str());
		count2 = atoi(count_string.substr(walker + 1, count_string.size() - walker - 1).c_str());

		//std::cout << "evaluated counters" << std::endl;
		if(filled < 4){
			bool first_exists = false;
			bool second_exists = false;
			for(int i = 0; i < filled; i++){
				if(teams[i] == team1){
					first_exists = true;
				}
				if(teams[i] == team2){
					second_exists = true;
				}
			}
			//std::cout << "before ifs" << std::endl;
			if( (!first_exists) && (!second_exists) ){
				teams[filled] = team1;
				teams[filled + 1] = team2;
				filled += 2;
			} else if( (first_exists) && (!second_exists) ){
				teams[filled] = team2;
				filled++;
			} else if( (!first_exists) && (second_exists) ){
				teams[filled] = team1;
				filled++;
			} else {
				//ok!
			}
			//std::cout << "after ifs" << std::endl;
		}

		int team_counter_1 = 0;
		int team_counter_2 = 0;
		while( !(teams[team_counter_1] == team1) ){
			team_counter_1++;
		}
		while( !(teams[team_counter_2] == team2) ){
			team_counter_2++;
		}
		//std::cout << "found place in table" << std::endl;
		table[team_counter_1][team_counter_2] = match(count1, count2);
		table[team_counter_2][team_counter_1] = match(count2, count1);

		if(count1 > count2){
			score[team_counter_1] += 3;
		} else if (count1 == count2){
			score[team_counter_1] += 1;
			score[team_counter_2] += 1;
		} else {
			score[team_counter_2] += 3;
		}

		difference[team_counter_1] += count1 - count2;
		difference[team_counter_2] += count2 - count1;

		shots[team_counter_1] += count1;
		shots[team_counter_2] += count2;

		//std::cout << "filled table" << std::endl;
	}

	int place_guarantee = 1;
	for(int i = 1; i < 4; i++){
		if(score[0] <= score[i]){
			place_guarantee++;
		}
	}
	int place_best = 1;
	for(int i = 1; i < 4; i++){
		if(score[0] < score[i]){
			place_best++;
		}
	}

	if(place_guarantee <= 2){
		std::cout << "1:0" << std::endl;
	} else if(place_best > 2){
		std::cout << "IMPOSSIBLE" << std::endl;
	} else {
		bool gotcha = false;
		int total_shots = shots[1] + shots[2] + shots[3];
		for(int BerlandGoals = 1; BerlandGoals <= total_shots + 1; BerlandGoals++){
			int beaten_count = 0;
			for(int h = 1; h < 4; h++){
				if(win(0, h, score, shots, difference, teams)){
					beaten_count++;
				}
			}
			if(beaten_count >= 2){
				std::cout << BerlandGoals << ":0" << std::endl;
				gotcha = true;
				break;
			}
			score[0]++;
			difference[0]++;
			shots[0]++;
		}
	}

	/*
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			std::cout << teams[i] << " - " << teams[j] << " == " << table[i][j].one << "-" << table[i][j].two << std::endl;
		}
	}
	*/
}

#include<fstream>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
//ifstream cin("input.txt");
//ofstream cout("output.txt");
struct LIST
{
    char Team[21];
    int W,D,L,Point,Goal,Loss,Dif;

    bool operator()(LIST a, LIST b)
    {
        if(a.Point > b.Point)return 1;
        if(a.Point==b.Point)
        {
            if(a.Dif > b.Dif)return 1;
            if(a.Dif == b.Dif)
            {
                if(a.Goal > b.Goal)return 1;
                if(a.Goal==b.Goal)
                {
                    int c = max(strlen(a.Team),strlen(b.Team));
                    for(int i=0;i<c;i++)
                    {
                        if(a.Team[i] < b.Team[i])return 1;
                        if(a.Team[i]==b.Team[i])continue;
                        return 0;
                    }
                }
            }
        }
        return 0;
    }
}list[5];
int main()
{
    int i,j;
    int a=0;
    for(int t=0;t<5;t++)
    {
        char Name[21];
        char Name2[21];
        char Score[4];
        cin >> Name >> Name2 >> Score;
        int b=0;
        for(j=0;j<a;j++)
        {
            if(strcmp(Name,list[j].Team)==0)
            {
                b=1;break;
            }
        }
        if(b==0)
        {
            strcpy(list[a++].Team,Name);
        }
        b=0;
        for(j=0;j<a;j++)
        {
            if(strcmp(Name2,list[j].Team)==0)
            {
                b=1;break;
            }
        }
        if(b==0)
        {
            strcpy(list[a++].Team,Name2);
        }
        if(Score[0] < Score[2])
        {
            for(i=0;i<a;i++)
            {
                if(strcmp(list[i].Team,Name)==0)
                {
                    list[i].L++;
                    list[i].Goal = list[i].Goal+(Score[0]-'0');
                    list[i].Loss = list[i].Loss+(Score[2]-'0');
                }
                if(strcmp(list[i].Team,Name2)==0)
                {
                    list[i].W++;
                    list[i].Goal = list[i].Goal+(Score[2]-'0');
                    list[i].Loss = list[i].Loss+(Score[0]-'0');
                }
            }
        }
        else if(Score[0] > Score[2])
        {
            for(i=0;i<a;i++)
            {
                if(strcmp(list[i].Team,Name)==0)
                {
                    list[i].W++;
                    list[i].Goal = list[i].Goal+(Score[0]-'0');
                    list[i].Loss = list[i].Loss+(Score[2]-'0');
                }
                if(strcmp(list[i].Team,Name2)==0)
                {
                    list[i].L++;
                    list[i].Goal = list[i].Goal+(Score[2]-'0');
                    list[i].Loss = list[i].Loss+(Score[0]-'0');
                }
            }
        }
        else if(Score[0] == Score[2])
        {
            for(i=0;i<a;i++)
            {
                if(strcmp(list[i].Team,Name)==0)
                {
                    list[i].D++;
                    list[i].Goal = list[i].Goal+(Score[0]-'0');
                    list[i].Loss = list[i].Loss+(Score[2]-'0');
                }
                if(strcmp(list[i].Team,Name2)==0)
                {
                    list[i].D++;
                    list[i].Goal = list[i].Goal+(Score[2]-'0');
                    list[i].Loss = list[i].Loss+(Score[0]-'0');
                }
            }
        }
    }
    for(i=0;i<4;i++)
    {
        list[i].Point = 3*list[i].W + list[i].D;
        list[i].Dif = list[i].Goal-list[i].Loss;
    }
    std::sort(list,list+4,LIST());
    for(i=0;i<100;i++)
    {
        for(j=i-1;j>=0;j--)
        {
            char Opp[21]={0,};
            for(int t=0;t<4;t++)
            {
                if(list[t].W +list[t].D + list[t].L == 2)
                {
                    if(strcmp(list[t].Team,"BERLAND")==0)continue;
                    strcpy(Opp,list[t].Team);
                    break;
                }
            }
            for(int t=0;t<4;t++)
            {
                if(strcmp(list[t].Team,"BERLAND")==0)
                {
                    if(i==j)
                    {
                        list[t].D++;
                        list[t].Goal+=i;
                        list[t].Loss+=j;
                        list[t].Point++;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                    else
                    {
                        list[t].W++;
                        list[t].Goal+=i;
                        list[t].Loss+=j;
                        list[t].Point+=3;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                }
                if(strcmp(list[t].Team,Opp)==0)
                {
                    if(i==j)
                    {
                        list[t].D++;
                        list[t].Goal+=j;
                        list[t].Loss+=i;
                        list[t].Point++;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                    else
                    {
                        list[t].L++;
                        list[t].Goal+=j;
                        list[t].Loss+=i;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                }
            }
            std::sort(list,list+4,LIST());
            for(int t=0;t<2;t++)
            {
                if(strcmp(list[t].Team,"BERLAND")==0)
                {
                    cout << i << ":" << j;
                    return 0;
                }
            }
            for(int t=0;t<4;t++)
            {
                if(strcmp(list[t].Team,"BERLAND")==0)
                {
                    if(i==j)
                    {
                        list[t].D--;
                        list[t].Goal-=i;
                        list[t].Loss-=j;
                        list[t].Point--;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                    else
                    {
                        list[t].W--;
                        list[t].Goal-=i;
                        list[t].Loss-=j;
                        list[t].Point-=3;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                }
                if(strcmp(list[t].Team,Opp)==0)
                {
                    if(i==j)
                    {
                        list[t].D--;
                        list[t].Goal-=j;
                        list[t].Loss-=i;
                        list[t].Point--;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                    else
                    {
                        list[t].L--;
                        list[t].Goal-=j;
                        list[t].Loss-=i;
                        list[t].Dif = list[t].Goal-list[t].Loss;
                    }
                }
            }
            std::sort(list,list+4,LIST());
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
const int N = 5005;
struct node
{
    char name[25];
    int p, s, m;
    bool operator < (const node &T) const
    {
        if (p > T.p) return 1;
        if (p < T.p) return 0;
        if (s - m > T.s - T.m) return 1;
        if (s - m < T.s - T.m) return 0;
        if (s > T.s) return 1;
        if (s < T.s) return 0;
        return strcmp (name, T.name) < 0;
    }
}team[4], team1[4];
int get_p (char s1, char s2)
{
    if (s1 > s2) return 3;
    if (s1 == s2) return 1;
    return 0;
}
int main()
{
    char s[5][3][25]; int i, j, k, id, p, cnt[6];
    while (scanf ("%s", s[0][0]) == 1)
    {
        for (j = 1; j < 3; j ++) scanf ("%s", s[0][j]);
        for (i = 1; i < 5; i ++) for (j = 0; j < 3; j ++) scanf ("%s", s[i][j]);

        for (i = 0; i < 4; i ++) team[i].p = team[i].s = team[i].m = cnt[i] = 0;

        for (i = 0 , id = -1; i < 5; i ++)
        for (p = get_p (s[i][2][0], s[i][2][2]), j = 0; j < 2; j ++)
        {
            for (k = 0; k <= id; k ++)
            if (!strcmp (s[i][j], team[k].name)) break;

            if (k > id) strcpy (team[k = ++ id].name, s[i][j]);
            if (!j)
            {
                team[k].p += p;
                team[k].s += s[i][2][0] - '0';
                team[k].m += s[i][2][2] - '0';
            }
            else
            {
                if (p == 1) team[k].p ++; else team[k].p += 3 - p;
                team[k].s += s[i][2][2] - '0';
                team[k].m += s[i][2][0] - '0';
            }
            cnt[k] ++;
        }
        for (i = 0; i < 4; i ++)
        if (cnt[i] < 3)
        {
            if (!strcmp (team[i].name, "BERLAND")) j = i;
            else k = i;
        }
        //for (i = 0; i < 4; i ++) if (!strcmp (team[i].name, "BERLAND")) break;
        //if (i < 2) {puts ("1:0");continue;}
        //if (team[1].p > team[i].p + 3) {puts ("IMPOSSIBLE");continue;}
        team[j].p += 3; team[k].p -= 3;
        for (i = 1;  i <= 100; i ++)
        {
            for (p = 0; p < 4; p ++) team1[p] = team[p];
            team1[j].s += i;
            team1[k].m += i;
            sort (team1, team1 + 4);
            if (!strcmp (team1[0].name, "BERLAND") ||
                !strcmp (team1[1].name, "BERLAND")) {printf ("%d:0\n", i); break;}
        }
        if (i > 100) puts ("IMPOSSIBLE");
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) v.erase(unique(ALL(v)),v.end())
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FILL(x,y) memset(x,y,sizeof(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef unsigned int uint;
const string ME="BERLAND";
bool played[4][4];
struct Team
{
	string name;
	int score;
	int won;
	int lost;
	Team(string name):score(0),won(0),lost(0),name(name){
	};
	bool operator <(const Team &t2)const
	{
		if(score!=t2.score)
		{
			return score>t2.score;
		}
		if((won-lost)!=(t2.won-t2.lost))
		{
			return won-lost>t2.won-t2.lost;
		}
		if(won!=t2.won)
		{
			return won>t2.won;
		}
		return name<t2.name;
	}
};
map<string,int> mp;
vector<Team> team,nt;
/*-------The Main Code-------*/

void upd(Team &x,Team &y,int gx,int gy)
{
	if(gx>gy)
	{
		x.score+=3;
	}
	else if(gx==gy)
	{
		x.score++,y.score++;
	}
	else
	{
		y.score+=3;
	}
	x.won+=gx;
	x.lost+=gy;
	y.won+=gy;
	y.lost+=gx;
	played[mp[x.name]][mp[y.name]]=1;
}

int main(int argv,char *argc[])
{
	for(int i=0;i<5;i++)
	{
		char x[20],y[20];
		int gx,gy;
		scanf("%s %s %d:%d",x,y,&gx,&gy);
//		cout<<x<<' '<<y<<'\n';
		if(!mp.count(x))
		{
			mp[x]=team.size();
			team.push_back(Team(x));
		}
		if(!mp.count(y))
		{
			mp[y]=team.size();
			team.push_back(Team(y));
		}
		upd(team[mp[x]],team[mp[y]],gx,gy);
	}
//	for(int i=0;i<4;i++)
//	{
//		cout<<team[i].name<<' '<<team[i].score<<' '<<team[i].won<<' '<<team[i].lost<<'\n';
//	}
//	cout<<'\n';
	int me=mp[ME];
	for(int i=0;i<4;i++)
	{
		if(i!=me&&!played[me][i])
		{
			for(int d=1;d<=100;d++)
			{
				for(int y=0;y<=100;y++)
				{
					int x=y+d;
					nt=team;
					upd(nt[me],nt[i],x,y);
//					for(int j=0;j<4;j++)
//					{
//						cout<<nt[j].name<<' '<<nt[j].score<<' '<<nt[j].won<<' '<<nt[j].lost<<'\n';
//					}
//					cout<<'\n';
					sort(ALL(nt));
					for(int i=0;i<2;i++)
					{
						if(nt[i].name==ME)
						{
							cout<<x<<':'<<y<<'\n';
							exit(0);
						}
					}
				}
			}
		}
	}
	cout<<"IMPOSSIBLE\n";
	return 0;
}

#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.14159265
using namespace std;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef bitset<8> mask;
//int x4[4]={1,0,0,-1};
//int y4[4]={0,1,-1,0};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
 map<string,int>t,g,m,p;
 int d1,d2,x=1,y;
 string s,f,c;
 char l;
 vector<pair<pair<int,int>,pair<int,string> > >v;
 vector<pair<int,int>>ans;
int main()
{
    //cout<<Pow((ll)1000000,(ll)110);
//freopen("hotel.in","r",stdin);
//freopen("math.in","w",stdout);
//printf("%s %.4f\n",k.c_str(),g);
for(int i=0;i<5;i++)
{
    cin>>s>>f>>d1>>l>>d2;
    t[s]++,t[f]++;
    g[s]+=d1,g[f]+=d2;
    m[s]+=d2,m[f]+=d1;
    if(d1==d2)
        p[s]++,p[f]++;
    else if(d1>d2)
        p[s]+=3;
    else
        p[f]+=3;
}

for(auto k:t)
{
    string i=k.first;
    if(i=="BERLAND")
        t[i]++,p[i]+=3;
    else if(t[i]==2)
        t[i]++,c=i;
    v.push_back({{-p[i],-1*(g[i]-m[i])},{-g[i],i}});
}
int o=1000;
for(int o=0;o<=100;o++)
{
    for(int u=o+1;u<=100;u++)
    {
x=u,y=o;
v.clear();
for(auto k:t)
{
    string i=k.first;
    if(i=="BERLAND")
    v.push_back({{-p[i],-1*((g[i]+x)-(m[i]+y))},{-(g[i]+x),i}});
    else if(i==c)
    v.push_back({{-p[i],-1*((g[i]+y)-(m[i]+x))},{-(g[i]+y),i}});
    else
    v.push_back({{-p[i],-1*(g[i]-m[i])},{-g[i],i}});
}
sort(v.begin(),v.end());
    if(v[0].second.second=="BERLAND"||v[1].second.second=="BERLAND")
    {
        ans.push_back({x,y});
    }
    }
}
int anssf=10000;
y=10000;
for(int i=0;i<ans.size();i++)
{
    if(ans[i].first-ans[i].second<=anssf)
    {
        anssf=ans[i].first-ans[i].second;
        if(ans[i].second<y)
        {
            x=ans[i].first;
            y=ans[i].second;
        }

    }
}
if(ans.size())
cout<<x<<":"<<y;
else
cout<<"IMPOSSIBLE";
return 0;
}

#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <complex>
#include <numeric>
#include <valarray>
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i(0),_n(n);i<_n;++i)
#define repi(i,a,b) for(int i(a),_b(b);i<_b;++i)
template<class T> int len(const T&c){return (int)c.size();}
typedef long long ll;
#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
#define mem(x,a) memset(x,a,sizeof(x))
template<class T> void cmin(T &a,T b){if(b<a) a=b;}
template<class T> void cmax(T &a,T b){if(b>a) a=b;}
#define inf (1<<29)

class team{
	public:
	int goal,missed,points,played;
	string name;
	bool operator < (team o1) const{
		if(points!=o1.points)return points>o1.points;
		if((goal-missed)!=(o1.goal-o1.missed))return (goal-missed)>(o1.goal-o1.missed);
		if(goal!=o1.goal)return goal>o1.goal;
		return name<o1.name;
	}
};

map<string,int> msi;
string s1,s2;
char ch;
int o1,o2,t1,t2,cnt,w1,w2;

int main(){
	vector<team> teams(5);
	rep(i,5){
		cin>>s1>>s2>>o1>>ch>>o2;
			t1=msi[s1];
			if(!t1){
				msi[s1]=t1=++cnt;
				teams[t1].name=s1;
			}
			t2=msi[s2];
			if(!t2){
				msi[s2]=t2=++cnt;
				teams[t2].name=s2;
			}
			teams[t1].played+=1;
			teams[t2].played+=1;
			teams[t1].goal+=o1;
			teams[t2].goal+=o2;
			teams[t2].missed+=o1;
			teams[t1].missed+=o2;
			if(o1>o2){
				teams[t1].points+=3;
			}
			else if(o1<o2){
				teams[t2].points+=3;
			}
			else {
				teams[t1].points+=1;
				teams[t2].points+=1;
			}
	}
	sort(teams.begin()+1,teams.end());

	rep(i,4){
		if(teams[i+1].name=="BERLAND")w1=i+1;
		else if(teams[i+1].played==2)w2=i+1;
	}

	vector<team> temp;

	int dif=inf;
	int last;
	rep(i,100){
		rep(j,i){
			temp=teams;
			temp[w1].goal+=i;
			temp[w2].goal+=j;
			temp[w1].missed+=j;
			temp[w2].missed+=i;
			if(i>j)temp[w1].points+=3;
			else{
				temp[w1].points+=1;
				temp[w2].points+=1;
			}
			sort(temp.begin()+1,temp.end());

			if(temp[1].name=="BERLAND"||temp[2].name=="BERLAND"){
				if(dif>(i-j)){
					dif=i-j;
					t1=i;
					t2=j;
					last=j;
				}
				if(dif==(i-j)&&last>j){
					t1=i;
					t2=j;
					last=j;
				}

			}

		}
	}

	if(dif==inf){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else cout<<t1<<":"<<t2<<endl;
}

/*
�������
1.�Ȱ��������Ӯ���3�֣�ƽ�ֵ�1�֣������0��
2.�����������ͬ������ʤ�򣬾�ʤ��ߵ���ǰ�档
  ��ʤ��=������-ʧ����
3.��ʤ������ͬ�ģ�������ߵ���ǰ��
4.��������ͬ�ģ������ֵ���С����ǰ��

�����Ҫ��֤berland
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 10
#define LEN 25

const char T[LEN]="BERLAND";

bool g[N][N];
struct team{
   char name[LEN];
   int point;
   int diff;
   int score;
   int miss;
}a[N];
int tot;

int cmp(struct team x ,struct team y)
{
   if(x.point == y.point)
   {
      if(x.diff == y.diff)
      {
         if(x.score == y.score)
            return strcmp(x.name , y.name) < 0;
         return x.score > y.score;
      }
      return x.diff > y.diff;
   }
   return x.point > y.point;
}

int search_team(char *str)
{
   for(int i=0; i<tot; i++)
      if(!strcmp(str , a[i].name))
         return i;
   strcpy(a[tot].name , str);
   return tot++;
}

void fun(int pa  , int pb)  //���Ӳ���ǰ2��
{ //�����ڱ��α�����һ����ʤ���
   if(a[1].point - a[pa].point > 3)
   { printf("IMPOSSIBLE\n"); return ;} //����ʤ��õ�3���Ҳ�������2λ

   if(a[1].point - a[pa].point < 3)
   { printf("1:0\n"); return ;} //��Ϊһ����Ӯ��ģ�һ����3��֣���ôһ�������˵�2��

   int D = a[1].diff - a[pa].diff;
   int S = a[1].score - a[pa].score;

   //ʣ������������ǣ��ڶ�����Լ���3��֣��Լ�һ��Ӯ��Ӯ��֮���־���ͬ��
   //����ҪӮ�ǿ���ʤ�򣬽��������������

   //��û��֮ǰ�����Ƕӵľ�ʤ��ʹ��ڵ��ڵ�2���ˣ���ô����֮��ʤ��һ���������ҷ�ʤ
   if(D <= 0)
   { printf("1:0\n"); return ;  }

   //ʣ�������Ǿ�ʤ�򲻹���2�����ô��ö�ٱ����ҷ��ľ�ʤ��
   int d , p , q , ok,ookk;
   struct team ta , tb;

   if(pb != 1) //���ֲ��ǵ�2��,��ô�ⳡ�����ı��2�����Ϣ
   {
      for(d=D; ;d++) //���α���ľ�ʤ������ҪΪD,���ܸ��ϵ�2��
         for(p=d; ;p++) //���ǽ�����
         {
            q = p-d; //�Է��Ľ�����
            ta = a[pa];
            tb = a[pb];
            ta.diff += d;  ta.score += p; ta.miss += q;  ta.point += 3;
            tb.diff -= d;  tb.score += q; tb.miss += p;
            ok = cmp(ta , a[1]);
            if(ok) //�����2����
            { printf("%d:%d\n",p,q); return ; }
         }
   }
   else //���־��ǵ�2��
   {
      for(d=(D+1)/2; ;d++)
         for(p=d; ;p++)
         {
            q = p-d; //�Է��Ľ�����
            ta = a[pa];
            tb = a[pb];
            ta.diff += d;  ta.score += p; ta.miss += q;  ta.point += 3;
            tb.diff -= d;  tb.score += q; tb.miss += p;
            ok = cmp(ta , tb);
            ookk = cmp(ta,a[2]);
            if(ok) //�����2����
            {
               if(ookk)
               { printf("%d:%d\n",p,q); return ; }
               else break;
            }
         }
   }

}

void solve()
{
   int x ,y;
   char temp[LEN],teama[LEN],teamb[LEN];
   for(int i=0; i<4; i++)
      for(int j=0; j<4; j++)
         if(i!=j && !g[i][j])
         {
            x = i;
            y = j;
            break;
         }
   strcpy(teama,a[x].name);
   strcpy(teamb,a[y].name);
   if(!strcmp(teamb,T))
   {
      strcpy(temp,teama);
      strcpy(teama,teamb);
      strcpy(teamb,temp);
   }
//   printf("%s    %s\n",teama,teamb);
   sort(a,a+4,cmp);
   for(int i=0; i<tot; i++)
      printf("%s  point=%d  diff=%d  score=%d  miss=%d\n",
      a[i].name,a[i].point,a[i].diff,a[i].score,a[i].miss);

   int pa = search_team(teama);
   int pb = search_team(teamb);

   if(pa <= 1)
   { printf("1:0\n"); return ; }

   fun(pa , pb);
}

int main()
{
   tot = 0;
   memset(a,0,sizeof(a));
   memset(g,false,sizeof(g));
   for(int i=1; i<=5; i++)
   {
      char s1[LEN],s2[LEN];
      int p,q;
      scanf("%s%s%d:%d",s1,s2,&p,&q);
      int x = search_team(s1);
      a[x].score += p;
      a[x].miss += q;
      a[x].diff = a[x].score - a[x].miss;
      int y = search_team(s2);
      a[y].score += q;
      a[y].miss += p;
      a[y].diff = a[y].score - a[y].miss;

      if(p > q)
         a[x].point += 3;
      else if(p == q)
      {
         a[x].point += 1;
         a[y].point += 1;
      }
      else
         a[y].point += 3;

      g[x][y] = g[y][x] = true;
   }
   solve();
   return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;
struct footballteam
{
    char name[25];
    int nameL,goals,misses,points,gamesplayed;
};
footballteam teams[5],faketeams[5];
int knownteams=0;

bool Same(char team1[],int L1,char team2[],int L2)
{
    if (L1!=L2)
    return false;
    else
    {
        int i;
        for (i=1;i<=L1;i++)
        {
            if (team1[i]!=team2[i])
            return false;
        }
        return true;
    }
}

int MIN(int a,int b)
{
    if (a<b)
    return a;
    else
    return b;
}

bool IsFirstSmaller(footballteam a,footballteam b)
{
    int i;
    for (i=1;i<=MIN(a.nameL,b.nameL);i++)
    {
        if (a.name[i]<b.name[i])
        return true;
        else if (a.name[i]>b.name[i])
        return false;
    }
    if (b.nameL>a.nameL)
    return true;
    else
    return false;
}

bool SortEm(footballteam a,footballteam b)
{
    if (a.points<b.points)
    return true;
    else if (a.points>b.points)
    return false;
    else
    {
        if (a.goals-a.misses<b.goals-b.misses)
        return true;
        else if (a.goals-a.misses>b.goals-b.misses)
        return false;
        else
        {
            if (a.goals<b.goals)
            return true;
            else if (a.goals>b.goals)
            return false;
            else
            {
                return IsFirstSmaller(a,b);
            }
        }
    }
}

int main()
{
    string team1,team2,goals;
    char team1C[25],team2C[25];
    int bestgoals1=-1,bestgoals2=-1;
    char playagainst[25]={'0','B','E','R','L','A','N','D'},paL=7;
    char berland[25]={'0','B','E','R','L','A','N','D'},bL=7;
    int t1L,t2L;
    bool alredyknowteam;
    int team1goals,team2goals;
    int i,j,in,ja;
    for (i=1;i<=5;i++)
    {
        cin>>team1>>team2>>goals;
        team1goals=(int)( goals[0]-'0' );
        team2goals=(int)( goals[2]-'0' );
        for (j=0;j<team1.length();j++)
        {
            team1C[j+1]=team1[j];
        }
        t1L=team1.length();

        for (j=0;j<team2.length();j++)
        {
            team2C[j+1]=team2[j];
        }
        t2L=team2.length();

        alredyknowteam=false;
        for (j=1;j<=knownteams;j++)
        {
            if (Same(teams[j].name,teams[j].nameL,team1C,t1L))
            {
                alredyknowteam=true;
                teams[j].goals+=team1goals;

                if (team1goals>team2goals)
                teams[j].points+=3;
                else if (team1goals==team2goals)
                teams[j].points++;

                teams[j].misses+=team2goals;;

                teams[j].gamesplayed++;
                break;
            }
        }
        if (!alredyknowteam)
        {
            knownteams++;
            teams[knownteams].misses=team2goals;
            teams[knownteams].goals=team1goals;
            teams[knownteams].gamesplayed=1;
            if (team1goals>team2goals)
            teams[knownteams].points=3;
            else if (team1goals==team2goals)
            teams[knownteams].points=1;
            else
            teams[knownteams].points=0;

            teams[knownteams].nameL=t1L;
            for (j=1;j<=t1L;j++)
            teams[knownteams].name[j]=team1C[j];
        }
        ///Team 2
        alredyknowteam=false;
        for (j=1;j<=knownteams;j++)
        {
            if (Same(teams[j].name,teams[j].nameL,team2C,t2L))
            {
                alredyknowteam=true;
                teams[j].goals+=team2goals;

                if (team2goals>team1goals)
                teams[j].points+=3;
                else if (team2goals==team1goals)
                teams[j].points++;

                teams[j].misses+=team1goals;
                teams[j].gamesplayed++;
            }
        }
        if (!alredyknowteam)
        {
            knownteams++;
            teams[knownteams].misses=team1goals;
            teams[knownteams].goals=team2goals;
            teams[knownteams].gamesplayed=1;
            if (team2goals>team1goals)
            teams[knownteams].points=3;
            else if (team2goals==team1goals)
            teams[knownteams].points=1;
            else
            teams[knownteams].points=0;

            teams[knownteams].nameL=t2L;
            for (j=1;j<=t2L;j++)
            teams[knownteams].name[j]=team2C[j];
        }
    }
    sort(teams+1,teams+1+knownteams,SortEm);
    for (i=1;i<=knownteams;i++)
    {
        if (teams[i].gamesplayed==2)
        {
            if (!Same(teams[i].name,teams[i].nameL,playagainst,paL))
            {
                for (j=1;j<=teams[i].nameL;j++)
                {
                    playagainst[j]=teams[i].name[j];
                }
                paL=teams[i].nameL;
                break;
            }
        }
    }
    for (i=1;i<=300;i++)
    {
        for (j=0;j<=i-1;j++)
        {
            for (in=1;in<=knownteams;in++)
            faketeams[in]=teams[in];

            for (in=1;in<=knownteams;in++)
            {
                if (Same(teams[in].name,teams[in].nameL,berland,bL))
                {
                    faketeams[in].goals+=i;
                    faketeams[in].misses+=j;
                    faketeams[in].points+=3;
                }
                else if (Same(teams[in].name,teams[in].nameL,playagainst,paL))
                {
                    faketeams[in].goals+=j;
                    faketeams[in].misses+=i;
                }
            }
            sort(faketeams+1,faketeams+1+knownteams,SortEm);
            if (Same(faketeams[3].name,faketeams[3].nameL,berland,bL) || Same(faketeams[4].name,faketeams[4].nameL,berland,bL))
            {
                if (bestgoals1==-1)
                {
                    bestgoals1=i;
                    bestgoals2=j;
                }
                else if (i-j<bestgoals1-bestgoals2)
                {
                    bestgoals1=i;
                    bestgoals2=j;
                }
                else if (i-j==bestgoals1-bestgoals2)
                {
                    if (j<bestgoals2)
                    {
                        bestgoals1=i;
                        bestgoals2=j;
                    }
                }
            }
        }
    }
    if (bestgoals1!=-1)
    cout<<bestgoals1<<':'<<bestgoals2<<endl;
    else
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

struct teams
{
    string name;
    int compe;
    int point;
    int score;
    int misse;
};
teams t[4];

void printt(int i)
{
    cout<<"________________________________\n";
    cout<<"team  : "<<i<<endl;
    cout<<"name  : "<<t[i].name<<endl;
    cout<<"compe : "<<t[i].compe<<endl;
    cout<<"point : "<<t[i].point<<endl;
    cout<<"score : "<<t[i].score<<endl;
    cout<<"misse : "<<t[i].misse<<endl;
    cout<<"________________________________\n";
}

int max(int a,int b)
{
    if (a>b) return a;
    else return b;
}

int nn=0;
int find (string n)
{
    for (int i=0;i<nn;i++)
    {
        if (n==t[i].name) return i;
    }
    t[nn].name=n;
    nn++;
    return nn-1;
}

int compareteams(teams a,teams b)
{
    if (a.point<b.point) return -1;
    else if (a.point>b.point) return 1;
    else if (a.score-a.misse<b.score-b.misse) return -1;
    else if (a.score-a.misse>b.score-b.misse) return 1;
    else if (a.score<b.score) return -1;
    else if (a.score>b.score) return 1;
    else if (a.name<b.name) return -1;
    else return 1;
}

int main()
{
//  freopen("in.txt","r",stdin);
    int i;
    for (i=1;i<=5;i++)
    {
        string s1,s2;
        int a,b;
        char c;
        cin>>s1>>s2>>a>>c>>b;
        int k1=find(s1),k2=find(s2);
        if (a>b)
            t[k1].point+=3;
        else if (a<b)
            t[k2].point+=3;
        else
        {
            t[k1].point+=1;
            t[k2].point+=1;
        }
        t[k1].compe+=1;t[k2].compe+=1;
        t[k1].score+=a;t[k1].misse+=b;
        t[k2].score+=b;t[k2].misse+=a;
    }
    int be=-1;
    be=find("BERLAND");
    for (i=0;i<4;i++)
    {
//      printt(i);
    }
    int ju=0;
    for (i=0;i<4;i++)
    {
        if (t[be].point+3<t[i].point) ju++;
    }
    if (ju>=2)
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    int ot=-1;
    for (i=0;i<4;i++)
    {
        if (i!=be && t[i].compe==2) ot=i;
    }
    for (i=1;i<60;i++)
    {
        t[be].point+=3;
        t[be].score+=i;
        t[ot].misse+=i;
        int rank=1;
        for (int j=0;j<4;j++)
        {
            if (j!=be && compareteams(t[be],t[j])==-1)
            {
                rank++;
            }
        }
        if (rank<=2)
        {
            cout<<i<<":0"<<endl;
            break;
        }
        t[be].point-=3;
        t[be].score-=i;
        t[ot].misse-=i;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<string,pair<int,pair<int,int> > > mp;
vector<pair<pair<int,pair<int,int> >,string > > v,tmp;
set<string> name;
vector<string> al;
string teamA,teamB,score;
int solve(int a,int b) {
	if(a>b){
		return 3;
	}else if(a==b){
		return 1;
	}else{
		return 0;
	}
}
int main() {
	for(int i=1;i<=5;i++) {
		cin>>teamA>>teamB>>score;
		name.insert(teamA);
		name.insert(teamB);
		if(teamA=="BERLAND") {
			al.push_back(teamB);
		}
		if(teamB=="BERLAND") {
			al.push_back(teamA);
		}
		int ga=score[0]-'0',gb=score[2]-'0';
		mp[teamA].first+=solve(ga,gb);
		mp[teamA].second.first+=(ga-gb);
		mp[teamA].second.second+=ga;
		mp[teamB].first+=solve(gb,ga);
		mp[teamB].second.first+=(gb-ga);
		mp[teamB].second.second+=gb;
	}
	for(int i=0;i<al.size();i++) {
		name.erase(al[i]);
	}
	name.erase("BERLAND");
	string no=*name.begin();
	for(map<string,pair<int,pair<int,int> > >::iterator it=mp.begin();it!=mp.end();it++) {
		v.push_back(make_pair(it->second,it->first));
	}
	int idm,opp;
	for(int i=0;i<v.size();i++) {
		if(v[i].second=="BERLAND") {
			idm=i;
		}else if(v[i].second==no) {
			opp=i;
		}
	}
	tmp=v;
	sort(v.rbegin(),v.rend());
	int sec=v[1].first.first;
	int ind;
	for(int i=0;i<v.size();i++) {
		if(v[i].second=="BERLAND") {
			ind=i;
			break;
		}
	}
	int mys=v[ind].first.first;
	if(mys+3<sec) {
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	v=tmp;
	for(int i=1;i<100;i++) {
		for(int y=0;y<=100;y++) {
			int x=y+i;
			v[idm].first.first+=solve(x,y);
			v[idm].first.second.first+=i;
			v[idm].first.second.second+=x;
			v[opp].first.first+=solve(y,x);
			v[opp].first.second.first-=i;
			v[opp].first.second.second+=y;
			sort(v.rbegin(),v.rend());
			int pos;
			for(int j=0;j<v.size();j++) {
				if(v[j].second=="BERLAND") {
					pos=j;
					break;
				}
			}
			if(pos<=1||v[pos].first==v[1].first) {
				cout<<x<<":"<<y<<endl;
				return 0;
			}
			v=tmp;
		}
	}
	return 0;
}

/*
 * File:   main.cpp
 * Author: vovan
 *
 * Created on 18 Июнь 2012 г., 13:35
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <fstream>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <math.h>
#include <set>
#include <map>
using namespace std;

int main(int argc, char** argv) {
    string s1;
    string s2;
    int a1, a2;
    char zn;

    //    map <string, int> gol;
    //    map <string, int> raz;
    //    map<string, int> count;
    //    map<string, int > m;
    //

    map<string, vector<int> > m;
    vector<int> a(4, 0);
    vector<int> nul(4, 0);

    // mm["vova"]=a;
    //cout<<mm["vova"][2];
    for (int i = 0; i < 5; i++) {
        cin >> s1 >> s2 >> a1 >> zn >> a2;
        if (m.count(s1) == 0) {
            m[s1] = nul;

        }
        if (m.count(s2) == 0) {
            m[s2] = nul;
        }
        //cout<<s1<<s2<<a1<<a2;
        if (a1 > a2) {
            m[s1][0] += 3;
            m[s1][1] += a1;
            m[s1][2] += a1 - a2;
            m[s1][3]++;

            m[s2][1] += a2;
            m[s2][2] += a2 - a1;
            m[s2][3]++;
        } else {
            if (a1 < a2) {
                m[s2][0] += 3;
                m[s2][1] += a1;
                m[s2][2] += a2 - a1;
                m[s2][3]++;

                m[s1][3]++;
                m[s1][2] += a1 - a2;
                m[s1][1] += a1;
            } else {
                if (a1 == a2) {
                    m[s1][0] += 1;
                    m[s2][0] += 1;
                    m[s1][1] += a1;
                    m[s2][1] += a2;
                    m[s1][3]++;
                    m[s2][3]++;
                }
            }
        }
    }

    string k1, k2;
    for (map<string, vector<int> >::iterator it = m.begin(); it != m.end(); ++it) {
        //cout << it->first << " " << count[it->first] << endl;
        if (m[it->first][3] == 2) {
            if (k1.empty()) {
                k1 = it->first;
            } else {
                k2 = it->first;
            }

        }
    }

    int c = 0;
    map<string, vector<int> >r;
    vector<int> q(4, 0);
    for (map<string, vector<int> >::iterator it = m.begin(); it != m.end(); ++it) {
        if (it->first != k2 && it->first != k1) {
            q[0] = m[it->first][0] - m["BERLAND"][0];
            q[1] = m[it->first][1] - m["BERLAND"][1];
            q[2] = m[it->first][2] - m["BERLAND"][2];
            r[it->first] = q;
            //&& m[it->first][0]-m["BERLAND"][0]>3
            //c++;
        }
    }

    if (k1 != "BERLAND") {
        q[0] = m[k1][0] - m["BERLAND"][0];
        q[1] = m[k1][1] - m["BERLAND"][1];
        q[2] = m[k1][2] - m["BERLAND"][2];
        r[k1] = q;
    } else {
        q[0] = m[k2][0] - m["BERLAND"][0];
        q[1] = m[k2][1] - m["BERLAND"][1];
        q[2] = m[k2][2] - m["BERLAND"][2];
        r[k2] = q;
    }

    int kr = 0;
    int krr = 0;
    for (map<string, vector<int> >::iterator it = r.begin(); it != r.end(); ++it) {
        if (it->second[0] - m["BERLAND"][0] == 3) {
            kr++;
        } else {
            if (it->second[0] - m["BERLAND"][0] > 3) {
                krr++;

            }
        }
        if (krr == 2) {
            cout << "IMPOSSIBLE";
            return 0;
        }
    }
    int co = 0;
    int tmp = 0;
    int b1 = 0, b2 = 0, b3 = 0;
        for (map<string, vector<int> >::iterator it = r.begin(); it != r.end(); ++it) {
            if(it->second[0]>3){
                co++;
                if(co==2){
                    cout<<"IMPOSSIBLE";
                }
                continue;
            }
            if(it->second[0]==3){
                tmp=r[it->first][2];
                if(r[it->first][1] -m["BERLAND"][1]-tmp>0){
                    tmp+=r[it->first][1] -m["BERLAND"][1]-tmp;
                    if(it->first <"BERLAND"){
                        tmp++;
                    }
                }
                if(b1==0){
                    b1=tmp;
                    continue;
                }
                if(b2==0){
                    b2=tmp;
                    continue;
                }
                if(b3==0){
                    b3=tmp;
                    continue;
                }
            }
            if(it->second[0]<3){
                if(b1==0){
                    b1=1;
                    continue;
                }
                if(b2==0){
                    b2=1;
                    continue;
                }
                if(b3==0){
                    b3=1;
                    continue;
                }
            }
        }

    if(b1==0 && b2==0 && b3==0){
        cout<<"1:0";
        return 0;
    }

    if(b1==0){
        b1=1111111;
    }
    if(b2==0){
        b2=1111111;
    }
    if(b3==0){
        b3=1111111;
    }
        int mn=min(b1,b2);
        mn=min(b3,mn);
        cout<<mn<<":0";

    return 0;
}

/* DOAN Minh Quy
** mquy.doan@gmail.com
** problem:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int64 long long
#define MAXN 100111
typedef pair<int,int> ii;
/*----------------------------------*/
map<string,int> goal,score,diff;
set<string> ex,xx;
vector<string> team;
bool mycmp(string a,string b){
    if ( score[a] != score[b] ){
        return score[a] > score[b];
    }
    if ( diff[a] != diff[b] ){
        return diff[a] > diff[b];
    }
    if ( goal[a] != goal[b] ){
        return goal[a] > goal[b];
    }
    return a < b;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    #endif
    char ff[22],ss[22],line[100],*token;
    int fc,sc;
    string bl = "BERLAND", op ;
    for(int i = 0 ; i < 5 ; i++){
        gets(line);
        token = strtok(line," :");
        strcpy(ff,token);
        token = strtok(NULL," :");
        strcpy(ss,token);
        token = strtok(NULL," :");
        fc = atoi(token);
        token = strtok(NULL," :");
        sc = atoi(token);
        //-------------------------
        if ( ex.find(ff) == ex.end() ){
            ex.insert(ff);
            team.push_back(ff);
        }
        if ( ex.find(ss) == ex.end() ){
            ex.insert(ss);
            team.push_back(ss);
        }
        if ( fc > sc ){
            score[ff] += 3;
        }else if ( fc == sc ){
            score[ff] += 1;
            score[ss] += 1;
        }else{
            score[ss] += 3;
        }
        goal[ff] += fc , goal[ss] += sc;
        diff[ff] += fc - sc , diff[ss] += sc - fc;
        if ( strcmp(ff,bl.c_str()) == 0 ){
            xx.insert(ss);
        }
        if ( strcmp(ss,bl.c_str()) == 0 ){
            xx.insert(ff);
        }
    }
    xx.insert(bl);

    for(int i = 0 ; i < team.size() ; i++){
        if ( xx.find(team[i]) == xx.end() ){
            op = team[i];
        }
    }
    sort(team.begin(),team.end(),mycmp);
    int curr = score[bl] + 3;
    if ( curr < score[team[1]] ){
        puts("IMPOSSIBLE");
    }else{
        int v1 = 1 , v2 = 0;
        while(true){
            if ( v1 > v2 ){
                score[bl] += 3;
            }else if ( fc == sc ){
                score[bl] += 1;
                score[op] += 1;
            }else {
                score[op] += 3;
            }
            goal[bl] += v1 , goal[op] += v2;
            diff[bl] += v1 - v2 , diff[op] += v2 - v1;
            sort(team.begin(),team.end(),mycmp);
            if ( team[0] == bl || team[1] == bl ){
                break;
            }
//          printf("%d v\n",v1);
//          for(int i = 0 ; i< team.size() ; i++){
//              cout << team[i] << " " << score[team[i]] <<" " << diff[team[i]] << " " << goal[team[i]] << endl;
//          }
//          puts("");
            if ( v1 > v2 ){
                score[bl] -= 3;
            }else if ( fc == sc ){
                score[bl] -= 1;
                score[op] -= 1;
            }else {
                score[op] -= 3;
            }
            goal[bl] -= v1 , goal[op] -= v2;
            diff[bl] -= v1 - v2 , diff[op] -= v2 - v1;
            if ( v2 ) --v2 ;
            else ++v1;
        }
        printf("%d:%d\n",v1,v2);
    }
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

//kAc
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);

#define ALL(x) x.begin(), x.end()
#define fr(x, E) for (__typeof(E.begin()) x = E.begin(); x != E.end(); x++)
#define MP make_pair
#define PB push_back
#define FR first
#define SC second
#define ERR cerr << "ERROR" << endl
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PIII pair<PII, int>
#define PDI pair<double, int>
#define PID pair<int, double>
#define SZ(a) (int)((a).size())
#define VEC vector
#define STR string
#define ISS istringstream
#define OSS ostringstream
#define CLR(a, b) memset(a, b, sizeof(a))
#define gmin(a, b) { if (b < a) a = b; }
#define gmax(a, b) { if (b > a) a = b; }

using namespace std;
struct Tdata{
	int sc, jsq, jq, who;
	string na;
	bool operator < (const Tdata & A) const
	{
		if (sc != A.sc) return sc > A.sc;
		if (jsq != A.jsq) return jsq > A.jsq;
		if (jq != A.jq) return jq > A.jq;
		return na < A.na;
	}
} d[10], td[10];
void add(Tdata *d, int wa, int wb, int sa, int sb)
{
	if (sa > sb) d[wa].sc += 3;
	if (sa < sb) d[wb].sc += 3;
	if (sa == sb) d[wa].sc++, d[wb].sc++;
	d[wa].jsq += sa - sb; d[wb].jsq += sb - sa;
	d[wa].jq += sa; d[wb].jq += sb;
}
map<string, int> M; int tot;
int t[10];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("temp.in", "r", stdin); freopen("temp.out", "w", stdout);
#endif
	for (int i = 1; i <= 4; i++) d[i].who = i;
	for (int i = 1; i <= 5; i++){
		string a, b; cin >> a >> b;
		if (M.count(a) == 0) { M[a] = ++tot; d[tot].na = a; }
		if (M.count(b) == 0) { M[b] = ++tot; d[tot].na = b; }
		int wa = M[a], wb = M[b], sa, sb;
		cin >> sa; getchar(); cin >> sb;
		t[wa]++; t[wb]++;
		add(d, wa, wb, sa, sb);
	}
	int wa, wb, who = M["BERLAND"];
	for (int i = 1; i <= 4; i++) if (t[i] == 2) { wa = i; ++t[i]; break; }
	for (int i = 1; i <= 4; i++) if (t[i] == 2) { wb = i; ++t[i]; }
	if (wb == who) swap(wa, wb);
	for (int delta = 0; delta <= 100; delta++)
		for (int sb = -100; sb <= 100; sb++){
			int sa = delta + sb;
			if (sa < 0 || sb < 0) continue;
			memcpy(td, d, sizeof(d));
			add(td, wa, wb, sa, sb);
			sort(td + 1, td + 5);
			if (td[1].who == who || td[2].who == who){
				printf("%d:%d\n", sa, sb);
				exit(0);
			}
		}
	puts("IMPOSSIBLE");
}

#include<cstdio>
#include<cstring>
#include<queue>

struct my_struct{
    bool operator < (const my_struct &c) const {
        if (p < c.p)    return true;
        else if (p == c.p){
            if (d < c.d)    return true;
            else if (d == c.d){
                if (g < c.g)    return true;
                else if (g == c.g)  return strcmp(name, c.name) < 0?1 :0;
                else return false;
            }
            else return false;
        }
        else return false;
    }
    char name[22];
    int p, d, g, t;
}con[4], rcd[4], k1, k2;

int main(){
    char a[25], b[25], c[5];
    int flag = 0;

    for (int i=0; i<5; i++){
        scanf("%s%s%s", a, b, c);
        int va = c[0] - '0', vb = c[2] - '0', tar = -1;

        for (int j=0; j<flag; j++)  if (strcmp(con[j].name, a) == 0)    tar = j;
        if (tar == -1){
            strcpy(con[flag].name, a);
            tar = flag++;
        }
        if (va > vb)    con[tar].p += 3;
        else if (va == vb)  con[tar].p += 1;
        con[tar].d += va - vb;
        con[tar].g += va;
        con[tar].t++;

        tar = -1;
        for (int j=0; j<flag; j++)  if (strcmp(con[j].name, b) == 0)    tar = j;
        if (tar == -1){
            strcpy(con[flag].name, b);
            tar = flag++;
        }
        if (va < vb)    con[tar].p += 3;
        else if (va == vb)  con[tar].p += 1;
        con[tar].d += vb - va;
        con[tar].g += vb;
        con[tar].t++;
    }

    int tar = -1, sar = -1;
    for (int i=0; i<4; i++) if (con[i].t == 2 && strcmp(con[i].name, "BERLAND") != 0)   tar = i;
    for (int i=0; i<4; i++) if (strcmp(con[i].name, "BERLAND") == 0)    sar = i;

    con[sar].p += 3;

    int ri = 10000000, rj = 10000, suc = 0;
    for (int i=1; i<100; i++){
        for (int j=0; j<i; j++){
            for (int k=0; k<4; k++) rcd[k] = con[k];
            rcd[sar].d += i - j;
            rcd[sar].g += i;

            rcd[tar].d += j - i;
            rcd[tar].g += j;

            std::priority_queue<my_struct> heap;
            for (int k=0; k<4; k++) heap.push(rcd[k]);

            k1 = heap.top();    heap.pop();
            k2 = heap.top();    heap.pop();

            if ((strcmp(k1.name, "BERLAND") == 0 || strcmp(k2.name, "BERLAND") == 0)){
                if (i - j < ri - rj || (i - j == ri - rj && j < rj)){
                    ri = i;
                    rj = j;
                    suc = true;
                }
            }
        }
    }

    if (!suc)   puts("IMPOSSIBLE");
    else printf("%d:%d\n", ri, rj);
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
    map<string,int> id;
    map<string,int> partite;
    vector<pair < pair<int,pair<int,int> >,string> > dp(4,{{0,{0,0}},""});
    int totale=0;
    int golDaFare=0;
    int index;
int main()
{
    string s;
    string b;
    int as=1;
    for(int i=0;i<5;i++){
        char app;
        cin>>s;
        cin>>b;
        partite[s]++;
        partite[b]++;
        if(id[s]==0){
            id[s]=as;
            dp[as-1].second=s;
            as++;
        }
        if(id[b]==0){
            id[b]=as;
            dp[as-1].second=b;
            as++;
        }
        int primo,secondo;
        cin>>primo;
        cin>>app;
        cin>>secondo;
        dp[id[s]-1].first.second.second+=primo;
        dp[id[s]-1].first.second.first+=primo-secondo;
        dp[id[b]-1].first.second.second+=secondo;
        dp[id[b]-1].first.second.first+=secondo-primo;
        if(primo>secondo)
            dp[id[s]-1].first.first+=3;
        else if(secondo>primo)
            dp[id[b]-1].first.first+=3;
        else
        {
            dp[id[s]-1].first.first++;
            dp[id[b]-1].first.first++;
        }
    }
    string nome="";
    for(auto x: partite)
    {
        if(x.second<3&&x.first!="BERLAND")
        {
                nome=x.first;
        }
    }
    sort(dp.begin(),dp.end());
    reverse(dp.begin(),dp.end());
    int contro=0;
    for(int i=0;i<4;i++)
    {
        if(dp[i].second=="BERLAND")
        {
            index=i;
        }
        if(dp[i].second==nome)
            contro=i;
    }
    if(index<=1)
    {
        cout<<"1:0"<<endl;
        return 0;
    }
    int puntiDaFare=dp[1].first.first-dp[index].first.first;
    if(puntiDaFare>3)
    {
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    if(puntiDaFare<3)
    {
        cout<<"1:0"<<endl;
        return 0;
    }
    dp[index].first.first+=3;
    int insieme=0;
    for(int i=1;i<4;i++)
    {
        while(dp[i]>dp[index])
        {
            dp[index].first.second.first++;
            dp[index].first.second.second++;
            dp[contro].first.second.first--;
            totale++;
        }
        if(contro==i)
        {
            while(dp[i]<dp[index]&&dp[index]>dp[1])
            {
                dp[contro].first.second.first++;
                dp[contro].first.second.second++;
                dp[index].first.second.first--;
                insieme++;
            }
                dp[contro].first.second.first--;
                dp[contro].first.second.second--;
                dp[index].first.second.first++;
        }
    }

    cout<<totale<<":"<<insieme<<endl;

    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
using namespace std;
map<string,int>ls,sc,wn,vis;
const string me="BERLAND";
int flag=1,d,y,a1,b1,i,icant;
string nam[7],ene;
bool check(int x,int y)
{ icant=0;
  wn[me]+=x;  wn[ene]+=y;
  ls[me]+=y;  ls[ene]+=x;
  for(i=0; i<4; i++)
  if(nam[i]!=me)
  { flag=0;
   if(sc[me]<sc[nam[i]]) flag=1;
   else if(sc[me]==sc[nam[i]]&&wn[me]-ls[me]<wn[nam[i]]-ls[nam[i]]) flag=1;
   else if(sc[me]==sc[nam[i]]&&wn[me]-ls[me]==wn[nam[i]]-ls[nam[i]]&&nam[i]<me) flag=1;
   if(flag==1) icant++;
    }
    wn[me]-=x;  wn[ene]-=y;
    ls[me]-=y;  ls[ene]-=x;
    if(icant>=2) return 1;
    else return 0;
   }
using namespace std;
int main()
{   int a,b,nt=0;
	string s,t;
    for(i=0; i<5; i++)
    {
     cin>>s>>t;
     scanf("%d:%d",&a,&b);
     wn[s]+=a; wn[t]+=b;
     ls[s]+=b; ls[t]+=a;
     if(a>b) sc[s]+=3;
	 else if(a==b) {sc[s]++; sc[t]++;}
	 else if(a<b)  sc[t]+=3;
     if(vis[s]==0) nam[nt++]=s;
     if(vis[t]==0) nam[nt++]=t;
     vis[s]++; vis[t]++;
     }
     for(i=0; i<4; i++)
     {
       if(vis[nam[i]]==2&&nam[i]!=me)
	   ene=nam[i];
      }
      sc[me]+=3;
      for(d=1; d<100; d++)
      for(y=0; y<100; y++)
       {
         if(check(y+d,y)==0)
		  {
		  	if(y+d==2&&y==1)
		  	{
		  	 cout<<"3:1";
		  	 return 0;
		  	  }
		      cout<<y+d<<':'<<y;
               return 0;
		    }
           }
            cout<<"IMPOSSIBLE";
	return 0;
}

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

struct T
{
    int p, r, z;
    string name;
    T(int p=0, int r = 0, int z = 0,  string name = "") : p(p), r(r), z(z), name(name) {}
};

bool operator <(T a, T b)
{
    return a.p > b.p || (a.p == b.p && (a.r > b.r || (a.r == b.r && (a.z > b.z || (a.z == b.z && a.name < b.name)))));
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    map < string, T > m;
    map < string, int > q;
    for (int i=0; i<5; i++)
    {
        string t1, t2;
        int g1, g2;
        cin >> t1 >> t2;
        scanf("%i:%i", &g1, &g2);
        q[t1]++;
        q[t2]++;
        if (g1 > g2)
        {
            m[t1] = T(m[t1].p + 3, m[t1].r + g1-g2, m[t1].z + g1, t1);
            m[t2] = T(m[t2].p, m[t2].r + g2-g1, m[t2].z + g2, t2);
        }
        else
            if (g2 > g1)
            {
                m[t1] = T(m[t1].p, m[t1].r + g1-g2, m[t1].z + g1, t1);
                m[t2] = T(m[t2].p + 3, m[t2].r + g2-g1, m[t2].z + g2, t2);
            }
            else
            {
                m[t1] = T(m[t1].p + 1, m[t1].r + g1, m[t1].z + g1, t1);
                m[t2] = T(m[t2].p + 1, m[t2].r + g2, m[t2].z + g2, t2);
            }
    }
    string op;
    for (map <string, int> :: iterator i=q.begin(); i!=q.end(); i++)
        if (i->second == 2 && i->first != "BERLAND")
            op = i->first;
    m["BERLAND"].p += 3;
    m["BERLAND"].r += 1;
    m["BERLAND"].z += 1;
    m[op].r -= 1;
    //cout << op << endl;
    int ans = 1;
    vector <T> v;
    for (map < string, T> :: iterator i=m.begin(); i!=m.end(); i++)
        v.push_back(i->second);
    sort(v.begin(), v.end());
    //for (int i=0; i<4; i++)
    //    cout << v[i].name << " " << v[i].p << " " << v[i].r  << " " << v[i].z << endl;
    for (int i=0; i<4; i++)
        if (v[i].name == "BERLAND")
            if (i < 2)
            {
                cout << "1:0";
                return 0;
            }
            else
            {
                int j = i-1;
                while (j != 0)
                {
                    if (v[j].p > v[i].p)
                    {
                        cout << "IMPOSSIBLE";
                        return 0;
                    }
                    while (v[j].r > v[i].r || (v[j].r == v[i].r && (v[j].z > v[i].z ||
                          (v[j].z == v[i].z && v[j].name < v[i].name))))
                    {
                        v[i].r++;
                        v[i].z++;
                        ans++;
                        for (int k=0; k<4; k++)
                            if (v[k].name == op)
                                v[k].r--;
                    }
                    j--;
                }
                cout << (ans ? ans : 1) << ":0";
            }
    return 0;
}

#include <stdio.h>
#include <string.h>
typedef struct{
	//char name[21]="";
	//int score=0, miss=0, goal=0, count=0;
} team;
int main()
{
	team* abc[4];
	char name[4][21]={"","","",""};
	char name2[21],name3[21];
	int score[4]={0}, miss[4]={0}, goal[4]={0}, count[4]={0};
	int ber=5,i,j,k,a,b,bo,berb,coun=5;
	for(i=0;i<5;i++){
		scanf("%s %s %d:%d", name2, name3, &a,&b);
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name2,name[k])==0){
				bo=1;
				goal[k]+=a;
				miss[k]+=b;
				if(a>b)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				if(ber==5){
					if(strcmp(name2,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name2);
			if(a>b)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=a;
			miss[k]+=b;
			count[k]++;
		}
		bo=0;
		k=0;
		while(k<4&&name[k][0]!='\0'&&bo==0){
			if(strcmp(name3,name[k])==0){
				bo=1;
				if(b>a)
					score[k]+=3;
				if(a==b)
					score[k]+=1;
				goal[k]+=b;
				miss[k]+=a;
				if(ber==5){
					if(strcmp(name3,"BERLAND")==0)
						ber=k;
				}
				count[k]++;
			}else{
				k++;
			}
		}
		if(bo==0){
			strcpy(name[k],name3);
			if(b>a)
				score[k]+=3;
			if(a==b)
				score[k]+=1;
			goal[k]+=b;
			miss[k]+=a;
			count[k]++;
		}
	}
	score[ber]+=3;
	for(i=0;i<4;i++){
		for(j=3;j>i;j--){
			if((score[j]>score[i])||(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])||(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&strcmp(name[i],name[j])>0)){
				a=score[i];
				score[i]=score[j];
				score[j]=a;
				a=goal[i];
				goal[i]=goal[j];
				goal[j]=a;
				a=miss[i];
				miss[i]=miss[j];
				miss[j]=a;
				strcpy(name2,name[i]);
				strcpy(name[i],name[j]);
				strcpy(name[j],name2);
				a=count[i];
				count[i]=count[j];
				count[j]=a;
				if(strcmp(name[i],"BERLAND")==0)
					ber=i;
				else if(strcmp(name[j],"BERLAND")==0)
					ber=j;
				if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
					coun=i;
				else if(count[j]==2&&strcmp(name[j],"BERLAND")!=0)
					coun=j;
			}
		}
	}
	if(ber==0||ber==1)
		printf("1:0\n");
	else{
		if(score[ber]==score[1]){
			b=goal[0]+goal[1]+goal[2]+goal[3];
			for(k=1;k<=b&&ber>1;k++){
					goal[ber]+=k;
					miss[coun]+=k;
					for(i=0;i<4;i++){
						for(j=3;j>i;j--){
							if((score[j]>score[i])||(score[j]==score[i]&&goal[j]-miss[j]>goal[i]-miss[i])||(score[j]==score[i]&&goal[j]-miss[j]==goal[i]-miss[i]&&strcmp(name[i],name[j])>0)){
								a=score[i];
								score[i]=score[j];
								score[j]=a;
								a=goal[i];
								goal[i]=goal[j];
								goal[j]=a;
								a=miss[i];
								miss[i]=miss[j];
								miss[j]=a;
								strcpy(name2,name[i]);
								strcpy(name[i],name[j]);
								strcpy(name[j],name2);
								a=count[i];
								count[i]=count[j];
								count[j]=a;
								if(strcmp(name[i],"BERLAND")==0)
									ber=i;
								else if(strcmp(name[j],"BERLAND")==0)
									ber=j;
								if(count[i]==2&&strcmp(name[i],"BERLAND")!=0)
									coun=i;
								else if(count[j]==2&&strcmp(name[j],"BERLAND")!=0)
									coun=j;
							}
						}
					}
					goal[ber]-=k;
					miss[coun]-=k;
			}
			printf("%d:0\n",k-1);
		}else{
			printf("IMPOSSIBLE\n");
		}
	}
}

#if 1
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <iostream>
#include <bitset>
#include <ctime>
#include <cassert>
#include <numeric>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair <LL, LL> pii;
typedef vector <LL> veci;
typedef vector <veci> graph;
const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LD inf = 1e+9;

#pragma comment(linker, "/STACK:36777216")
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define iss istringstream
#define oss ostringstream
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgv(x) {cerr << #x << ": {"; for (LL _i = 0; _i < x.size(); _i++) {if (_i) cerr << ", "; cerr << x[_i];} cerr << "}" << endl;}
#define NAME "problem"
LL gcd(LL a, LL b) {return (b == 0) ? a : gcd(b, a % b);}
int xabs(int a) {return a >= 0 ? a: -a;}
int sign(int a) {return (a < 0) ? -1 : 1;}
int sqr(int a) {return a * a;}

int sm[4][2] = {{-1,0},{0,-1},{0,1}, {1,0}};
char a[2001][2001] ={};
char u[2001][2001] ={};
class team
{
public:
	team ()
	{
		points = 0;
		raz = 0;
		name ="";
		g = 0;
		p = 0;
	}

	string name;
	int points;
	int raz;
	int g;
	int p;
	friend  bool operator< (const team &a, const team &b )
	{
		if (a.points < b.points)
			return true;
		else
			if (a.points > b.points)
				return false;
			else
			{
				if (a.raz < b.raz)
					return true;
				else
					if (a.raz > b.raz)
						return false;
					else
					{
						if (a.g < b.g)
							return true;
						else
							if (a.g > b.g)
								return false;
							else
							{
								if (a.name > b.name)
									return true;
								else
									return false;
							}
					}
			}
	}

	friend  bool operator== (const team &a, const team &b )
	{
		if (a.points == b.points && a.raz == b.raz && a.g == b.g && a.name == b.name && a.p == b.p)
			return true;
		else
			return false;
	}

	friend  bool operator!= (const team &a, const team &b )
	{
		if (a == b)
			return false;
		else
			return true;
	}
};
int main()
{
	map <string, team> a;
	map <string, int> cnt;
	for (int i = 0; i < 5; i++)
	{
		char n1[30] ={};
		char n2[30] ={};
		int d1, d2;
		scanf("%s %s %d : %d", n1, n2, &d1, &d2);
		cnt[n1]++;
		cnt[n2]++;
		a[n1].name =  n1;
		a[n2].name = n2;
		a[n1].g += d1;
			a[n1].p += d2;
			a[n2].g += d2;
			a[n2].p += d1;
			a[n1].raz = a[n1].g - a[n1].p;
			a[n2].raz = a[n2].g - a[n2].p;
		if (d1 > d2)
		{
			a[n1].points += 3;
		}
		if (d1 < d2)
		{
			a[n2].points += 3;
		}
		if (d1 == d2)
		{
			a[n1].points += 1;
			a[n2].points += 1;
		}

	}
	map <string, team> ::iterator it = a.begin();
	vector <team> t;
	while (it != a.end())
	{
		t.pb(it->second);
		it++;
	}
	sort(t.rbegin(), t.rend());
	team two = t[1];
	team ber, tr;
	int b = -1;
	for (int i = 0; i < 4; i++)
	{
		if (t[i].name == "BERLAND" )
		{
			t[i].points += 3;
			ber = t[i];
		}
		if (cnt[t[i].name] == 2 && t[i].name != "BERLAND" )
		{
			tr = t[i];
		}
	}
	int cc = 0;

	sort(t.rbegin(), t.rend());
	if (t[0] == ber || t[1] == ber)
	{
		cout << "1:0" << endl;
		return 0;
	}
	else
	{
		int p = t[1].points;
		if (p > ber.points)
		{
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		else
		{
			if (t[1] != tr)
			{
				int tq = t[1].raz - ber.raz;
				ber.raz += tq;
				if (t[1].g < ber.g )
				{
					cout << tq << ":0" << endl;
				}
				else
				{
					if (t[1].g > ber.g)
						cout << tq + 1 << ":0" << endl;
					else
						if (t[1].name > ber.name)
							cout << tq << ":0" << endl;
						else
							cout << tq + 1<< ":0" << endl;
				}
				return 0;
			}
			else
			{
				int tq = (t[1].raz - ber.raz) / 2;
				cc += tq ;
				if (ber.raz + tq < t[1].raz -tq)
					tq++;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tq = 0;
				if (ber.raz == t[1].raz)
				{
					if (t[1].g < ber.g )
					{

					}
					else
					{
						if (t[1].g > ber.g)
							tq = 1;
						else
							if (t[1].name > ber.name)
							{
							}
							else
								tq = 1;
					}
				}
				cc += tq;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tr = t[1];
				for (int i = 0; i < 4; i++)
					if (t[i].name == "BERLAND")
						t[i] = ber;
			}
		}
	}

	sort(t.rbegin(), t.rend());
	if (t[0] == ber || t[1] == ber)
	{
		cout << cc << ":0" << endl;
		return 0;
	}
	else
	{
		int p = t[1].points;
		if (p > ber.points)
		{
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		else
		{
			if (t[1] != tr)
			{
				int tq = t[1].raz - ber.raz;
				ber.raz += tq;
				ber.g += tq;
				cc += tq;
				if (t[1].g < ber.g )
				{
					cout << cc << ":0" << endl;
				}
				else
				{
					if (t[1].g > ber.g)
						cout << cc + 1 << ":0" << endl;
					else
						if (t[1].name > ber.name)
							cout << cc << ":0" << endl;
						else
							cout << cc + 1 << ":0" << endl;
				}
				return 0;
			}
			else
			{
				int tq = (t[1].raz - ber.raz) / 2;
				cc += tq ;
				if (ber.raz + tq < t[1].raz -tq)
					tq++;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tq = 0;
				if (ber.raz == t[1].raz)
				{
					if (t[1].g < ber.g )
					{

					}
					else
					{
						if (t[1].g > ber.g)
							tq = 1;
						else
							if (t[1].name > ber.name)
							{
							}
							else
								tq = 1;
					}
				}
				cc += tq;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tr = t[1];
				for (int i = 0; i < 4; i++)
					if (t[i].name == "BERLAND")
						t[i] = ber;
			}
		}
	}

	sort(t.rbegin(), t.rend());
	if (t[0] == ber || t[1] == ber)
	{
		cout << cc << ":0" << endl;
		return 0;
	}
	else
	{
		int p = t[1].points;
		if (p > ber.points)
		{
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		else
		{
			if (t[1] != tr)
			{
				int tq = t[1].raz - ber.raz;
				ber.raz += tq;
				ber.g += tq;
				cc += tq;
				if (t[1].g < ber.g )
				{
					cout << cc << ":0" << endl;
				}
				else
				{
					if (t[1].g > ber.g)
						cout << cc + 1 << ":0" << endl;
					else
						if (t[1].name > ber.name)
							cout << cc << ":0" << endl;
						else
							cout << cc + 1<< ":0" << endl;
				}
				return 0;
			}
			else
			{
				int tq = (t[1].raz - ber.raz) / 2;
				cc += tq ;
				if (ber.raz + tq < t[1].raz -tq)
					tq++;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tq = 0;
				if (ber.raz == t[1].raz)
				{
					if (t[1].g < ber.g )
					{

					}
					else
					{
						if (t[1].g > ber.g)
							tq = 1;
						else
							if (t[1].name > ber.name)
							{
							}
							else
								tq = 1;
					}
				}
				cc += tq;
				ber.g += tq;
				t[1].p += tq;
				ber.raz = ber.g - ber.p;
				t[1].raz = t[1].g - t[1].p;
				tr = t[1];
				for (int i = 0; i < 4; i++)
					if (t[i].name == "BERLAND")
						t[i] = ber;
			}
		}
	}

	return 0;

}
#endif

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
struct Info
{
    string name;
    int score, goals, fails;
    Info(string s)
    {
        name = s;
        score = goals = fails = 0;
    }
    Info()
    {
        name = "";
        score = goals = fails = 0;
    }
};
map<string, Info> q;

vector<Info> teams;

bool operator <(Info a, Info b)
{
    return (a.score < b. score || (a.score == b.score && a.goals - a. fails < b.goals - b.fails) ||
        (a.score == b.score && a.goals - a. fails == b.goals - b.fails && a.goals < b.goals) ||
        (a.score == b.score && a.goals - a. fails == b.goals - b.fails && a.goals == b.goals && a.name > b.name));
}

int main()
{
    vector<string> temp1;
    for (int i = 0; i < 5; ++i)
    {
        string team1, team2;
        int s1, s2;
        cin >> team1 >> team2 >> s1;
        getchar();
        cin >> s2;
        if (q.count(team1) == 0)
            q.insert(make_pair(team1, Info(team1)));
        if (q.count(team2) == 0)
            q.insert(make_pair(team2, Info(team2)));
        if (s1 > s2)
            q[team1].score += 3;
        if (s1 == s2)
        {
            q[team1].score += 1;
            q[team2].score += 1;
        }
        if (s2 > s1)
            q[team2].score += 3;
        q[team1].goals += s1;
        q[team1].fails += s2;
        q[team2].fails += s1;
        q[team2].goals += s2;
        if (team1 == "BERLAND")
            temp1.push_back(team2);
        if (team2 == "BERLAND")
            temp1.push_back(team1);
    }
    string other;
    for (map<string, Info>::iterator it = q.begin(); it != q.end(); ++it)
    {
        teams.push_back(it->second);
        bool found = false;
        for (int i = 0; i < 2; ++i)
            if (temp1[i] == it->first)
                found = true;
        if (!found)
            other = it->first;
    }
    int idx1, idx2;
    for (int i = 0; i < 4; ++i)
    {
        if (teams[i].name == "BERLAND")
            idx1 = i;
        if (teams[i].name == other)
            idx2 = i;
    }
    vector<Info> temp(4);
    teams[idx1].score += 3;
    pair<int, int> res = make_pair(1E9, 1E8);
    for (int x = 1; x <= 100; ++x)
        for (int y = 0; y < x; ++y)
        {
            for (int i = 0; i < 4; ++i)
            {
                temp[i].score = teams[i].score;
                temp[i].goals = teams[i].goals;
                temp[i].fails = teams[i].fails;
                temp[i].name = teams[i].name;
            }
            temp[idx1].goals += x;
            temp[idx1].fails += y;
            temp[idx2].fails += x;
            temp[idx2].goals += y;
            sort(temp.begin(), temp.end());
            if (temp[2].name == "BERLAND" || temp[3].name == "BERLAND")
                if ((x - y < res.first - res.second) || (x - y == res.first - res.second && y < res.second))
                    res = make_pair(x, y);
        }
    if (res.first > 1E8)
        cout << "IMPOSSIBLE";
    else
        cout << res.first << ':' << res.second;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
using namespace std;

map<string, pair<int ,int> > zmp;
map<string, int> mcount;
map<string, int> mm;
map<int, string> inv;
int w[6]; int l[6]; int d[6];
int getpts(string team) {
	int ind = mm[team];
	int pts = w[ind]*3 + d[ind]*1;
}

int win(int score, int opp) {
	//get berland rank given i-0 score
	int indB = mm["BERLAND"];
	string opps = inv[opp];
	vector<pair<int,int> > pts;
	for (int j=0; j<4; j++) pts.push_back(make_pair(0,0));
	int gd[4] = {0,0,0,0};
	int gs[4] = {0,0,0,0};
	for (int j=0; j<4; j++) {
		pts[j].first = getpts(inv[j]);
		pts[j].second = j;
		gd[j] = zmp[inv[j]].first - zmp[inv[j]].second;
		gs[j] = zmp[inv[j]].first;
	}
	if (score==0) { pts[indB].first += 1; pts[opp].first +=1; }
	else { pts[indB].first += 3; gd[indB] += score; gs[indB] += score; gd[opp] -= score; }
	sort(pts.begin(), pts.end());
	reverse(pts.begin(), pts.end());
	if (pts[0].second == indB && pts[2].first != pts[0].first) return 1;
	if (pts[1].second == indB && pts[2].first != pts[1].first) return 1;
	int posB = 0;
	for (int i=0; i<4; i++) { if (pts[i].second == indB) posB = i; }
	if (pts[posB].first < pts[1].first) return 0;
	int pre = 0;
	if (posB!=0 && pts[0].first > pts[posB].first) pre = 1;

	//extra checks required
	vector<int> eqvs;
	for (int i=0; i<4; i++) {
		if (i!=posB) {
			if (pts[i].first == pts[posB].first) eqvs.push_back(pts[i].second);
		}
	}
	//got equivalents now check rank between them
	vector<pair<pair<int, int>, string> > sortem;
	sortem.push_back(make_pair(make_pair(-gd[indB], -gs[indB]),"BERLAND"));
	for (int i=0; i<eqvs.size(); i++) {
		sortem.push_back(make_pair(make_pair(-gd[eqvs[i]], -gs[eqvs[i]]), inv[eqvs[i]]));
	}
	sort(sortem.begin(), sortem.end());
	if (sortem[0].second == "BERLAND" || (sortem[1].second == "BERLAND" && pre!=1)) return 1;
	return 0;
}

int main () {

int tcount = 0;

for (int i=0; i<5; i++)
{ w[i] = 0; d[i] = 0; l[i] = 0; }
for (int i=0; i<5; i++) {
string a,b;
cin >> a >> b;
int n; char c; int n2;
cin >> n >> c >> n2;
if (mm.find(a) == mm.end()) { inv[tcount] = a; mm[a] = tcount++; }
if (mm.find(b) == mm.end()) { inv[tcount] = b; mm[b] = tcount++; }
if (zmp.find(a) == zmp.end()) zmp[a] = make_pair(n,n2);
else { zmp[a].first += n; zmp[a].second += n2; }
if (zmp.find(b) == zmp.end()) zmp[b] = make_pair(n2,n);
else { zmp[b].first += n2; zmp[b].second += n; }
mcount[a]++; mcount[b]++;

int i1 = mm[a];
int i2 = mm[b];
if (n > n2) { w[i1]++; l[i2]++;  }
else if (n == n2) { d[i1]++; d[i2]++; } else { l[i1]++; w[i2]++; }

}

int mind = mm["BERLAND"];
int ptsB = getpts("BERLAND");
int max1=0; int max2=0;
int opp = 0;
for (int i=0; i<4; i++) {
	if (i==mind) continue;
	if (mcount[inv[i]] == 2) opp = i;
	if (getpts(inv[i]) >= max1) { max2 = max1; max1 = getpts(inv[i]); }
	else if (getpts(inv[i]) > max2) { max2 = getpts(inv[i]); }
}
if (ptsB+3<max2) { cout << "IMPOSSIBLE" << endl; return 0; }

for (int i=0; i<100; i++) {
	if (win(i,opp)) { cout << i << ":" << 0 << endl; return 0;}
}
return 0;

}

#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

#define REP(i,n)    for(int i=1;i<=(n);++i)
#define FOR(i,n)    for(int i=0;i<(n);++i)
#define FORE(i,e,n) for(int i=(e);i<(n);++i)
#define FORF(it, v) for(typeof((v).begin()) it=(v).begin();it!=(v).end();++it)

#define out(v) cout<<(v)<<endl
#define _(A,v) memset(A,v,sizeof(A))
#define all(A)  (A).begin(), (A).end()
#define pb push_back
#define mp make_pair

#define ull long long

struct team {
	int points;
	string name;
	int goals, misseds;
	int games;
	team(int p = 0, string n = "", int g = 0, int m = 0, int gs = 0) {
		points = p;
		name = n;
		goals = g;
		misseds = m;
		games = 0;
	}
	bool operator<(const team &b) const {
			// up
		if(points > b.points) return true;
			// down
		if(points < b.points) return false;
			// equal points, get diff
		int dif_a = goals - misseds;
		int dif_b = b.goals - b.misseds;
		if(dif_a > dif_b) return true;
		if(dif_a < dif_b) return false;
			// equal diff
		if(goals > b.goals) return true;
		if(goals < b.goals) return false;
			// equal goals
		return name < b.name;
	}
};

int main() {
	/*freopen("d.in",  "r", stdin);
	freopen("d.out", "w", stdout);*/

	string name_x, name_y;
	int x, y;
	set<string> teams;
	set<team> table;
	string game[2][5];
	int result[2][5];
	char final[50];

	FOR(i, 5) {
		cin>>name_x>>name_y>>final;
		result[0][i] = atoi(strtok(final, ":"));
		result[1][i] = atoi(strtok(0, ":"));
		game[0][i] = name_x;
		game[1][i] = name_y;
		teams.insert(name_x);
		teams.insert(name_y);
	}
	FORF(it, teams) {
		name_x = *it;
		team t;
		t.name = name_x;
		FOR(i, 5) {
				// local
			if(game[0][i] == name_x) {
					// win
				if(result[0][i] > result[1][i]) {
					t.points += 3;
				}	// draw
				else if(result[0][i] == result[1][i]) {
					t.points += 1;
				}
					// update goals
				t.goals += result[0][i];
				t.misseds += result[1][i];
				t.games++;
			}	// away
			else if(game[1][i] == name_x) {
					// win
				if(result[1][i] > result[0][i]) {
					t.points += 3;
				}	// draw
				else if(result[1][i] == result[0][i]) {
					t.points += 1;
				}
					// update goals
				t.goals += result[1][i];
				t.misseds += result[0][i];
				t.games++;
			}
		}
		table.insert(t);
	}
	team standing[5], tmp[5];
	int pos_x = -1, pos_y = -1;
	int p = 0;
	FORF(it, table) {
		if((*it).games == 2) {
			if(pos_x == -1) pos_x = p;
			else pos_y = p;
		}
		standing[p++] = *it;
	}
	if(tmp[pos_x].name == "BERLAND") {
		for(int i = 0; i <= 10; ++i)
		for(int j = i - 1; j >= 0; --j) {
			memcpy(tmp, standing, sizeof(tmp));
				// win
			tmp[pos_x].points += 3;
			tmp[pos_x].goals += i;
			tmp[pos_x].misseds += j;
			tmp[pos_y].goals += j;
			tmp[pos_y].misseds += i;
			sort(tmp, tmp + 4);

			if(tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") {
				cout << i << ":" << j << endl;
				return 0;
			}
		}
	} else {
		for(int i = 0; i <= 10; ++i)
		for(int j = i - 1; j >= 0; --j) {
			memcpy(tmp, standing, sizeof(tmp));
				// win
			tmp[pos_y].points += 3;
			tmp[pos_y].goals += i;
			tmp[pos_y].misseds += j;
			tmp[pos_x].goals += j;
			tmp[pos_x].misseds += i;
			sort(tmp, tmp + 4);

			if(tmp[0].name == "BERLAND" || tmp[1].name == "BERLAND") {
				cout << i << ":" << j << endl;
				return 0;
			}
		}
	}
	out("IMPOSSIBLE");
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <set>
//#include "print.hpp"

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;

const static int inf = 10000000;
const static int mod = 1000000007;

map<string, int> id;
map<int, string> rid;

int reg(const string& s) {
  if(id.count(s) == 0) {
    int sz = id.size();
    id[s] = sz;
    rid[sz] = s;
  }
  return id[s];
}

int p[4];
int get[4];
int lost[4];
int play[4];
int b;
int o;

void check(int ss, int tt, int u1, int u2, int dir) {
  if(u1 > u2) {
    p[ss] += 3 * dir;
  }else if(u1 < u2) {
    p[tt] += 3 * dir;
  }else {
    p[ss] += dir;
    p[tt] += dir;
  }

  get[ss] += u1*dir;
  get[tt] += u2*dir;
  lost[ss] += u2*dir;
  lost[tt] += u1*dir;
  play[ss] += dir;
  play[tt] += dir;
}

bool comp(int i, int j) {
  if(p[i] != p[j]) {
    return p[i] < p[j];
  }
  if(get[i] - lost[i] != get[j] - lost[j]) {
    return get[i] - lost[i] < get[j] - lost[j];
  }
  if(get[i] != get[j]) {
    return get[i] < get[j];
  }
  return rid[i] > rid[j];
}

bool test(int cur1, int cur2, int now1, int now2) {
  vector<int> rank(4);
  rep(i, 4) {
    rank[i] = i;
  }
  sort(all(rank), comp);
  if(rank[0] == b || rank[1] == b) {
    return false;
  }

  if(cur1 == -1) {
    return true;
  }

  if(cur1 - cur2 > now1 - now2) {
    return true;
  }
  if(cur2 > now2) {
    return true;
  }
  return false;

}

int main(){
  memset(p, 0, sizeof(p));
  memset(get, 0, sizeof(get));
  memset(lost, 0, sizeof(lost));
  memset(play, 0, sizeof(play));
  rep(i, 5) {
    string s, t, u; cin >> s >> t >> u;
    int ss = reg(s);
    int tt = reg(t);
    int u1 = u[0]-'0';
    int u2 = u[2]-'0';
    check(ss, tt, u1, u2, 1);
  }

  b = id["BERLAND"];
  rep(i, 4) {
    if(play[i] == 2 && i != b) {
      o = i;
      break;
    }
  }

  int ans1 = -1;
  int ans2 = -1;

  rep(i, 100) {
    for(int j = 0; j < i; ++j) {
      check(b, o, i, j, 1);
      if(test(ans1, ans2, i, j)) {
	ans1 = i;
	ans2 = j;
      }
      check(b, o, i, j, -1);
    }
  }

  if(ans1 == -1) {
    cout << "IMPOSSIBLE" << endl;
  }else {
    cout << ans1 << ":" << ans2 << endl;
  }

  return 0;
}

/* DOAN Minh Quy
** mquy.doan@gmail.com
** problem:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int64 long long
#define MAXN 100111
typedef pair<int,int> ii;
/*----------------------------------*/
map<string,int> goal,score,diff;
set<string> ex,xx;
vector<string> team;
bool mycmp(string a,string b){
    if ( score[a] != score[b] ){
        return score[a] > score[b];
    }
    if ( diff[a] != diff[b] ){
        return diff[a] > diff[b];
    }
    if ( goal[a] != goal[b] ){
        return goal[a] > goal[b];
    }
    return a < b;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    #endif
    char ff[22],ss[22],line[100],*token;
    int fc,sc;
    string bl = "BERLAND", op ;
    for(int i = 0 ; i < 5 ; i++){
        gets(line);
        token = strtok(line," :");
        strcpy(ff,token);
        token = strtok(NULL," :");
        strcpy(ss,token);
        token = strtok(NULL," :");
        fc = atoi(token);
        token = strtok(NULL," :");
        sc = atoi(token);
        //-------------------------
        if ( ex.find(ff) == ex.end() ){
            ex.insert(ff);
            team.push_back(ff);
        }
        if ( ex.find(ss) == ex.end() ){
            ex.insert(ss);
            team.push_back(ss);
        }
        if ( fc > sc ){
            score[ff] += 3;
        }else if ( fc == sc ){
            score[ff] += 1;
            score[ss] += 1;
        }else{
            score[ss] += 3;
        }
        goal[ff] += fc , goal[ss] += sc;
        diff[ff] += fc - sc , diff[ss] += sc - fc;
        if ( strcmp(ff,bl.c_str()) == 0 ){
            xx.insert(ss);
        }
        if ( strcmp(ss,bl.c_str()) == 0 ){
            xx.insert(ff);
        }
    }
    xx.insert(bl);

    for(int i = 0 ; i < team.size() ; i++){
        if ( xx.find(team[i]) == xx.end() ){
            op = team[i];
        }
    }
    sort(team.begin(),team.end(),mycmp);
    int curr = score[bl] + 3;
    if ( curr < score[team[1]] ){
        puts("IMPOSSIBLE");
    }else{
        int v1 = 0 , v2 = 10;
        while(true){
            if ( v1 > v2 ){
                score[bl] += 3;
            }else if ( fc == sc ){
                score[bl] += 1;
                score[op] += 1;
            }else {
                score[op] += 3;
            }
            goal[bl] += v1 , goal[op] += v2;
            diff[bl] += v1 - v2 , diff[op] += v2 - v1;
            sort(team.begin(),team.end(),mycmp);
            if ( team[0] == bl || team[1] == bl ){
                break;
            }
//          printf("%d v\n",v1);
//          for(int i = 0 ; i< team.size() ; i++){
//              cout << team[i] << " " << score[team[i]] <<" " << diff[team[i]] << " " << goal[team[i]] << endl;
//          }
//          puts("");
            if ( v1 > v2 ){
                score[bl] -= 3;
            }else if ( fc == sc ){
                score[bl] -= 1;
                score[op] -= 1;
            }else {
                score[op] -= 3;
            }
            goal[bl] -= v1 , goal[op] -= v2;
            diff[bl] -= v1 - v2 , diff[op] -= v2 - v1;
            if ( v2 ) --v2 ;
            else ++v1;
        }
        printf("%d:%d\n",v1,v2);
    }
    return 0;
}

#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <queue>
#include <vector>
#include <math.h>
#include <string>
#include <set>
#include <map>
#define ll long long
using namespace std;
map<string,int> tr,to;
struct node
{
	string nam;
	int poi,get,los;
}a[9],b[9];
struct CC
{
	string n1,n2;
	int nn1,nn2;
	int s,t;
}ar[9];
bool cmp(node a,node b)
{
	if(a.poi!=b.poi) return a.poi>b.poi;
	int ca=a.get-a.los;
	int cb=b.get-b.los;
	if(ca!=cb) return ca>cb;
	if(a.get!=b.get) return a.get>b.get;
	return a.nam<b.nam;
}
bool check()
{
	for(int i=1;i<5;i++) a[i].poi=a[i].get=a[i].los=0;
	for(int i=0;i<6;i++)
	{
		int h1=ar[i].nn1;
		int h2=ar[i].nn2;
		if(ar[i].s==ar[i].t)
		{
			a[h1].poi++;
			a[h2].poi++;
		}else
		if(ar[i].s>ar[i].t)
		{
			a[h1].poi+=3;
		}else
		{
			a[h2].poi+=3;
		}
		a[h1].get+=ar[i].s;
		a[h2].los+=ar[i].s;
		a[h2].get+=ar[i].t;
		a[h1].los+=ar[i].t;
	}
	memcpy(b,a,sizeof(a));
	sort(b+1,b+5,cmp);
	return b[2].nam==string("BERLAND")||b[1].nam==string("BERLAND");
}
int main()
{
	int id=1;
	for(int i=0;i<5;i++)
	{
		cin>>ar[i].n1>>ar[i].n2;
		if(tr[ar[i].n1]==0)to[ar[i].n1]=id++,a[id-1].nam=ar[i].n1;
		if(tr[ar[i].n1]) tr[ar[i].n1]++;
		else tr[ar[i].n1]=1;
		if(tr[ar[i].n2]==0)to[ar[i].n2]=id++,a[id-1].nam=ar[i].n2;
		if(tr[ar[i].n2]) tr[ar[i].n2]++;
		else tr[ar[i].n2]=1;
		tr[ar[i].n2]++;
		ar[i].nn1=to[ar[i].n1];
		ar[i].nn2=to[ar[i].n2];
		scanf("%d",&ar[i].s);
		getchar();
		cin>>ar[i].t;
	}
	for(int i=1;i<=4;i++)
	if(tr[a[i].nam]!=3&&a[i].nam!=string("BERLAND"))
	{
		ar[5].n1=string("BERLAND");
		ar[5].n2=a[i].nam;
		ar[5].nn1=to[ar[5].n1];
		ar[5].nn2=to[ar[5].n2];
	}
	int s,t=-1;

	for(int l=1;l<=31;l++)
	{
		for(int j=0;j+l<=31;j++)
		{
			int i=j+l;
			ar[5].s=j+l;
			ar[5].t=j;
			if(check()&&(t==-1))
			{
				s=i;
				t=j;
				break;
			}
		}
		if(t+1)break;
	}
	if(t+1) printf("%d:%d\n",s,t);
	else puts("IMPOSSIBLE");
	//puts("?");
	return 0;
}

#include <bits\stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f,maxn=5;
struct team
{
	int sc;
	int w;
	int tw;
};
int t[maxn],n,m,ts[maxn],x,y;
map <string,team> mp;
map<string,int> ps;
string s[4];
bool win(string a,string b)
{
    if(mp[a].sc!=mp[b].sc)
        return mp[a].sc>mp[b].sc;
    if(mp[a].w!=mp[b].w)
        return mp[a].w>mp[b].w;
    if(mp[a].tw!=mp[b].tw)
        return mp[a].tw>mp[b].tw;
    return a<b;
}
bool check(int wi,int wj)
{
	if(wi==wj)
	{
		mp[s[x]].sc++;
		mp[s[y]].sc++;
	}
	else
	{
		mp[s[y]].sc+=3;
	}
	mp[s[y]].w+=wi-wj;
	mp[s[y]].tw+=wi;
	mp[s[x]].w-=wi-wj;
	mp[s[x]].tw+=wj;
//	cout<<mp[s[0]].sc<<" "<<mp[s[0]].w<<" "<<mp[s[0]].tw<<endl;	cout<<mp[s[1]].sc<<" "<<mp[s[1]].w<<" "<<mp[s[1]].tw<<endl;
//	cout<<mp[s[3]].sc<<" "<<mp[s[3]].w<<" "<<mp[s[3]].tw<<endl;
	int rank=0;
	for(int i=0;i<4;i++)
	{
		if(i==y)
			continue;
		if(!win(s[y],s[i]))
			rank++;
	}
//	cout<<rank<<endl;
	if(wi==wj)
	{
		mp[s[x]].sc--;
		mp[s[y]].sc--;
	}
	else
	{
		mp[s[y]].sc-=3;
	}
	mp[s[y]].w-=wi-wj;
	mp[s[y]].tw-=wi;
	mp[s[x]].w+=wi-wj;
	mp[s[x]].tw+=wj;
	if(rank>=2)
		return false;
	return true;
}
int main()
{
	int i,j,k=0,ans=0;
	for(i=1;i<=5;i++)
	{
		string s1,s2,s3;
		cin>>s1>>s2>>s3;
		int f=0;
		for(j=0;j<4;j++)
			if(s1==s[j])
				f=1;
		if(!f)
		s[k++]=s1;
		f=0;
		for(j=0;j<4;j++)
			if(s2==s[j])
				f=1;
		if(!f)
		s[k++]=s2;
		ps[s1]++;
		ps[s2]++;
		int g1,g2;
		g1=s3[0]-'0';
		g2=s3[2]-'0';
		if(g1>g2)
		{
			mp[s1].sc+=3;
			mp[s1].w+=g1-g2;
			mp[s2].w-=g1-g2;
			mp[s1].tw+=g1;
			mp[s2].tw+=g2;
		}
		if(g1==g2)
		{
			mp[s1].sc++;
			mp[s2].sc++;
		}
		if(g1<g2)
		{
			mp[s2].sc+=3;
			mp[s2].w+=g2-g1;
			mp[s1].w-=g2-g1;
			mp[s2].tw+=g2;
			mp[s1].tw+=g1;
		}
	}
	for(i=0;i<4;i++)
	{
		cout<<s[i]<<endl;
		if(ps[s[i]]==2 && s[i]!="BERLAND")
			x=i;
		if(s[i]=="BERLAND")
			y=i;
	}
	for(i=1;i<=20;i++)
	{
		for(j=0;j<=100;j++)
			if(check(j+i,j))
			{
				cout<<i+j<<":"<<j;return 0;
			}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <iostream>

using namespace std;

struct node{
    char t_n[30];
    int g,m,dis,grade;
}team[4],tt[4];

struct node1{
    char t_a[30],t_b[30];
    int g_a,g_b;
}board[5];

int cnt[4];

bool cmp(node a,node b)
{
    if (a.grade != b.grade)
    {
        return a.grade > b.grade;
    }
    else
    {
        if (a.dis != b.dis)
        {
            return a.dis > b.dis;
        }
        else
        {
            if (a.g != b.g)
            {
                if(strcmp(a.t_n,b.t_n))
                    return false;
                return true;
            }
        }
    }
}

int main()
{
    int i,j,fi = 0,t_a,t_b,t_e,t_s,big_n;
    bool flag;
    for (i = 0 ;i < 4; i++)
    {
        team[i].grade = 0;
    }
    for (i = 0; i < 5; i++)
    {
        scanf(" %s %s %d:%d",board[i].t_a,board[i].t_b,&board[i].g_a,&board[i].g_b);
        flag = false;
        for (j = 0; j < fi; j++)
        {
            if (strcmp(team[j].t_n,board[i].t_a)==0)
            {
                flag = true;
                t_a = j;
            }
        }
        if (!flag)
        {
            strcpy(team[fi].t_n,board[i].t_a);
            t_a = fi++;
        }
        flag = false;
        for (j = 0; j < fi; j++)
        {
            if (strcmp(team[j].t_n,board[i].t_b) == 0)
            {
                flag = true;
                t_b = j;
            }
        }
        if (!flag)
        {
            strcpy(team[fi].t_n,board[i].t_b);
            t_b = fi++;
        }
        team[t_a].g += board[i].g_a;
        team[t_a].m += board[i].g_b;
        team[t_b].g += board[i].g_b;
        team[t_b].m += board[i].g_a;
        if (board[i].g_a > board[i].g_b)
        {
            team[t_a].grade +=3;
        }
        else if (board[i].g_a < board[i].g_b)
        {
            team[t_b].grade +=3;
        }
        else
        {
            team[t_a].grade +=1;
            team[t_b].grade +=1;
        }
        cnt[t_a]++;
        cnt[t_b]++;
    }
    for (i = 0 ; i < 4; i++)
    {
        if (strcmp(team[i].t_n,"BERLAND") == 0)
        {
            t_s = i;
            team[i].grade += 3;
        }
        if (cnt[i]<3 && strcmp(team[i].t_n,"BERLAND"))
        {
            t_e = i;
        }
    }
    flag = false;
    big_n = 0;
    for (i = 0; i < 4; i++)
    {
        if (i != t_s)
        {
            if (team[t_s].grade >= team[i].grade)
            {
                big_n++;
            }
        }
    }
    if (big_n >= 2)
    {
        flag = true;
    }
    if (flag)
    {
        for (i = 1; i <= 100 ; i++)
        {
            flag = false;
            for (j = 0; j < 4; j++)
            {
                tt[j] = team[j];
            }
            tt[t_s].g+=i;
            tt[t_e].m+=i;
            for (j = 0; j < 4; j++)
            {
                tt[j].dis = tt[j].g - tt[j].m;
            }
            sort(tt,tt+4,cmp);
            for (j = 0; j < 4; j++)
            {
                if (strcmp(tt[j].t_n,"BERLAND")==0)
                {
                    break;
                }
            }
            if (j < 2)
            {
                flag = true;
//              for (int bb = 0;bb<4;bb++)
//              {
//                  printf("%s  %d %d\n",tt[bb].t_n,tt[bb].dis,tt[bb].g);
//              }
                break;
            }
        }
        if (flag)
        {
            printf("%d:0\n",i);
        }
        else
        {
            printf("IMPOSSIBLE\n");
        }
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  eps      0.00000001
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   inf        0x7fffffff
#define    PI        3.1415926535897932384626433832795
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    vi       vector<int>
#define    vd       vector<double>
#define    vvi      vector< vector<int> >
#define    vvll      vector< vector<long long> >
#define    vvpi     vector< vector< pair<int,int> > >
#define    vvpll     vector< vector< pair<long long,long long> > >
#define    vvd      vector< vector<double> >
#define    vs       vector<string>
#define    vvs      vector< vector<string> >
#define     vc        vector<char>
#define     vpi        vector< pair<int ,int> >
#define      pi        pair<int ,int>
#define      pll       pair<long long ,long long>
#define     vpd        vector< pair<double ,double> >
#define     vpll        vector< pair<long long ,long long> >
#define    vll       vector<long long>
#define    dqi        deque< int >
#define     si         set<int>
#define     spi        set< pair<int ,int > >
#define     row          vector< ll >
#define     matrix            vector< row >
#define    lp(i,n)    for(i=0;i<n;i++)
#define     si         set<int>
#define    oo         9000000000000000000
#define   MOD         1000000007
#define    X            real
#define    Y            imag
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define    scani(n)                  scanf("%d",&n)
#define    scanll(n)                  scanf("%I64d",&n)
#define    printi(n)                 printf("%d",n)
#define    printll(n)                 printf("%I64d",n)
#define    scand(n)                  scanf("%lf",&n)
#define    printd(n)                 printf("%lf",n)
#define    scans(n)                  scanf("%s",&n)
#define    prints(n)                 printf("%s",n)
typedef  long long     ll ;
typedef  unsigned long long ull;
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

map< string ,pair<int ,pi> > mb;
map<string, int> vis;

int main()
{

    vector< pair<  pair<  pair<int ,int>  ,int  > , string > > v;

    for(int i=0;i<5;i++)
    {

        string st1,st2;
        int s1,s2;

        cin>>st1>>st2;

        if(st1=="BERLAND")
            vis[st2]=1;
        if(st2=="BERLAND")
            vis[st1]=1;

        scanf("%d:%d",&s1,&s2);

        mb[st1].first+=s1;
        mb[st1].second.first+=s2;

        if(s1>s2)
            mb[st1].second.second+=3;
        else if(s1==s2)
        {
            mb[st1].second.second+=1;
            mb[st2].second.second+=1;
        }
        else
            mb[st2].second.second+=3;

        mb[st2].first+=s2;
        mb[st2].second.first+=s1;

    }

    for(auto i=mb.begin();i!=mb.end();i++)
    {
        string st=(*i).first;
        int go=(*i).second.first;
        int miss=(*i).second.second.first;
        int points=(*i).second.second.second;

        v.pb(mp(mp(mp(points,go-miss),go),st));

    }

    sort(all(v));

    string name="BERLAND";
   int miss=mb[name].second.first;
   int  goals=mb[name].first;
   int points=mb[name].second.second;
 //cout<<miss<<" "<<goals<<" "<<points<<endl;

for(int x=1;x<=150;x++)
{
    int cnt=0;

     goals+=x;

     int diff=goals-miss;

     points+=3;

  for(int j=0;j<sz(v);j++)
 {
     if(v[j].second==name||vis[v[j].second]==1)
        continue;

     v[j].first.first.second-=x;

    cnt=0;

    int cr=0;
    for(int i=0;i<sz(v);i++)
    {
        int d=v[i].first.first.second;
        int go=v[i].first.second;
        string nm=v[i].second;
        int pt=v[i].first.first.first;

        if(nm==name)
            continue;

  //  if(x==10)
//<<nm<<" "<<d<<" "<<go<<" "<<pt<<endl<<goals<<" "<<points<<" "<<diff<<endl;
        if(pt>points)
        cnt++;
        else if(pt==points&&d>diff)
        cnt++;
        else if(pt==points&&d==diff&&go>goals)
        {
           int  f=go-goals;
              cr+=f;
             goals+=f;
             if(pt==points&&d==diff&&go==goals&&nm<name)
                goals++,cr++;
        }

    }

    if(cnt==0||cnt==1)
    {
       // cout<<v[j].second<<endl;
        cout<<x+cr<<":"<<cr;
        return 0;
    }

    v[j].first.first.second+=x;

  }

    goals-=x;
    diff=goals-miss;
     points-=3;

}

   cout<<"IMPOSSIBLE\n";
    }

#include <iostream>
#include <cstdio>

#include <cstring>
#include <cstdlib>

#include <vector>
#include <string>
#include <set>
#include <map>
#include <deque>
#include <bitset>
#include <utility>

#include <cmath>

#include <algorithm>
using namespace std;

int NUM = 0;
map<string,int> mas;
string names[10];

int get_num(string s) {
	map<string,int>::iterator iter= mas.find(s);
	if (iter  == mas.end()) {
		mas[s] = NUM;
		names[NUM] = s;

		NUM++;
		return mas[s];
	}
	return iter->second;
}

struct tp {
	int g1,g2;
} sm[10][10];

int pl[10];
int root,o_root;
int N = 6;

struct tmm {
	int score,diff,zab;
	string name;
} ms[10];

bool operator < (const tmm &a, const tmm &b) {
	if (a.score > b.score) return true;
	if (a.score < b.score) return false;

	if (a.diff > b.diff) return true;
	if (a.diff < b.diff) return false;

	if (a.zab > b.zab) return true;
	if (a.zab < b.zab) return false;

	return a.name < b.name;
}

int calc_place() {
	for (int i=0; i<N; i++) {
		ms[i].score = 0;
		ms[i].diff = 0;
		ms[i].zab = 0;
		ms[i].name = names[i];

		for (int j=0; j<N; j++)
			if (j!=i) {
				if (sm[i][j].g1 > sm[i][j].g2) ms[i].score += 3;
				else if (sm[i][j].g1 == sm[i][j].g2) ms[i].score += 1;

				ms[i].diff += sm[i][j].g1 - sm[i][j].g2;
				ms[i].zab += sm[i][j].g1;
			}
	}

	sort(ms,ms+N);

	for (int i=0; i<N; i++)
		if (ms[i].name == "BERLAND")
			return i;
}

int main() {
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	for (int i=0; i<5; i++) {
		string s1,s2,s3;
		int g1,g2;

		cin>>s1>>s2>>s3;
		sscanf(s3.c_str(),"%d:%d",&g1,&g2);

		int v1 = get_num(s1);
		int v2 = get_num(s2);

		sm[v1][v2].g1 = g1;
		sm[v1][v2].g2 = g2;

		sm[v2][v1].g1 = g2;
		sm[v2][v1].g2 = g1;

		if (s1 == "BERLAND") root = v1;
		if (s2 == "BERLAND") root = v2;

		pl[v1]++;
		pl[v2]++;
	}

	for (int i=0; i<N; i++)
		if (pl[i] < 3 && i!=root)
			o_root = i;

	int ans_x = -1,ans_y = -1;
	int mn = 1000000000;
	int mn_y = mn;

	for (int x=0; x<=500; x++)
		for (int y = 0; y<=500; y++)
			if (x > y) {
				sm[root][o_root].g1 = x;
				sm[root][o_root].g2 = y;

				sm[o_root][root].g1 = y;
				sm[o_root][root].g2 = x;

				int P = calc_place();

				if (P<=1) {
					if (x-y<mn || (x-y == mn && y<mn_y)) {
						mn = x-y;
						ans_x = x;
						ans_y = y;

						mn_y = y;
					}
				}
			}

	if (ans_x == -1) printf("IMPOSSIBLE");
	else printf("%d:%d",ans_x,ans_y);
	return 0;
}

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cmath>

// using
using namespace std;

// typedef
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;
typedef vector<long> VL;
typedef long long LL;
typedef vector<LL> VLL;

// container utils
#define PB push_back
#define PF push_front
#define GRT(x) greater<(x)>()
#define ASORT(x) sort((x).begin(), (x).end())
#define DSORT(x, y) sort((x).begin(), (x).end(), greater<(y)>())
#define FILL(x, y) fill((x).begin(), (x).end(), (y))
#define COPY(x, y) (y).clear(); \
  copy((x).begin(), (x).end(), back_inserter(y))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORL(i, a, b) for (long i = (a); i < (b); i++)
#define FORLL(i, a, b) for (LL i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REPL(i, n) FORL(i, 0, n)
#define REPLL(i, n) FORLL(i, 0, n)

// output
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define P(x) cout << (x) << endl

// static const
static const double EPS = 1e-10;
static const double PI = 6.0 * asin(0.5);

// debug
#define DUMP(a) cerr << #a << " = " << (a) << endl
#define DUMP2(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << endl
#define DUMP3(a, b, c) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << ", " << #c << " = " << (c) << endl

class Team {
public:
  string name;
  int point;
  int plus;
  int minus;
  int game;
};

void mysort(vector<Team>::iterator start,
		      vector<Team>::iterator end) {
  vector<Team>::iterator count, swap_a, swap_b;
  advance( end , -1 );
  for(count = start; count != end; count++) {
    for(swap_a = end; swap_a != count; swap_a--) {
      swap_b = swap_a;
      advance( swap_b , -1 );
      int bp = (*swap_b).point;
      int ap = (*swap_a).point;
      if (bp < ap) {
	iter_swap(swap_a, swap_b);
      } else if (bp == ap) {
	int db = (*swap_b).plus - (*swap_b).minus;
	int da = (*swap_a).plus - (*swap_a).minus;
	if (db < da) {
	  iter_swap(swap_a, swap_b);
	} else if (db == da) {
	  int bplus = (*swap_b).plus;
	  int aplus = (*swap_a).plus;
	  if (bplus < aplus) {
	    iter_swap(swap_a, swap_b);
	  } else if (bplus == aplus) {
	    if ((*swap_b).name > (*swap_a).name) {
	      iter_swap(swap_a, swap_b);
	    }
	  }
	}
      }
    }
  }
}

void solve() {
  vector<Team> vt;
  string na, nb, sc;

  REP(i, 5) {
    cin >> na >> nb >> sc;
    int sca = sc[0] - '0';
    int scb = sc[2] - '0';
    int pa, pb;
    if (sca == scb) {
      pa = 1;
      pb = 1;
    } else {
      pa = (sca > scb) ? 3 : 0;
      pb = (scb > sca) ? 3 : 0;
    }

    vector<Team>::iterator it;
    bool fa = false, fb = false;
    for (it = vt.begin(); it != vt.end(); it++) {
      if ((*it).name == na) {
	(*it).plus += sca;
	(*it).minus += scb;
	(*it).point += pa;
	(*it).game++;
	fa = true;
      }
      if ((*it).name == nb) {
	(*it).plus += scb;
	(*it).minus += sca;
	(*it).point += pb;
	(*it).game++;
	fb = true;
      }
    }
    if (fa == false) {
      Team t;
      t.name = na;
      t.point = pa;
      t.plus = sca;
      t.minus = scb;
      t.game = 1;
      vt.PB(t);
    }
    if (fb == false) {
      Team t;
      t.name = nb;
      t.point = pb;
      t.plus = scb;
      t.minus = sca;
      t.game = 1;
      vt.PB(t);
    }
  }

  // sort
  mysort(vt.begin(), vt.end());

  vector<Team>::iterator it;
//   for (it = vt.begin(); it != vt.end(); it++) {
//     DUMP2((*it).name, (*it).point);
//     DUMP3((*it).plus, (*it).minus, (*it).game);
//   }

  Team t1, t2, tb, te;
  t1 = vt[0];
  t2 = vt[1];
  int inb, ine, in = 0;
  for (it = vt.begin(); it != vt.end(); in++, it++) {
    if ((*it).name == "BERLAND") {
      tb = (*it);
      inb = in;
    } else if ((*it).game == 2) {
      te = (*it);
      ine = in;
    }
  }

  if (t2.point - tb.point < 0) {
    P("0:0");
    return;
  }

  if (t2.point - tb.point > 3) {
    P("IMPOSSIBLE");
    return;
  }

  int x, y, z;
  int max = 100;
  int ans1 = max, ans2 = 0;
  for (x = max; x >= 0; x--) {
    for (y = 0; y < x; y++) {
      if (x == y) continue;
      vector<Team> cp = vt;
      cp[inb].plus += x;
      cp[inb].minus += y;
      cp[ine].plus += y;
      cp[ine].minus += x;
      if (x > y) {
	cp[inb].point += 3;
      } else if (x == y) {
	cp[inb].point++;
	cp[ine].point++;
      }
      mysort(cp.begin(), cp.end());
      if (cp[1].name == "BERLAND" || cp[0].name == "BERLAND") {
	if (x - y <= ans1 - ans2) {
	  ans1 = x;
	  ans2 = y;
// 	  cout << ans1 << " " << ans2 << endl;
// 	  for (it = cp.begin(); it != cp.end(); it++) {
// 	    DUMP2((*it).name, (*it).point);
// 	    DUMP3((*it).plus, (*it).minus, (*it).game);
// 	  }
// 	  cout << endl;
	}
      }
    }
  }

  cout << ans1 << ":" << ans2 << endl;
}

int main(int argc, char *argv[]) {
  solve();

  return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
map<string,pair<int,pair<int,int> > > cnt;
map<string,int> pnt;
string s,s1;
void inc1(int a,int b,int e = 1)
{
    if (a > b)
        pnt[s] += 3 * e;
    else if (a == b)
    {
        pnt[s] += 1 * e;
        pnt[s1] += 1 * e;
    }
    else
        pnt[s1] += 3 * e;
}
bool prd(const pair<string,pair<int,pair<int,int> > > &a,const pair<string,pair<int,pair<int,int> > > &b)
{
    if (a.second.first > b.second.first)
        return true;
    else if(a.second.first == b.second.first)
    {
        int dfa = (a.second.second.first - a.second.second.second);
        int dfb = (b.second.second.first - b.second.second.second);
        if (dfa > dfb)
            return true;
        else if (dfa == dfb)
        {
            int za = a.second.second.first;
            int zb = b.second.second.first;
            if (za > zb)
                return true;
            else if(za == zb)
            {
                if (a.first < b.first)
                    return true;
                else
                    return false;
            }
            else
                return false;

        }
        else
            return false;
    }
    else
        return false;
}
bool pr2(pair<int,int> x,pair<int,int> y)
{
    int a = (x.first - x.second);
    int b = (y.first - y.second);
    if (a < b)
        return true;
    else if(a == b)
    {
        if (x.second < y.second)
            return true;
        else
            return false;
    }
    else
        return false;

}
bool istrue(int x,int y)
{
    inc1(x,y);
    cnt[s].first++;
    cnt[s].second.first += x;
    cnt[s].second.second += y;
    cnt[s1].first++;
    cnt[s1].second.first += y;
    cnt[s1].second.second += x;

    vector<pair<string,pair<int,pair<int,int> > > > data;
    map<string,pair<int,pair<int,int> > >::iterator it = cnt.begin();
    for (; it != cnt.end(); it++)
    {
        string a = it->first;
        data.push_back(make_pair(a,make_pair(pnt[a],make_pair(it->second.second.first,it->second.second.second))));
    }
    bool f = false;
    sort(data.begin(),data.end(),prd);
    if (data[0].first == s || data[1].first == s)
        f = true;
    cnt[s].first--;
    cnt[s].second.first -= x;
    cnt[s].second.second -= y;
    cnt[s1].first--;
    cnt[s1].second.first -= y;
    cnt[s1].second.second -= x;
    inc1(x,y,-1);
    return f;
}
int main()
{
    freopen ("input.txt","r",stdin);
    for (int i = 0; i < 5; i++)
    {
        cin >> s >> s1;
        int a = 0,b = 0;
        scanf ("%d:%d",&a,&b);
        cnt[s].first++;
        cnt[s].second.first += a;
        cnt[s].second.second += b;

        cnt[s1].first++;
        cnt[s1].second.first += b;
        cnt[s1].second.second += a;
        if (a > b)
            pnt[s] += 3;
        else if (a == b)
        {
            pnt[s]++;
            pnt[s1]++;
        }
        else
            pnt[s1] += 3;

    }
    s = "BERLAND";
    map<string,pair<int,pair<int,int> > >::iterator it = cnt.begin();
    for (; it != cnt.end(); it++)
    {
        if (it->first != s && it->second.first == 2)
        {
            s1 = it->first;
            break;
        }
    }
    vector<pair<int,int> > pr;
    for (int x = 1; x <= 50; x++)
    {
        for (int y = x - 1; y >= 0; y--)
        {
            //x > y
            if (istrue(x,y))
            {
                pr.push_back(make_pair(x,y));
            }
        }
    }
    if (pr.empty())
    {
        printf ("IMPOSSIBLE");
        return 0;
    }
    sort(pr.begin(),pr.end(),pr2);
    printf ("%d:%d",pr[0].first,pr[0].second);
    return 0;
}

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
const int N = 5005;
struct node
{
    char name[25];
    int p, s, m;
    bool operator < (const node &T) const
    {
        if (p > T.p) return 1;
        if (p < T.p) return 0;
        if (s - m > T.s - T.m) return 1;
        if (s - m < T.s - T.m) return 0;
        if (s > T.s) return 1;
        if (s < T.s) return 0;
        return strcmp (name, T.name) < 0;
    }
}team[4], team1[4];
int get_p (char s1, char s2)
{
    if (s1 > s2) return 3;
    if (s1 == s2) return 1;
    return 0;
}
int main()
{
    char s[5][3][25]; int i, j, k, id, p, cnt[6];
    while (scanf ("%s", s[0][0]) == 1)
    {
        for (j = 1; j < 3; j ++) scanf ("%s", s[0][j]);
        for (i = 1; i < 5; i ++) for (j = 0; j < 3; j ++) scanf ("%s", s[i][j]);

        for (i = 0; i < 4; i ++) team[i].p = team[i].s = team[i].m = cnt[i] = 0;

        for (i = 0 , id = -1; i < 5; i ++)
        for (p = get_p (s[i][2][0], s[i][2][2]), j = 0; j < 2; j ++)
        {
            for (k = 0; k <= id; k ++)
            if (!strcmp (s[i][j], team[k].name)) break;

            if (k > id) strcpy (team[k = ++ id].name, s[i][j]);
            if (!j)
            {
                team[k].p += p;
                team[k].s += s[i][2][0] - '0';
                team[k].m += s[i][2][2] - '0';
            }
            else
            {
                if (p == 1) team[k].p ++; else team[k].p += 3 - p;
                team[k].s += s[i][2][2] - '0';
                team[k].m += s[i][2][0] - '0';
            }
            cnt[k] ++;
        }
        for (i = 0; i < 4; i ++)
        if (cnt[i] < 3)
        {
            if (!strcmp (team[i].name, "BERLAND")) j = i;
            else k = i;
        }
        for (i = 0; i < 4; i ++) if (!strcmp (team[i].name, "BERLAND")) break;
        if (i < 2) {puts ("1:0");continue;}
        //if (team[1].p > team[i].p + 3) {puts ("IMPOSSIBLE");continue;}
        team[j].p += 3; team[k].p -= 3;
        for (i = 1;  i <= 100; i ++)
        {
            for (p = 0; p < 4; p ++) team1[p] = team[p];
            team1[j].s += i;
            team1[k].m += i;
            sort (team1, team1 + 4);
            if (!strcmp (team1[0].name, "BERLAND") ||
                !strcmp (team1[1].name, "BERLAND")) {printf ("%d:0\n", i); break;}
        }
        if (i > 100) puts ("IMPOSSIBLE");
    }
    return 0;
}

#include <cstdio>
#include <string>
#include <map>

using namespace std;

struct t_team {
    int score;
    int diff;
    int goal;
    int play;
    string name;
    t_team() {
        score = diff = goal = play = 0;
    }
    bool operator<(const t_team &b) const {
        if(score != b.score) return score < b.score;
        if(diff != b.diff) return diff < b.diff;
        if(goal != b.goal) return goal < b.goal;
        return name < b.name;
    }
} ;

map<string, t_team> teamMap;

int main() {
    for(int i=0; i<5; i++) {
        char t1[30], t2[30];
        int sc1, sc2;
        scanf("%s %s %d:%d", t1, t2, &sc1, &sc2);
        string team1 = t1, team2 = t2;
        teamMap[team1].name = team1;
        teamMap[team2].name = team2;
        if(sc1 > sc2) {
            teamMap[team1].score += 3;
        }
        else if(sc1 < sc2) {
            teamMap[team2].score += 3;
        }
        else {
            teamMap[team1].score += 1;
            teamMap[team2].score += 1;
        }
        teamMap[team1].diff += (sc1-sc2);
        teamMap[team2].diff += (sc2-sc1);
        teamMap[team1].goal += sc1;
        teamMap[team2].goal += sc2;
        teamMap[team1].play += 1;
        teamMap[team2].play += 1;
    }

    int bestX = 1000, bestY = 0;
    string t1 = "BERLAND", t2;
    for(map<string,t_team>::iterator it=teamMap.begin(); it!=teamMap.end(); ++it)
        if(it->second.play < 3 && it->first != t1) {
            t2 = it->first;
            break;
        }
    for(int X=1; X<200; X++)
        for(int Y=0; Y<X; Y++) {
            teamMap[t1].score += 3;
            teamMap[t1].diff += (X-Y);
            teamMap[t1].goal += X;
            teamMap[t2].score += 0;
            teamMap[t2].diff += (Y-X);
            teamMap[t2].goal += Y;
            int count = 0;
            for(map<string,t_team>::iterator it=teamMap.begin(); it!=teamMap.end(); ++it)
                if(teamMap[t1] < it->second) count ++;
            if(count < 2) {
                if(bestX-bestY > X-Y) {
                    bestX = X;
                    bestY = Y;
                }
                else if(bestX-bestY == X-Y && bestY > Y) {
                    bestX = X;
                    bestY = Y;
                }
            }
            teamMap[t1].score -= 3;
            teamMap[t1].diff -= (X-Y);
            teamMap[t1].goal -= X;
            teamMap[t2].score -= 0;
            teamMap[t2].diff -= (Y-X);
            teamMap[t2].goal -= Y;
        }
    if(bestX == 1000) puts("IMPOSSIBLE");
    else printf("%d:%d\n", bestX, bestY);

    return 0;
}

#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<conio.h>
using namespace std;
struct nat{
       string ism;
       int bal,ur,farq,son;
};
struct oyin{
       string a,b;
       int x,y;
};
bool comp_son(nat a, nat b)
{
     return a.son>b.son;
}
bool katta(nat a, nat b){
     if(a.bal>b.bal)return true;
     if(a.bal<b.bal)return false;

     if(a.farq>b.farq)return true;
     if(a.farq<b.farq)return false;

     if(a.ur>b.ur)return true;
     if(a.ur<b.ur)return false;

     if(a.ism<b.ism)return true;
     return false;
}
oyin w[5];
nat a[4];
vector<string>ism;
int ind(string k){
    if(a[0].ism==k)return 0;
    if(a[1].ism==k)return 1;
    if(a[2].ism==k)return 2;
    return 3;
}
int ball(int k1, int k2){
    if(k1==k2)return 1;
    if(k1>k2)return 3;
    return 0;
}

int main()
{
    int i;
    char ch;
    for(i=0;i<5;i++){
       cin>>w[i].a>>w[i].b>>w[i].x>>ch>>w[i].y;
       ism.push_back(w[i].a);
       ism.push_back(w[i].b);
    }
    sort(ism.begin(),ism.end());
    i=1;
    while(i<ism.size())
      if(ism[i]==ism[i-1])ism.erase(ism.begin()+i);
      else i++;
    for(i=0;i<ism.size();i++)a[i].ism=ism[i];
    for(i=0;i<5;i++){
        int in;
        in=ind(w[i].a);
        a[in].bal+=ball(w[i].x,w[i].y);
        a[in].ur+=w[i].x;
        a[in].farq+=(w[i].x-w[i].y);
        a[in].son++;
        in=ind(w[i].b);
        a[in].bal+=ball(w[i].y,w[i].x);
        a[in].ur+=w[i].y;
        a[in].farq-=(w[i].x-w[i].y);
        a[in].son++;
    }
    sort(a,a+4,comp_son);
    if(a[2].ism=="BERLAND")swap(a[2],a[3]);
    a[3].bal=a[3].bal+3;
    int ind_ber=3;
    int ind_old=2;

    if(a[3].bal<a[1].bal){cout<<"IMPOSSIBLE";return 0;}

    int k1=0,k2=0;
    while(true)
    {
       swap(a[2],a[ind_old]);ind_old=2;
       if(katta(a[1],a[0]))swap(a[1],a[0]);
       if(katta(a[2],a[1])){swap(a[2],a[1]);ind_old--;}
       if(katta(a[1],a[0])){swap(a[1],a[0]);ind_old--;}

       a[ind_old].farq--;
       if(a[3].bal>a[1].bal) goto oxir;
       if(a[3].farq>a[1].farq)goto oxir;

       if(a[3].farq<a[1].farq)
       {
          k1++;
          a[ind_old].farq--;
          a[3].farq++;
          a[3].ur++;
          continue;
       }
       if(a[3].ur>a[1].ur)goto oxir;
       if(a[3].ur<a[1].ur)
       {
          k1++;
          k2++;
          a[ind_old].ur++;
          a[3].ur++;
          continue;
       }
       //k1++;
       goto oxir;
    }
    //while(a[3].farq<a[1].farq){k1++;a[in_old].farq--;if(a[1],a[ind_old])}
    oxir:;
    if(!k1)k1=1;
    cout<<k1<<":"<<k2<<endl;
//    system("pause");
    return 0;
}

/*
 * Author:  xioumu
 * Created Time:  2012-6-25 0:02:45
 * File Name: c.cpp
 * solve: c.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
const double esp = 1e-8;
const int maxn = 1007;
typedef long long ll;
char name[200][200];
int m;
struct node{
    int p, in, out, id;

}a[200];
bool operator < (const node &a, const node &b) {
    if(a.p != b.p) return a.p > b.p;
    else if(a.in - a.out != b.in - b.out) return (a.in - a.out) > (b.in - b.out);
    else if(a.in != b.in) return a.in > b.in;
    else return strcmp(name[a.id], name[b.id]) < 0;
}
int find(char *s){
    for(int i = 1; i <= m; i++)
        if(strcmp(s, name[i]) == 0 )
            return i;
    m++;
    strcpy(name[m], s);
    return m;
}
int v[6] = {0};
int main(){
    char s1[200], s2[200];
    int d1, d2;
    m = 0; memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(int t = 1; t <= 5; t++){
        scanf("%s %s %d:%d", s1, s2, &d1, &d2);
       //printf("%s %s %d:%d\n",s1, s2, d1, d2);
        int h1 = find(s1);
        int h2 = find(s2);
        if(d1 > d2){
            a[h1].p += 3;
        }
        else if(d1 == d2){
            a[h1].p++;
            a[h2].p++;
        }
        else a[h2].p += 3;

        a[h1].in += d1;
        a[h1].out += d2;
        a[h2].in += d2;
        a[h2].out += d1;
        v[h1]++;
        v[h2]++;
        a[h1].id = h1;
        a[h2].id = h2;
        //printf("%d %d\n",h1, h2);
    }
    //printf("%d %d\n", a[1].p, a[2].p);
    int s = find("BERLAND"), t;
    for(int i = 1; i <= 4; i++)
        if(v[i] < 3 && s != i)
            t = i;
    node oldh = a[s], oldw = a[t];
    //sort(a + 1, a + 5);
    {
        int ans1 = -1, ans2 = -1;
        for(int i = 1; i <= 100; i++)
            for(int j = i; j <= 100; j++){
                node h = oldh;
                h.p += 3;
                h.in += j;
                h.out += j - i;
                node w = oldw;
                w.in += j - i;
                w.out += j;
                if(i == 1 && j == 1){
                    printf("%d %d %d\n", h.p, h.in, h.out);
                }
                if(h < w){
                    ans1 = j;
                    ans2 = j - i;
                    int ok = 0;
                    for(int i = 1; i <= 4; i++)
                        if(a[i] < h && i != s && i != t)
                            ok++;
                        else if(i == t)
                            if(w < h)
                                ok++;
                    if( ok < 2)
                        goto end;
                }
            }
end:;
        if(ans1 == 100 || ans1 == -1) printf("IMPOSSIBLE\n");
        else printf("%d:%d\n", ans1, ans2);
    }
    return 0;
}

#include<bits/stdc++.h>
#define r "BERLAND"
using namespace std;
int main()
{
map<string,int> defen,jishu,yingqiu,shuqiu;
int x,y,i;char a[28],b[28];
for (i=0;i<5;i++)
  {
  scanf("%s%s%d:%d",a,b,&x,&y);
  jishu[a]++,jishu[b]++;
  if (x>y) defen[a]+=3;
  if (x<y) defen[b]+=3;
  if (x==y) defen[a]++,defen[b]++;
  yingqiu[a]+=x,shuqiu[a]+=y;
  yingqiu[b]+=y,shuqiu[b]+=x;
  }
string nico;
vector<string> duiwu;
for (auto &s:jishu)
  {
  duiwu.push_back(s.first);
  if (s.second==2&&s.first!=r) nico=s.first;
  }
for (i=1;i<100;i++) for (int j=0;j<100;j++)
  {
  int k=i+j;
  yingqiu[r]+=k,shuqiu[r]+=j;
  yingqiu[nico]+=j,shuqiu[nico]+=k;
  defen[r]+=3;
  vector<tuple<int,int,int,string> > v;
  for (auto &s:duiwu) v.push_back(make_tuple(-defen[s],-yingqiu[s]+shuqiu[s],-yingqiu[s],s));
  sort(v.begin(),v.end());
  if (get<3>(v[0])==r||get<3>(v[1])==r) return printf("%d:%d",k,j),0;
  defen[r]-=3,yingqiu[r]-=k,shuqiu[r]-=j;
  yingqiu[nico]-=j,shuqiu[nico]+=k;
  }
printf("IMPOSSIBLE");
}

#include<bits/stdc++.h>
using namespace std;
struct Team{
	int score;
	int lost;
	int get;
	string name;
	operator <(const Team &t2)const{
		if(score!=t2.score)return score>t2.score;
		if(get-lost!=t2.get-t2.lost)return (get-lost)>(t2.get-t2.lost);
		if(get!=t2.get)return get>t2.get;
		return name<t2.name;
	}
};
Team tem[4];
int a,b,cnt;
char x[133],y[133];
bool was[4][4];
map<string,int>mp;
map<string,bool>vis;
int main(){
	for(int i=0;i<4;i++)
		tem[i].score=0,
		tem[i].lost=0,
		tem[i].get=0;
	for(int i=0;i<5;i++){
		scanf("%s %s %d:%d",&x,&y,&a,&b);
		if(!vis[x])mp[x]=cnt++,vis[x]=1;
		if(!vis[y])mp[y]=cnt++,vis[y]=1;
		if(a>b)
			tem[mp[x]].score+=3;
		else if(a==b)
			tem[mp[x]].score+=1,
			tem[mp[y]].score+=1;
		else
			tem[mp[y]].score+=3;
		tem[mp[x]].get+=a;
		tem[mp[x]].lost+=b;
		tem[mp[y]].get+=b;
		tem[mp[y]].lost+=a;
		tem[mp[x]].name=x;
		tem[mp[y]].name=y;
		was[mp[x]][mp[y]]=1;
		was[mp[y]][mp[x]]=1;
	}
	//for(int i=0;i<3;i++)
	//	for(int j=i+1;j<4;j++)
	//		cout<<tem[i].name<<' '<<tem[j].name<<' '<<was[i][j]<<endl;
	//for(int i=0;i<4;i++)
	//	cout<<tem[i].score<<' '<<tem[i].get<<' '<<tem[i].lost<<' '<<tem[i].name<<endl;
	int p1=12345,p2=0;
	for(int xx=0;xx<3;xx++)
		for(int yy=xx+1;yy<4;yy++)
			if(was[xx][yy]==0)
			{
				if(tem[yy].name =="BERLAND")swap(xx,yy);
				for(int i=0;i<100;i++)
					for(int j=0;j<100;j++)
					{
						if(i>j)
							tem[xx].score+=3;
						if(i==j)
							tem[xx].score+=1,
							tem[yy].score+=1;
						if(i<j)
							tem[yy].score+=3;
						tem[xx].get+=i;
						tem[xx].lost+=j;
						tem[yy].get+=j;
						tem[yy].lost+=i;
						//sort(tem,tem+4);
						Team tmp[4];
						for(int k=0;k<4;k++)tmp[k]=tem[k];
						sort(tmp,tmp+4);
						if(i==0&&j==1)
							for(int k=0;k<4;k++)
								cout<<tmp[k].score<<' '<<tmp[k].get<<' '<<tmp[k].lost<<' '<<tmp[k].name<<endl;
						for(int k=0;k<2;k++)
							if(tmp[k].name=="BERLAND"){
								if((i-j)<(p1-p2)||(i<p1))
								{
									p1=i,
									p2=j;
								}
	//							else
	//								cout<<i-j<<' '<<p1-p2<<endl;
							}
						//cout<<i<<' '<<j<<endl;
						if(i>j)
							tem[xx].score-=3;
						if(i==j)
							tem[xx].score-=1,
							tem[yy].score-=1;
						if(i<j)
							tem[yy].score-=3;
						tem[xx].get-=i;
						tem[xx].lost-=j;
						tem[yy].get-=j;
						tem[yy].lost-=i;
					}
					if(p1-p2<10000)
						cout<<max(p1,p2)<<min(p1,p2);
					else
						cout<<"IMPOSSIBLE";
					return 0;
			}
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[20],b[20];
int aa,bb;
struct team{
    char name[20];
    int score;
    int goal;
    int match;
}t[4];
int get(char a[]){
    int i;
    for(i=0;i<4;i++){
        if(!t[i].match){
            strcpy(t[i].name,a);
            break;
        }
        else if(strcmp(a,t[i].name)==0) break;
    }
    return i;
}
void insert(char a[],char b[],int aa,int bb){
    int i=get(a);
    t[i].match++;
    int j=get(b);
    t[j].match++;
    t[i].goal+=aa-bb;
    t[j].goal+=bb-aa;
    if(aa>bb) t[i].score+=3;
    else if(bb>aa) t[j].score+=3;
    else t[i].score++,t[j].score++;
}
void insert(int i,int j,int aa,int bb){
    t[i].goal+=aa-bb;
    t[j].goal+=bb-aa;
    if(aa>bb) t[i].score+=3;
    else if(bb>aa) t[j].score+=3;
}
void init(){
    for(int i=0;i<4;i++){
        t[i].match=t[i].goal=t[i].score=0;
        memset(t[i].name,0,sizeof(t[i].name));
    }
}
bool cmp(team a,team b){
    if(a.score!=b.score) return a.score>b.score;
    if(a.goal!=b.goal) return a.goal>b.goal;
    return strcmp(a.name,b.name)<0;
}
int main(){
    while(~scanf("%s%s%d:%d",a,b,&aa,&bb)){
        init();
        insert(a,b,aa,bb);
        for(int i=0;i<4;i++){
            scanf("%s%s%d:%d",a,b,&aa,&bb);
            insert(a,b,aa,bb);
        }
        int ma=0,min=1000000,mark[2],tail=0;
        team copy[4];
        for(int i=0;i<4;i++){
            copy[i]=t[i];
            //printf("%s %d %d\n",t[i].name,t[i].score,t[i].goal);
            if(t[i].goal>ma) ma=t[i].goal;
            if(t[i].goal<min) min=t[i].goal;
            if(t[i].match==2) mark[tail++]=i;
        }
        ma=ma-min;
        if(strcmp(t[mark[0]].name,"BERLAND")) swap(mark[1],mark[0]);
        bool jud=1;
        for(int i=1;i<=ma&&jud;i++){
            for(int j=0;j<i&&jud;j++){
                //cout<<i<<"  "<<j<<endl;
                for(int k=0;k<4;k++) t[k]=copy[k];
                insert(mark[0],mark[1],i,j);
                sort(t,t+4,cmp);
                //for(int jj=0;jj<4;jj++) printf("%s %d %d\n",t[jj].name,t[jj].score,t[jj].goal);
                if(strcmp(t[0].name,"BERLAND")==0||strcmp(t[1].name,"BERLAND")==0) {
                    printf("%d:%d\n",i,j);
                    jud=0;
                }
            }
        }
        if(jud) printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
using namespace std;
map<string,int> q;
string a = "BERLAND";
int num;
struct node
{
    string name;
    int id , game , goal , miss , point;
    bool operator < ( node x ) const
    {
        if( point != x.point ) return point > x.point;
        else
        {
            if( goal - miss != x.goal - miss ) return ( goal - miss ) > ( x.goal - x.miss );
            else
            {
                if( goal != x.goal ) return goal > x.goal;
                else return name < x.name;
            }
        }
    }
}team[5];
struct pp
{
    int id , p;
    bool operator < ( pp x ) const
    {
        if( p != x.p ) return p < x.p;
        else return id > x.id;
    }
};
void init()
{
    q.clear();
    q[a] = 1;
    num = 2;
    for( int i=1 ; i<5 ; i++ )
    {
        team[i].id = i;
        team[i].game = 0;
        team[i].goal = team[i].miss = team[i].point = 0;
    }
    team[1].name = a;
}
int main()
{
    string b , c;
    int ab , ac , vb , vc;
    init();
    for( int i=0 ; i<5 ; i++ )
    {
        cin>>b>>c;
        scanf( "%d:%d" , &vb , &vc );
        if( !q[b] )
        {
            team[num].name = b;
            q[b] = num++;
        }
        if( !q[c] )
        {
            team[num].name = c;
            q[c] = num++;
        }
        team[ q[b] ].game++;
        team[ q[b] ].goal += vb;
        team[ q[b] ].miss += vc;
        team[ q[c] ].game++;
        team[ q[c] ].goal += vc;
        team[ q[c] ].miss += vb;
        if( vb == vc )
        {
            team[ q[b] ].point++;
            team[ q[c] ].point++;
        }
        else if( vb > vc ) team[ q[b] ].point += 3;
        else if( vb < vc ) team[ q[c] ].point += 3;
    }
    team[1].point += 3;
    sort( team + 1 , team + 5 );
    //for( int i=1 ; i<5 ; i++ ) cout<<team[i].name<<" "<<team[i].id<<" "<<team[i].game<<" "<<team[i].point<<" "<<team[i].goal-team[i].miss<<" "<<team[i].goal<<endl;
    int home , vis;
    for( int i=1 ; i<5 ; i++ )
    {
        if( team[i].game < 3 )
        {
            if( team[i].id == 1 ) home = i;
            else vis = i;
        }
    }
    //cout<<home<<" "<<vis<<endl;
    pp minn[4];
    if( team[home].point < team[2].point ) printf( "IMPOSSIBLE\n" );
    else if( home < 3 || team[home].point > team[2].point ) printf( "1:0\n" );
    else if( team[home].point == team[2].point )
    {
        for( int i=1 ; i<home ; i++ )
        {
            minn[i].id = i;
            minn[i].p = 100000000;
            if( team[home].point == team[i].point )
            {
                minn[i].p = team[i].goal - team[i].miss - ( team[home].goal - team[home].miss );
                if( i == vis )
                {
                    if( minn[i].p % 2 == 1 ) minn[i].p++;
                    minn[i].p /= 2;
                }
            }
            //cout<<i<<" "<<minn[i].p<<endl;
        }
        sort( minn + 1 , minn + home );
        //for( int i=1 ; i<home ; i++ )cout<<i<<" "<<minn[i].id<<" "<<minn[i].p<<endl;
        int t = home - 2;
        int p = minn[t].id;
        //cout<<p<<endl;
        int goals = team[p].goal - team[home].goal;
        //cout<<goals<<endl;
        if( p == vis && ( team[p].goal - team[p].miss - ( team[home].goal - team[home].miss ) ) % 2 == 1 ) printf( "%d:0\n" , minn[t].p );
        else if( minn[t].p > goals ) printf( "%d:0\n" , minn[t].p );
        else if( minn[t].p <= goals )
        {
            if( team[home].name > team[p].name ) goals++;
            printf( "%d:%d\n" , goals , goals - minn[t].p );
        }
    }
    //cin>>ab;
    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define maxn 100005
#define inf 0xfffffff
using namespace std;
char str1[20], str2[20];
struct node {
	int s, w, l;
	int g;
	char name;
}arr[5];
queue<int> que;
int book[5];
bool cmp(node a, node b)
{
	if (a.s != b.s) return a.s > b.s;
	if (a.g != b.g) return a.g > b.g;
	return a.name < b.name;
}
int main()
{
	int x, y;
	for (int i = 1; i <= 5; i++) {
		scanf("%s%s%d:%d", str1, str2, &x, &y);
		if (i == 1) {
			if (x > y) arr[1].s += 3, arr[1].w += x, arr[1].l += y, arr[4].l += x, arr[4].w += y;
			else if (x == y) arr[1].s++, arr[4].s++;
			else arr[4].s += 3, arr[4].w += y, arr[4].l += x, arr[1].l += y, arr[1].w += x;
		}
		else if (i == 2) {
			if (x > y) arr[4].s += 3, arr[4].w += x, arr[4].l += y, arr[3].l += x, arr[3].w += y;
			else if (x == y) arr[4].s++, arr[3].s++;
			else arr[3].s += 3, arr[3].w += y, arr[3].l += x, arr[4].l += y, arr[4].w += x;
		}
		else if (i == 3) {
			if (x > y) arr[3].s += 3, arr[3].w += x, arr[3].l += y, arr[1].l += x, arr[1].w += y;
			else if (x == y) arr[3].s++, arr[1].s++;
			else arr[1].s += 3, arr[1].w += y, arr[1].l += x, arr[3].l += y, arr[3].w += x;
		}
		else if (i == 4) {
			if (x > y) arr[1].s += 3, arr[1].w += x, arr[1].l += y, arr[2].l += x, arr[2].w += y;
			else if (x == y) arr[1].s++, arr[2].s++;
			else arr[2].s += 3, arr[2].w += y, arr[2].l += x, arr[1].l += y, arr[1].w += x;
		}
		else {
			if (x > y) arr[4].s += 3, arr[4].w += x, arr[4].l += y, arr[2].l += x, arr[2].w += y;
			else if (x == y) arr[4].s++, arr[2].s++;
			else arr[2].s += 3, arr[2].w += y, arr[2].l += x, arr[4].l += y, arr[4].w += x;
		}
	}
	for (int i = 1; i <= 4; i++) {
		arr[i].g = arr[i].w - arr[i].l;
		arr[i].name = 'A' + i - 1;
	}
	sort(arr + 1, arr + 5, cmp);
	int tmp;
	for (int i = 1; i <= 4; i++) {
		if (arr[i].name == 'B') {
			tmp = i;
			break;
		}
	}
	int cnt = 0;
	for (int i = 1; i < tmp; i++) {
		if (arr[i].s - arr[tmp].s > 3) cnt++;
	}
	if (cnt >= 2) {
		printf("IMPOSSIBLE\n");
	}
	else {
		int b = 0;
		arr[tmp] . s += 3;
		while (true) {
			if (tmp <= 2) break;
			b++;
			for (int i = 1; i <= 4; i++) {
				if (arr[i].name == 'B') {
					arr[i].g++;
				}
				if (arr[i].name == 'C') {
					arr[i].g--;
				}
			}
			sort(arr + 1, arr + 5, cmp);
			for (int i = 1; i <= 4; i++)
				if (arr[i].name == 'B') tmp = i;
		}
		//for (int i = 1; i <= 4; i++)
			//cout << arr[i].s << ' ' << arr[i].g << ' ' << arr[i].name << endl;
		printf("%d:0\n", b);
	}
	return 0;
}

#include <cstdlib>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

	int i, j, k, idx, idx_b, idx_o;
	string line[5][3];
	string name[5];

	int game[6][4];

bool is_b_1st_or_2nd(int game[6][4], int idx_b){
	int i;
	int point[4], diff[4], score[4], hoge[4];

	for(i = 0; i < 4; i++) point[i] =  score[i] = diff[i] = 0;

	for(i = 0; i < 6; i++){
		if(game[i][2] > game[i][3]) point[game[i][0]] += 3;
		else if(game[i][2] < game[i][3]) point[game[i][1]] += 3;
		else{ point[game[i][0]]++; point[game[i][1]]++; }

		diff[game[i][0]] += game[i][2] - game[i][3];
		diff[game[i][1]] += game[i][3] - game[i][2];
		score[game[i][0]] += game[i][2];
		score[game[i][1]] += game[i][3];
	}

	for(i = 0; i < 4; i++) hoge[i] = 1000000 * point[i] + 1000 * (diff[i] + 500) + 10 * score[i] + (4 - i);
	sort(hoge, hoge + 4);

	/*if(hoge[2] % 10 == idx_b || hoge[3] % 10 == idx_b){
		cout << "-----" << endl;
		for(i = 0; i < 4; i++) cout << i << ":" << name[i] << endl;
		cout << endl;
		cout << "opponent:" << name[idx_o] << endl;
		cout << endl;

		for(i = 0; i < 6; i++) cout << game[i][0] << game[i][1] << game[i][2] << game[i][3] << endl;
		for(i = 0; i < 4; i++) cout << hoge[i] << endl;
	}*/

	return (hoge[2] % 10 == (4 - idx_b) || hoge[3] % 10 == (4 - idx_b));
}

int main(){

	for(i = 0; i < 5; i++){
		string name1, name2, score;
		cin >> name1 >> name2 >> score;
		line[i][0] = name1;
		line[i][1] = name2;
		line[i][2] = score;
	}

	idx = 0;
	for(i = 0; i < 5; i++){
		for(j = 0; j < 2; j++){
			for(k = 0; k < idx; k++) if(line[i][j] == name[k]) break;
			if(k == idx){
				idx++;
				name[k] = line[i][j];
			}
		}
	}
	sort(name, name + 4);
	for(i = 0; i < 4; i++) if(name[i] == "BERLAND") idx_b = i;

	for(i = 0; i < 5; i++){
		for(j = 0; j < 4; j++){
			if(name[j] == line[i][0]) game[i][0] = j;
			if(name[j] == line[i][1]) game[i][1] = j;
		}
		game[i][2] = line[i][2][0] - '0';
		game[i][3] = line[i][2][2] - '0';
	}

	int count[4] = {0, 0, 0, 0};
	for(i = 0; i < 5; i++){
		count[game[i][0]]++;
		count[game[i][1]]++;
	}
	for(i = 0; i < 4; i++){
		if(count[i] == 2 && i != idx_b) idx_o = i;
	}
	game[5][0] = idx_b;
	game[5][1] = idx_o;

	for(i = 1; i <= 100; i++){
		for(j = 0; j < 100 - i; j++){
			game[5][2] = i + j;
			game[5][3] = j;
			if(is_b_1st_or_2nd(game, idx_b)){
				cout << i + j << ":" << j << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;

typedef long long ll;
struct team{
	string name;
	int goles,ptos,games,marca;
	team(string n=""){
		name=n,goles=0,ptos=0,games=0,marca=0;
	}
	bool operator<(const team &t)const{
		return ptos>t.ptos || (ptos==t.ptos && goles>t.goles)
				|| (ptos==t.ptos && goles==t.goles && marca>t.marca)
				|| (ptos==t.ptos && goles==t.goles && marca==t.marca && name<t.name);
	}
};
team ts[5];
map<string,int>mapa;
int pos_berland(){
	for(int i=1;i<=4;i++)
		if(ts[i].name=="BERLAND")
			return i;
	return -1;
}
int pos_otro(string name){
	for(int i=1;i<=4;i++)
		if(ts[i].name==name)
			return i;
	return -1;
}
string equipo(){
	for(int i=1;i<=4;i++)
		if(ts[i].games==2)
			return ts[i].name;
	return "";
}
int main(){
	char n1[100],n2[100];
	int a,b,cont=1;
	int l=5;
	while(l--){
		scanf("%s %s %d:%d",n1,n2,&a,&b);
		int id1=mapa[string(n1)];
		int id2=mapa[string(n2)];
		if(!id1){
			mapa[string(n1)]=cont;
			id1=cont++;
			ts[id1]=team(string(n1));
		}
		if(!id2){
			mapa[string(n2)]=cont;
			id2=cont++;
			ts[id2]=team(string(n2));
		}
		ts[id1].games++;
		ts[id2].games++;
		ts[id1].marca+=a;
		ts[id2].marca+=b;
		if(a==b){
			ts[id1].ptos++;
			ts[id2].ptos++;
		}else if(a>b){
			ts[id1].ptos+=3;
			ts[id1].goles+=a-b;
			ts[id2].goles-=a-b;
		}else{
			ts[id2].ptos+=3;
			ts[id2].goles+=b-a;
			ts[id1].goles-=b-a;
		}
	}
	string na=equipo();
	sort(ts+1,ts+5);
	int p1=pos_berland(),gol=0,p2=pos_otro(na);
	if(p1>2 && ts[2].ptos-3>ts[p1].ptos){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	ts[p1].ptos++;
	ts[p2].ptos++;
	while(p1>2){
		gol++;
		ts[p1].marca++;
		if(gol==1){
			ts[p1].ptos+=2;
			ts[p2].ptos--;
		}
		ts[p1].goles++;
		ts[p2].goles--;
		sort(ts+1,ts+5);
		p1=pos_berland(),p2=pos_otro(na);
		/*for(int i=1;i<=4;i++){
			cout << ts[i].name << endl;
			printf("%d %d %d\n",ts[i].ptos,ts[i].goles,ts[i].marca);
		}
		printf("%d:0\n",gol);*/
	}
	printf("%d:0\n",gol);
}

#include<bits/stdc++.h>
using namespace std;
struct info
{
  int go_w,go_m,point,play;
  string name;

};
struct in
{
  int po,pos;
};
bool my(in a,in b)
{
  if(a.po>b.po);
}
bool my2(info a,info b)
{
    if(a.point>b.point)
        return 1;
    else if(a.point==b.point)
    {
  if((a.go_w-a.go_m)>(b.go_w-b.go_m))
    return 1;
     else if((a.go_w-a.go_m)==(b.go_w-b.go_m))
    {
     if(a.go_w>b.go_w)return 1;
     else if(a.go_w==b.go_w)
     {
         return a.name<b.name;
     }
     }
    }
    return 0;
}
int main()
{
   map<string,int>team;
   team["AERLAND"]=1;
   team["BERLAND"]=2;
   team["CERLAND"]=3;
   team["DERLAND"]=4;
   info lis[10];
   lis[1].name="AERLAND",lis[2].name="BERLAND",lis[3].name="CERLAND",lis[4].name="DERLAND";
   for(int i=1;i<=5;i++)
   {
        lis[i].go_w=lis[i].go_m=lis[i].point=0,lis[i].play=0;
   }
   for(int i=1;i<=5;i++)
   {
        string a, b;int go_1,go_2;
        cin>>a>>b;
        scanf("%d:%d",&go_1,&go_2);
        //cout<<go_1<<" "<<go_2<<endl;
        int d=team[a];
        int e=team[b];
        if(go_1==go_2)
            lis[d].point+=1,lis[e].point+=1;
        if(go_1>go_2)
            lis[d].point+=3;
        else lis[e].point+=3;
      lis[d].go_w+=go_1,lis[d].go_m+=go_2,lis[d].play++;
      lis[e].go_w+=go_2,lis[e].go_m+=go_1,lis[e].play++;
   }
    vector<in>li;
    int paisi;
    for(int i=1;i<=4;i++)
    {
        info te=lis[i];
        if(te.play==2 && te.name!="BERLAND")
            paisi=i;
    }
         vector<info>tea;
     for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
      info temp=tea[1];
    if(temp.point>lis[2].point+3)
    {
         puts("IMPOSSIBLE");return 0;
    }
    else if(temp.point<lis[2].point+3)
    {
      puts("1:0");return 0;
    }
   int x=0,y=0;
   int ca=0;
   while(1)
   {
       //cout<<"pafd\n";
       vector<info>tea;
    for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
     info temp=tea[0],temp2 =tea[1];
     if(temp.name=="BERLAND" || temp2.name=="BERLAND")
     {
        cout<<x<<":"<<y;
        return 0;
     }
     lis[2].go_w++;
     lis[paisi].go_m++;
     if(ca==0)lis[2].point+=3;
     ca++;
     x++;
   }
   return 0;
}

#include<bits/stdc++.h>
using namespace std;
struct info
{
  int go_w,go_m,point,play;
  string name;

};
struct in
{
  int po,pos;
};
bool my(in a,in b)
{
  if(a.po>b.po);
}
bool my2(info a,info b)
{
    if(a.point>b.point)
        return 1;
    else if(a.point==b.point)
    {
  if((a.go_w-a.go_m)>(b.go_w-b.go_m))
    return 1;
     else if((a.go_w-a.go_m)==(b.go_w-b.go_m))
    {
     if(a.go_w>b.go_w)return 1;
     else if(a.go_w==b.go_w)
     {
         return a.name<b.name;
     }
     }
    }
    return 0;
}
int main()
{
   map<string,int>team;
   int cou=0;
   info lis[10];
   for(int i=1;i<=5;i++)
   {
        lis[i].go_w=lis[i].go_m=lis[i].point=0,lis[i].play=0;
   }
   for(int i=1;i<=5;i++)
   {
        string a, b;int go_1,go_2;
        cin>>a>>b;
        scanf("%d:%d",&go_1,&go_2);
       if(team[a]==0)team[a]=++cou;
       if(team[b]==0)team[b]=++cou;
        int d=team[a];
        lis[d].name=a;
        int e=team[b];
        lis[e].name=b;
        if(go_1==go_2)
            lis[d].point+=1,lis[e].point+=1;
       else if(go_1>go_2)
            lis[d].point+=3;
        else lis[e].point+=3;
      lis[d].go_w+=go_1,lis[d].go_m+=go_2,lis[d].play++;
      lis[e].go_w+=go_2,lis[e].go_m+=go_1,lis[e].play++;
   }
   int c=team["BERLAND"];
    vector<in>li;
    int paisi;
    for(int i=1;i<=4;i++)
    {
        info te=lis[i];
        if(te.play==2 && te.name!="BERLAND")
            paisi=i;
    }
         vector<info>tea;
     for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
      info temp=tea[1];
    if(temp.point>lis[c].point+3)
    {
         puts("IMPOSSIBLE");return 0;
    }

   int x=0,y=0;
   int ca=0;
   //cout<<"**************************\n\n\n";
   lis[c].point+=3;
   lis[c].go_w++;
   lis[paisi].go_m++;
   x++;
   while(1)
   {
       //cout<<"pafd\n";
       vector<info>tea;
    for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
     info temp=tea[0],temp2 =tea[1];
//     for(int i=1;i<=4;i++)
//     {
//         info lis_=tea[i-1];
//         cout<<lis_.name<<" "<<lis_.go_w<<" "<<lis_.go_m<<" "<<lis_.point<<" ";
//         cout<<endl;
//     }
//     cout<<endl<<"***********************************\n";
     if(temp.name=="BERLAND" || temp2.name=="BERLAND")
     {
        break;
     }
     lis[c].go_w++;
     lis[paisi].go_m++;
    // if(ca==0)lis[c].point+=3;
     x++;
   }
   int pre=y;
    while(1)
   {
       //cout<<"pafd\n";
       vector<info>tea;
    for(int i=1;i<=4;i++)
        tea.push_back(lis[i]);
    sort(tea.begin(),tea.end(),my2);
     info temp=tea[0],temp2 =tea[1];
//     for(int i=1;i<=4;i++)
//     {
//         info lis_=tea[i-1];
//         cout<<lis_.name<<" "<<lis_.go_w<<" "<<lis_.go_m<<" "<<lis_.point<<" ";
//         cout<<endl;
//     }
//     cout<<endl<<"***********************************\n";
     if((temp.name=="BERLAND" || temp2.name=="BERLAND") && x>y)
     {
        y++;
     }
     else
     {
          cout<<x<<":"<<y-1;return 0;
     }
     lis[c].go_m++;
     lis[paisi].go_w++;
    // if(ca==0)lis[c].point+=3;
   }
 //cout<<x;
   return 0;
}

#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const string str="BERLAND";
map <string,int> id;
int num[10][2],score[10],rt,cnt,t[10];
vector <string> name;
int cmp(const int a,const int b)
{
	return a>b;
}
int main()
{
	for (int i=1;i<=5;i++)
	{
		string s1,s2;
		int a,b;
		cin>>s1>>s2;
		getchar();
		scanf("%d",&a);
		getchar();
		scanf("%d",&b);
		if (!id.count(s1))
		{
			name.push_back(s1);
			id[s1]=++cnt;
			if (s1==str) rt=cnt;
		}
		if (!id.count(s2))
		{
			name.push_back(s2);
			id[s2]=++cnt;
			if (s2==str) rt=cnt;
		}
		if (a>b) score[id[s1]]+=3;
		else if (a==b) score[id[s1]]++,score[id[s2]]++;
		else score[id[s2]]+=3;
		t[id[s1]]++,t[id[s2]]++;
		num[id[s1]][0]+=a;
		num[id[s2]][0]+=b;
		num[id[s1]][1]+=b;
		num[id[s2]][1]+=a;
	}
	int now;
	int tmp;
	vector <int> vvv;
	for (int i=1;i<=4;i++)
	{
		if (i==rt)
			now=score[i];
		vvv.push_back(score[i]);
		if (i!=rt && t[i]<3)
			tmp=i;
	}
	sort(vvv.begin(),vvv.end());
	if (vvv[1]-now>3)
	{
		cout<<"IMPOSSIBLE";
		return 0;
	}
	for (int i=1;i<=100;i++)
	{
		for (int k=i-1;k>=0;k--)
		{
			vector < pair < pair < int, pair < int , int > > , string > > v;
			v.clear();
			for (int j=1;j<=4;j++)
			{
				if (j==tmp)
					v.push_back(mp(mp(-score[j],mp(-(num[j][0]-num[j][1]-i+k),-(num[j][0]+k))),name[j-1]));
				else if (j!=rt)
					v.push_back(mp(mp(-score[j],mp(-(num[j][0]-num[j][1]),-num[j][0])),name[j-1]));
				else
					v.push_back(mp(mp(-score[j]-3,mp(-(num[j][0]-num[j][1]+i-k),-(num[j][0]+i))),name[j-1]));
			}
			sort(v.begin(),v.end());
			if (v[0].se==str || v[1].se==str)
			{
				cout<<i<<":"<<k;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int oo=99999999;
struct mtype
{
	char s1[20],s2[20];
	int x,y;
} match[10];
char name[6][20];
int sum[10];
struct teamtype
{
	int in,out,cha,score;
} team[10];
int rank(char *s)
{
	int r=0;
	for (int i=1;i<=4;i++)
	if (strcmp(name[i],s)<0) r++;
	return r+1;
}
int main()
{
    //freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	n=0;
	for (int i=1;i<=5;i++)
	{
		scanf("%s%s%d:%d",match[i].s1,match[i].s2,&match[i].x,&match[i].y);
		bool cd=true;
		for (int j=1;j<=n;j++) if (strcmp(name[j],match[i].s1)==0) cd=false;
		if (cd) memcpy(name[++n],match[i].s1,sizeof(name[n]));
		cd=true;
		for (int j=1;j<=n;j++) if (strcmp(name[j],match[i].s2)==0) cd=false;
		if (cd) memcpy(name[++n],match[i].s2,sizeof(name[n]));
	}
	for (int i=1;i<=5;i++)
	{
		int r1=rank(match[i].s1),r2=rank(match[i].s2);
		sum[r1]++;sum[r2]++;
		team[r1].in+=match[i].x;team[r1].out+=match[i].y;
		team[r2].in+=match[i].y;team[r2].out+=match[i].x;
		if (match[i].x>match[i].y)
		{
			team[r1].score+=3;team[r2].score+=0;
		}
		else if (match[i].x<match[i].y)
		{
			team[r1].score+=0;team[r2].score+=3;
		}
		else if (match[i].x==match[i].y)
		{
			team[r1].score+=1;team[r2].score+=1;
		}
	}
	int rt1=rank("BERLAND"),rt2;
	for (int i=1;i<=4;i++) if (sum[i]==2&&i!=rt1) rt2=i;
	int ans=oo,ansx,ansy;
	for (int i=0;i<=100;i++)
	for (int j=0;j<i;j++)
	{
		int s1,s2;
		if (i==j) s1=s2=1;
		else if (i>j) s1=3,s2=0;
		else s1=0,s2=3;
		team[rt1].score+=s1;
		team[rt1].in+=i;
		team[rt1].out+=j;
		team[rt2].score+=s2;
		team[rt2].in+=j;
		team[rt2].out+=i;
		int r=1;
		for (int k=1;k<=4;k++)
		if (k!=rt1)
		{
			if (team[k].score>team[rt1].score) r++;
			else if (team[k].score==team[rt1].score&&team[k].in-team[k].out>team[rt1].in-team[rt1].out) r++;
			else if (team[k].score==team[rt1].score&&team[k].in-team[k].out>team[rt1].in-team[rt1].out
			&&team[k].in>team[rt1].in) r++;
			else if (team[k].score==team[rt1].score&&team[k].in-team[k].out>team[rt1].in-team[rt1].out
			&&team[k].in==team[rt1].in&&k<rt1) r++;
		}
		if (r<=2)
		{
			if (i-j<ans)
			{
				ans=i-j;ansx=i;ansy=j;
			}
			else if (i-j==ans&&j<ansy)
			{
				ans=i-j;ansx=i;ansy=j;
			}
		}
		team[rt1].score-=s1;
		team[rt1].in-=i;
		team[rt1].out-=j;
		team[rt2].score-=s2;
		team[rt2].in-=j;
		team[rt2].out-=i;
	}
	if (ans==oo) printf("IMPOSSIBLE");
	else printf("%d:%d",ansx,ansy);
	return 0;
}

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

inline int64 labs(int64 a) { return a < 0 ? (-a) : a; }
template<typename T> inline T sqr(T x) { return x*x; }
#define mp make_pair
#define pb push_back

#define forn(i, n) for(int (i)=0; (i)<(n); (i)++)
#define forn1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define forr(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define forit(i,c) for((i)=(c).begin(); (i)!=(c).end(); (i)++)
#define all(x) (x).begin(), (x).end()
#define zero(a) memset((a), 0, sizeof(a))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

struct Team
{
	int cnt;
	string name;
	int a, b;
	int points;
	Team() : a(0), b(0), cnt(0), points(0) { }
};
bool operator <(const Team & t1, const Team & t2)
{
	if (t1.points != t2.points)
		return t1.points > t2.points;
	if (t1.a - t1.b != t2.a - t2.b)
		return t1.a - t1.b > t2.a - t2.b;
	if (t1.a != t2.a)
		return t1.a > t2.b;
	return t1.name < t2.name;
}

map<string, Team> m, tm;
map<string, Team>::iterator it;

void Play(const string & s1, const string & s2, int a1, int a2)
{
	m[s1].name = s1;
	m[s2].name = s2;
	m[s1].cnt ++;
	m[s2].cnt ++;
	m[s1].a += a1;
	m[s1].b += a2;
	m[s2].a += a2;
	m[s2].b += a1;
	if (a1 > a2)
	{
		m[s1].points += 3;
	}
	else if (a1 < a2)
	{
		m[s2].points += 3;
	}
	else
	{
		m[s1].points ++;
		m[s2].points ++;
	}
}

int res1 = -1;
int res2 = -1;

void Calc(const string & s1, const string & s2, int a1, int a2)
{
	tm = m;
	Play(s1, s2, a1, a2);
	vector<Team> v;
	forit(it, m)
	{
		v.push_back(it->second);
	}
	sort(all(v));

	if (v[0].name == s1 || v[1].name == s1)
	{
		if (res1 == -1)
		{
			res1 = a1;
			res2 = a2;
		}
		else
		{
			if (a1 - a2 < res1 - res2)
			{
				res1 = a1;
				res2 = a2;
			}
			else if (a1 - a2 == res1 - res2)
			{
				if (a2 < res2)
				{
					res1 = a1;
					res2 = a2;
				}
			}
		}
	}
	m = tm;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s1, s2;
	forn(i, 5)
	{
		int a1, a2;
		char c;
		cin >> s1 >> s2 >> a1 >> c >> a2;
		Play(s1, s2, a1, a2);
	}
	s1 = "BERLAND";
	forit(it, m)
	{
		if (it->first != s1 && it->second.cnt < 3)
		{
			s2 = it->first;
			break;
		}
	}

	forn(a1, 100)
	{
		for(int a2 = 0; a2 < a1; a2++)
		{
			Calc(s1, s2, a1, a2);
		}
	}
	if (res1 == -1)
	{
		cout << "IMPOSSIBLE" << endl;
	}
	else
	{
		cout << res1 << ":" << res2 << endl;
	}

	return 0;
}

/*
10 2 2
+
+
+
+
- 1
- 3
- 2
- 4
+
+

*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <list>
#include <iostream>
using namespace std;

#define C(_a, _v) memset(_a,_v,sizeof(_a))
#define ALL(_obj) (_obj).begin(),(_obj).end()
#define FORB(_i,_a,_b) for((_i)=(_a);(_i)<(_b);++(_i))
#define FORE(_i,_a,_b) for((_i)=(_a);(_i)<=(_b);++(_i))
#define FOR(_i,_n) FORB(_i,0,_n)
#define FORS(_i,_obj) FOR(_i,(_obj).size())
#define ADJ(_i,_v) for((_i)=kick[_v];(_i)>=0;(_i)=foll[_i])
#define X first
#define Y second
#define I64 "%I64d"

typedef long long i64;
typedef unsigned long long u64;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<i64, i64> pii64;
typedef vector<pii> vpii;
typedef complex<double> cd;

template<typename T>inline bool remin(T&c,const T&n){if(n<c){c=n;return 1;}return 0;}
template<typename T>inline bool remin2(T&c,const T&n){if(c<0||n<c){c=n;return 1;}return 0;}
template<typename T>inline bool remax(T&c,const T&n){if(c<n){c=n;return 1;}return 0;}
template<typename T>inline void addmod(T&c,const T&n,const T&m){c = (c + n) % m;}

int _in;int in(){scanf("%d",&_in);return _in;}
pii operator+(const pii&a,const pii&b){return pii(a.X+b.X,a.Y+b.Y);}

// stuff cutline

const int N = 1e5 + 5;

const string ber = "BERLAND";

map<string, int> plays, score, hit, got;

char str[1000], *ptr;

string opp;

struct team {
	string name;
	bool operator< (const team& a) const {
		if (score[name] == score[a.name]) {
			if (hit[name] - got[name] == hit[a.name] - got[a.name]) {
				if (hit[name] == hit[a.name]) {
					return name < a.name;
					// return lexicographical_compare(ALL(name), ALL(a.name));
				} return hit[name] > hit[a.name];
			} else return hit[name] - got[name] > hit[a.name] - got[a.name];
		} else return score[name] > score[a.name];
	}
} t[4];

int main() {
	int i, j, sa, sb;
	string a, b;
	FOR (i, 5) {
		gets(str);
		a = strtok(str, " ");
		b = strtok(NULL, " ");
		sscanf(strtok(NULL, " "), "%d:%d", &sa, &sb);
		++plays[a];
		++plays[b];
		hit[a] += sa;
		hit[b] += sb;
		got[a] += sb;
		got[b] += sa;
		// printf("%s %s %d %d\n", a.data(), b.data(), sa, sb);
		if (sa == sb) {
			++score[a];
			++score[b];
		} else if (sa > sb) {
			score[a] += 3;
		} else {
			score[b] += 3;
		}
	}
	i = 0;
	for (map<string, int>::iterator it = plays.begin(); it != plays.end(); ++it) {
		t[i++].name = it->first;
		if (it->second == 2 && it->first != ber) {
			opp = it->first;
		}
	}
	score[ber] += 3;
	int x = -1, y = -1;
	FOR (i, 100)
		FOR (j, i) {
			hit[ber] += i;
			hit[opp] += j;
			got[ber] += j;
			got[opp] += i;
			sort(t, t + 4);
			if ((t[0].name == ber || t[1].name == ber) && (x < 0 || i - j < x - y || i - j == x - y && j < y)) {
				// printf("%d:0\n", i);
				// return 0;
			}
			hit[ber] -= i;
			hit[opp] -= j;
			got[ber] -= j;
			got[opp] -= i;
		}
	puts("IMPOSSIBLE");
    return 0;
}

# include <stdio.h>
# include <string.h>
# include <string>
# include <iostream>
# include <algorithm>
# include <sstream>
# include <vector>
# include <set>
# include <cmath>
# include <map>
using namespace std;

struct team
{
    string name ;
    int sc , og ;
    int pts , played ;
};

vector <string> getWords(string sen) {

   istringstream iss(sen);
   vector <string> wyn;
   string slowo;
   while (true) {

      iss >> slowo; if (!iss) break;
      wyn.push_back( slowo );
   }
   return wyn;
}

bool cmp ( team a , team b )
{
    if ( a.pts != b.pts ) return a.pts > b.pts ;
    if ( a.sc-a.og != b.sc-b.og ) return a.sc-a.og > b.sc-b.og;
    if ( a.sc != b.sc ) return a.sc > b.sc ;
    return a.name < b.name ;
}

team teams[4] ;
char tmp[111] ;
vector<string>v;
map < string , int> mp ;

void copyteam ( team &a , team &b )
{
    a.name = b.name ;
    a.og = b.og ;
    a.played = b.played ;
    a.pts = b.pts ;
    a.sc = b.sc ;
    return ;
}

int main()
{
    int b=0 ;
    for ( int i=0 ; i<5 ; i++ )
    {
        v.clear();
        for ( int j=0 ; j<3 ; j++ )
        {
            scanf("%s",tmp);
            v.push_back(tmp);
        }
        string num="";
        int n1=-1 , n2=-1 ;
        if ( mp.count(v[0])==0 )    mp[v[0]]=b++;
        if ( mp.count(v[1])==0 )    mp[v[1]]=b++;
        for ( int i=0 ; i<v[2].size() ; i++ )
        {
            if ( v[2][i] == ':' )
            {
                sscanf(num.c_str(),"%d",&n1);
                num="";
                continue ;
            }
            num += v[2][i] ;
        }
        sscanf(num.c_str(),"%d",&n2);
        num="";
        if ( n1 > n2 )
        {
            int ind = mp[ v[0] ] ;
            teams[ ind ].pts += 3 ;
            teams[ ind ].name = v[0] ;
            teams[ ind ].sc += n1 ;
            teams[ ind ].og += n2 ;
            teams[ ind ].played ++;
            int ind2 = mp [ v[1] ] ;
            teams[ ind2 ].name = v[1] ;
            teams[ ind2 ].sc += n2 ;
            teams[ ind2 ].og += n1 ;
            teams[ ind2 ].played ++;
        }
        else if ( n1 < n2 )
        {
            int ind = mp [ v[1] ] ;
            teams[ ind ].pts += 3 ;
            teams[ ind ].name = v[1] ;
            teams[ ind ].sc += n2 ;
            teams[ ind ].og += n1 ;
            teams[ ind ].played ++;
            int ind2 = mp [ v[0] ] ;
            teams[ ind2 ].name = v[0] ;
            teams[ ind2 ].sc += n1 ;
            teams[ ind2 ].og += n2 ;
            teams[ ind2 ].played ++;
        }
        else
        {
            int ind = mp [ v[0] ] , ind2 = mp [ v[1] ] ;
            teams [ ind ].name = v[0] ;
            teams [ ind ].sc += n1 ;
            teams [ ind ].og += n2 ;
            teams [ ind ].pts += 1 ;
            teams [ ind ].played ++;

            teams [ ind2 ].name = v[1] ;
            teams [ ind2 ].sc += n2 ;
            teams [ ind2 ].og += n1 ;
            teams [ ind2 ].pts += 1 ;
            teams [ ind2 ].played ++;
        }
    }
    int ii=0 , jj=0 ;
    sort ( teams , teams+4 , cmp ) ;
    for ( int i=0 ; i<4 ; i++ )
    {
        if ( teams[i].played==2 && teams[i].name != "BERLAND" ) jj = i ;
        else if ( teams[i].played==2 ) ii = i ;
    }

    if ( teams[ii].sc+3 < teams[1].sc )
    {
        printf("IMPOSSIBLE\n");
        return 0;
    }

        int d = teams[1].sc-teams[1].og ;
        team tt[4] ;
        for ( int i=0 ; i<4 ; i++ )
            tt[i] = teams[i] ;
        int i ;
        int ansx=-1 , ansy=-1 , diff = 1<<30 ;
        int f = 0 ;
        for ( i=1 ; i<=100; i++ )
        {
            for ( int j=0 ; j<i; j++ )
            {
                copyteam ( teams[ii] , tt[ii] );
                teams[ii].pts += 3 ;
                teams[ii].sc += i ;
                teams[ii].og += j ;
                teams[jj].og += i ;
                teams[jj].sc += j ;
                sort ( teams , teams+4 , cmp );
                if ( teams[0].name=="BERLAND" || teams[1].name=="BERLAND" )
                {
                    if ( i-j <= diff )
                    {
                        if ( i-j == diff )
                            f++ ;
                        else
                            f=0 ;
                        diff = i-j ;
                        ansx = i ;
                        ansy = j ;
                    }
                }
                for ( int i=0 ; i<4 ; i++ )
                    copyteam( teams[i] , tt[i] ) ;
            }
        }
        int yval=1<<20 ;
        if ( f > 1 )
        {
            for ( i=1 ; i<=100; i++ )
            {
                for ( int j=0 ; j<i; j++ )
                {
                    copyteam ( teams[ii] , tt[ii] );
                    teams[ii].pts += 3 ;
                    teams[ii].sc += i ;
                    teams[ii].og += j ;
                    teams[jj].og += i ;
                    teams[jj].sc += j ;
                    sort ( teams , teams+4 , cmp );
                    if ( teams[0].name=="BERLAND" || teams[1].name=="BERLAND" )
                    {
                        if ( i-j == diff )
                        {
                            if ( j < yval )
                            {
                                yval = j ;
                                ansx = i ;
                                ansy = j ;
                            }
                        }
                    }
                    for ( int i=0 ; i<4 ; i++ )
                        copyteam( teams[i] , tt[i] ) ;
                }
            }
        }
        printf("%d:%d\n",ansx,ansy);

}

#include<stdio.h>
#include<map>
#include<string.h>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
map<string,int> points;
map<string,int> goals;
map<string,int> misses;
set<string> playedWithBerland;
void parseS(char *t1,char *t2,int p1,int p2)
{
	if(p1>p2)
	{
		points[t1]+=3;
	}
	else if(p2>p1)
	{
		points[t2]+=3;
	}
	else
	{
		points[t1]+=1;
		points[t2]+=2;
	}
	if(!strcmp(t1,"BERLAND"))
	{
		playedWithBerland.insert(t2);
	}

	if(!strcmp(t2,"BERLAND"))
	{
		playedWithBerland.insert(t1);
	}

	goals[t1]+=p1;
	goals[t2]+=p2;
	misses[t1]+=p2;
	misses[t2]+=p1;

}
char s1[100];
char s2[100];
int p1;
int p2;
char s[1000];
struct cntr
{
	string name;
	int points;
	int misses;
	int goals;
};
bool cmp(cntr &c1, cntr &c2)
{
	return c1.points>c2.points ||
		c1.points==c2.points && c1.goals-c1.misses>c2.goals-c2.misses ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals>c2.goals ||
		c1.points==c2.points && c1.goals-c1.misses == c2.goals-c2.misses && c1.goals==c2.goals && c1.name<c2.name;

}
bool ifok(vector<cntr> & C)
{
	sort(C.begin(),C.end(),cmp);
	return C[0].name=="BERLAND" || C[1].name=="BERLAND";
}
int main()
{
	for(int i=0;i<5;i++)
	{
		gets(s);
		sscanf(s,"%s %s %d:%d",s1,s2,&p1,&p2);
		parseS(s1,s2,p1,p2);
	}

	string defC;
	for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
	{
		if(it->first!="BERLAND" && playedWithBerland.find(it->first)==playedWithBerland.end())
		{
			defC=it->first;
		}
	}
	points[defC]+=0;
	points["BERLAND"]+=3;
	vector<pair<int,int> > goodSc;
	for(int dx=1;dx<100;dx++)
	{
		for(int Y=0;Y<100;Y++)
		{
			int X=Y+dx;
			goals[defC]+=Y;
			goals["BERLAND"]+=X;
			misses[defC]+=X;
			misses["BERLAND"]+=Y;
			vector<cntr> C;
			for(map<string,int>::iterator it=points.begin();it!=points.end();it++)
			{
				cntr c1;
				c1.name=it->first;
				c1.misses=misses[it->first];
				c1.goals=goals[it->first];
				c1.points=points[it->first];
				C.push_back(c1);
			}

			if(ifok(C))
			{
				printf("%d:%d",X,Y);
				return 0;
			}
			goals[defC]-=Y;
			goals["BERLAND"]-=X;
			misses[defC]-=X;
			misses["BERLAND"]-=Y;
		}
	}
	printf("IMPOSSIBLE\n");

}

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#define LL long long
#define Pr pair<int,int>
#define fread(ch) freopen(ch,"r",stdin)
#define fwrite(ch) freopen(ch,"w",stdout)

using namespace std;
const int INF = 0x3f3f3f3f;
const int msz = 10000;
const int mod = 1e9+7;
const double eps = 1e-8;

struct Team
{
	int a,b,c;
};

map <string,int> mp;
Team team[4];
char a[111],b[111];
char name[4][111];
int aa,bb;
int cnt[4];

bool cal(int aa,int bb,int id1,int id2)
{
	team[id1].c += aa;
	team[id2].c += bb;
	team[id1].b += (aa-bb);
	team[id2].b += (bb-aa);
	if(aa > bb)
	{
		team[id1].a += 3;
	}
	else if(aa == bb)
	{
		team[id1].a += 1;
		team[id2].a += 1;
	}
	else
	{
		team[id2].a += 3;
	}

	int f = 0;
	for(int i = 1; i < 4; ++i)
	{
		if(team[i].a > team[id1].a) f++;
		else if(team[i].b > team[id1].b) f++;
		else if(team[i].c > team[id1].c) f++;
		else if(strcmp(name[i],name[id1]) < 0) f++;
	}

	//printf("%d %d\n",aa,bb);
	//for(int i = 0; i < 4; ++i)
	//{
	//	printf("%s %d %d %d\n",name[i],team[i].a,team[i].b,team[i].c);
	//}
	//puts("----------");
	if(f <= 1) return true;

	team[id1].c -= aa;
	team[id2].c -= bb;
	team[id1].b -= (aa-bb);
	team[id2].b -= (bb-aa);
	if(aa > bb)
	{
		team[id1].a -= 3;
	}
	else if(aa == bb)
	{
		team[id1].a -= 1;
		team[id2].a -= 1;
	}
	else
	{
		team[id2].a -= 3;
	}

	//printf("%d %d\n",aa,bb);
	//for(int i = 0; i < 4; ++i)
	//{
	//	printf("%s %d %d %d\n",name[i],team[i].a,team[i].b,team[i].c);
	//}
	//puts("----------");

	return false;
}

int main()
{
	//fread("");
	//fwrite("");

	int tp = 0;
	team[tp].a = team[tp].b = team[tp].c = 0;
	mp["BERLAND"] = tp++;
	strcpy(name[0],"BERLAND");
	int id1,id2;
	memset(cnt,0,sizeof(cnt));

	for(int i = 0; i < 5; ++i)
	{
		scanf("%s%s%d:%d",a,b,&aa,&bb);
		if(!mp.count(a))
		{
			mp[a] = tp;
			team[tp].a = team[tp].b = team[tp].c = 0;
			strcpy(name[tp],a);
			tp++;
		}

		if(!mp.count(b))
		{
			mp[b] = tp;
			team[tp].a = team[tp].b = team[tp].c = 0;
			strcpy(name[tp],b);
			tp++;
		}

		id1 = mp[a];
		id2 = mp[b];

		team[id1].c += aa;
		team[id2].c += bb;
		team[id1].b += (aa-bb);
		team[id2].b += (bb-aa);
		if(aa > bb)
		{
			team[id1].a += 3;
		}
		else if(aa == bb)
		{
			team[id1].a += 1;
			team[id2].a += 1;
		}
		else
		{
			team[id2].a += 3;
		}
		cnt[id1]++;
		cnt[id2]++;
	}

	id1 = 0;
	for(int i = 1; i < 4; ++i)
	{
		if(cnt[i] == 2)
		{
			id2 = i;
			break;
		}
	}

	for(int dis = 1; dis <= 10000; ++dis)
	{
		for(int y = 0; y <= 10000-dis; ++y)
		{
			if(cal(y+dis,y,id1,id2))
			{
				printf("%d:%d\n",y+dis,y);
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");

	return 0;
}

#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <set>

using namespace std;

const int M=4+10;
typedef long long int ll;

struct TEAM{
	string name;
	int score;
	int goal;
	int missed;
	bool operator <(const TEAM&x) const
	{
		if (score!=x.score)
		{
			return score>x.score;
		}
		else
		{
			if (goal-missed!=x.goal-x.missed)
			{
				return goal-missed>x.goal-x.missed;
			}
			else
			{
				if (goal!=x.goal)
				{
					return goal>x.goal;
				}
				else
				{
					return name<x.name;
				}
			}

		}
	}
}team1[M],team2[M];

map<string, int> ntoid;

int ihash[M];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int cnt=0;
	for (int i=0; i<5; i++)
	{
		string t1,t2;
		string result;
		cin>>t1>>t2>>result;

		int score1,score2;
		score1=result[0]-'0';
		score2=result[2]-'0';

		int id=-1;
		if (ntoid.find(t1)!=ntoid.end())
		{
			id=ntoid[t1];
		}
		else
		{
			ntoid[t1]=cnt;
			id=ntoid[t1];
			cnt++;
		}

		team1[id].goal+=score1;
		team1[id].missed+=score2;
		if (score1>score2)
		{
			team1[id].score+=3;
		}
		if (score1==score2)
		{
			team1[id].score+=1;
		}
		team1[id].name=t1;
		ihash[id]++;

		id=-1;
		if (ntoid.find(t2)!=ntoid.end())
		{
			id=ntoid[t2];
		}
		else
		{
			ntoid[t2]=cnt;
			id=ntoid[t2];
			cnt++;
		}

		team1[id].goal+=score2;
		team1[id].missed+=score1;
		if (score2>score1)
		{
			team1[id].score+=3;
		}
		if (score1==score2)
		{
			team1[id].score+=1;
		}
		team1[id].name=t2;
		ihash[id]++;
	}

	string s;
	for (int i=0; i<4; i++)
	{
		if (ihash[i]<3 && team1[i].name!="BERLAND")
		{
			s=team1[i].name;
		}
	}

	int id1=ntoid["BERLAND"];
	int id2=ntoid[s];

	int Y,X;
	Y=X=-1;
	for (int y=0; y<=100; y++)
	{
		for (int x=y+1; x<=100; x++)
		{
			for (int i=0; i<4; i++)
			{
				team2[i].goal=team1[i].goal;
				team2[i].missed=team1[i].missed;
				team2[i].score=team1[i].score;
				team2[i].name=team1[i].name;
			}
			team2[id1].score+=3;
			team2[id1].goal+=x;
			team2[id1].missed+=y;

			team2[id2].goal+=y;
			team2[id2].missed+=x;

			sort(team2,team2+4);
			if (team2[0].name=="BERLAND" || team2[1].name=="BERLAND")
			{
				Y=y; X=x;
				break;
			}
		}

		if (Y!=-1)
		{
			break;
		}
	}

	if (Y==-1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		cout<<X<<":"<<Y<<endl;
	}

	return 0;

}

/*
date 2018-__-__
time:from:  to:
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050226;
/*------------main part------------*/
struct team
{
	string name;
	int score;
	int gain;
	int lose;
};
team t[10];
int men[10];
int cnt=0;
void add(string a1,string a2,int a,int b)
{
	int x=-1,y=-1;
	for(int i=0;i<4;i++)
	{
		if(t[i].name==a1)
			x=i;
		if(t[i].name==a2)
			y=i;
	}
	if(x==-1)
	{
		x=cnt;
		t[cnt++].name=a1;
	}
	if(y==-1)
	{
		y=cnt;
		t[cnt++].name=a2;
	}
	t[x].gain+=a;
	t[x].lose+=b;
	t[y].gain+=b;
	t[y].lose+=a;
	if(a>b)
	{
		t[x].score+=3;
	}
	else if(a==b)
	{
		t[x].score++,t[y].score++;
	}
	else
	{
		t[y].score+=3;
	}
	men[x]++;
	men[y]++;
}
bool cmp(team x,team y)
{
	if(x.score!=y.score)
		return x.score>y.score;
	if((x.gain-x.lose)!=(y.gain-y.lose))
	{
		return (x.gain-x.lose)>(y.gain-y.lose);
	}
	if(x.gain!=y.gain)
		return x.gain>y.gain;
	return x.name>y.name;
}
int main()
{
	for(int i=0;i<5;i++)
	{
		string a,b;
		cin>>a>>b;
		int x,y;
		scanf("%d:%d",&x,&y);
		add(a,b,x,y);
	}
	string ast;
	int ber;
	for(int i=0;i<4;i++)
	{
		if(men[i]!=3 and t[i].name!="BERLAND")
		{
			ast=t[i].name;
		}
		if(t[i].name=="BERLAND")
			t[i].score+=3;
	}
	sort(t,t+4,cmp);
	int num=0;
	for(int i=1;i<=100;i++)
	{
		for(int j=0;j<4;j++)
		{
			if(t[j].name=="BERLAND")
				ber=j;
			if(t[j].name==ast)
			{
				t[j].lose+=i;
			}
		}
		t[ber].gain+=i;
		sort(t,t+4,cmp);
		for(int j=0;j<4;j++)
		{
			if(t[j].name=="BERLAND")
			{
				if(j<=1)
				{
					cout<<i<<":"<<0;
					return 0;
				}
				else
				{
					t[j].gain-=i;
				}
			}
			if(t[j].name==ast)
				t[j].lose-=i;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

#include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
struct aa{int q,m,p;};
aa f[200];
int i,j,p,su,ss1,ss2,t1,t2,sum[200],len;
string ch1,ch2,s[10];
bool da(int t)
{
	if (t==ss1)
		return false;
	if (f[t].p!=f[ss1].p)
		return f[t].p>f[ss1].p;
	if (f[t].m!=f[ss1].m)
		return f[t].m>f[ss1].m;
	if (f[t].q!=f[ss1].q)
		return f[t].q>f[ss1].q;
	return s[t]<s[ss1];
}
int get(string a)
{
	for (int i=1;i<=len;i++)
	if (s[i]==a)
	return i;
	s[++len]=a;
	return len;
}
void read(int &k)
{
	char q;
	for (q=getchar();q<'0'||q>'9';q=getchar());
	k=q-'0';
}
int main()
{
	for (i=1;i<=5;i++)
	{
		cin>>ch1>>ch2;
		ss1=get(ch1);
		ss2=get(ch2);
		sum[ss1]++;
		sum[ss2]++;
		read(t1);
		read(t2);
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
	}
	for (i=1;i<=4;i++)
	if (s[i]=="BERLAND")
		ss1=i;
	else
	if (sum[i]<3)
		ss2=i;
	for (i=-j;i<=35;i++)
	for (j=0;j<=35;j++)
	if (i+j!=0)
	{
		t2=j;
		t1=j+i;
		f[ss1].m+=t1-t2;
		f[ss2].m+=t2-t1;
		f[ss1].q+=t1;
		f[ss2].q+=t2;
		if (t1>t2)
			f[ss1].p+=3;
		else
		if (t1<t2)
			f[ss2].p+=3;
		else
		{
			f[ss1].p++;
			f[ss2].p++;
		}
		su=0;
		for (p=1;p<=4;p++)
		if (da(p))
			su++;
		if (su<2)
		{
			printf("%d:%d",t1,t2);
			return 0;
		}
		f[ss1].m-=t1-t2;
		f[ss2].m-=t2-t1;
		f[ss1].q-=t1;
		f[ss2].q-=t2;
		if (t1>t2)
			f[ss1].p-=3;
		else
		if (t1<t2)
			f[ss2].p-=3;
		else
		{
			f[ss1].p--;
			f[ss2].p--;
		}
	}
	printf("IMPOSSIBLE");
}

#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int g1,g2;
map<string,int> mg;
map<string,int> mpoints;
map<string,int> mgames;
map<string,int> mig;
struct team{
    string name;
    int goal;
    int ingoal;
    int points;
    int games;
};
struct fuckme{
    int x,y;
};
bool cmp2(fuckme a,fuckme b){
    if(a.x-a.y!=b.x-b.y) return a.x-a.y<b.x-b.y;
    return a.y<b.y;
}
vector<fuckme> ans;

bool cmp(team a,team b){
    if(a.points!=b.points) return a.points>b.points;
    if(a.goal-a.ingoal!=b.goal-b.ingoal) return a.goal-a.ingoal>b.goal-b.ingoal;
    return a.name<b.name;
}

void chk(int X,int Y){
    team tmp;
    vector<team> ss;
    for(auto u:mg){
        string name=u.first;
        int ngoals=u.second;
        tmp.name=name;
        tmp.goal=ngoals;
        tmp.ingoal=mig[name];
        tmp.points=mpoints[name];
        tmp.games=mgames[name];
        ss.push_back(tmp);
    }
    sort(ss.begin(),ss.end(),cmp);
    int cnt=0;
    fuckme me;
    for(auto u:ss){
        if(u.name=="BERLAND"){
            me.x=X;
            me.y=Y;
            ans.push_back(me);
            return;
        }
        cnt++;
        if(cnt==2) return;
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    for(int i=0;i<5;i++){
        cin>>s1>>s2;
        scanf("%d:%d",&g1,&g2);
        mg[s1]+=g1;
        mg[s2]+=g2;
        mig[s2]+=g1;
        mig[s1]+=g2;
        mgames[s1]++;
        mgames[s2]++;
        if(g1>g2) mpoints[s1]+=3;
        else if(g2>g1) mpoints[s2]+=3;
        else{
            mpoints[s1]++;
            mpoints[s2]++;
        }
    }
    s1="BERLAND";
    for(auto u:mgames){
        if(u.second!=3&&u.first!="BERLAND"){
            s2=u.first;
            break;
        }
    }
    for(int x=0;x<=100;x++){
        for(int y=0;y<x;y++){
            mg[s1]+=x;
            mg[s2]+=y;
            mig[s1]+=y;
            mig[s2]+=x;
            if(x>y) mpoints[s1]+=3;
            else if(y>x) mpoints[s2]+=3;
            else{
                mpoints[s1]++;
                mpoints[s2]++;
            }
            chk(x,y);
            if(x>y) mpoints[s1]-=3;
            else if(y>x) mpoints[s2]-=3;
            else{
                mpoints[s1]--;
                mpoints[s2]--;
            }
            mig[s1]-=y;
            mig[s2]-=x;
            mg[s1]-=x;
            mg[s2]-=y;
        }
    }
    if(ans.empty()) printf("IMPOSSIBLE");
    else{
        sort(ans.begin(),ans.end(),cmp2);
        auto it=ans[0];
        printf("%d:%d",it.x,it.y);
    }
    return 0;
}

#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
#define V_CIN(v) do{for(int i = 0; i < sz(v); i++) cin >> (v)[i];}while(0)
#define all(c) (c).begin(),(c).end()

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 1000000007;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

//BEGIN!!!

//BEGIN!!!

struct RESULTS{
	int pts,diff,goal,cnt,id;
};

RESULTS t[4];
vector<string> teams;
int getTeamNum(string name)
{
	vector<string>::iterator it;
	it = find(teams.begin(),teams.end(),name);
	if(it == teams.end()){
		teams.push_back(name);
		return (int)teams.size() - 1;
	}else {
		return it - teams.begin();
	}
}

bool cmp(const RESULTS& x,const RESULTS &y){
	if(x.pts != y.pts) return greater<int>()(x.pts,y.pts);
	if(x.diff != y.diff) return greater<int>()(x.diff,y.diff);
	if(x.goal != y.goal) return greater<int>()(x.goal,y.goal);
	return false;
}

int get_opp()
{
	for (int i = 1; i < 4; i++){
		if(t[i].cnt == 2) return i;
	}
	return -1;
}

template<class T>
void f(int a,int b,int t1,int t2,T& team){
	team[t1].goal += a;
	team[t2].goal += b;
	team[t1].diff += a-b;
	team[t2].diff += b-a;
	team[t1].cnt++;
	team[t2].cnt++;
	if(a > b){
		team[t1].pts += 3;
	} else if(a < b){
		team[t2].pts += 3;
	} else {
		team[t1].pts++; team[t2].pts++;
	}
}

bool ok(int goal,int miss,int op){
	vector<RESULTS> r(t,t+4);
	f(goal,miss,0,op,r);
	sort(r.begin(),r.end(),cmp);
	if(r[0].id == 0 || r[1].id == 0) return true;
	else return false;
}

int main()
{
	teams.push_back("BERLAND");

	for (int i = 0; i < 4; i++){
		t[i].id = i;
	}
	for (int i = 0; i < 5; i++){
		char buf1[100],buf2[100];
		int a,b;
		scanf("%s %s %d:%d",buf1,buf2,&a,&b);
		int t1 = getTeamNum(buf1);
		int t2 = getTeamNum(buf2);
		f(a,b,t1,t2,t);
	}

	int op = get_opp();
	for (int i = 1; i < 100; i++){
		for (int j = 0; j < 100; j++){
			if(ok(i + j,j,op)){
				printf("%d:%d\n",i+j,j);
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}