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

   public class A
    {
        public static void Main(string[] args)
        {
            string s = find();
        }

        private static string find()
        {
            string k1 = Console.ReadLine();
            int k = int.Parse(k1);
            string l1 = Console.ReadLine();
            int l = int.Parse(l1);
            string m1 = Console.ReadLine();
            int m = int.Parse(m1);
            string n1 = Console.ReadLine();
            int n = int.Parse(n1);
            string d1 = Console.ReadLine();
            int d = int.Parse(d1);

            int[] fg = new int[4];
            fg[0] = k;
            fg[1] = l;
            fg[2] = m;
            fg[3] = n;

            List<int> fh = new List<int>();
            bool lt = false;
            fh.Add(k);
            for (int v = 0; v < 4; v++)
            {
                lt = false;
                for (int v1 = v + 1; v1 < 4; v1++)
                {
                    if (bol(fg[v], fg[v1]) == 1)
                        lt = true;
                }

                if (!lt)
                    fh.Add(fg[v]);
            }

                foreach (int kt in fg)
                {

                }

            List<int> dr = new List<int>();
            int kTotal = k;

            foreach (int drg in fh)
            {
                kTotal = drg;
                while (kTotal <= d)
                {
                    if (dr.Contains(kTotal))
                    {
                        kTotal = kTotal + drg;
                        continue;
                    }
                    dr.Add(kTotal);
                    kTotal = kTotal + drg;
                }
            }

            int top = 0;
            foreach (int num in dr)
            {
                top = top + 1;
            }
            Console.WriteLine(top);
            return "";

        }

        private static int bol(int x,int y)
        {
            int k, k1;
            if (x < y)
            {
                k = y;
                k1 = x;
            }
            else
            {
                k = x;
                k1 = y;
            }
            int k2 = k1;
            while (k2 < k)
            {
                k2 = k2 + k1;
            }
            if (k2 == k)
                return 1;
            else
                return 0;

        }
    }


using System;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
		int a = int.Parse(Console.ReadLine());
		int b = int.Parse(Console.ReadLine());
		int c = int.Parse(Console.ReadLine());
		int d = int.Parse(Console.ReadLine());
		int tot = int.Parse(Console.ReadLine());
		List<int> nums = new List<int>();
		int res =0;

		if (a==1 || b==1 || c==1 || d==1)
		{
			res=tot;
		}
		else
		{
			for(int i=a; i<=tot; i+=a)
			{
				if(nums.IndexOf(i)<0)
				{
					nums.Add(i);
				}
			}
			for(int i=b; i<=tot; i+=b)
			{
				if(nums.IndexOf(i)<0)
				{
					nums.Add(i);
				}
			}
			for(int i=c; i<=tot; i+=c)
			{
				if(nums.IndexOf(i)<0)
				{
					nums.Add(i);
				}
			}
			for(int i=d; i<=tot; i+=d)
			{
				if(nums.IndexOf(i)<0)
				{
					nums.Add(i);
				}
			}
			res = nums.Count;
		}

		Console.WriteLine(res);
	}
}


using System;
using System.Collections.Generic;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            int l = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int[] c = { k, l, m, n };
            List<int> molestedDragon = new List<int>();

            for (int j = 0; j < 4; j++)
            {
                for (int i = 1; i <= d; i++)
                {
                    if ((i % c[j] == 0) && !molestedDragon.Contains(i)) molestedDragon.Add(i);
                }
            }

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver
{
    public void Solve(Scanner sc)
    {
        int N, M;
        sc.Make(out N, out M);
        ModInt res = 0;
        res += ModInt.Pow(M, N);//空部分列
        ModInt.Build(100100);
        //iは部分列aの長さ
        for(int i = 1; i <= N; i++)
        {
            //部分列dp的に、任意のkに対してA[0,k)でaをとれる->j<=kであるようなものを数える
            res += ModInt.Pow(M, i) * ModInt.Pow(M-1, N - i) * ModInt.Comb(N, i - 1);
        }
        WriteLine(res);
    }
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static void PopBack<T>(this List<T> A) => A.RemoveAt(A.Count - 1);
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var ns = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int n = ns[0], s = ns[1];
            var a = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            Array.Sort(a);
            Console.WriteLine(a.Take(n - 1).Sum() < s ? "YES" : "NO");
        }
    }
}


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

class GFG
{

    public static void Main()
    {

        var input = Console.ReadLine();

        var n = int.Parse(input);

        List<double> lstnum = new List<double>();
        int i = 1;
        while (true)
        {
            double num = (i * (i + 1)) / 2.0;
            if (num > n)
                break;
            lstnum.Add(num);
            i++;
        }

        foreach(var nn in lstnum)
        {
            if(lstnum.Contains(Math.Abs(n-nn)))
            {
                Console.Write("YES");
                return;
            }
        }

        Console.Write("NO");

    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> k = new List<int>();
            k.Add(1);
            for (int i = 1; k[i - 1] + i + 1 < n; i++)
            {
                k.Add(k[i - 1] + i + 1);
            }
            for (int i = 0; i < k.Count; i++)
                for (int j = 0; j < k.Count; j++)
                    if (k[i] + k[j] == n)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
            Console.WriteLine("NO");
        }
    }
}


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

namespace triangnums
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            bool pos = false;
            long[] mas = new long[(long)Math.Sqrt(2*n)];
            long i, j;
            for (i = 1; i <= Math.Sqrt(2*n); i++)
                mas[i-1] = i * (i + 1)/2;
            for (i = 0; i < Math.Sqrt(2 * n)-1; i++)
                for (j = (long)Math.Sqrt(2 * n) - 1; j >= 0; j--)
                    if (mas[i] + mas[j] == n)
                    {
                        pos = true;
                        j = -1;
                        i = (long)Math.Sqrt(2 * n) + 1;
                    }
                    else if (mas[i] + mas[j] < n)
                        break;
            if (pos)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

