using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace Compete2
{
    partial class MainClass
    {
        public static void Main(string[] args)
        {
            int count = 1; //int.Parse(Console.ReadLine());
            List<string> output = new List<string>();

            for (int z = 0; z < count; z++)
            {
                //Console.ReadLine();
                //var s = Console.ReadLine();
                //var n = int.Parse(Console.ReadLine());
                var a = Console.ReadLine().Split(' ').Select(qw => ulong.Parse(qw)).ToList();
                //var b = Console.ReadLine().Split(' ').Select(qw => long.Parse(qw)).ToList();
                //var c = Console.ReadLine().Split(' ').Select(qw => long.Parse(qw)).ToList();
                //var b = long.Parse(Console.ReadLin    e());

                ulong o = ulong.MaxValue;
                //bool can = true;

                Stack<ulong[]> q = new Stack<ulong[]>();

                if ((ulong)a[1].ToString().Length >= a[0])
                    o = 0;
                else
                    q.Push(new ulong[] { a[1], 0 });

                while (q.Count>0)
                {
                    var x = q.Pop();

                    if (x[1] + 1 >= o)
                        continue;

                    var ds = x[0].ToString().Distinct().Select(i=>int.Parse(i.ToString())).OrderByDescending(i=>i).ToList();

                    if (ds.Contains(1))
                        ds.Remove(1);

                    if (ds.Contains(0))
                        ds.Remove(0);

                    BigInteger bi = x[0];

                    for (int i = 0; i < ds.Count; i++)
                    {
                        BigInteger bi2 = bi * ds[i];

                        if ((ulong)bi2.ToString().Length >= a[0])
                        {
                            if (x[1] + 1 < o)
                                o = x[1] + 1;
                        }
                        else
                        {
                            q.Push(new ulong[] {(ulong)bi2,x[1]+1 });
                        }
                    }
                }

                if (o == ulong.MaxValue)
                    output.Add("-1");
                else
                output.Add(o.ToString());
                //output.Add(string.Join(" ", o));
                /*if (can)
                    output.Add("Yes");
                else
                    output.Add("No");*/
            }

            output.ForEach(d => Console.WriteLine(d));
        }
    }
}


