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

public static partial class MyExtension
{
    public const int DEFAULT_BUFFER_SIZE = 4194304;
    public class Solution
    {
        /* Head ends here */

        public const int PAD_FACTOR = 7;

        bool solve()
        {
            var pass = ReadLine();
            var N = ReadInt32();
            var arr = new List<string>(N);
            range(1, N).forEach(_ => arr.Add(ReadLine()));
            if (arr.Contains(pass)) return true;
            var first = arr.Any(s => s[0] == pass[1]);
            var second = arr.Any(s => s[1] == pass[0]);
            return first && second;
        }

        public void zStart()
        {
            Console.WriteLine(solve() ? "YES" : "NO");
            ///////////////////////////////////////

            //foreach (var @__ in Enumerable.Range(1, ReadInt32()))
            //{
                // start... - no CONSOLE

                // end...

                //var ansLines = new List<string>(9999);
                //{
                //    // ANS start...

                //    //ansLines.AddRange(inp.Select(x => new string(x)));
                //    //...

                //    Console.Write("Case #{0}: ", @__);
                //    Console.WriteLine(string.Join(" ", __getFormattedString(ans)));
                //    ansLines.ForEach(x => Console.WriteLine(x));
                //}
                //Trace.WriteLine(string.Format("DONE_{0}.", @__));
            //}
        }