namespace triangnums
{
    class Program
    {
        public static long binsearch(long[] x, long n, long l, long r)
        {

            if (x.Length == 0)
            {
                return -1;
            }
            else if (x[0] > n)
            {
                return -1;
            }
            else if (x[x.Length-1] < n)
            {
                return -1;
            }
            long mid;
            while (l<r)
            {
                mid = l + (r - l) / 2;

                if (n <= x[mid])
                    r = mid;
                else
                    l = mid + 1;
            }
             if (x[r] == n)
            {
                return r;
            }
             else
            {
                return -1;
            }
        }

        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            bool pos = false;
            long[] mas = new long[(long)Math.Sqrt(2*n)];
            long i, x;
            for (i = 1; i <= Math.Sqrt(2*n); i++)
                mas[i-1] = i * (i + 1)/2;
            for (i = 0; i < (long)Math.Sqrt(2 * n); i++)
            {
                x = binsearch(mas, n - mas[i], 0, (long)Math.Sqrt(2 * n) + 1);
                if (x > 0)
                {
                    pos = true;
                    break;
                }
            }
            if (pos)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


using System;

namespace Algorithm
{
    class Program
    {
        static void Main()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int curr, temp1 = 1, temp2;

            for (int i = 2; temp1 < n; i++)
            {
                curr = n - temp1;
                temp2 = 1;
                for (int j = 2; temp2 < curr; j++)
                {
                    temp2 = (j * (j + 1)) >> 1;
                }
                if (curr - temp2 == 0)
                {
                    Console.WriteLine("YES");
                    return;
                }
                temp1 = (i * (i + 1)) >> 1;
            }

            Console.WriteLine("NO");
        }
    }
}


using System;
using Systenm.Linq;

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var a = s[0]; var x = s[1]; var y = s[2];
    if (y < a && y > 0) {
      Console.Write(2*Math.Abs(x) < a ? 1 : -1);
      return;
    }
    var add = y / (2*a);
    y %= 2*a;

    if (y < a && y > 0) {
      Console.Write(2*Math.Abs(x) < a ? 2+3*add : -1);
      return;
    }
    if (y < 2*a && y > a) {
      Console.Write(x != 0 && Math.Abs(x) < a ? 2+3*add+(x<0?1:2) : -1);
      return;
    }
    Console.Write(-1);
  }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long a, x, y, role, sqr;
            string str;
            string[] split = new string[3];
            str = Console.ReadLine();
            split = str.Split();
            a = Convert.ToInt32(split[0]);
            x = Convert.ToInt32(split[1]);
            y = Convert.ToInt32(split[2]);

            if (y % a == 0)
                Console.WriteLine("-1");
            else
            {
                role = y / a + 1;
                if (y < a)
                {

                    if (Math.Abs(x) < a / 2.0)
                        Console.WriteLine("1");
                    else Console.WriteLine("-1");
                }
                else
                {
                    sqr = role % 2 + 1;
                    if (sqr == 1)
                        if (Math.Abs(x) < a / 2)
                            Console.WriteLine((1 + (role - 2) / 2 * 3)+1);
                        else Console.WriteLine("-1");
                    else
                        if ((x>0)&&(x<a))
                            Console.WriteLine((2 + (role - 3) / 2 * 3) +2);
                        else if ((x<0)&&(x>-a))
                            Console.WriteLine((2 + (role - 3) / 2 * 3) + 1);
                        else Console.WriteLine("-1");

                    // 2+(role-3)/2*3
                    //1 + (role-2)/2*3
                }
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public Scanner sc;
    public void Solve()
    {
        int N, M;long K;
        sc.Make(out N, out M, out K);
        if (K < N) Fail($"{K+1} {1}");
        if (K == N) Fail($"{K} {2}");
        K -= N;
        long n = K / (M - 1);K /= M - 1;
        long m;
        if (n % 2 == 0) m = K + 2;
        else m = (M - K );
        n = N - n;
        Console.WriteLine($"{n} {m}");
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var sol = new Solver() { sc = new Scanner() };
        //var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
        sol.Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6, out T7 v7) { Make(out v1, out v2, out v3, out v4, out v5, out v6); v7 = Next<T7>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            long n = Convert.ToInt64(l.Split(' ')[0]);
            long m = Convert.ToInt64(l.Split(' ')[1]);
            long k = Convert.ToInt64(l.Split(' ')[2]);
            int x = 1, y = 1;
            bool snake = false;
            bool goRight = true;
            while(k > 0)
            {
                if (x == n)
                {
                    snake = true;
                }
                //reached destination
                if (x == 1 && y == 2)
                {
                    k = 0;
                    break;
                }
                //going down along the left side
                else if (snake == false && x < n)
                {
                    x++;
                    k--;
                }
                else if(snake && goRight)
                {
                    if (y < m)
                    {
                        k--;
                        y++;
                    }
                    else if(y == m)
                    {
                        x--;
                        k--;
                        goRight = false;
                    }
                }
                else if(snake && goRight == false)
                {
                    if(y > 2)
                    {
                        y--;
                        k--;
                    }
                    else if(y == 2)
                    {
                        k--;
                        x--;
                        goRight = true;
                    }
                }
                //Console.WriteLine(x + " " + y);
            }
            Console.WriteLine(x + " " + y);
        }
    }
}