#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Team : IComparable<Team>
    {
        public string name;
        public int goal;
        public int miss;
        public int point;
        public int cnt;
        public int CompareTo(Team y)
        {
            if (this.point > y.point)
            {
                return 1;
            }
            else
            {
                if (this.goal - this.miss > y.goal - y.miss)
                {
                    return 1;
                }
                else
                {
                    if (this.goal - this.miss == y.goal - y.miss)
                    {
                        if (this.goal > y.goal)
                        {
                            return 1;
                        }
                        else
                        {
                            if (this.goal == y.goal)
                            {
                                if (this.name.CompareTo(y.name) > 0)
                                    return 1;
                                else
                                    return -1;
                            }
                            else
                            {
                                return -1;
                            }
                        }

                    }
                    else
                    {
                        return -1;
                    }
                }
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            Team[] t = new Team[4];
            for (int i = 0; i < 5; i++)
            {
                string[] input = ReadArray();
                string[] score = input[2].Split(':');
                int x = int.Parse(score[0]);
                int y = int.Parse(score[1]);
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[0];
                    }
                    if (t[j].name.Equals(input[0]))
                    {
                        if (x > y) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += x;
                        t[j].miss += y;
                        t[j].cnt++;
                        break;
                    }

                }
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[1];
                    }
                    if (t[j].name.Equals(input[1]))
                    {
                        if (y > x) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += y;
                        t[j].miss += x;
                        t[j].cnt++;
                        break;
                    }
                }
            }
            int opp = 0;
            int ans = 0;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    t[i].point += 3;
                    t[i].goal++;
                    ans++;

                }
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                {
                    t[i].miss++;
                }
            }

            Team[] L = new Team[4];
            Team[] R = new Team[4];
            ArrayUtils.Merge_Sort(t, 0, 3, L, R);
            for (int i = 0; i < 4; i++)
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                    opp = i;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    if (i >= 2)
                    {
                        Console.WriteLine("1:0");
                        return;
                    }
                    for (int j = i + 1; j < 3; j++)
                    {
                        if (t[j].point > t[i].point && j <= 2)
                        {
                            Console.WriteLine("IMPOSSIBLE");
                            return;
                        }
                        else
                        {
                            while (t[i].CompareTo(t[j]) < 0)
                            {
                                t[i].goal++;
                                ans++;
                                t[opp].miss++;
                            }
                        }
                    }
                    Console.WriteLine(ans + ":0");
                }
            }

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

   /* public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

   /* class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;

        public Graph(int n)
        {
            g = new List<int>[n + 1];
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static void DFS(int u, ref int time, Graph g)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    DFS(v, ref time, g);
                }
            }
            g.color[u] = black;
            g.c[u] = time;
            time++;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }*/
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Team : IComparable<Team>
    {
        public string name;
        public int goal;
        public int miss;
        public int point;
        public int cnt;
        public int CompareTo(Team y)
        {
            if (this.point > y.point)
            {
                return 1;
            }
            else
            {
                if (this.goal - this.miss > y.goal - y.miss)
                {
                    return 1;
                }
                else
                {
                    if (this.goal - this.miss == y.goal - y.miss)
                    {
                        if (this.goal > y.goal)
                        {
                            return 1;
                        }
                        else
                        {
                            if (this.goal == y.goal)
                            {
                                if (this.name.CompareTo(y.name) > 0)
                                    return 1;
                                else
                                    return -1;
                            }
                            else
                            {
                                return -1;
                            }
                        }

                    }
                    else
                    {
                        return -1;
                    }
                }
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            Team[] t = new Team[4];
            for (int i = 0; i < 5; i++)
            {
                string[] input = ReadArray();
                string[] score = input[2].Split(':');
                int x = int.Parse(score[0]);
                int y = int.Parse(score[1]);
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[0];
                    }
                    if (t[j].name.Equals(input[0]))
                    {
                        if (x > y) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += x;
                        t[j].miss += y;
                        t[j].cnt++;
                        break;
                    }

                }
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[1];
                    }
                    if (t[j].name.Equals(input[1]))
                    {
                        if (y > x) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += y;
                        t[j].miss += x;
                        t[j].cnt++;
                        break;
                    }
                }
            }
            int opp = 0;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    t[i].point += 3;
                    t[i].goal++;

                }
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                {
                    opp = i;
                    t[i].miss++;
                }
            }

            Team[] L = new Team[4];
            Team[] R = new Team[4];
            ArrayUtils.Merge_Sort(t, 0, 3, L, R);
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    if (i >= 2)
                    {
                        Console.WriteLine("1:0");
                        return;
                    }
                    for (int j = i + 1; j < 3; j++)
                    {
                        if (t[j].point > t[i].point && j <= 2)
                        {
                            Console.WriteLine("IMPOSSIBLE");
                            return;
                        }
                        else
                        {
                            while (t[i].CompareTo(t[j]) < 0)
                            {
                                t[i].goal++;
                                t[opp].miss++;
                            }
                        }
                    }
                    Console.WriteLine(t[i].goal + ":0");
                }
            }

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

   /* public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

   /* class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;

        public Graph(int n)
        {
            g = new List<int>[n + 1];
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static void DFS(int u, ref int time, Graph g)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    DFS(v, ref time, g);
                }
            }
            g.color[u] = black;
            g.c[u] = time;
            time++;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }*/
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Team : IComparable<Team>
    {
        public string name;
        public int goal;
        public int miss;
        public int point;
        public int cnt;
        public int CompareTo(Team y)
        {
            if (this.point > y.point)
            {
                return 1;
            }
            else
            {
                if (this.point == y.point)
                {
                    if (this.goal - this.miss > y.goal - y.miss)
                    {
                        return 1;
                    }
                    else
                    {
                        if (this.goal - this.miss == y.goal - y.miss)
                        {
                            if (this.goal > y.goal)
                            {
                                return 1;
                            }
                            else
                            {
                                if (this.goal == y.goal)
                                {
                                    if (this.name.CompareTo(y.name) < 0)
                                        return 1;
                                    else
                                        return -1;
                                }
                                else
                                {
                                    return -1;
                                }
                            }

                        }
                        else
                        {
                            return -1;
                        }
                    }
                }
                else
                {
                    return -1;
                }
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            Team[] t = new Team[4];
            for (int i = 0; i < 5; i++)
            {
                string[] input = ReadArray();
                string[] score = input[2].Split(':');
                int x = int.Parse(score[0]);
                int y = int.Parse(score[1]);
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[0];
                    }
                    if (t[j].name.Equals(input[0]))
                    {
                        if (x > y) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += x;
                        t[j].miss += y;
                        t[j].cnt++;
                        break;
                    }

                }
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[1];
                    }
                    if (t[j].name.Equals(input[1]))
                    {
                        if (y > x) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += y;
                        t[j].miss += x;
                        t[j].cnt++;
                        break;
                    }
                }
            }
            int opp = 0;
            int ans = 0;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    t[i].point += 3;
                    t[i].goal++;
                    ans++;

                }
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                {
                    t[i].miss++;
                }
            }

            Team[] L = new Team[4];
            Team[] R = new Team[4];
            ArrayUtils.Merge_Sort(t, 0, 3, L, R);
            for (int i = 0; i < 4; i++)
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                    opp = i;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    if (i >= 2)
                    {
                        Console.WriteLine("1:0");
                        return;
                    }
                    for (int j = i + 1; j < 3; j++)
                    {
                        if (t[j].point > t[i].point && j <= 2)
                        {
                            Console.WriteLine("IMPOSSIBLE");
                            return;
                        }
                        else
                        {
                            while (t[i].CompareTo(t[j]) < 0)
                            {
                                t[i].goal++;
                                ans++;
                                t[opp].miss++;
                            }
                        }
                    }
                    int ans1 = 0;
                    int comp = 1;
                    while (comp > 0)
                    {
                        t[opp].goal++;
                        t[i].miss++;
                        for (int j = 0; j < 3; j++)
                        {
                            if (j == i) continue;
                            if (t[i].CompareTo(t[j]) < 0)
                                comp = -1;
                        }
                        if (comp > 0)
                        {
                            ans1++;
                        }
                    }
                    Console.WriteLine(ans + ":" + ans1);
                }
            }

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

   /* public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

   /* class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;

        public Graph(int n)
        {
            g = new List<int>[n + 1];
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static void DFS(int u, ref int time, Graph g)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    DFS(v, ref time, g);
                }
            }
            g.color[u] = black;
            g.c[u] = time;
            time++;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }*/
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Team : IComparable<Team>
    {
        public string name;
        public int goal;
        public int miss;
        public int point;
        public int cnt;
        public int CompareTo(Team y)
        {
            if (this.point > y.point)
            {
                return 1;
            }
            else
            {
                if (this.point == y.point)
                {
                    if (this.goal - this.miss > y.goal - y.miss)
                    {
                        return 1;
                    }
                    else
                    {
                        if (this.goal - this.miss == y.goal - y.miss)
                        {
                            if (this.goal > y.goal)
                            {
                                return 1;
                            }
                            else
                            {
                                if (this.goal == y.goal)
                                {
                                    if (this.name.CompareTo(y.name) < 0)
                                        return 1;
                                    else
                                        return -1;
                                }
                                else
                                {
                                    return -1;
                                }
                            }

                        }
                        else
                        {
                            return -1;
                        }
                    }
                }
                else
                {
                    return -1;
                }
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            Team[] t = new Team[4];
            for (int i = 0; i < 5; i++)
            {
                string[] input = ReadArray();
                string[] score = input[2].Split(':');
                int x = int.Parse(score[0]);
                int y = int.Parse(score[1]);
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[0];
                    }
                    if (t[j].name.Equals(input[0]))
                    {
                        if (x > y) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += x;
                        t[j].miss += y;
                        t[j].cnt++;
                        break;
                    }

                }
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[1];
                    }
                    if (t[j].name.Equals(input[1]))
                    {
                        if (y > x) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += y;
                        t[j].miss += x;
                        t[j].cnt++;
                        break;
                    }
                }
            }

            int ans = 0;
            int _ans = 0;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    t[i].point += 3;
                    t[i].goal++;
                    ans++;
                }
                else if (t[i].cnt == 2)
                {
                    t[i].miss++;
                }
            }

            Team[] L = new Team[4];
            Team[] R = new Team[4];
            ArrayUtils.Merge_Sort(t, 0, 3, L, R);

            int opp = 0;
            for (int i = 0; i < 4; i++)
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                    opp = i;

            for (int i = 0; i < 4; i++)
            {
                if (!t[i].name.Equals("BERLAND")) continue;

                if (i >= 2)
                {
                    Console.WriteLine("1:0");
                    return;
                }
                if (t[i].point < t[2].point)
                {
                    Console.WriteLine("IMPOSSIBLE");
                    return;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (j == i) continue;
                    while (t[i].CompareTo(t[j]) < 0)
                    {
                        t[i].goal++;
                        t[opp].miss++;
                        ans++;
                    }
                }
                while (true)
                {
                    int comp = 1;
                    for (int j = 0; j < 3; j++)
                    {
                        if (j == i) continue;
                        if ((t[i].goal - t[i].miss) - (t[j].goal - t[j].miss) <= 0 && t[i].point == t[j].point)
                            comp = -1;
                    }
                    if (comp > 0)
                    {
                        t[i].miss++;
                        t[opp].goal++;
                        _ans++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (t[i].CompareTo(t[opp]) < 0)
                {
                    t[i].miss--;
                    t[opp].goal--;
                    _ans--;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (i == j) continue;
                    if ((t[i].goal - t[i].miss) - (t[j].goal - t[j].miss) == 0 && t[j].goal > t[i].goal)
                    {
                        int dif = (t[j].goal - t[i].goal) + (t[i].name.CompareTo(t[j].name) < 0 ? 0 : 1);
                        ans += dif;
                        _ans += dif;
                        t[i].goal += dif;
                        t[opp].goal += dif;
                        t[i].miss += dif;
                        t[opp].miss += dif;
                    }
                }
                if (ans == _ans)
                    _ans--;
                Console.WriteLine(ans + ":" + _ans);

            }

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

   /* public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

   /* class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;

        public Graph(int n)
        {
            g = new List<int>[n + 1];
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static void DFS(int u, ref int time, Graph g)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    DFS(v, ref time, g);
                }
            }
            g.color[u] = black;
            g.c[u] = time;
            time++;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }*/
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}


#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Team : IComparable<Team>
    {
        public string name;
        public int goal;
        public int miss;
        public int point;
        public int cnt;
        public int CompareTo(Team y)
        {
            if (this.point > y.point)
            {
                return 1;
            }
            else
            {
                if (this.point == y.point)
                {
                    if (this.goal - this.miss > y.goal - y.miss)
                    {
                        return 1;
                    }
                    else
                    {
                        if (this.goal - this.miss == y.goal - y.miss)
                        {
                            if (this.goal > y.goal)
                            {
                                return 1;
                            }
                            else
                            {
                                if (this.goal == y.goal)
                                {
                                    if (this.name.CompareTo(y.name) < 0)
                                        return 1;
                                    else
                                        return -1;
                                }
                                else
                                {
                                    return -1;
                                }
                            }

                        }
                        else
                        {
                            return -1;
                        }
                    }
                }
                else
                {
                    return -1;
                }
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            Team[] t = new Team[4];
            for (int i = 0; i < 5; i++)
            {
                string[] input = ReadArray();
                string[] score = input[2].Split(':');
                int x = int.Parse(score[0]);
                int y = int.Parse(score[1]);
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[0];
                    }
                    if (t[j].name.Equals(input[0]))
                    {
                        if (x > y) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += x;
                        t[j].miss += y;
                        t[j].cnt++;
                        break;
                    }

                }
                for (int j = 0; j < 4; j++)
                {
                    if (t[j] == null)
                    {
                        t[j] = new Team();
                        t[j].name = input[1];
                    }
                    if (t[j].name.Equals(input[1]))
                    {
                        if (y > x) t[j].point += 3;
                        if (x == y) t[j].point++;
                        t[j].goal += y;
                        t[j].miss += x;
                        t[j].cnt++;
                        break;
                    }
                }
            }

            int ans = 0;
            int _ans = 0;
            for (int i = 0; i < 4; i++)
            {
                if (t[i].name.Equals("BERLAND"))
                {
                    t[i].point += 3;
                    t[i].goal++;
                    ans++;
                }
                else if (t[i].cnt == 2)
                {
                    t[i].miss++;
                }
            }

            Team[] L = new Team[4];
            Team[] R = new Team[4];
            ArrayUtils.Merge_Sort(t, 0, 3, L, R);

            int opp = 0;
            for (int i = 0; i < 4; i++)
                if (!t[i].name.Equals("BERLAND") && t[i].cnt == 2)
                    opp = i;

            for (int i = 0; i < 4; i++)
            {
                if (!t[i].name.Equals("BERLAND")) continue;

                if (i >= 2)
                {
                    Console.WriteLine("1:0");
                    return;
                }
                if (t[i].point < t[2].point)
                {
                    Console.WriteLine("IMPOSSIBLE");
                    return;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (j == i) continue;
                    while (t[i].CompareTo(t[j]) < 0)
                    {
                        t[i].goal++;
                        t[opp].miss++;
                        ans++;
                    }
                }
                while (true)
                {
                    int comp = 1;
                    for (int j = 0; j < 3; j++)
                    {
                        if (j == i) continue;
                        if ((t[i].goal - t[i].miss) - (t[j].goal - t[j].miss) <= 0 && t[i].point == t[j].point)
                            comp = -1;
                    }
                    if (comp > 0)
                    {
                        t[i].miss++;
                        t[opp].goal++;
                        _ans++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (t[i].CompareTo(t[opp]) < 0)
                {
                    t[i].miss--;
                    t[opp].goal--;
                    _ans--;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (i == j) continue;
                    if ((t[i].goal - t[i].miss) - (t[j].goal - t[j].miss) == 0 && t[j].goal > t[i].goal)
                    {
                        int dif = (t[j].goal - t[i].goal) + 1;
                        ans += dif;
                        _ans += dif;
                        t[i].goal += dif;
                        t[opp].goal += dif;
                        t[i].miss += dif;
                        t[opp].miss += dif;
                    }
                }
                if (ans == _ans)
                    _ans--;
                Console.WriteLine(ans + ":" + _ans);

            }

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

   /* public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

   /* class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;

        public Graph(int n)
        {
            g = new List<int>[n + 1];
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static void DFS(int u, ref int time, Graph g)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    DFS(v, ref time, g);
                }
            }
            g.color[u] = black;
            g.c[u] = time;
            time++;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }*/
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}