        T __getFormattedString<T>(T val) { return val; }
#if DEBUG
        string __getFormattedString(double d) { return d.ToString("0.000000"); }
#endif
        /* Tail starts here */
    }

#if TORIQ
    static void Pretest()
    {
        Test(@"ya
4
ah
oy
to
ha", "YES");
        Test(@"hp
2
ht
tp", "NO");
        Test(@"ah
1
ha", "YES");
    }
    static void MainTest()
    {
        Test(File.ReadAllText("input.txt")
            , File.ReadAllText("output.txt")
            );
        //
    }
#endif

    // =============================================================================================

    #region faSTDIO
    [DebuggerNonUserCode]
    static void Main(String[] args)
    {
#if TORIQ
        zTestSuite();
        //new Solution().zInternalTestSuite();
        return;
#endif
#if GOOGLE
        zGoogle();
        return;
#endif
        new Solution().zStart();
    }

    static IEnumerable<char> Read()
    {
        int cin;
        var empty = true;
        while ((cin = Console.Read()) > -1)
        {
            var c = (char)cin;
            if (c == ' ' || c == '\n' || c == '\r' || c == '\t')
            {
                if (empty) continue;
                else break;
            }
            yield return c;
            empty = false;
        }
    }
    static T Read<T>(Converter<string, T> convert, int capacity = 20)
    { var temp = ReadString(capacity); return convert(temp); }
    static string ReadString(int capacity = 1000000)
    {
        capacity += Solution.PAD_FACTOR;
        var ans = new System.Text.StringBuilder(capacity);
        foreach (var c in Read()) ans.Append(c);
        return ans.ToString();
    }
    static string ReadLine(int capacity = DEFAULT_BUFFER_SIZE)
    {
        capacity += Solution.PAD_FACTOR;
        var ans = Console.ReadLine();
        if (string.IsNullOrWhiteSpace(ans.Trim()))
            ans = Console.ReadLine();
        return ans;
    }
    static int ReadInt32() { return Read(Convert.ToInt32); }
    static long ReadLong64() { return Read(Convert.ToInt64); }

    #endregion
    #region LIBS
    [DebuggerNonUserCode]
    public static void assert(bool mustBeTrue, string message = "ASSERTION FAILED", params object[] args)
    {
        if (mustBeTrue == false)
            throw new ApplicationException(string.Format(message, args));
    }

    [DebuggerNonUserCode]
    public static T assert<T>(T actual, T expected)
    {
        if (object.Equals(actual, expected) == false)
        {
            Debug.WriteLine(expected, "CORRECT");
            Debug.WriteLine(actual, "ACTUAL");
            assert(false, "[{0}] SHOULD BE [{1}]", actual, expected);
        }
        return actual;
    }

    [Conditional("DEBUG")]
    public static void EmptyConditionalDebugBreak() { }

    public static bool isLrLeftRight<T>(T left, T right) where T : IComparable<T>
    { return left.CompareTo(right) <= 0; }

    [DebuggerNonUserCode]
    public static void lrLeftRight_ASSERT<T>(T left, T right) where T : IComparable<T>
    { assert(isLrLeftRight(left, right), "Expect left [{0}] <= [{1}] right", left, right); }

    public static IEnumerable<T> forEach<T>(this IEnumerable<T> range, Action<T> action)
    { foreach (var elem in range) action(elem); return range; }

    [DebuggerNonUserCode]
    public static void __AssertIncrStep(double incrStep) { assert(incrStep > 0, "Expect 'incrStep [{0}] > 0'", incrStep); }

    public static IEnumerable<int> range(int left, int right, int incrStep = 1)
    {
        lrLeftRight_ASSERT(left, right);
        __AssertIncrStep(incrStep);
        for (var i = left; i <= right; i += incrStep) yield return i;
    }
    public static IEnumerable<int> rangeReverse(int left, int right, int decrStep = 1)
    {
        lrLeftRight_ASSERT(left, right);
        __AssertIncrStep(decrStep);
        for (var i = right; i >= left; i -= decrStep) yield return i;
    }

    #endregion

    // =============================================================================================

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _513A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n1 = Convert.ToInt32(str[0]);
            int n2 = Convert.ToInt32(str[1]);

            if (n2 >= n1) { Console.WriteLine("Second"); } else
            {
                Console.WriteLine("First");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// Codeforces problem 513A "Игра"
// http://codeforces.com/problemset/problem/513/A
namespace _513_A
{
	class Program
	{
		static void Main(string[] args)
		{
			#region Read data
			string[] tmp = Console.ReadLine().Split();
			int n1 = Convert.ToInt32(tmp[0]);
			int n2 = Convert.ToInt32(tmp[1]);
			int k1 = Convert.ToInt32(tmp[2]);
			int k2 = Convert.ToInt32(tmp[3]);
			#endregion
			#region Process data

			#endregion
			#region Write results
			if (n1 > n2)
			{
				Console.WriteLine("First");
			}
			else
			{
				Console.WriteLine("Second");
			}
			Console.ReadLine();
			#endregion
		}
	}
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int[][] divs = new []
    {
        null,
        null,
        new [] { 2 },
        new [] { 3 },
        new [] { 2, 2 },
        new [] { 5 },
        new [] { 2, 3 },
        new [] { 7 },
        new [] { 2, 2, 2 },
        new [] { 3, 3 }
    };

    public void Solve()
    {
        ReadInt();
        var count = new int[8];
        foreach (char c in ReadToken())
            for (int i = 2; i <= c - '0'; i++)
                foreach (int x in divs[i])
                    count[x]++;

        foreach (var x in new [] { 7, 5, 3, 2})
            while (count[x] > 0)
            {
                writer.Write(x);
                for (int i = 2; i <= x; i++)
                    foreach (int y in divs[i])
                        count[y]--;
            }
        Write();
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("game.in");
        //writer = new StreamWriter("game.out");
#endif
        try
        {
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);
            thread.Start();
            thread.Join();
            //new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

/// <id guid="88cbde0b-19a8-421c-98c3-0b7b0a589973" />
public class Program
{
    static int[] primes = new int[] { 2, 3, 5, 7 };
    static Tuple<int, int, int, int>[] preCalc = new Tuple<int, int, int, int>[10];
    static Tuple<int, int, int, int>[] preCalcFact = new Tuple<int, int, int, int>[10];
    private static void init()
    {
        for (int i = 0; i <= 9; i++)
        {
            int[] states = new int[4];

            int tmp = i;
            for (int j = 0; j < primes.Length && i >= 2; j++)
            {
                while (tmp % primes[j] == 0)
                {
                    tmp /= primes[j];
                    states[j]++;
                }
            }

            preCalc[i] = new Tuple<int, int, int, int>(states[0], states[1], states[2], states[3]);
        }

        for (int i = 0; i <= 9; i++)
        {
            if (i - 1 >= 0)
            {
                preCalcFact[i] = new Tuple<int,int,int,int>(
                    preCalcFact[i - 1].Item1 + preCalc[i].Item1,
                    preCalcFact[i - 1].Item2 + preCalc[i].Item2,
                    preCalcFact[i - 1].Item3 + preCalc[i].Item3,
                    preCalcFact[i - 1].Item4 + preCalc[i].Item4);
            }
            else
            {
                preCalcFact[i] = preCalc[i];
            }
        }
    }

    private static Dictionary<Tuple<int, int, int, int>, string> dp;

    private static void Main()
    {
        init();

        int n = Int32.Parse(Console.ReadLine());

        string input = Console.ReadLine();

        dp = new Dictionary<Tuple<int, int, int, int>, string>();

        Console.WriteLine(solve(Convert(input)));
    }

    private static string solve(Tuple<int, int, int, int> state)
    {
        if (state.Item1 == 0 && state.Item2 == 0 && state.Item3 == 0 && state.Item4 == 0)
        {
            return "";
        }
        else if (dp.ContainsKey(state))
        {
            return dp[state];
        }
        else
        {
            string best = null;
            for (int i = 2; i <= 9; i++)
            {
                if (state.Item1 >= preCalcFact[i].Item1 &&
                    state.Item2 >= preCalcFact[i].Item2 &&
                    state.Item3 >= preCalcFact[i].Item3 &&
                    state.Item4 >= preCalcFact[i].Item4)
                {
                    string subString = solve(new Tuple<int, int, int, int>(state.Item1 - preCalcFact[i].Item1,
                        state.Item2 - preCalcFact[i].Item2,
                        state.Item3 - preCalcFact[i].Item3,
                        state.Item4 - preCalcFact[i].Item4));

                    if (subString != null)
                    {
                        string now = (char)('0' + i) + subString;

                        if (best == null || now.Length > best.Length || (now.Length == best.Length && String.Compare(now, best) > 0))
                        {
                            best = now;
                        }
                    }
                }
            }

            dp[state] = best;

            return best;
        }
    }

    static Tuple<int, int, int, int> Convert(string input)
    {
        int[] states = new int[4];
        for (int i = 0; i < input.Length; i++)
        {
            states[0] += preCalcFact[input[i] - '0'].Item1;
            states[1] += preCalcFact[input[i] - '0'].Item2;
            states[2] += preCalcFact[input[i] - '0'].Item3;
            states[3] += preCalcFact[input[i] - '0'].Item4;
        }

        return new Tuple<int, int, int, int>(states[0], states[1], states[2], states[3]);
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static int dp(string s,int c)
        {
            int res = -1;
            if ((c==0)&&(s.Length==0)) return 0;
            if ((c == 0) && (s.Length != 0)) return -1;
            if (s.Length >= c)
            {
                string num="";
                int sum=-1;
                for (int i = 0; i < 7 && i < s.Length - c + 1; i++)
                {
                    num += s[i];
                    int tt =int.Parse(num);
                    if (tt <= 1000000)
                    {
                        int t = dp(s.Substring(i + 1, s.Length - i - 1), c - 1);
                        if ((t != -1) && ((num[0] != '0') || (num.Length == 1)))
                            sum = Math.Max(sum, tt + t);
                    }
                }
                return sum;
            }
            return res;

        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(dp(s, 3));
            Console.ReadLine();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;
        private static bool s_time = false;

        private void Go()
        {
            string s = GetString();
            int n = s.Length;
            int max = -1;
            for (int l1 = 1; l1 <= n-2; l1++)
            {
                for (int l2 = 1; l2 <= n - l1 - 1; l2++)
                {
                    string s1 = s.Substring(0, l1);
                    string s2 = s.Substring(l1, l2);
                    string s3 = s.Substring(l1 + l2);

                    if ((s1[0] == '0' && s1 != "0") || (s2[0] == '0' && s2 != "0") || (s3[0] == '0' && s3 != "0")) continue;
                    if (s1.Length > 7 || s2.Length > 7 || s3.Length > 7) continue;
                    int i1 = int.Parse(s1);
                    int i2 = int.Parse(s2);
                    int i3 = int.Parse(s3);
                    if (i1 > 1000000 || i2 > 1000000 || i3 > 1000000) continue;

                    if (max < i1 + i2 + i3)
                        max = i1 + i2 + i3;
                }
            }

            Wl(max);
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _476b
{
    class Program
    {
        static void Main(string[] args)
        {
            int transmit=0;
            int reseive = 0;
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            int count = 0;
            int count2 = 0;
            int i = 0;
            while (i < s1.Length)
            {
                transmit += s1[i] == '+' ? 1 : -1;
                if (s2[i] != '?')
                    reseive += s2[i] == '+' ? 1 : -1;
                else
                    count++;
                i++;
            }
            if(count == 0)
            {
                if (transmit == reseive)
                    Console.WriteLine(1);
                else
                    Console.Write(0);
            }
            else
            {
                if (Math.Abs((transmit - reseive)) % 2 == count % 2 && (transmit - reseive) <= count && (transmit - reseive) >= -count)
                {
                    int k = (count - (transmit - reseive)) / 2;
                    double result = 1;
                    for (int z = 0; z < k; z++)
                    {
                        result *= (double)(count - z) / (z + 1);
                    }
                    Console.WriteLine((result / Math.Pow(2, count)).ToString("0.000000000000").Replace(',', '.'));
                }
                else
                {
                    Console.WriteLine(0);
                }

            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dreamoon_and_WiFi
{
    class Program
    {
        static void Main(string[] args)
        {
  //Teste x = new Teste();
                //x.calcula(Console.ReadLine(), Console.ReadLine());
                Codigo cod = new Codigo(Console.ReadLine(), Console.ReadLine()); //Chama a função com os dois valores digitados
                cod.exibe(); //Exibe o resultado em decimal
        }
    }

    class Codigo
    {
        //Iniciando um vetor que vai guardar os dois valores possíveis nas instruções
        private int[] contaDreamon = new int[2];
        private int[] contaDrazil = new int[2];

        //Quantidade de valores desconhecidos passados ao drazil
        private int quantInt;

        private int distancia;
        private int posDreamoon;
        private int posDrazil;

        public Codigo(string drazil, string dreamoon)
        {
            contaDreamon[0] = dreamoon.Split(new char[] { '-' }).Length - 1; //Vai contar quantos '-' possui e vai passar para a variável, e assim respectivamente com as 3 próxima linhas
            contaDreamon[1] = dreamoon.Split(new char[] { '+' }).Length - 1;
            contaDrazil[0] = drazil.Split(new char[] { '-' }).Length - 1;
            contaDrazil[1] = drazil.Split(new char[] { '+' }).Length - 1;
            quantInt = dreamoon.Split(new char[] { '?' }).Length - 1; //Quantidade de códigos desconhecidos
            posDrazil = contaDrazil[1] - contaDrazil[0]; //Determina a posição do Drazil depois de enviar os comandos
            posDreamoon = contaDreamon[1] - contaDreamon[0]; //Determina a posição do dreamoon depois de receber os comandos
            distancia = posDrazil - posDreamoon; //Define a distância restante para Dreamoon chegar na mesma posição
        }

        private double compara()
        {
            if (contaDreamon[0] == contaDrazil[0] && contaDreamon[1] == contaDrazil[1]) //Se receberem a mesma quantidade de '+' e '-', a conta termina em 100%
            {
                return 1;
            }
            else if (quantInt < Math.Abs(distancia)) //Se a quantidade de caminhos duvidosos for maior que a distância restante, a chance é zero
                return 0;
            else
            {
                int m = (quantInt + Math.Abs(distancia)) / 2; //Calcula a quantidade de passos válidos para chegar na posição correta

                double combinacao = (fatorial(quantInt) / (fatorial(quantInt - m) * (fatorial(m)))); //Realiza o cálculo da combinação

                return (double)combinacao / (1 << quantInt); //Retorna o restante da formula C(Quantidade de ?, m) / 2 ^ quantidade de ?
            }
        }

        public void exibe()
        {
            string result = compara().ToString();
            result = result.Replace(',', '.');
            Console.WriteLine("{0:F12}", result); //Exibe o resultado com 12 algarismos
        }

        private double fatorial(int n)
        {
            if (n == 1 || n == 0)
                return 1;
            else
                return (n * fatorial(n - 1));
        }
    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e, f;
            a = int.Parse( Console.ReadLine() );
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            e = int.Parse(Console.ReadLine());
            f = int.Parse(Console.ReadLine());

            if (e > f)
            {
                int delim = Math.Min(a, d);
                int ans = delim * e;
                if (delim != d)
                {
                    d -= a;
                    delim = Math.Min(b, Math.Min(c, d));
                    ans += delim * f;
                }
                Console.WriteLine(ans);
            }else
            {
                int delim = Math.Min(b, Math.Min(c, d));
                int ans = delim * f;
                if (delim != d)
                {
                    d -= delim;
                    delim = Math.Min(a, d);
                    ans += delim * e;
                }
                Console.WriteLine(ans);
            }
            //Console.ReadKey();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication37
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            int b = Convert.ToInt32(Console.ReadLine());
            int c = Convert.ToInt32(Console.ReadLine());
            int d = Convert.ToInt32(Console.ReadLine());
            int e = Convert.ToInt32(Console.ReadLine());
            int f = Convert.ToInt32(Console.ReadLine());

            if (f >= e)
            {
                int min = Math.Min(b, Math.Min(c, d));

                long ans = min * f;
                if (d > min)
                {
                    d = d - min;

                    int minn = Math.Min(a, d);
                    ans = ans + minn * e;

                    Console.WriteLine(ans);
                }
                else
                    Console.WriteLine(ans);
            }
            else if (f < e)
            {
                int min = Math.Min(a, d);
                long ans = min * e;

                if (d == min)
                    Console.WriteLine(ans);
                else
                {
                    d = d - min;
                    ans = ans + Math.Min(b, Math.Min(c, d)) * f;
                    Console.WriteLine(ans);
                }
            }
        }
    }
}


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

namespace comp
{
    class Program
    {

        static void Main(string[] args)
        {
            string a = "";
            a = Console.ReadLine();
           // string a = "WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB";
            a = a.Replace("WUB", " ");
            Console.WriteLine(a) ;

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contesa
{
    class Program
    {
        static void Main(string[] args)
        {
            string Song = Console.ReadLine();
            Song = Song.Replace("WUB", " ");
            Console.WriteLine(Song.TrimStart());

        }

    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace MakeCalendar
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static void Main(string[] args)
        {

            int P = 1000000007 ;

            int n = ReadIntLine();

            long k = 1;
            long s_k = 0;
            long d_k = 1;

            while (k != n)
            {
                long s_k1 = (3 * d_k) % P;
                long d_k1 = (2 * d_k + s_k) % P;

                d_k = d_k1;
                s_k = s_k1;

                k++;
            }

            PrintLn(s_k);

        }

    }

}


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

namespace Codeforce158
{
    class Program
    {
        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            List<int> res = new List<int>();
            for (int i = 0; i < temp.Length; i++)
            {
                res.Add(Convert.ToInt32(temp[i]));
            }
            return res.ToArray();
        }

        const int Mod = 1000000007;
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            int[,] F = new int[n + 2, 4];

            F[1, 1] = 0;
            F[1, 2] = 0;
            F[1, 3] = 0;
            F[1, 0] = 1;

            for (int i = 2; i <= n + 1; i++)
            {
                F[i, 1] = ((F[i - 1, 2] + F[i - 1, 3]) % Mod + F[i - 1, 0])%Mod;
                F[i, 2] = ((F[i - 1, 1] + F[i - 1, 3]) % Mod + F[i - 1, 0])%Mod;
                F[i, 3] = ((F[i - 1, 1] + F[i - 1, 2]) % Mod + F[i - 1, 0])%Mod;
                F[i, 0] = ((F[i - 1, 1] + F[i - 1, 2]) % Mod + F[i - 1, 3])%Mod;
            }

            Console.WriteLine(F[n + 1, 0]);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
namespace CP
{
    class Program
    {
        static void Main(string [] main)
        {
            int [] nAndM = Array.ConvertAll(Console.ReadLine().Split(' ') , x => Convert.ToInt32(x));
            Console.WriteLine(nAndM.Max() - 1 + " " + nAndM.Min());
        }
    }
}


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

namespace Timus
{

    class Program
    {
        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            List<int> res = new List<int>();
            for (int i = 0; i < temp.Length; i++)
            {
                res.Add(Convert.ToInt32(temp[i]));
            }
            return res.ToArray();
        }

        static void Main(string[] args)
        {
            int[] data = parseInt(Console.ReadLine());
            if (data[0] < data[1])
            {
                int temp = data[0];
                data[0] = data[1];
                data[1] = temp;
            }

            int a1 = data[1] + (data[0] - data[1] - 1);
            int a2 = data[1];
            Console.WriteLine(a1 + " " + a2);

        }

    }
}


using System;
using System.Text;

namespace codeforces_round_157_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3,3];
            int sum = 0;
            int sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                string[] st = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                {
                    arr[i, j] = Int32.Parse(st[j]);
                    sum += arr[i, j];
                }
            }
            sum /= 2;
            arr[0,0] = sum - (arr[0, 1] + arr[0, 2]);
            arr[2, 2] = sum - (arr[0, 2] + arr[1, 2]);
            arr[1, 1] = (arr[0, 0] + arr[2, 2])/2;
            int x = 0;
            foreach (int i in arr)
            {
                if (x++ < 2)
                    Console.Write(i+" ");
                else
                {
                    Console.WriteLine(i);
                    x = 0;
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CDF157
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] a = new int[3, 3];
            string[] input;
            for (int i = 0; i < 3; i++)
            {
                input = Console.ReadLine().Split(' ');
                for (int j = 0; j < 3; j++)
                    a[i, j] = int.Parse(input[j]);
            }
            int e = (a[0, 1] + a[0, 2] + a[1, 0] + a[1, 2] + a[2, 0] + a[2, 1]) / 2;
            a[0,0] = e - a[0, 1] - a[0, 2];
            a[1,1]= e - a[1, 0] - a[1, 2];
            a[2,2] = e - a[2, 0] - a[2, 1];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    Console.Write(a[i, j] + " ");
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Komanda
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int l = int.Parse(s[0]);
            int r = int.Parse(s[1]);
            int a = int.Parse(s[2]);
            int min = Math.Min(l, r);
            int max = Math.Max(l, r);
            int diff = max - min;
            min += Math.Min(a, diff);
            a -= Math.Min(a, diff);
            min += a / 2;
            Console.Write(min * 2);

        }
    }
}


using System;
using System.Collections.Generic;

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R469A.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R469A();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R469A : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            var ints = this.ReadIntArray();
            var l = ints[0];
            var r = ints[1];
            var a = ints[2];

            var b = Math.Min(l, r);
            var over = Math.Max(l - b, r - b);
            if (a >= over)
            {
                b += over;
                a -= over;
                b += a / 2;
            }
            else
            {
                b += a;
            }

            yield return (b*2).ToString();
        }
    }

    internal class R469B : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }
    internal class R469C : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }
    internal class R469D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        /// <summary>
        /// Pring array of T
        /// </summary>
        /// <typeparam name="T">Generic paramter.</typeparam>
        /// <param name="items">The items.</param>
        /// <param name="prefixMessage">The message shown first.</param>
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}


using System;
using System.Collections.Generic;

namespace a1
{
	public class Program
	{
		public static int F(int x)
		{
			var v = x + 1;
			while (v % 10 == 0)
			{
				v /= 10;
			}

			return v;
		}

		public static void Main(string[] args)
		{
			var n = Int32.Parse(Console.ReadLine());

			var d = new HashSet<int>();

			for (var i = 0; i < 10000; i++)
			{
				d.Add(n);
				n = F(n);
			}

			Console.WriteLine(d.Count);
		}
	}
}


using System;
using System.Text;

namespace UdsuTest
{
    class Program
    {
        public static void Main(string[] args)
        {
            Int64 input =  Int64.Parse(Console.ReadLine());

            Int64 answer = 1;
            if (input < 10)
            {
                answer = 0;
            }

            while (input >= 10L)
            {
                Int64 right = input % 10L;

                answer = 9L - right + answer;

                input /= 10;
            }

            answer += 9;

            Console.WriteLine(answer);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;

namespace CodeForcesApp
{
    class B
    {
        #region Shortcuts
        static string RL() { return Console.ReadLine(); }
        static string[] RSA() { return RL().Split(' '); }
        static int[] RIA() { return Array.ConvertAll<string, int>(RSA(), int.Parse); }
        static int RInt() { return int.Parse(RL()); }
        static long RLong() { return long.Parse(RL()); }
        static double RDouble() { return double.Parse(RL()); }
        static void RInts2(out int p1, out int p2) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; }
        static void RInts3(out int p1, out int p2, out int p3) { int[] a = RIA(); p1 = a[0]; p2 = a[1]; p3 = a[2]; }

        static void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        static void Fill<T>(T[] d, T v) { for (int i = 0; i < d.Length; i++) d[i] = v; }
        static void Fill<T>(T[,] d, T v) { for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { d[i, j] = v; } } }
        #endregion

        static void Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            //SolutionTester tester = new SolutionTester(CodeForcesTask.B);
            //tester.Test();

            Task task = new Task();
            task.Solve();
        }

        public class Task
        {
            public void Solve()
            {
                string cd = RL();
                string bd = RL();

                string[] cd_dd = cd.Split('.');

                string format = "dd.MM.yyyy";

                DateTime cd_date = DateTime.ParseExact(string.Format("{0}.{1}.{2}", cd_dd[0], cd_dd[1], 2000 + int.Parse(cd_dd[2])), format, CultureInfo.InvariantCulture);

                int[] dd = Array.ConvertAll<string, int>(bd.Split('.'), int.Parse);

                int[] p = { 0, 1, 2 };

                do
                {
                    string nd = string.Format("{0}.{1}.{2}", dd[p[0]].ToString().PadLeft(2, '0'), dd[p[1]].ToString().PadLeft(2, '0'), 2000 + dd[p[2]]);

                    DateTime ddt;
                    if (DateTime.TryParseExact(nd, format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out ddt))
                    {
                        if (ddt.Year % 4 == 0 && ddt.Month == 2 && ddt.Day == 29)
                            ddt = new DateTime(ddt.Year, 3, 1);

                        if (ddt.AddYears(18) <= cd_date.AddMinutes(23 * 60 + 59))
                        {
                            Console.WriteLine("YES");
                            return;
                        }
                    }

                } while (GetNext(p));

                Console.WriteLine("NO");
            }

            public bool GetNext(int[] p)
            {
                int n = p.Length;
                int i = n - 2;
                while (i >= 0 && p[i] >= p[i + 1])
                    i--;
                if (i == -1)
                    return false;

                int k = i + 1;
                for (int j = i + 1; j < n; j++)
                    if (p[j] < p[k] && p[j] > p[i])
                        k = j;

                int t = p[i];
                p[i] = p[k];
                p[k] = t;

                for (int j = 0; j < (n - i - 1) / 2; j++)
                {
                    t = p[j + i + 1];
                    p[j + i + 1] = p[n - j - 1];
                    p[n - j - 1] = t;
                }

                return true;
            }
        }

    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;

class Program
{
    void solve()
    {
        int[] a = get();
        int[] m = get();
        String res = "NO";
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
            {
                if (i == j)
                    continue;
                int k = 3 - i - j;
                int[] cur = new int[3];
                cur[0] = m[i];
                cur[1] = m[j];
                cur[2] = m[k];
                if (ok(cur, a))
                    res = "YES";
            }
        println(res);
    }

    private bool ok(int[] cur, int[] a)
    {
        int[]d=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        cur[1]--;
        if(cur[1]>=12)
            return false;
        if (cur[2] % 4 == 0)
        {
            d[1]++;
        }
        if (d[cur[1]] < cur[0])
            return false;
        int y = cur[2]+18;
        int[] t = new int[3];
        t[2] =y;
        t[1] = cur[1];
        t[0] = cur[0];
        if (cur[0] == 29 && cur[1] == 1)
        {
            if (y % 4 == 0)
                t[0] = 29;
            else
            {
                t[0] = 1;
                t[1]++;
            }
        }
        t[1]++;
        for (int i = 2; i >= 0; i--)
            if (a[i] != t[i])
                return t[i] < a[i];
        return true;

    }

    private int[] get()
    {
        string[] t = nextString().Split('.');
        int[] r = new int[3];
        for (int i = 0; i < 3; i++)
            r[i] = int.Parse(t[i]);
        return r;
    }

    ////////////
    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        Console.WriteLine(Doublenum);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}


using System;
using System.Linq;

namespace KitaharaHarukisGift
{
    class Program
    {
        static void Main(string[] args)
        {
            int apples = int.Parse(Console.ReadLine());
            int[] grams = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(x => x).ToArray<int>();
            int friend1 = 0;
            int friend2 = 0;
            for (int i = 0; i < grams.Length; i++)
            {
                if (friend1 <= friend2)
                    friend1 += grams[i];
                else
                    friend2 += grams[i];
            }
            Console.WriteLine(friend1 == friend2 ? "YES" : "NO");
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Schema;

namespace Codeforces
{
    internal static class Program
    {
        private const string Problem = "a";

        private static void Solve()
        {
            var n = ReadInt();
            var w = ReadIntArray();
            var sum = w.Sum();
            var a = sum/2;
            if(a % 200 == 0 || (a% 100 == 0 && w.Contains(100)))
                WriteLine("YES");
            else
                WriteLine("NO");
        }

        private static void Main()
        {
            var isDebbuger = Debugger.IsAttached;
            if (isDebbuger)
            {
                var projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent;
                var testsPath = Path.Combine(projectPath != null? projectPath.FullName: "", "tests");
                var files = Directory.GetFiles(testsPath, string.Format("{0}*.in", Problem));

                foreach (var file in files)
                {
                    Console.SetIn(new StreamReader(file));
                    Console.WriteLine(Path.GetFileNameWithoutExtension(file));
                    Solve();

                    Console.WriteLine();

                    Console.In.Close();
                    Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                }

                Console.ReadLine();
            }
            else
                Solve();
        }

        private static int[] SortIndexs<T>(this IEnumerable<T> source) where T : IComparable
        {
            var array = source == null ? new List<T>() : source.ToList();
            var n = array.Count;
            var res = Enumerable.Range(0, n).ToArray();
            Array.Sort(res, (a, b) =>
            {
                var compare = array[a].CompareTo(array[b]);
                return compare == 0 ? a.CompareTo(b) : compare;
            });
            return res;
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
            a6 = (T)Convert.ChangeType(input[5], typeof(T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Теорема_Пифагора_II
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 n;
            n = Convert.ToInt64(Console.ReadLine());
            Int64 sqn = n * n;
            Int64 a, b, c, ret = 0;
            double sqc;
            for (a = 1; a <= n; a++)
                for (b = a; b <= n; b++)
                {
                    c = a * a + b * b;
                    sqc = Math.Sqrt(c);
                    if (c <= sqn)
                    {
                        if ((int)sqc == sqc) ret++;
                    }
                    else break;
                }
            Console.Write(ret);

        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace MakeCalendar
{
    public static class MainClass
    {

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

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static void Main(string[] args)
        {
            int ub = ReadIntLine();
            int k = (int)Math.Ceiling(Math.Sqrt(ub));

            HashSet<string> set = new HashSet<string>();

            for (int m = 1; m < k; m++)
            {
                for (int n = 1; n < m; n++)
                {
                    if (gcd(n, m) == 1)
                    {
                        int c = m * m + n * n;
                        int b = Math.Max(m * m - n * n,2*m*n);
                        int a = Math.Min(m * m - n * n, 2 * m * n);

                        int cc = c, bb = b, aa = a;

                        while (cc<=ub)
                        {
                            //PrintLn(aa,bb,cc);
                            set.Add(aa + "," + bb);
                            aa += a;
                            bb += b;
                            cc += c;
                        }
                    }
                }
            }

            PrintLn(set.Count);

        }

    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var a = sr.NextInt64();
            var b = sr.NextInt64();
            var f = sr.NextInt64();
            var k = sr.NextInt64();

            var currB = b;
            var count = 0L;
            for (var i = 0; i < k; i++) {
                var firstStation = i % 2 == 0 ? f : a - f;
                var secondStation = i % 2 == 0 ? 2*a - f : a + f;
                if (i + 1 == k) {
                    if (currB - a >= 0) {
                        break;
                    }
                    else {
                        if (currB < firstStation) {
                            sw.WriteLine(-1);
                            return;
                        }
                        if (b < (a - firstStation)) {
                            sw.WriteLine(-1);
                            return;
                        }
                        count++;
                        break;
                    }
                }
                if (currB < firstStation) {
                    sw.WriteLine(-1);
                    return;
                }
                if (currB >= secondStation) {
                    currB -= a;
                }
                else {
                    currB = b - (a - firstStation);
                    count++;
                }
            }

            sw.WriteLine(count);
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;

namespace Codeforces
{
    class Program : IDisposable
    {
        private static readonly TextReader textReader = new StreamReader(Console.OpenStandardInput());
        private static readonly TextWriter textWriter = new StreamWriter(Console.OpenStandardOutput());

        private void Solve()
        {
            var s = Console.ReadLine().Split(' ');
            var a = long.Parse(s[0]);
            var b = long.Parse(s[1]);
            var f = long.Parse(s[2]);
            var k = long.Parse(s[3]);

            long sum = f;
            long dist = k*a;
            var points = new List<long>() {0,f};
            var forw = 2*(a-f);
            var back = 2*f;
            var sw = true;
            while (sum<dist)
            {
                if (sw)
                {
                    sum += forw;
                    points.Add(sum);
                }
                else
                {
                    sum += back;
                    points.Add(sum);
                }
                sw = !sw;
            }
            points[points.Count-1] = dist;

            if (points[1] - points[0] > b)
            {
                Console.WriteLine(-1);
                return;
            }

            var cnt = 0;
            var r = b;
            for (int i = 1; i < points.Count; i++)
            {
                var d = points[i]-points[i-1];
                if (d > r)
                {
                    cnt++;
                    r = b;
                    if (r < d)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
               r -= d;
            }
            Console.WriteLine(cnt);
        }

        int BinarySearch(int[] arr, int q)
        {
            var l = 0;
            var r = arr.Length - 1;
            //int med = -1;
            while (l <= r)
            {
                var med = l + (r - l) / 2;
                if (arr[med] == q)
                {
                    return med;
                }
                if (q < arr[med])
                {
                    r = med - 1;
                }
                else
                {
                    l = med + 1;
                }
            }
            return -1;
        }

        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
            //Console.ReadLine();
            //p.Dispose();
            //////////////////////////////
        }

        #region Helpers

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

        private static long ReadLong()
        {
            return long.Parse(textReader.ReadLine());
        }

        private static int[] ReadIntArray()
        {
            return textReader.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion

        public void Dispose()
        {
            textReader.Close();
            textWriter.Close();
        }
    }

    //class Trie
    //{
    //    public TrieNode root;

    //    public Trie()
    //    {
    //        root = new TrieNode();
    //    }

    //    public void Insert(string s)
    //    {
    //        var current = root;
    //        for (int i = 0; i < s.Length; i++)
    //        {
    //            var ch = s[i];
    //            if (!current.Children.ContainsKey(ch))
    //                current.Children.Add(ch, new TrieNode());
    //            current = current.Children[ch];
    //        }
    //        current.IsEnd = true;
    //    }

    //    public bool Search(string word)
    //    {
    //        var current = root;
    //        for (int i = 0; i < word.Length; i++)
    //        {
    //            var ch = word[i];
    //            if (!current.Children.ContainsKey(ch))
    //                return false;
    //            current = current.Children[ch];
    //        }
    //        return current.IsEnd;
    //    }
    //}

    //class TrieNode
    //{
    //    public Dictionary<char, TrieNode> Children { get; set; }
    //    public bool IsEnd { get; set; }

    //    public TrieNode()
    //    {
    //        Children = new Dictionary<char, TrieNode>();
    //        IsEnd = false;
    //    }

    //}
}


using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class solution
{
    static void Main(string[] args)
    {
        string[] ab = Console.ReadLine().Split(' ');
        long n = Convert.ToInt64(ab[0]);
        long k = Convert.ToInt64(ab[1]);
        long div = n / k;
        long val = k*(div+1);
        Console.Write(val);
    }
}


using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] res = input.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(res[0]);
            int k = int.Parse(res[1]);
            Console.WriteLine(k*(n/k + 1));

        }
    }
}


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

namespace CodeForcecTrain
{
    class Program
    {
        static void Main(string[] args)
        {
            var kupuri = new int[] { 1, 5, 10, 20, 100 };
            var start = int.Parse(Console.ReadLine());
            int index = 0;
            int res = 0;
            while (start>0)
            {
                if (index < kupuri.Length)
                {
                    while (start - kupuri[kupuri.Length - index - 1] >= 0)
                    {
                        start -= kupuri[kupuri.Length - index - 1];
                        res++;
                    }
                }
                index++;
            }
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            // input //
            int money = int.Parse(Console.ReadLine());

            // process //
            int counter = 0;
            while(money != 0)
            {
                if (money >= 100)
                {
                    counter += money / 100;
                    money %= 100;
                }
                else if (money >= 20)
                {
                    counter += money / 20;
                    money %= 20;
                }
                else if (money >= 10)
                {
                    counter += money / 10;
                    money %= 10;
                }
                else if (money >= 5)
                {
                    counter += money / 5;
                    money %= 5;
                }
                else
                {
                    counter += money / 1;
                    money = 0;
                }
            }

            // output //
            Console.Write(counter);
            Console.ReadLine();

        }
    }
}


using System;

namespace ConsoleApp5
{

    class Program
    {

        static void Main(string[] args)
        {
            Int32 n = Int32.Parse(Console.ReadLine());

            Console.Write(n/2 +1);
            Console.ReadLine();

        }
    }
}


using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n/2+1);
        }
    }
}


using System;
public class Codeforces
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        var lim = (long)Math.Sqrt(n * 2) + 1;
        var i = 1L;
        var j = lim;
        while (i <= lim && j > 0)
        {
            if (i * i + i + j * j + j == 2 * n)
            {
                Console.WriteLine("YES");
                return;
            }
            if (i * i + i + j * j + j > 2 * n)
            {
                j--;
            }
            else
            {
                i++;
            }
        }
        Console.WriteLine("NO");
    }
}


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

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

namespace _121b
{
    class Program
    {
        static string _inputFilename = "in.txt";
        static string _outputFilename = "out.txt";
        static bool _useFileInput = false;

        static long n;
        //static int m;

        static int[] a;
        static int[] b;

        static void Main(string[] args)
        {
            StreamWriter file = null;
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

            #region SOLUTION
            n = readLong();
            var can = false;
            for (int i = 1; i < n; i++)
            {
                var sum = i * (i + 1) / 2;
                if (sum >= n)
                {
                    break;
                }

                var rem = n - sum;
                var l = 1L;
                var r = n;
                while (true)
                {
                    if (l == r)
                    {
                        break;
                    }

                    var m = l + (r - l) / 2;
                    var ns = m * (m + 1) / 2;
                    if (ns < rem)
                    {
                        l = m + 1;
                    }
                    else
                    {
                        r = m;
                    }
                }

                var ns1 = l * (l + 1) / 2;
                if (rem == ns1)
                {
                    can = true;
                    break;
                }
            }

            Console.WriteLine(can ? "YES" : "NO");
            //n = readInt();
            //m = readInt();

            //a = readIntArray();
            //b = readIntArray();
            #endregion

            if (_useFileInput)
            {
                file.Close();
            }
        }

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

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}


using System;
 class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = n / 7 * 2;
            n%=7;
            Console.WriteLine("{0} {1}", (a + (n == 6 ? 1 : 0)), (a+(n>1?2:n)));
        }
    }


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.IO;
namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int min=0;
            int max=0;

                min = (n / 7) * 2 + (n - (n / 7) * 7) / 6;
                if (n % 7 == 0) {
                    max = min;
                }
                if (n % 7 > 1)
                {
                    max = (n / 7 + 1) * 2;

                }
                if (n % 7 == 1)
                {
                    max = (n / 7 * 2 + 1);
                }
                Console.WriteLine(min.ToString() + " " + max.ToString());
                Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace Algorithm
{
    class Solver
    {
        Player[] a = new Player[4];

        public void Run()
        {
            for (int i = 0; i < 4; i++)
            {
                string[] tokens = cin.ReadLine().Split();
                int x = int.Parse(tokens[0]);
                int y = int.Parse(tokens[1]);
                a[i] = new Player(x, y);
            }

            if (can_win(a[0].Defence, a[1].Attak, a[2].Defence, a[3].Attak) &&
                can_win(a[0].Defence, a[1].Attak, a[3].Defence, a[2].Attak))
            {
                cout.WriteLine("Team 1");
                return;
            }
            if (can_win(a[1].Defence, a[0].Attak, a[2].Defence, a[3].Attak) &&
                can_win(a[1].Defence, a[0].Attak, a[3].Defence, a[2].Attak))
            {
                cout.WriteLine("Team 1");
                return;
            }

            int cnt = 0;
            if (can_win(a[2].Defence, a[3].Attak, a[0].Defence, a[1].Attak) ||
               can_win(a[3].Defence, a[2].Attak, a[0].Defence, a[1].Attak)) cnt++;
            if (can_win(a[2].Defence, a[3].Attak, a[1].Defence, a[0].Attak) ||
                can_win(a[3].Defence, a[2].Attak, a[1].Defence, a[0].Attak)) cnt++;

            if (cnt == 2)
                cout.WriteLine("Team 2");
            else
                cout.WriteLine("Draw");
        }

        bool can_win(int a, int b, int c, int d)
        {
            if (a > d && b > c) return true;
            return false;
        }

        void Swap(ref int a, ref int b)
        {
            int tmp = a;
            a = b;
            b = tmp;
        }

        public StreamReader cin = null;
        public StreamWriter cout = null;
    }

    class Player
    {
        public Player() { }
        public Player(int _a, int _d)
        {
            this.Attak = _a;
            this.Defence = _d;
        }
        public int Attak;
        public int Defence;
    }

    class Program
    {
        public static void Main(string[] args)
        {
            Solver task = new Solver();
#if DEBUG
            task.cin = new StreamReader("input.txt");
            task.cout = new StreamWriter("output.txt");
#else
            task.cin = new StreamReader(Console.OpenStandardInput());
            task.cout = new StreamWriter(Console.OpenStandardOutput());
#endif
            task.cout.AutoFlush = true;
            task.Run();
        }
    }
}


// Submitted by Silithus @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace RCC2014
{
	class QR_C
	{
		private int beat(int a_atk, int a_def, int b_atk, int b_def)
		{
			if (a_atk > b_def && a_def > b_atk) return 1;
			if (b_atk > a_def && b_def > a_atk) return -1;
			return 0;
		}

		public void Solve(XOI xoi)
		{
			int i, j, res, ans;
			int[,] team;
			string[] ans_words = { "Team 2", "Draw", "Team 1" };

			team = new int[4, 2];
			for (i = 0; i < 4; i++)
				for (j = 0; j < 2; j++)
					team[i, j] = xoi.ReadInt();

			for (i = 0, ans = -1999; i <= 1; i++)
			{
				for (j = 2, res = 1999; j <= 3; j++)
					res = Math.Min(res, beat(team[i, 1], team[1 - i, 0], team[j, 1], team[5 - j, 0]));
				ans = Math.Max(ans, res);
			}

			xoi.o.WriteLine(ans_words[ans + 1]);
		}
	}

	class RCC2014_QR
	{
		static void Main(string[] args)
		{
			XOI xoi = new XOI();
			(new QR_C()).Solve(xoi);
		}
	}
}

namespace CCF_XOI
{
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{	// I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var numbers = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();

            var criminals = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();

            long left = numbers[1] - 1;
            long right = numbers[1] - 1;

            long sum = 0;

            while (left >= 0 || right <= numbers[0] - 1)
            {
                if (left == right)
                {
                    sum += criminals[left];
                }
                else if (left < 0)
                {
                    sum += criminals[right];
                }
                else if (right > numbers[0] - 1)
                {
                    sum += criminals[left];
                }
                else
                {
                    if (criminals[right] == 1 && criminals[left] == 1)
                    {
                        sum += 2;
                    }
                }
                left--;
                right++;
            }

            Console.WriteLine(sum);

        }

    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution{
	 static void Main(string[] args) {
        var tmp = Console.ReadLine().Split(' ');
            int n = int.Parse(tmp[0]);
            int m = int.Parse(tmp[1]);

            m--;

            bool[] A = Array.ConvertAll(Console.ReadLine().Split(' '), x => x == "1");

            int ans = 0;
            if (A[m]) ans++;
            int i = m - 1, j = m + 1;
            while (i >= 0 && j < n) {
                if (A[i] && A[j]) ans += 2;
                i--; j++;
            }

            for (; i >= 0; i--) if (A[i]) ans++;
            for (; j < n; j++) if (A[j]) ans++;
            Console.WriteLine(ans);
	 }
}


using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            byte [] p = {0,0,0};

            int n = int.Parse(Console.ReadLine()) % 6;

            p[int.Parse(Console.ReadLine())] = 1;

            byte tmp;

            for(int i = n; i >= 1; i--)
            {
                    tmp = p[0 + (1 - i % 2)];
                    p[0 + (1 - i % 2)] = p[1 + (1 - i % 2)];
                    p[1 + (1 - i % 2)] = tmp;
            }

            Console.WriteLine(p[0] == 1 ? 0 : (p[1] == 1 ? 1 : 2));
        }
    }
}


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

namespace MyNewConsoleApp
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            byte x = byte.Parse(Console.ReadLine());

            for(int i = n % 6; i > 0; i--)
            {
                if(i % 2 == 0)
                {
                    if (x == 1)
                        x = 2;
                    else if (x == 2)
                        x = 1;
                }
                else
                {
                    if (x == 0)
                        x = 1;
                    else if (x == 1)
                        x = 0;
                }
            }
            Console.WriteLine(x);
        }
    }
}


using System;

namespace mod
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = Convert.ToInt32(Console.ReadLine());
            double m = Convert.ToInt32(Console.ReadLine());

            double res = m % Math.Pow(2, n);
            Console.WriteLine(res);
        }
    }
}


using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace Rextester {
    public class Program {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);

        public static void Main(string[] args) {

            long n = Next();
            long m = Next();

            Console.WriteLine(m%Math.Pow(2,n));
        }

        private static long Next() {
            long c;
            long m = 1;
            do {
                c = reader.Read();
                if (c == '-')
                    m = -1;
            } while (c < '0' || c > '9');
            long res = c - '0';
            while (true) {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return m*res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


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

namespace contest
{

    class contest
    {

        static void Main(string[] args)
        {

            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = int.Parse(Console.ReadLine());
            string s = (Console.ReadLine());

            bool only = true;

            var memoA = new int[n];
            var memoB = new int[n];
            for(int i =0; i< n; i++)
            {

                int tmp = s[i]-'0';

                if (tmp == 0)
                {
                    memoA[i] = 8;
                }
                else if (tmp == 3) memoA[i] = -1;
                else memoA[i] = tmp - 3;

                if(tmp ==0)
                {
                    memoB[i] = 11;
                }
                else if(tmp ==8) memoB[i] = 0;
                else memoB[i] = tmp + 3;

            }

            if (!memoA.Any(c => c < 0 || c >= 10) || !memoB.Any(c => c < 0 || c >= 10)) only = false;

            memoA = new int[n];
            memoB = new int[n];
            for (int i = 0; i < n; i++)
            {

                int tmp = s[i] - '0';

                if (tmp == 1)
                {
                    memoA[i] = -1;
                }
                else if (tmp == 4 || tmp ==7) memoA[i] = -1;
                else memoA[i] = tmp - 1;

                if (tmp == 0)
                {
                    memoB[i] = 11;
                }
                else if (tmp == 3 || tmp==6) memoB[i] = 11;
                else memoB[i] = tmp + 1;

            }
            if (!memoA.Any(c => c < 0 || c >= 10) || !memoB.Any(c => c < 0 || c >= 10)) only = false;

            if (only) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }

    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace TaskA
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve().OutputResult();
        }

        private class ExtendedReader : StreamReader
        {
            private static readonly char Separator = ' ';

            public ExtendedReader(Stream stream) : base(stream) { }
            public ExtendedReader(Stream stream, bool detectEncodingFromByteOrderMarks) : base(stream, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding) : base(stream, encoding) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(stream, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }
            public ExtendedReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) : base(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen) { }
            public ExtendedReader(string path) : base(path) { }
            public ExtendedReader(string path, bool detectEncodingFromByteOrderMarks) : base(path, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding) : base(path, encoding) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks) : base(path, encoding, detectEncodingFromByteOrderMarks) { }
            public ExtendedReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize) : base(path, encoding, detectEncodingFromByteOrderMarks, bufferSize) { }

            public char ReadChar()
            {
                return (char)this.Read();
            }

            public double ReadDoubleFromArray()
            {
                StringBuilder sb = new StringBuilder();
                char ch = this.ReadChar();
                while (ch != Separator && ch != '\n')
                {
                    sb.Append(ch);
                    ch = this.ReadChar();
                }
                return Convert.ToDouble(sb.ToString());
            }

            public int ReadInt()
            {
                return int.Parse(this.ReadLine());
            }

            public Int64 ReadInt64()
            {
                return Int64.Parse(this.ReadLine());
            }

            public int[] ReadIntArray()
            {
                return this.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            public char[] ReadCharArray()
            {
                return this.ReadLine().ToCharArray();
            }

            public string ReadString()
            {
                return this.ReadLine();
            }

            public string[] ReadStringArray()
            {
                return this.ReadLine().Split(' ').ToArray();
            }

            public Int64[] ReadInt64Array()
            {
                return this.ReadLine().Split(Separator).Select(Int64.Parse).ToArray();
            }

            public Double[] ReadDoubleArray()
            {
                return this.ReadLine().Split(Separator).Select(Double.Parse).ToArray();
            }
        }

        private abstract class SolverBase
        {
            protected readonly ExtendedReader _reader;
            protected readonly TextWriter _writer;

            protected SolverBase()
            {
#if DEBUG
                _reader = new ExtendedReader("input.txt");
                //_writer = new StreamWriter("output.txt");
                _writer = new StreamWriter(Console.OpenStandardOutput());
#else
                _reader = new ExtendedReader(Console.OpenStandardInput());
                _writer = new StreamWriter(Console.OpenStandardOutput());
#endif
            }

            public abstract Solver Solve();

            public abstract void OutputResult();
        }

        private class Solver : SolverBase
        {
            private bool result = false;

            public override Solver Solve()
            {
                // link to task: http://codeforces.com/problemset/problem/688/A

                var n = _reader.ReadInt();
                var s = _reader.ReadString();

                result = ShiftLeft(s) || ShiftRight(s) || ShiftUp(s) || ShiftDown(s);
                result = !result;

                return this;
            }

            private bool ShiftDown(string s)
            {
                return !s.Replace('0', '-').Replace('7', '-').Replace('9', '-').Contains("-");
            }

            private bool ShiftUp(string s)
            {
                return !s.Replace('1', '-').Replace('2', '-').Replace('3', '-').Contains("-");
            }

            private bool ShiftRight(string s)
            {
                return !s.Replace('0', '-').Replace('3', '-').Replace('6', '-').Replace('9', '-').Contains("-");
            }

            private bool ShiftLeft(string s)
            {
                return !s.Replace('0', '-').Replace('1', '-').Replace('4', '-').Replace('7', '-').Contains("-");
            }

            public override void OutputResult()
            {
                string answer = result ? "YES" : "NO";

                _writer.WriteLine(answer);
                _writer.Dispose();
            }
        }
    }
}