var x=Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int a=x[0];
		int b=x[1];
		int n=x[2];
		int s=0, q=0;

		while(n>0)
		{
			if(q==0)
			{
			 s=gcd(a,n);
			 n-=s;
			 q=1;
			}
			else
			{
				s=gcd(b,n);
				n-=s;
				q=0;
			}
		}
		Console.WriteLine(q==0? "1":"0");

	}
	public static int gcd(int y, int z)
	{
		while (y!= z)
      {
        if (y > z)
             y = y- z;

          if (z > y)
              z = z - y;
       }
             return y;
     }


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

class PairVariable:IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication252
{

    class Program
    {

        static bool IsPrime(int n)
        {
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        static void Main()
        {
            string[] z = Console.ReadLine().Split();
            double a = double.Parse(z[0]);
            double b = double.Parse(z[1]);
            double c = double.Parse(z[2]);
            double d = double.Parse(z[3]);
            double ballMisha = Math.Max(3 * a / 10, a - ((a * c) / 25));
            double ballVasya = Math.Max(3 * b / 10, b - ((b * d) / 25));
            if (ballMisha > ballVasya)
            {
                Console.WriteLine("Misha");
            }
            else if (ballVasya > ballMisha)
            {
                Console.WriteLine("Vasya");
            }
            else
            {
                Console.WriteLine("Tie");
            }

        }
    }
}


Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "A.Contest", "A.Contest\A.Contest.csproj", "{1E33F78A-68B3-42F4-A54D-07412C28A48F}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x86 = Debug|x86
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{1E33F78A-68B3-42F4-A54D-07412C28A48F}.Debug|x86.ActiveCfg = Debug|x86
		{1E33F78A-68B3-42F4-A54D-07412C28A48F}.Debug|x86.Build.0 = Debug|x86
		{1E33F78A-68B3-42F4-A54D-07412C28A48F}.Release|x86.ActiveCfg = Release|x86
		{1E33F78A-68B3-42F4-A54D-07412C28A48F}.Release|x86.Build.0 = Release|x86
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


using System;

namespace _122A
{
	class MainClass
	{
		private static char[] a = new char[] {'4', '7'};
		private static string res = "NO";
		public static void Main ( string[] args )
		{
			string s = Console.ReadLine ( );
			int n;
			int.TryParse ( s , out n );
			Try ( 0 , "" , s.Length , n );
			Console.Write ( res );
		}

		private static void Try(int i, string s, int length, int n)
		{
			if ( isLucky ( n ) )
			{
				res = "YES";
				return;
			}
			for ( int j = 0 ; j < 2 ; ++j )
			{
				if ( res != "YES" )
				{
					s += a [ j ];
					++i;
					if ( i == length - 1 )
					{
						int x = int.Parse ( s );
						if ( x < n && n % x == 0 )
						{
							res = "YES";
							return;
						}
					}
					else Try ( i + 1 , s , length , n );
					--i;
					s.Remove ( i , 1 );
				}
			}
		}

		private static bool isLucky(int n)
		{
			int x = n;
			while ( x > 0 )
			{
				if ( x % 10 != 4 && x % 10 != 7 )
					return false;
				x /= 10;
			}
			return true;
		}
	}
}


Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Global
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "A", "A\A.csproj", "{7C02893E-192C-4692-BDCC-E2D81901F781}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x86 = Debug|x86
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{7C02893E-192C-4692-BDCC-E2D81901F781}.Debug|x86.ActiveCfg = Debug|x86
		{7C02893E-192C-4692-BDCC-E2D81901F781}.Debug|x86.Build.0 = Debug|x86
		{7C02893E-192C-4692-BDCC-E2D81901F781}.Release|x86.ActiveCfg = Release|x86
		{7C02893E-192C-4692-BDCC-E2D81901F781}.Release|x86.Build.0 = Release|x86
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] akk = new int[3];
            for (int i = 0; i < 3; i++)
            {
                switch (input[i])
                {
                    case "C": akk[i] = 0; break;
                    case "C#": akk[i] = 1; break;
                    case "D": akk[i] = 2; break;
                    case "D#": akk[i] = 3; break;
                    case "E": akk[i] = 4; break;
                    case "F": akk[i] = 5; break;
                    case "F#": akk[i] = 6; break;
                    case "G": akk[i] = 7; break;
                    case "G#": akk[i] = 8; break;
                    case "A": akk[i] = 9; break;
                    case "B": akk[i] = 10; break;
                    case "H": akk[i] = 11; break;
                    default: akk[i] = -1; break;
                }
            }
            int type = 0;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    int k = 3 - (i + j);
                    if (d(akk[i], akk[j]) == 7)
                    {
                        if ((d(akk[i], akk[k]) == 4) & (d(akk[k], akk[j]) == 3)) { type = 1; break; }
                        else if ((d(akk[i], akk[k]) == 3) & (d(akk[k], akk[j]) == 4)) type = -1;
                    }
                }
            }
            switch (type)
            {
                case 1: Console.Write("major"); break;
                case -1: Console.Write("minor"); break;
                default: Console.Write("strange"); break;
            }
        }
        static int d(int a1, int a2)
        {
            if (a2 >= a1) return a2 - a1; else return 12 - (a1 - a2);
        }
    }
}


class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(long.Parse(Console.ReadLine()) / 2520L);
        }
    }


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

namespace Contest
{
    class Program
    {
        static void Main()
        {
            int b = Convert.ToInt32(Console.ReadLine());
            int g = Convert.ToInt32(Console.ReadLine());
            int n = Convert.ToInt32(Console.ReadLine());
            if (b + g == n) Console.WriteLine(1);
            else
            Console.WriteLine(Math.Min(b, Math.Min(g, Math.Min(Math.Max(n-g-b,0),n)))+1);
        }

    }

}


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

using static System.Math;
namespace megaPolis
{
    class Program
    {
        static void Main(string[] args)
        {
            int b = int.Parse(Console.ReadLine());
            int g = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine(Min(n, g) - n + Min(n, b));
          //  Console.ReadKey();

        }
    }
}


using System;
using System.Linq;

namespace tren
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] mass = Enumerable.Range(n, Math.Abs(n) + 10).ToArray();
            for(int i = 1; i < mass.Count(); i++)
            {
                if (mass[i].ToString().Contains('8')) { Console.Write(i); return; }
            }
        }
    }
}


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

namespace a2oj
{
    class Program
    {
        static bool cheight(int num)
        {
            while(num>0)
            {
                if (num % 10 != 8)
                    num /= 10;
                else
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int n;
            int t;
            n = int.Parse(Console.ReadLine());
            t=n;
            //List<int> val = new List<int>();
            //string s= Console.ReadLine();
            //string []all=s.Split(' ');
            //foreach(string st in all)
            //{
            //    val.Add(int.Parse(st));
            //}
            n++;
            while (!cheight(n))
                n++;
            Console.WriteLine(n - t);

            Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    private static void chmin<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == 1 ? val : num;
    private static void chmax<T>(ref T num, T val) where T : IComparable<T>
        => num = num.CompareTo(val) == -1 ? val : num;
    private static void swap<T>(ref T v1,ref T v2)
    { var t = v2;v2 = v1;v1 = t; }
    static void Main(string[] args)
    {
        var pr = new Program();
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        pr.Solve();
        Console.Out.Flush();
    }
    void Solve()
    {
        int n, l, r;
        Input.Make(out n, out l, out r);
        var min = n - l + 1;
        var c = 1;
        for(var i=1;i<l;i++)
        {
            c *= 2;
            min += c;
        }
        var max = 1L;
        c = 1L;
        for(var i=1;i<r;i++)
        {
            c *= 2;
            max += c;
        }
        WriteLine($"{min} {max + c * (n - r)}");
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static T[] create<T>(int n, Func<int, T> f)
        => Enumerable.Repeat(0, n).Select(f).ToArray();
    public static char[][] grid(int h)
        => create(h, _ => read.ToCharArray());
    public static int[] ar1D(int n)
        => create(n, _ => num);
    public static long[] arL1D(int n)
        => create(n, _ => numL);
    public static string[] strs(int n)
        => create(n, _ => read);
    public static int[][] ar2D(int n)
        => create(n, _ => ar);
    public static long[][] arL2D(int n)
        => create(n, _ => arL);
    public static List<T>[] edge<T>(int n)
        => create(n, _ => new List<T>());
    public static T GetValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static void Make<T1, T2>(out T1 v1, out T2 v2)
    {
        v1 = Next<T1>();
        v2 = Next<T2>();
    }
    public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        Make(out v1, out v2);
        v3 = Next<T3>();
    }
    public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4)
    {
        Make(out v1, out v2, out v3);
        v4 = Next<T4>();
    }
    public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5)
    {
        Make(out v1, out v2, out v3, out v4);
        v5 = Next<T5>();
    }
    public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6)
    {
        Make(out v1, out v2, out v3, out v4, out v5);
        v6 = Next<T6>();
    }
    private static Queue<string> sc;
    public static T Next<T>(){ sc = sc ?? new Queue<string>(); if (sc.Count == 0) foreach (var item in read.Split(' ')) sc.Enqueue(item);return GetValue<T>(sc.Dequeue()); }
    public static void Next<T>(ref T val) => val = Next<T>();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1 { get; set; }
    public T2 v2 { get; set; }
    public Pair() { v1 = Input.Next<T1>(); v2 = Input.Next<T2>(); }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString()
        => $"{v1.ToString()} {v2.ToString()}";
    public override bool Equals(object obj)
        => this == (Pair<T1, T2>)obj;
    public override int GetHashCode()
        => v1.GetHashCode() ^ v2.GetHashCode();
    public static bool operator ==(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) == 0;
    public static bool operator !=(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) != 0;
    public static bool operator >(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) == 1;
    public static bool operator >=(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) != -1;
    public static bool operator <(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) == -1;
    public static bool operator <=(Pair<T1, T2> p1, Pair<T1, T2> p2)
        => p1.CompareTo(p2) != 1;
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3 { get; set; }
    public Pair() : base() { v3 = Input.Next<T3>(); }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString()
        => $"{base.ToString()} {v3.ToString()}";
}


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

namespace ConsoleApp41
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int min = x[1];
            int max = x[2];
            int max1 = max;
            int max2 = max;
            int n = x[0];
            int[] minSum = new int[n];
            minSum[0] = 1;
            int[] maxSum = new int[n];
            maxSum[0] = 1;
            int minSumma = 1;
            int maxSumma = 1;
            for(int i = 1; i < n; i++)
            {
                if( max1 > 0)
                {
                    minSum[i] = 1;
                    max1--;
                }
                else
                    minSum[i] = minSum[i - 1] * 2;
                minSumma += minSum[i];
            }
            for(int i = 1; i < n; i++)
            {

                if (max2  > 1)
                {
                    max2--;
                    maxSum[i] = maxSum[i - 1] * 2;

                }
                else
                    maxSum[i] = maxSum[i - 1];
                maxSumma += maxSum[i];

            }

            Console.WriteLine(minSumma + " " + maxSumma);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
             string[] Input = Console.ReadLine().Split(' ');
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[3];
            for (int i = 0; i < 3; i++) arr[i] = Convert.ToInt32(Input[i]);
            int[] brr = new int[3];
            for (int j = 0; j < 3; j++) brr[j] = Convert.ToInt32(Input[j]);
            int a, b, c;
            a = arr[0];
            b = arr[1];
            c = arr[2];
            while(n>0)
            {
                if (a + b + c == n) break;
                if (a < brr[0]) a++;
                if (b < brr[1]) b++;
                if (c < brr[2]) c++;
            }
            Console.WriteLine(a + " " + b +" "+ c );
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading.Tasks;
using System.IO;
using System.Globalization;
namespace ConsoleApplication1
{
    class Program
    {
        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }
        static void Main( )
        {
            var init = int.Parse(Console.ReadLine());
            var line1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var line2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var line3 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var max1 = line1[1];
            var max2 = line2[1];
            var max3 = line3[1];

            var min1 = line1[0];
            var min2 = line2[0];
            var min3 = line3[0];

          //  var dip1 = Math.Min(init - min2 - min3, max1);
            //var dip2 = Math.Min(init - dip1 - min3, max2);
            //var dip3 = Math.Min(init - dip1 - dip2, max3);

            while (n>0)
            {
                if (min1 + min2 + min3 == n) break;
                if (min1 < max1) min1++;
                else if (min2 < max2) min2++;
                else if (min3 < max3) min3++;
            }

            Console.WriteLine(min1 + " " + min2 + " " + min3);

        }
    }
}


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

namespace a
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var x = new List<Tuple<int,int>> ();
            for (var i = 0; i < 3; i++) {
                var line = Console.ReadLine ().Split (new char[]{ ' ' }, StringSplitOptions.RemoveEmptyEntries).Select (int.Parse).ToArray();
                x.Add (new Tuple<int, int> (line [0], line [1]));
            }

            var result = new int[3];
            var remain = new int[3];
            for (var o = x [0].Item2; o >= x [0].Item1; o--) {
                result [0] = o;
                remain [0] = n - o;
                for (var p = Math.Min(remain [0], x[1].Item2); p >= x [1].Item1; p--) {
                    result [1] = p;
                    remain [1] = remain [0] - p;
                    for (var q = Math.Min(remain [1], x[2].Item2); q >= x [2].Item1; q--) {
                        result [2] = q;
                        remain [2] = remain [1] - q;
                        if (remain [2] == 0) {
                            Console.WriteLine (result [0] + " " + result [1] + " " + result [2]);
                            return;
                        }
                    }
                }
            }
        }
    }
}


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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            long m = ReadLong();
            long a = ReadLong();
            long b = ReadLong();

            long[] f = Enumerable.Repeat(-1L, (int) a).ToArray();
            f[0] = 0;

            var queue = new Queue<long>();
            queue.Enqueue(0);
            long inc = a * ((b + a - 1) / a);
            while (queue.Count > 0)
            {
                long cur = queue.Dequeue();
                long d = cur + inc;
                long t = d - b;
                while (t >= 0 && f[t % a] < 0)
                {
                    f[t % a] = Math.Max(d, f[cur % a]);
                    queue.Enqueue(t);
                    t -= b;
                }
            }

            // WriteArray(f);

            long ans = 0;
            for (int i = 0; i < a; i++)
            {
                if (f[i] >= 0 && f[i] <= m)
                {
                    long k = Calc(m, i, a) - Calc(f[i] - 1, i, a);
                    // Writer.WriteLine($"{i} : {k}");
                    ans += k;
                }
            }

            Writer.WriteLine(ans);
        }

        public static long Calc(long st, long k, long a)
        {
            long full = (st - k + 1) / a;
            long ans = a * full * (full + 1) / 2;
            ans += (st - k + 1) % a * (full + 1);
            return ans;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static void Solve()
        {
#if DEBUG
            var sw = Stopwatch.StartNew();
#endif

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                // Writer.Write("Case #{0}: ", 1 - t);
                SolveCase();
            }*/

#if DEBUG
            sw.Stop();
            Console.WriteLine($"{sw.ElapsedMilliseconds} ms");
#endif
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Shuffle(result);
            return result;
        }

        private static void Shuffle<T>(IList<T> array)
        {
            Random rnd = new Random();
            for (int i = array.Count - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = array[k];
                array[k] = array[i];
                array[i] = tmp;
            }
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        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 string ReadLine()
        {
            return Reader.ReadLine();
        }

        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 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));
        }

        #endregion
    }
}


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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] ms = Console.ReadLine().Split(' ');
            int n = int.Parse(ms[0]);
            int m = int.Parse(ms[1]);
            int min= int.Parse(ms[2]);
            int max = int.Parse(ms[3]);

            List<int> M = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int ma = 2;
            if (min != max)
            {
                if (M.IndexOf(min) != -1)
                    ma--;
                if (M.IndexOf(max) != -1)
                    ma--;

                if (m <= n - ma)
                    Console.WriteLine("Correct");
                else
                    Console.WriteLine("Incorrect");
            }
            else
            {
                bool b = true;
                for (int i=0; i<M.Count;i++)
                    if (M[i]!=min)
                    {
                        b = false;
                        break;
                    }
                if (b)
                    if (n == 0)
                        if (m == 0)
                            b = false;
                if (b)
                    Console.WriteLine("Correct");
                else
                    Console.WriteLine("Incorrect");
            }
        }
    }
}


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

namespace Graph
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            string str = Console.ReadLine();

            int res = 0;
            bool done = false;
            int n = str.Length;
            for (int i = 0; i < n; i++)
            {
                res = i;
                //Console.WriteLine(i + " " + str + " " + done + " " + n);
                if (!done)
                {
                    for (int j = 0; j < num.Length; j++)
                    {
                        if (num[j] == '9' || num[j] == '6')
                        {
                            if (str.IndexOf('9') != -1)
                            {
                                str = str.Remove(str.IndexOf('9'), 1);
                            }
                            else
                            {
                                if (str.IndexOf('6') != -1)
                                {
                                    str = str.Remove(str.IndexOf('6'), 1);
                                }
                                else
                                {
                                   // Console.WriteLine("Нет девятки и шестерки");
                                    done = true;
                                    Console.WriteLine(res);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (num[j] == '5' || num[j] == '2')
                            {
                                if (str.IndexOf('5') != -1)
                                {
                                    str = str.Remove(str.IndexOf('5'), 1);
                                }
                                else
                                {
                                    if (str.IndexOf('2') != -1)
                                    {
                                        str = str.Remove(str.IndexOf('2'), 1);
                                    }
                                    else
                                    {
                                        //Console.WriteLine("Нет двойки и пятерки");
                                        done = true;
                                        Console.WriteLine(res);
                                        return;
                                    }
                                }
                            }
                            else {
                                if (str.IndexOf(num[j]) != -1)
                                {
                                    str = str.Remove(str.IndexOf(num[j]), 1);
                                }
                                else {
                                    //Console.WriteLine("Нет " + num[j]);
                                    done = true;
                                    Console.WriteLine(res);
                                    return;
                                    //break;
                                }

                            }
                        }
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}


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

    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(' ');
                int n = int.Parse(s[0]);
                int m = int.Parse(s[1]);
                int z = int.Parse(s[2]);
                int l, b;
                int ans = 0;
                if (m > n)
                {
                    b = m;
                    l = n;
                }
                else
                {
                    l = m;
                    b = n;
                }
                int bFirst = b;
                while (b<=z)
                {
                    if (b%l == 0)
                    {
                        ans++;
                    }
                    b+=bFirst;
                }
                Console.WriteLine(ans);
            }

            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();
            }
        }
    }


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

namespace ConsoleApplication1
{
    class Program
    {
        static int potencia(int x, int n)
        {
            int y = 1;

            for (int i = 0; i < n; i = i + 1)
            {
                y = y * x;

            }

            return y;
        }
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int drink = input;
            int resta = 5;
            int contador = 0;
            int personas = 0;

            for (resta = 5; drink > resta; resta = resta * 2)
            {
                drink = drink - resta;
                contador++;
            }
            //Console.WriteLine(drink);
            //Console.WriteLine(contador);
            personas = potencia(2, contador);
            //Console.WriteLine(personas);

            string[] fila = new string[personas * 5];
            for (int n = 0; n < personas * 5; n++)
            {
                if (n < personas)
                {
                    fila[n] = "Sheldon";
                }
                else if (n >= personas && n < personas * 2)
                {
                    fila[n] = "Leonard";
                }
                else if (n >= personas * 2 && n < personas * 3)
                {
                    fila[n] = "Penny";
                }
                else if (n >= personas * 3 && n < personas * 4)
                {
                    fila[n] = "Rajesh";
                }
                else
                {
                    fila[n] = "Howard";
                }
            }
            Console.WriteLine(fila[drink - 1]);

        }
    }
}


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

namespace Test1
{
    public class Test1
    {
        public static string getName(int input, List<string> names)
        {
            string output = "";
            for (int i = 0; i < input; i++)
            {
                if (i == input - 1) { output = names[i]; }
                else { names.Add(names[i]); names.Add(names[i]); }
            }
            return output;
        }

        public static void Main()
        {
            List<string> queue = new List<string>();
            queue.Add("Sheldon");
            queue.Add("Leonard");
            queue.Add("Penny");
            queue.Add("Rajesh");
            queue.Add("Howard");
            Console.WriteLine(getName(Convert.ToInt32(Console.ReadLine()), queue));
        }
    }
}


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

namespace AcmSolution
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            Do();

            Console.ReadLine();
        }

        private static void Do()
        {
            int n = GetInt();
            ArrayList list = new ArrayList();
            list.Add("Sheldon");
            list.Add("Leonard");
            list.Add("Penny");
            list.Add("Rajesh");
            list.Add("Howard");

            string name = "";
            for (int i = 0; i < n; i++)
            {
                name = list[i].ToString();
                list.Add(name);
                list.Add(name);
            }
            Console.WriteLine(name);
        }

        #region Utils
        private const double Epsilon = 0.00000001;

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

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

        private static string[] GetStrs(int cnt)
        {
            var s = new string[cnt];
            for (var i = 0; i < cnt; ++i)
                s[i] = GetStr();
            return s;
        }

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

        private static void GetInts(out int a, out int b)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
        }

        private static void GetInts(out int a, out int b, out int c)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
            c = q[2];
        }

        private static int[] GetInts()
        {
            var s = GetStrs();
            var a = new int[s.Length];
            for (var i = 0; i < s.Length; ++i)
                a[i] = int.Parse(s[i]);
            return a;
        }

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

        private static IEnumerable<long> GetLongs()
        {
            return GetStrs().Select(long.Parse);
        }

        private static void WriteDouble<T>(T d)
        {
            Console.WriteLine(string.Format("{0:0.000000000}", d).Replace(',', '.'));
        }

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

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

        private static void Assert(bool b)
        {
            if (!b) throw new Exception();
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            var temp = a;
            a = b;
            b = temp;
        }

        #endregion
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
class Problem
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split();
        int n = Convert.ToInt32( str[0] );
        int m = Convert.ToInt32( str[1] );
        int kq = n;
        while(n / m >= 1)
        {
            kq += n / m;
            if(n / m == 1 && kq % m == 0)
            {
                kq++;
                continue;
            }
            else
                n /= m;
        }
        Console.WriteLine( kq );
    }
}


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

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

namespace _13d
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

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

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static int mod = 1000 * 1000 * 1000 + 7;
        static void mult(long[,] a, long[,] b, long[,] res, int n)
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    res[i, j] = 0;
                    for (int k = 0; k < n; k++)
                    {
                        res[i, j] += a[i, k] * b[k, j] % mod;
                        res[i, j] %= mod;
                    }
                }
            }
        }

        static void copy(long[,] from, long[,] to, int n)
        {
            for (int i = 0; i < n; i++)
            {
                for (int k = 0; k < n; k++)
                {
                    to[i, k] = from[i, k];
                }
            }
        }

        static void pow(long[,] a, long p, int n)
        {
            var temp = new long[n, n];
            var res = new long[n, n];
            for (int i = 0; i < n; i++)
            {
                res[i, i] = 1;
            }

            while (true)
            {
                var rem = p % 2;
                if (rem == 1)
                {
                    mult(res, a, temp, n);
                    copy(temp, res, n);
                }

                if (p == 1)
                {
                    break;
                }

                p /= 2;
                mult(a, a, temp, n);
                copy(temp, a, n);
            }

            copy(res, a, n);
        }

        static void solution()
        {
            #region SOLUTION
            var d = readLongArray();
            var a = d[0];
            var b = d[1];
            var n = d[2];
            var x = d[3];

            var mm = new long[2, 2];
            mm[0, 0] = a;
            mm[0, 1] = b;
            mm[1, 0] = 0;
            mm[1, 1] = 1;

            pow(mm, n, 2);

            var res = x * mm[0, 0] % mod + mm[0, 1];
            Console.WriteLine(res);

            //var n = readInt();
            //var m = readInt();

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

        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;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    private const int MOD = 1000000007;

    long ModPow(long x, long p)
    {
        long ret = 1;
        while (p > 0)
        {
            if ((p & 1) == 1)
                ret = ret * x % MOD;
            x = x * x % MOD;
            p >>= 1;
        }
        return ret;
    }

    public void Solve()
    {
        int a = ReadInt();
        int b = ReadInt();
        long n = ReadLong();
        int x = ReadInt();

        if (a == 1)
        {
            Write((x + 1L * n * b) % MOD);
            return;
        }

        long ans = x * ModPow(a, n % (MOD - 1));
        ans += (ModPow(a, n % (MOD - 1)) + MOD - 1) % MOD * ModPow(a - 1, MOD - 2) % MOD * b;
        Write(ans % MOD);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            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); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

namespace Jzzhu_and_Sequences
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = Int32.Parse(input[0]);
            int y = Int32.Parse(input[1]);
            int n = Int32.Parse(Console.ReadLine());
            int[] f = new int[6] { x, y, y - x, -x, -y, x - y };
            int res = n % 6;
            //Console.WriteLine(res);
            //Console.WriteLine(f[res - 1]);
            if (f[res - 1] >= 0)
                Console.WriteLine(f[res - 1] % (1000000007));
            else
                Console.WriteLine(1000000007 + (f[res - 1] % (1000000007)));
            Console.ReadLine();
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var d=rla();
		var N=rl();
		mod=(long)1e9+7;
		if(N==1){
			d[0]%=mod;
			if(d[0]<0)d[0]+=mod;
			Console.WriteLine("{0}",d[0]);
			return;
		}
		if(N==2){
			d[1]%=mod;
			if(d[1]<0)d[1]+=mod;
			Console.WriteLine("{0}",d[1]);
			return;
		}

		int M=1;
		while(N>(0x1<<M))M++;

		long[][] Arr=new long[M][];
		for(int i=0;i<M;i++){
			Arr[i]=new long [4];
		}

		Arr[0][0]=1;
		Arr[0][1]=-1;
		Arr[0][2]=1;
		Arr[0][3]=0;

		for(int i=1;i<M;i++){
			Arr[i][0]=Arr[i-1][0]*Arr[i-1][0]+Arr[i-1][1]*Arr[i-1][2];
			Arr[i][1]=Arr[i-1][0]*Arr[i-1][1]+Arr[i-1][1]*Arr[i-1][3];
			Arr[i][2]=Arr[i-1][2]*Arr[i-1][0]+Arr[i-1][3]*Arr[i-1][2];
			Arr[i][3]=Arr[i-1][2]*Arr[i-1][1]+Arr[i-1][3]*Arr[i-1][3];
			Arr[i][0]%=mod;
			Arr[i][1]%=mod;
			Arr[i][2]%=mod;
			Arr[i][3]%=mod;
			if(Arr[i][0]<0)Arr[i][0]+=mod;
			if(Arr[i][1]<0)Arr[i][1]+=mod;
			if(Arr[i][2]<0)Arr[i][2]+=mod;
			if(Arr[i][3]<0)Arr[i][3]+=mod;

		}

		long[] D=new long[4]{1,0,0,1};

		for(int i=0;i<M;i++){
			if((((N-2)>>i )& 0x1)>0){
				long[] DD=new long[4]{D[0],D[1],D[2],D[3]};
				D[0]=Arr[i][0]*DD[0]+Arr[i][1]*DD[2];
				D[1]=Arr[i][0]*DD[1]+Arr[i][1]*DD[3];
				D[2]=Arr[i][2]*DD[0]+Arr[i][3]*DD[2];
				D[3]=Arr[i][2]*DD[1]+Arr[i][3]*DD[3];
				D[0]%=mod;
				D[1]%=mod;
				D[2]%=mod;
				D[3]%=mod;
				if(D[0]<0)D[0]+=mod;
				if(D[1]<0)D[1]+=mod;
				if(D[2]<0)D[2]+=mod;
				if(D[3]<0)D[3]+=mod;
			}
		}

		long ans=D[0]*d[1]+D[1]*d[0];
		ans%=mod;
		if(ans<0)ans+=mod;
		Console.WriteLine(ans);

	}
	long mod;
	public Sol(){
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}


namespace Jzzhu
{
    class Program
    {
        static void Main(string[] args)
        {
            JzzhuSequence jzzhu = new JzzhuSequence();

            string text = Console.ReadLine();

            int x = int.Parse(text.Split(' ')[0]);
            int y = int.Parse(text.Split(' ')[1]);

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

            Console.Write(jzzhu.Module(jzzhu.Calculate(x, y, n), 1000000007));
        }
    }

    class JzzhuSequence
    {

        public int Calculate(int x, int y, int n)
        {
            if (n == 1)
            {
                return x;
            }
            else if (n == 2)
            {
                return y;
            }
            else
            {
                double rad = (n / 3) * Math.PI;

                double res = (x - y) * Math.Cos(rad) + (x + y) * Math.Sqrt(3) * Math.Sin(rad);

                return (int)res;

                //int i = Calculate(x, y, n - 1) - Calculate(x, y, n - 2);
                //return i;
            }
        }

        public int Module(int dividend, int divisor)
        {
            int remainder = 0;

            if(dividend < 0)
            {
                remainder = divisor + dividend;
            }
            else
            {
                remainder = dividend % divisor;
            }

            return remainder;
        }
    }

}


#define TRACE
#undef DEBUG
/*
Author: w1ld [dog] inbox [dot] ru

 */
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using static System.Math;

public class Solver
{
    public void Solve()
    {
        int x = ReadInt();
        int y = ReadInt();
        int n = ReadInt();
        // f3 = f2 - f1
        // f4 = f3 - f2
        // f5 = f4 - f3
        // ...
        // fn = f{n-1} - f{n-2}
        // fn = f{n-2} - f{n-3} - (f{n-3} - f{n-4})
        // fn = f{n-2} - 2*f{n-3} + f{n-4}
        // fn = f{n-3} - fn-4 - 2*(f{n-4} - fn-5) + f{n-5} - f(n-6)
        // fn = f{n-3} - fn-4 - 2*(f{n-4} - fn-5) + f{n-5} - f(n-6)
        //
        //

        n -= 2;
        const int MOD = (int)(1e9 + 7);
        y %= MOD;
        if (y < 0) y += MOD;
        while (n > 0)
        {
            int z = (y - x) % MOD;
            if (z < 0)
                z += MOD;
            x = y;
            y = z;
            n -= 1;
        }
        Write(y);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        Debug.Listeners.Clear();
        Debug.Listeners.Add(new ConsoleTraceListener());
        Trace.Listeners.Clear();
        Trace.Listeners.Add(new ConsoleTraceListener());

        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        new Solver().Solve();
        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); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

class Program
{
    private static int Solve(int a, int b)
    {
        if (a < 1 || b < 1) return 0;

        if (dp[a, b] > 0) return dp[a, b];

        int answer = 1 + Math.Max(Solve(a + 1, b - 2), Solve(a - 2, b + 1));
        dp[a, b] = answer;
        return answer;
    }

    private static int[,] dp = new int[103, 103];
    static void Main(string[] args)
    {
        Console.Write(Solve(ReadInt(), ReadInt()));
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n + 1];
        for (int i = 0; i <= n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            var a = ReadInt();
            var b = ReadInt();

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt();
            int b = ReadInt();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

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

    private const int BufferSize = 1 << 12;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

    private static int ReadInt()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static long ReadLong()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] ReadIntArray(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadInt();
        return ans;
    }

    private static long[] ReadLongArray(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadLong();
        return ans;
    }

    private static char[] ReadString()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans < 'a' || ans > 'z');

        List<char> s = new List<char>();
        //int pos = 0;
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans >= 'a' && ans <= 'z');

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans < 'a' || ans > 'z');

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            ans = consoleReader.Read();
        } while (ans >= 'a' && ans <= 'z');

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans - (int)'0';
        }
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }
}


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

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        static int Count(string source, string key)
        {

            List<int> indices = new List<int>();

            int index = source.IndexOf(key, 0);

            while (index > -1)
            {
                indices.Add(index);
                index = source.IndexOf(key, index + key.Length);
            }

            return indices.Count();
        }

        public static string Check(string s)
        {
            string letters = "aeiouy";

            while (true)
            {
                bool used = false;

                for (int i = 0; i < s.Length - 1; i++)
                {
                    if (letters.Contains(s[i].ToString()) && letters.Contains(s[i + 1].ToString()))
                    {
                        s = s.Remove(i + 1, 1);

                        used = true;
                    }
                }

                if (!used)
                {
                    return s;
                }
            }
        }

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif
            int N = int.Parse(Console.ReadLine());

            string s = Console.ReadLine();

            int max = 0;

            for (int i = 1; i <= N; i++)
            {
                if (2 * i > N)
                {
                    break;
                }

                if (s.Substring(0, i).Equals(s.Substring(i, 2 * i)))
                {
                    max = i;
                }

            }

            Console.WriteLine(Math.Min((N - 2 * max) + max + 1, N));

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


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

namespace Codeforces
{
   class B
   {
      static void Main(string[] args)
      {
         int n = int.Parse(Console.ReadLine());
         string s = Console.ReadLine();

         int ans = n;
         int dup = 0;

         int up = (n%2==0)?n/2:(n-1)/2;
         string m1 = s[0] + "" + s[1];

         for(int i=2;i<=up;i++){
           string m2 = "";
           for(int j=i; ;j++){
             m2 += s[j]+"";
             if(m2.Length==i)break;
           }

           if(m2==m1){
             dup = Math.Max(dup,m2.Length);
           }

           m1 += s[i]+"";

         }

        if(dup>1){
          ans -= dup;
          ans++;
        }

         Console.WriteLine(ans);

      }
   }
}