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

namespace CodeForces
{
	internal class B
	{
		class Lem : IComparable<Lem>
		{
			public int Mass { get; set; }
			public int Speed { get; set; }
			public int Id { get; set; }
			public int CompareTo( Lem other )
			{
				if ( Mass != other.Mass )
					return Mass.CompareTo( other.Mass );
				else return Speed.CompareTo( other.Speed );
			}
		}
		private void Solve()
		{
			int n = NextInt(), k = NextInt(), h = NextInt();
			Lem[] a = new Lem[n];
			for ( int i = 0; i < n; ++i )
			{
				a[i] = new Lem();
				a[i].Mass = NextInt();
				a[i].Id = i + 1;
			}
			for ( int i = 0; i < n; ++i )
			{
				a[i].Speed = NextInt();
			}
			Random rnd = new Random( 123 );
			for ( int i = 1; i < n; ++i )
			{
				int j = rnd.Next( i + 1 );
				Lem tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
			Array.Sort( a );

			double l = 0, r = 1000000009;
			for ( int times = 0; times < 200; ++times )
			{
				double m = ( l + r ) / 2;
				if ( can( a, m, k, h ) ) r = m; else l = m;
			}
			var res = get( a, r, k, h );
			foreach ( var re in res )
			{
				Out.Write( re + " " );
			}
		}

		private bool can( Lem[] lems, double m, int k, int h )
		{
			int need = k;
			for ( int i = lems.Length - 1; i >= 0; --i )
			{
				double mx = Math.Min( k, m * lems[i].Speed / h );
				if ( mx >= need )
				{
					--need;
				}
				if ( need == 0 ) break;
			}
			return need == 0;
		}

		private List<int> get( Lem[] lems, double m, int k, int h )
		{
			List<int> res = new List<int>();
			int need = k;
			for ( int i = lems.Length - 1; i >= 0; --i )
			{
				double mx = Math.Min( k, m * lems[i].Speed / h );
				if ( mx >= need )
				{
					--need;
					res.Add( lems[i].Id );
				}
				if ( need == 0 ) break;
			}
			res.Reverse();
			return res;
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new B().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


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

namespace CodeForces
{

	class A
	{

		private void Solve()
		{
			int n = NextInt(), m = NextInt(), k = NextInt();
			int[,] a = new int[n, m], b = new int[n, m], c = new int[n, m];
			long res = 0;
			for ( int i = 0; i < n; ++i )
			{
				var name = NextLine();
				for ( int j = 0; j < m; ++j )
				{
					a[i, j] = NextInt();
					b[i, j] = NextInt();
					c[i, j] = NextInt();
				}
			}

			int[] cc = new int[m];

			for ( int i = 0; i < n; ++i )
				for ( int j = 0; j < n; ++j )
					if ( i != j )
					{
						for ( int t = 0; t < m; ++t ) cc[t] = c[i, t];
						int can = k;
						long cur = 0;
						while ( can > 0 )
						{
							int maxV = 0, tt = -1;
							for ( int t = 0; t < m; ++t )
								if ( cc[t] > 0 && b[j, t] - a[i, t] > maxV )
								{
									maxV = b[j, t] - a[i, t];
									tt = t;
								}
							if ( tt == -1 ) break;
							int sell = Math.Min( c[i, tt], can );
							cur += (long)sell * maxV;
							can -= sell;
							cc[tt] -= sell;
						}
						res = Math.Max( res, cur );
					}
			Out.WriteLine( res );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new A().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}


using System;
using System.IO;
using System.Text;

namespace Golden_Plate
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int w = Next(), h = Next(), k = Next();

            int ans = 0;
            for (int i = 0; i < k; i++)
            {
                ans += 2*w + 2*h - 4;
                w -= 4;
                h -= 4;
            }
            return ans;
        }

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


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		long U = long.Parse(str[0]);
		long V = long.Parse(str[1]);
		if(U==0){
			if(V==0){
				Console.WriteLine("0");
			} else if(V%2==0){
				Console.WriteLine("2");
				Console.WriteLine(V/2+" "+V/2);
			} else {
				Console.WriteLine("-1");
			}
		} else if(U>V){
			Console.WriteLine("-1");
		} else {
			V -= U;
			if(V==0){
				Console.WriteLine("1");
				Console.WriteLine(U);
			} else if(V%2==0){
				long x = 1;
				bool flag = true;
				while(x<V){
					if(U/x%2==1 && V/2/x%2==1){
						flag = false;
						break;
					}
					x *= 2;
				}
				if(flag){
					Console.WriteLine("2");
					Console.WriteLine((U+V/2)+" "+V/2);
				} else {
					Console.WriteLine("3");
					Console.WriteLine(U+" "+V/2+" "+V/2);
				}
			} else {
				Console.WriteLine("-1");
			}
		}
	}
}


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

namespace ConsoleApplication1
{
    class Test
    {
        public static void Main()
        {
            //Initializing variables and input
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            string s3 = Console.ReadLine();
            string s4 = Console.ReadLine();

            string[] sh1 = s1.Split(null);
            string[] sh2 = s2.Split(null);
            string[] sh3 = s3.Split(null);
            string[] sh4 = s4.Split(null);

            Int64[] n1 = new Int64[2];
            Int64[] n2 = new Int64[2];

            for(int i=0; i < 2; i++)
            {
                n1[i] = Int64.Parse(sh1[i]);
            }

            for (int i = 0; i < 2; i++)
            {
                n2[i] = Int64.Parse(sh3[i]);
            }

            Int64[] d1 = new Int64[n1[0]];
            Int64[] d2 = new Int64[n2[0]];

            for (int i = 0; i < n1[0]; i++)
            {
                d1[i] = Int64.Parse(sh2[i]);
            }

            for (int i = 0; i < n2[0]; i++)
            {
                d2[i] = Int64.Parse(sh4[i]);
            }

            //Execution

            Int64 num1 = 0;
            Int64 num2 = 0;

            for(int i = 0 ; i < n1[0] ; i++)
            {
                num1 = num1 + ((d1[n1[0] - i - 1]) * Convert.ToInt64(Math.Pow(n1[1], i)));
            }

            for (int i = 0; i < n2[0]; i++)
            {
                num2 = num2 + ((d2[n2[0] - i - 1]) * Convert.ToInt64(Math.Pow(n2[1], i)));
            }

            if(num1 == num2)
            {
                Console.WriteLine("=");
            }
            else if (num1 > num2)
            {
                Console.WriteLine(">");
            }
            else
            {
                Console.WriteLine("<");
            }
        }
    }
}


using System;

namespace Codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			new Solution();
		}
	}
	class Solution
	{
		public Solution(){
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx = x.ToString();
            int count = 1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si = i.ToString().ToCharArray();
                if (x % i == 0 && sx.IndexOfAny(si) >= 0)
                {
                    count++;
                }
                if (i > 1 && i != x / i && x % (x / i) == 0)
                {
                    char[] ssi = (x / i).ToString().ToCharArray();
                    if(sx.IndexOfAny(ssi)>=0)
                        count++;
                }
            }
            Console.Write(count);
            //Console.ReadKey(true);

		}
	}
}
/*A
int n=int.Parse(Console.ReadLine());
Console.Write(n+" ");
for (int i = 1; i < n; i++)
{
    Console.Write(i + " ");
}
*/

/* B
            int x = int.Parse(Console.ReadLine());
            if (x == 1)
            {
                Console.WriteLine("1");
                return;
            }
            String sx=x.ToString();
            int count=1;
            for (int i = 1; i <= Math.Sqrt(x); i++)
            {
                char[] si=i.ToString().ToCharArray();
                if (x%i==0 && sx.IndexOfAny(si)>=0)
                {
                        count++;
                 }
            }
            Console.Write(count);
            */
/*C
            int n = int.Parse(Console.ReadLine());
            String s=Console.ReadLine();
            String[] z=s.Split(' ');
            int[] c = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = int.Parse(z[i]);
            }
            int count = 0;
            for (int i = 1; i < n; i++)
            {
                if (c[i - 1] > c[i]) count++;
                if (count > 2)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (count == 2 || count ==0)
            {
                Console.WriteLine("YES");
                return;
            }
            if (count == 1)
            {
                int i=0;
                while (c[i] <= c[i + 1]) i++;
                int p=c[i];
                int t=c[i+1];i++;
                while (i<n && c[i] == t) i++;
                if (i == n)
                {
                    Console.WriteLine("YES");
                    return;
                }
                if (c[i] == p)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            */


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

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    var res = GetPrices(s[0], s[1]).Last();
    Console.Write(res);
  }

  static IEnumerable<long> GetPrices(long p, long d) {
    yield return p;
    var min = p - d;
    var mult = 10L;
    while (true) {
      p -= (1 + p%mult) % mult;
      if (p < min) yield break;
      yield return p;
      mult *= 10;
    }
  }
}


using System;
using System.IO;
using System.Text;

namespace Turn
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            long n = long.Parse(reader.ReadLine());

            n %= 360;

            if (n >= 0)
            {
                if (n <= 45)
                    writer.WriteLine("0");
                else if (n <= 45 + 90)
                    writer.WriteLine("1");
                else if (n <= 45 + 180)
                    writer.WriteLine("2");
                else if (n < 45 + 270)
                    writer.WriteLine("3");
                else
                {
                    writer.WriteLine("0");
                }
            }
            else
            {
                if (n >= -45)
                    writer.WriteLine("0");
                else if (n > -45 - 90)
                    writer.WriteLine("3");
                else if (n > -45 - 180)
                    writer.WriteLine("2");
                else if (n > -45 - 270)
                    writer.WriteLine("1");
                else
                {
                    writer.WriteLine("0");
                }
            }

            writer.WriteLine();
            writer.Flush();
        }
    }
}


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

namespace cdfRound
{
    class MainClass
    {
        public static void Main()
        {
            string input = Console.ReadLine();
            int[] first = new int[3];
            int[] second = new int[3];
            int sum1 = 0, sum2 = 0;
            for (int i = 0; i < 3; i++)
            {
                first[i] = int.Parse(input[i].ToString());
                sum1 += first[i];
            }
            for (int i = 3; i < 6; i++)
            {
                second[i - 3] = int.Parse(input[i].ToString());
                sum2 += second[i - 3];
            }
            if (sum1 == sum2)
                Console.WriteLine(0);
            else
            {
                if (sum1 > sum2)
                {
                    int[] el = new int[6];
                    for (int i = 0; i < 3; i++)
                        el[i] = 9 - second[i];
                    for (int i = 0; i < 3; i++)
                        el[i + 3] = first[i];
                    int sum = sum1 - sum2;
                    Array.Sort(el);
                    if (sum <= el[5]) Console.WriteLine(1);
                    else if (sum <= (el[5] + el[4])) Console.WriteLine(2);
                    else Console.WriteLine(3);
                }
                else
                {
					int[] el = new int[6];
					for (int i = 0; i < 3; i++)
                        el[i] = 9 - first[i];
					for (int i = 0; i < 3; i++)
                        el[i + 3] = second[i];
					int sum = sum2 - sum1;
					Array.Sort(el);
					if (sum <= el[5]) Console.WriteLine(1);
					else if (sum <= (el[5] + el[4])) Console.WriteLine(2);
					else Console.WriteLine(3);
                }
            }
        }
    }
}


using System;
using System.Linq;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ');
            var n = Int32.Parse(arr[0]);
            var m = long.Parse(arr[1]);
            var res = GetRes(n, m);
            Console.WriteLine(res);

            // Test();
        }

        const int MOD_VAL = 998244353;
        private static int GetRes(int n, long m)
        {
            if (n == 1) return 0;
            var fullCount = GetFullCount(n, m);
            var noOk = GetNOKCount(n,m);
            var res = fullCount - noOk;
            if(res < 0) res+=MOD_VAL;
            return res;
        }

        private static int GetFullCount(int n, long m)
        {
            var divisor = (int)((m-1) % MOD_VAL);
            if (divisor == 0) return n;
            var reverse = GetReverse(divisor);
            var mAfterMod = (int)(m % MOD_VAL);
            var res = (int)(((long)GetPow(mAfterMod, n+1) - mAfterMod) *
                reverse % MOD_VAL);
            if (res < 0) res+=MOD_VAL;
            return res;
        }

        private static int GetReverse(int val)
        {
            var (a,b) = ExGcd(MOD_VAL, val);
            return b >= 0 ? (int) b: (int)(MOD_VAL+b);
        }

        private static (long, long) ExGcd(long num0, long num1)
        {
            if (num0 % num1 == 0)
            {
                return (0, 1);
            }
            // a0 * num0 + b0 * num1 = num2
            var num2 = num0 % num1;
            var a0 = 1;
            var b0 = -(num0 / num1);
            // a1 * num1 + b1 * num2 = gcd
            var (a1, b1) = ExGcd(num1, num2);
            // (a0*b1) * num0 + (a1 + b0*b1) * num1 = gcd
            return (a0 * b1, a1 + b0 * b1);
        }

        private static int GetPow(int baseVal, int exponent)
        {
            var index = 0;
            var res = 1L;
            long tmp = baseVal;
            while(1<<index <= exponent)
            {
                if ((1<<index & exponent)!=0)
                {
                    res = res * tmp % MOD_VAL;
                }
                tmp = tmp * tmp % MOD_VAL;
                index++;
            }
            return (int)res;
        }

        private static int GetNOKCount(int n, long m)
        {
            var primes = new int[]
            {
                2,3,5,7,11,13,17,19,23,29,31,37
            };
            var product = 1L;
            var noOkI = m % MOD_VAL;
            var noOk = noOkI;
            for(var i =2;i<=n;i++)
            {
                if(primes.Contains(i))
                {
                    product*=i;
                }
                if( m < product)
                {
                    break;
                }
                noOkI = noOkI * (m/product % MOD_VAL) % MOD_VAL;
                noOk = (noOk + noOkI) % MOD_VAL;
            }
            return (int)noOk;
        }

        private static (int,int) GetTestData(Random random)
        {
            return (random.Next(10)+3, random.Next(4));
        }

    }
}


using System;

namespace _779B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string n = input[0]; int k = int.Parse(input[1]);
            int i = input[0].Length - 1, s = 0;
            while (i > 0 && k > 0)
            {
                if (n[i] == '0') k--;
                else s++;
                i--;
            }
            if (k == 0) Console.WriteLine(s);
            else Console.WriteLine(n.Length - 1);
        }
    }
}


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

namespace олимпиадное_программирование
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if(x==1)
                Console.WriteLine(-1);
            else
            {
                if(x%2==0)
                    Console.WriteLine("{0} {1}", x,2);
                else
                    Console.WriteLine("{0} {1}", x-1, 2);
            }
        }
    }
}


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

namespace CodeForces
{
    class R172_Div2_B
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);
            int n = int.Parse(s[2]);
            double dx = (double) x;
            double dy = (double) y;

            long mina = 0, minb = 0;
            double min = long.MaxValue;
            for (long b = 1; b <= n; b++)
            {
                double db = (double)b;
                long aMin = b * x / y;
                long aMax = Convert.ToInt64(Math.Ceiling(db * dx / dy));

                for (long a = aMin; a <= aMax; a++)
                {
                    double da = (double)a;
                    double d = Math.Abs(dx / dy - da / db);
                    d = Math.Floor(d * 1e15) / 1e15;
                    if (d < min)
                    {
                        min = d;
                        mina = a;
                        minb = b;
                    }
                }
            }

            Console.WriteLine(mina + "/" + minb);

        }
    }
}


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

namespace CyberMainProject
{
    class CyberMainClass
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int min = 0, max = 0;
            if (n <= 2)
            {
                min = 0;
                max = n;
            }
            else if (n <= 5)
            {
                min = 0;
                max = 2;
            }
            else if (n>5)
            {
                if (n >= 7 && n%7 == 0)
                {
                    min = (n/7)*2;
                    max = (n/7)*2;
                }
                else
                {
                    if (n == 6)
                    {
                        min = 1;
                        max = 2;
                    }
                    else
                    {
                        int m = n/7;
                        min = m *2;
                        max = m *2;
                        int t = n-(m*7);
                        if (t <= 2)
                        {
                            max += t;
                        }
                        else
                        {

                            max += 2;
                            if (t == 6)
                            {
                                min +=1;
                            }
                        }
                    }
                }
            }
            Console.WriteLine(min + " " +max);
        }
    }
}


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

namespace CF_273_d {
  public class Program {

    public static int r;
    public static int g;
    public static int h;
    public static int cntRG;
    public static ulong[] a;
    public static ulong[] ap;
    public static int n;
    public static int c1;
    public static int c2;
    public static ulong max = 1000000007;
    //public static ulong max = 1000000000;
    public static ulong maxCnt = 0;

    public static void Main(string[] args) {

      string[] str = Console.ReadLine().Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
      r = int.Parse(str[0]);
      g = int.Parse(str[1]);

      ulong cnt = Func1();

      Console.WriteLine(cnt);
      Console.ReadLine();
    }

    public static ulong Func1() {

      double d = 1 + 4 * (r + g) * 2;
      double x = (-1 + Math.Sqrt(d)) / 2;
      h = (int)x;
      cntRG = (h + 1) * h / 2;
      c1 = r;
      c2 = g;
      if(g < c1) {
        c1 = g;
        c2 = r;
      }

      if(c1 == 0) return 1;

      a = new ulong[c1 + 1];
      ap = new ulong[c1 + 1];

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

      n = 1;
      Func2();

      ulong sumA = 0;
      for(int i = 0; i <= c1; i++) {
        sumA += a[i];
        if(sumA > max) {
          maxCnt+= sumA / max;
          sumA = sumA % max;
        }
      }

      return sumA;

    }

    public static void Func2() {

      while(n < h) {
        Array.Copy(a, ap, a.Length);
        n++;
        for(int i = 0; i <= c1; i++) {
          int k1 = i - n;
          ulong a1 = 0;
          if(k1 >= 0) a1 = ap[k1];

          int cnt = (n + 1) * n / 2;
          int gi = cnt - i;
          ulong a2 = 0;
          if(gi <= c2) {
            a2 = ap[i];
          }

          a[i] = a1 + a2;

          if(a[i] > max) {
            a[i] %= max;
          }
        }
      }
    }
  }
}


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

namespace Codeforces_CS
{
    class Class1
    {
        static void Main(string[] args)
        {
            new Class1().run();
        }

        int bpb = 0;
        int spb = 0;
        int cpb = 0;
        int bh = 0;
        int sh = 0;
        int ch = 0;
        int bp = 0;
        int sp = 0;
        int cp = 0;
        long price = 0;

        void run()
        {
            string burger = Console.ReadLine();

            for (int i = 0; i < burger.Length; i++)
            {
                if (burger[i] == 'B') bpb++;
                if (burger[i] == 'S') spb++;
                if (burger[i] == 'C') cpb++;
            }
            string[] tokens = Console.ReadLine().Split();
            bh = int.Parse(tokens[0]);
            sh = int.Parse(tokens[1]);
            ch = int.Parse(tokens[2]);

            tokens = Console.ReadLine().Split();
            bp = int.Parse(tokens[0]);
            sp = int.Parse(tokens[1]);
            cp = int.Parse(tokens[2]);

            price = long.Parse(Console.ReadLine());

            long ox = 1;
            long nx = 2;
            if (can(1))
            {
                while (can(nx))
                {
                    ox <<= 1;
                    nx <<= 1;
                }
                long ans = ox;
                while (ox <= nx)
                {
                    long mid = (ox + nx) / 2;
                    if (can(mid))
                    {
                        ans = mid;
                        ox = mid + 1;
                    }
                    else
                    {
                        nx = mid - 1;
                    }
                }
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine(0);
            }

        }

        bool can(long burgers)
        {
            long cr = Math.Max(0,(cpb * burgers) - ch);
            long br = Math.Max(0,(bpb * burgers) - bh);
            long sr = Math.Max(0,(spb * burgers) - sh);
            long total = br * bp + sr * sp + cr * cp;
            return total <= price;
        }

    }

}


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

class Solution
{
	static void Main (string[] args)
	{
		int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		int n = nums [0];
		int s = nums [1];
		int target = nums [2];
		int[] v = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		string c = Console.ReadLine ();

		List<Node> nodes = new List<Node> ();
		for (int i = 0; i < n; i++) {
			nodes.Add (new Node (i, v [i], c [i]));
		}
		nodes.ForEach (node => node.AddNeighbors (nodes));

		Node initialNode = new Node (s - 1, 0, ' ');
		initialNode.Neighbors = nodes;

		List<State>[] search = new List<State>[n * n + 2];
		for (int i = 0; i < search.Length; i++) {
			search [i] = new List<State> ();
		}
		search [0].Add (new State{ Missing = target, Current = initialNode });
		bool[,] expanded = new bool[target + 1, n];

		for (int t = 0; t < search.Length; t++) {
			foreach (State state in search[t]) {
				if (state.Solved) {
					Console.WriteLine (t - 1);
					return;
				}
				if (expanded [state.Missing, state.Current.Index])
					continue;
				expanded [state.Missing, state.Current.Index] = true;
				foreach (State s2 in state.Expand()) {
					search [s2.Time].Add (s2);
				}
			}
		}
		Console.WriteLine (-1);
	}

	class State {
		public int Missing;
		public Node Current;
		public int Time;

		public bool Solved => Missing <= 0;

		public IEnumerable<State> Expand() {
			foreach(Node n in Current.Neighbors) {
				State s = new State();
				s.Current = n;
				s.Missing = Missing - n.Value;
				s.Time = Time + Current.Dist(n);
				yield return s;
			}
		}
	}

	class Node {
		public int Index;
		public int Value;
		public char Color;
		public List<Node> Neighbors;

		public Node(int index, int value, char color) {
			this.Index = index;
			this.Value = value;
			this.Color = color;
		}

		public int Dist(Node n) {
			return Math.Abs(Index - n.Index) + (Color == ' ' ? 1 : 0);
		}

		public void AddNeighbors(List<Node> nodes) {
			Neighbors = nodes.Where (n => n.Color != this.Color && n.Value > this.Value).ToList ();
		}
	}
}


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

namespace Practise
{
    class Program
    {
        public static void Main()
        {
            String input = Console.ReadLine();
            String pending = Console.ReadLine();

            String left = input.Substring(0, input.IndexOf('|'));
            String right = input.Substring(input.IndexOf('|') + 1);
            int lLeft = left.Length;
            int lRight = right.Length;

            int diff = Math.Abs(lLeft - lRight);
            if (diff > pending.Length || (pending.Length - diff) % 2 != 0)
            {
                Console.WriteLine("Impossible");
            }
            else
            {
                int expLength = (lLeft + lRight + pending.Length) / 2;
                int i = 0;
                while (left.Length < expLength)
                {
                    left += pending[i++];
                }
                while (right.Length < expLength)
                {
                    right += pending[i++];
                }
                Console.WriteLine(left + "|" + right);
            }
        }
    }
}


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

namespace ChallengePennants
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = long.Parse(s);
            if (n <= 10)
            {
                Console.WriteLine(1);
            }
            else
            {
                long x = n / 2 + n / 3 + n / 5 + n / 7;
                x -= n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35;
                x += n / 30 + n / 42 + n / 70 + n / 105;
                x -= n / 210;
                Console.WriteLine("{0:d}", n - x);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var a = sc.Integer();
            var b = sc.Integer();
            var k = sc.Integer();
            const long mod = (long)1e9 + 7;
            var dp = new long[5050];
            dp[a]++;
            for (int _ = 0; _ < k; _++)
            {
                var ndp = new long[5050];
                for (int i = 1; i <= n; i++)
                {
                    if (i == b) continue;
                    var d = Math.Abs(b - i) - 1;
                    var l = Math.Max(1, i - d);
                    var r = Math.Min(n, i + d);
                    ndp[l] += dp[i];
                    ndp[i] -= dp[i];
                    ndp[i + 1] += dp[i];
                    ndp[r + 1] -= dp[i];
                }
                for (int i = 1; i <= n; i++)
                    ndp[i] = (ndp[i] + ndp[i - 1]) % mod;
                dp = ndp;
            }
            long ret = 0;
            for (int i = 1; i <= n; i++)
                ret = (ret + dp[i]) % mod;
            IO.Printer.Out.WriteLine((ret + mod) % mod);
        }
        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


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

namespace CF
{
    public static class FromConsole
    {
        public static T To<T>(this string input) where T : IConvertible
        {
            return (T)Convert.ChangeType(input, typeof(T));
        }

        public static T[] ToArrayOf<T>(this string input, char? delimiter = null) where T : IConvertible
        {
            IEnumerable<string> sequence = delimiter == null ? input.Select(x => x.ToString()) : input.Split(delimiter.Value);

            return sequence.Select(x => x.ToString().To<T>()).ToArray();
        }

        public static T[] ToArrayOf<T>(int count) where T : IConvertible
        {
            T[] output = new T[count];

            for (int i = 0; i < count; i++)
            {
                output[i] = Console.ReadLine().To<T>();
            }

            return output;
        }

        public static T[] ToArrayOf<T>(T value, int count)
        {
            return Enumerable.Repeat(value, count).ToArray();
        }

        public static T[][] ToMatrixOf<T>(int n, char? delimiter = null) where T : IConvertible
        {
            T[][] output = new T[n][];

            for (int i = 0; i < n; i++)
            {
                output[i] = Console.ReadLine().ToArrayOf<T>(delimiter);
            }

            return output;
        }

        public static T[][] ToMatrixOf<T>(T value, int n, int m)
        {
            T[][] output = new T[n][];

            for (int i = 0; i < n; i++)
            {
                output[i] = ToArrayOf(value, m);
            }

            return output;
        }

        public static Tuple<int, int> IndexOf<T>(this T[][] input, params T[] targets)
        {
            for (int i = 0; i < input.Length; i++)
            {
                for (int j = 0; j < input[0].Length; j++)
                {
                    if (targets.Any(x => x.Equals(input[i][j])))
                    {
                        return new Tuple<int, int>(i, j);
                    }
                }
            }

            return new Tuple<int, int>(-1, -1);
        }

        public static void AddToList<T, U>(this Dictionary<T, List<U>> input, T k, U v)
        {
            if (input.ContainsKey(k))
            {
                input[k].Add(v);
            }
            else
            {
                input.Add(k, new List<U>() { v });
            }
        }

        public static void AddAndIncrement<T>(this Dictionary<T, int> input, T k)
        {
            if (input.ContainsKey(k))
            {
                input[k]++;
            }
            else
            {
                input.Add(k, 1);
            }
        }

        public static string ToBinary(this long input)
        {
            return Convert.ToString(input, 2);
        }

        public static long ToDecimal(this string input)
        {
            return Convert.ToInt32(input, 2);
        }

        public static long Binomial(long n, long k)
        {
            long r = 1;
            long d;
            if (k > n) return 0;
            for (d = 1; d <= k; d++)
            {
                r *= n--;
                r /= d;
            }
            return r;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = Console.ReadLine().To<int>();
            string s = Console.ReadLine();

            char previous = ' ';
            bool duplicates = false;
            for (int i = 0; i < s.Length; i++)
            {
                char c = s[i];

                if (c == previous && c != '?')
                {
                    duplicates = true;
                    break;
                }

                previous = c;
            }

            bool canConfigure = false;
            if (!duplicates)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    char c = s[i];

                    if (c == '?')
                    {
                        if (i == 0 || i == s.Length - 1)
                        {
                            canConfigure = true;
                            break;
                        }
                        else
                        {
                            char l = s[i - 1];
                            char r = s[i + 1];

                            if (l == r || l == '?' || r == '?')
                            {
                                canConfigure = true;
                                break;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(canConfigure ? "Yes" : "No");
            //Console.ReadKey();
        }
    }

    //public class SegmentTreeLadder
    //{
    //    private Tuple<bool, char>[] tree;
    //    private List<int> input;

    //    public SegmentTreeLadder(List<int> input)
    //    {
    //        this.input = input;
    //        tree = new Tuple<bool, char>[4 * input.Count];
    //        Build(1, 0, input.Count - 1);
    //    }

    //    public Tuple<bool, char> RMQ(int i, int j)
    //    {
    //        return Query(1, 0, input.Count - 1, i, j);
    //    }

    //    private int Left(int p)
    //    {
    //        return 2 * p;
    //    }

    //    private int Right(int p)
    //    {
    //        return (2 * p) + 1;
    //    }

    //    private Tuple<bool, char> Compose(Tuple<bool, char> left, Tuple<bool, char> right)
    //    {
    //        if (left.Item1 && right.Item1)
    //        {
    //            if (left.Item2 == '^' && right.Item2 == 'v'
    //                || left.Item2 == '=' && right.Item2 == '='
    //                || left.Item2 == '^' && right.Item2 == '='
    //                || left.Item2 == '=' && right.Item2 == 'v')
    //            {
    //                new Tuple<bool, char>(true, '=');
    //            }

    //            // also need another char sentinel for 'mixed'
    //            // really don't need tuple, just
    //        }

    //        return new Tuple<bool, char>(false, '=');
    //    }

    //    private void Build(int p, int leftIndex, int rightIndex)
    //    {
    //        if (leftIndex == rightIndex)
    //        {
    //            // EDIT: store summarized node val here
    //            tree[p] = default(TSummary);
    //            return;
    //        }

    //        int middle = (leftIndex + rightIndex) / 2;
    //        Build(Left(p), leftIndex, middle);
    //        Build(Right(p), middle + 1, rightIndex);

    //        // EDIT: just key into tree here and get the summary of both nodes.
    //        //       this is just an access, no actual work is being done here.
    //        TSummary leftNode = tree[Left(p)];
    //        TSummary rightNode = tree[Right(p)];
    //        // EDIT: do tree[p] = f(leftIndex, rightIndex) here
    //        tree[p] = Compose(leftNode, rightNode);
    //    }

    //    private TSummary Query(int p, int leftIndex, int rightIndex, int i, int j)
    //    {
    //        // if the current segment (l, r) is outside the requested range (i, j)
    //        if (i > rightIndex || j < leftIndex)
    //        {
    //            return default(TSummary); // EDIT: should be min(T), but order would need to be defined
    //        }
    //        // if the current segment (l, r) is inside the requested range (i, j)
    //        if (i <= leftIndex && j >= rightIndex)
    //        {
    //            return tree[p];
    //        }

    //        int middle = (leftIndex + rightIndex) / 2;
    //        TSummary leftNode = Query(Left(p), leftIndex, middle, i, j);
    //        TSummary rightNode = Query(Right(p), middle + 1, rightIndex, i, j);

    //        if (leftNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
    //        {
    //            return rightNode;
    //        }
    //        if (rightNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
    //        {
    //            return leftNode;
    //        }

    //        return Compose(leftNode, rightNode);
    //    }
    //}

    public class SegmentTreeGeneralized<TSummary, TInput>
    {
        private TSummary[] tree;
        private List<TInput> input;

        public SegmentTreeGeneralized(List<TInput> input)
        {
            this.input = input;
            tree = new TSummary[4 * input.Count];
            Build(1, 0, input.Count - 1);
        }

        public TSummary RMQ(int i, int j)
        {
            return Query(1, 0, input.Count - 1, i, j);
        }

        private int Left(int p)
        {
            return 2 * p;
        }

        private int Right(int p)
        {
            return (2 * p) + 1;
        }

        private TSummary Compose(TSummary left, TSummary right)
        {
            return default(TSummary);
        }

        private void Build(int p, int leftIndex, int rightIndex)
        {
            if (leftIndex == rightIndex)
            {
                // EDIT: store summarized node val here
                tree[p] = default(TSummary);
                return;
            }

            int middle = (leftIndex + rightIndex) / 2;
            Build(Left(p), leftIndex, middle);
            Build(Right(p), middle + 1, rightIndex);

            // EDIT: just key into tree here and get the summary of both nodes.
            //       this is just an access, no actual work is being done here.
            TSummary leftNode = tree[Left(p)];
            TSummary rightNode = tree[Right(p)];
            // EDIT: do tree[p] = f(leftIndex, rightIndex) here
            tree[p] = Compose(leftNode, rightNode);
        }

        private TSummary Query(int p, int leftIndex, int rightIndex, int i, int j)
        {
            // if the current segment (l, r) is outside the requested range (i, j)
            if (i > rightIndex || j < leftIndex)
            {
                return default(TSummary); // EDIT: should be min(T), but order would need to be defined
            }
            // if the current segment (l, r) is inside the requested range (i, j)
            if (i <= leftIndex && j >= rightIndex)
            {
                return tree[p];
            }

            int middle = (leftIndex + rightIndex) / 2;
            TSummary leftNode = Query(Left(p), leftIndex, middle, i, j);
            TSummary rightNode = Query(Right(p), middle + 1, rightIndex, i, j);

            if (leftNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
            {
                return rightNode;
            }
            if (rightNode.Equals(default(TSummary))) // EDIT: again, should be min(T)
            {
                return leftNode;
            }

            return Compose(leftNode, rightNode);
        }
    }
}


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

namespace _680B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' '), input2 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]), a = int.Parse(input1[1]) - 1;
            bool[] t = new bool[n];
            for (int i = 0; i < n; i++) t[i] = input2[i] == "1";

            int result = 0, distance = 0;
            while (true)
            {
                bool leftExist = (a - distance) >= 0, rightExist = (a + distance) < n;
                if (!leftExist && !rightExist) break;

                if ((distance == 0 && t[a]) ||
                    (distance > 0 && leftExist && !rightExist && t[a - distance]) ||
                    (distance > 0 && !leftExist && rightExist && t[a + distance]))
                {
                    result++;
                }
                else if (distance > 0 && leftExist && rightExist && t[a - distance] && t[a + distance])
                {
                    result += 2;
                }

                distance++;
            }

            Console.WriteLine(result);
            //Console.ReadLine();
        }
    }
}


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

namespace Tasks_010918
{
    public class Program
    {
        public static string LongStringChange (string s)
        {
            string s1 = "";
            if (s.Length < 10)
                Console.WriteLine(s);
            else
            {
                string b = s.Substring(1, s.Length - 2);
                int count = b.Length;

               s1 = string.Concat(s.Replace(b, Convert.ToString(count)));
                Console.WriteLine(s1);

            }
            return s1;
        }

        public static string StringChangedMethod (string x)
        {
            x = x.ToLower();
            string y = "AOEYUI".ToLower();

            int index = 0;
            for (int i = 0; i < x.Length; i++)
            {
                for (int j = 0; j < y.Length; j++)
                {
                    if (x[i] == y[j])
                    {
                        index = i;
                        x = x.Remove(index, 1);
                    }
                    index = 0;
                }
            }

            for (int i = 0; i < x.Length; i++)
            {
                if (i % 2 == 0)
                 x = x.Insert(i, Convert.ToString('.'));
            }

            return x;
        }

        static bool IsAllDigitsDifferent(int n)
        {
            string toString = n.ToString();  // 1988

            Dictionary<char, int> charsOccurence = new Dictionary<char, int>();
            foreach (char item in toString)
            {
                if (!charsOccurence.ContainsKey(item))
                {
                    charsOccurence[item] = 1;
                }
                else return false;
            }
            return true;
        }

        public static int GetNextDistinctInteger(int n)
        {
            for(int i = n + 1; i <= 9012; i++)
            {
                if (IsAllDigitsDifferent(i))
                {
                    return i;
                }
            }
            return 0;
        }

        static int BeatifullYearFunc (int n)
        {
            IList<int> y = new List<int>();
            for (int i = n + 1; i < 9000; i++)
            {
                string v = Convert.ToString(i);
                Dictionary<char, int> by = new Dictionary<char, int>();
                bool isTwiced = false;
                foreach(char x in v)
                {
                    if (!by.ContainsKey(x))
                    {
                        by[x] = 1;
                    }
                    else
                    {
                       by[x]++;
                    }
                    if (by[x] == 2)
                    {
                        isTwiced = true;
                        break;
                    }
                }

                if (isTwiced == false)
                {
                    n = Convert.ToInt32(y[i]);
                    Console.WriteLine(n);
                }

            }

            return n;
        }

        public static string ReturnStrMethod (string str, string subStr)
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (str.ToLower(). Contains(subStr.ToLower()))
                {
                    int n = str.IndexOf(subStr);
                    str = str.Replace(subStr, " ");
                }
            }

            return str;
        }

        public static int CountElephantSteps (int x)
        {
            int res = 0;
            if (x % 5 == 0)
            {
                res = x / 5;
                Console.WriteLine("Количество шагов = {0}", res);
            }
            else
            {
                if (x % 4 == 0)
                {
                    res = x / 4;
                    Console.WriteLine("Количество шагов = {0}", res);
                }
                else
                {

                    if (x % 3 == 0)
                    {
                        res = x / 3;
                        Console.WriteLine("Количество шагов = {0}", res);
                    }
                    else
                    {

                        if (x % 2 == 0)
                        {
                            res = x / 2;
                            Console.WriteLine("Количество шагов = {0}", res);
                        }
                        else
                        {

                            if (x % 1 == 0)
                            {
                                res = x / 1;
                                Console.WriteLine("Количество шагов = {0}", res);
                            }
                        }
                    }
                }
            }
            return res;
        }

        public static int CountResultFunc (int n, int[] points)
        {
            int countResult = 0;
            int max = points[0];
            int min = points[0];
            int indexMin = 0, indexMax = 0;

            for (int i = 0; i < points.Length; i++)
            {
                if (points[i] < min)
                {
                    min = points[i];
                    indexMin = i;
                    countResult++;
                }
                indexMin = 0;
            }
            Console.WriteLine("------------------");
            for (int i = 0; i < points.Length; i++)
            {
                if (points[i] > max)
                {
                    max = points[i];
                    indexMax = i;
                    countResult++;
                }
                indexMax = 0;
            }
            Console.WriteLine("Количество удивительных выступлений = {0}", countResult);
            return countResult;
        }

        static void Main(string[] args)
        {
            #region Taks 1
            //Console.WriteLine("Введите количество строк");
            //int n = Convert.ToInt32(Console.ReadLine());
            //string[] s = new string[n];

            //if (n > 0)
            //{
            //    for (int i = 0; i < n; i++)
            //    {
            //        Console.WriteLine("Введите слово");
            //        s[i] = Console.ReadLine();
            //    }

            //    foreach (string item in s)
            //    {
            //        LongStringChange(item);
            //    }

            //}
            #endregion

            #region Task 2
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();

            //Console.WriteLine(StringChangedMethod(str));

            #endregion

            #region Taks 3
            //Console.WriteLine("Введите количество строк");
            //int n = Convert.ToInt32(Console.ReadLine());
            //string[] num = new string[n];
            //int x = 0;

            //if (n > 0)
            //{
            //    for (int i = 0; i < n; i++)
            //    {
            //        Console.WriteLine("Введите операцию, которую надо выполнить");
            //        num[i] = Console.ReadLine();
            //    }

            //    foreach (string item in num)
            //    {
            //        if (item == "x++" || item == "++x")
            //            x++;
            //        else if (item == "x--" || item == "--x")
            //            x--;
            //    }

            //    Console.WriteLine(x);

            //}
            #endregion

            #region Task 4
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //StringBuilder sb = new StringBuilder(str);

            //for (int i = 0; i < sb.Length; i++)
            //{
            //    sb[0] = Char.ToUpper(sb[0]);
            //}

            //string newString = sb.ToString();
            //Console.WriteLine(newString);
            #endregion

            #region Task 5
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();

            //if (str.Length % 2 == 0)
            //    Console.WriteLine("Chat with her");
            //else
            //    Console.WriteLine("Ignore him");
            #endregion

            #region Task 6
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //StringBuilder sb = new StringBuilder(str);

            //for (int i = 0; i < sb.Length; i++)
            //{
            //    if (Char.IsLower(sb[0]) == true || Char.IsUpper(sb[i]) == true)
            //    {
            //        sb[0] = Char.ToUpper(sb[0]);
            //        sb[i] = Char.ToLower(sb[i]);
            //    }
            //    else
            //    {
            //        sb[i] = sb[i];
            //    }
            //}

            //string newString = sb.ToString();
            //Console.WriteLine(newString);
            #endregion

            #region Task 7
            //Console.WriteLine("Введите целое число");
            //int n = Convert.ToInt32(Console.ReadLine());

            //string s = n.ToString();
            //int count = 0;

            //for (int i = 0; i < s.Length; i++)
            //{
            //    if (s[i] == '4' || s[i] == '7')
            //    {
            //        count++;
            //    }
            //}

            //if (count == 4 || count == 7)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");
            #endregion

            #region Task 8
            //string s = "";
            //string t = "";

            //Console.WriteLine("Введите слово");
            //s = Console.ReadLine();
            //char[] reversed = s.Reverse().ToArray();
            //string str = new string(reversed);

            //Console.WriteLine("Введите слово");
            //t = Console.ReadLine();

            //if (String.Equals(str, t) == true)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");

            #endregion

            #region Task 9
            string input = Console.ReadLine();

            int n = Convert.ToInt32(input);

            int next = GetNextDistinctInteger(n);

            Console.WriteLine(next);
            Console.ReadLine();
            #endregion

            #region Task 10
            /*
            Console.WriteLine("Введите целое число");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine(CountElephantSteps(x));
            */
            #endregion

            #region Task 11
            //Console.WriteLine("Введите слово");
            //string str = Console.ReadLine();
            //string f = "WUB";
            //Console.WriteLine(ReturnStrMethod(str, f));
            #endregion

            #region Task 12
            //Console.WriteLine("Введите целое число");
            //int x = Convert.ToInt32(Console.ReadLine());
            //int[] points = new int[x];

            //for (int i = 0; i < x; i++)
            //{
            //    Console.WriteLine("Введите целое число");
            //    points[i] = Convert.ToInt32(Console.ReadLine());
            //}

            //Console.WriteLine("------------------");

            //for (int i = 0; i < points.Length; i++)
            //{
            //    Console.WriteLine(points[i]);
            //}

            //Console.WriteLine("------------------");
            //CountResultFunc(x, points);
            #endregion

            #region Task 13
            //Console.WriteLine("Введите строку");
            //string str = Console.ReadLine();
            //string s = "HQ9+";
            //int n = 0;

            //for (int i = 0; i < str.Length; i++)
            //{
            //    for (int j = 0; j < s.Length; j++)
            //    {
            //        if (str[i] == s[j])
            //            n = 1;
            //    }
            //}

            //if (n > 0)
            //{
            //    Console.WriteLine("YES");
            //} else { Console.WriteLine("NO"); }

            #endregion

            #region Task 14
            //Console.WriteLine("Введите число строк");
            //int n = Convert.ToInt32(Console.ReadLine());

            //Console.WriteLine("Введите число столбцов");
            //int m = Convert.ToInt32(Console.ReadLine());
            //char[,] y = new char[n, m];

            //char[] colors = { 'C', 'M', 'Y', 'W', 'G', 'B' };
            //int res = 0;

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        Console.WriteLine("введите любой символ из {0}", colors);
            //        y[i, j] = Convert.ToChar(Console.ReadLine());
            //        Console.WriteLine();
            //    }
            //}

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        Console.Write(y[i, j] + "\t");
            //    }
            //    Console.WriteLine();
            //}

            //for (int i = 0; i < n; i++)
            //{
            //    for (int j = 0; j < m; j++)
            //    {
            //        for (int z = 0; z < colors.Length; z++)
            //        {
            //            if ((y[i, j].CompareTo('W') == 0 || y[i, j].CompareTo('B') == 0 || y[i, j].CompareTo('G') == 0) && (y[i, j].CompareTo('Y') == -1 || y[i, j].CompareTo('C') == -1 || y[i, j].CompareTo('M') == -1))
            //                res = 1;
            //            else
            //            {
            //                res = 0;
            //            }
            //        }
            //    }
            //}

            //if (res == 1)
            //    Console.WriteLine("#Black&White");
            //else { Console.WriteLine("#Color"); }

            #endregion

            Console.ReadLine();
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            //var n = Int64.Parse(Console.ReadLine());
            //var a = Array.ConvertAll(Console.ReadLine().Split(' '), Int64.Parse);
            var s = Console.ReadLine();
            var chs = 0;
            var qms = 0;
            var sns = 0;
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case '?':
                        qms++;
                        break;
                    case '*':
                        sns++;
                        break;
                    default:
                        chs++;
                        break;
                }
            }
            var k = Int32.Parse(Console.ReadLine());
            var possible = true;

            if (chs == k)
            {
                sns = 0;
                qms = 0;
            }
            else if (chs < k)
            {
                if (sns > 0)
                {
                    qms = 0;
                    sns = 1;
                }
                else
                {
                    possible = false;
                }
            }
            else //chs > k
            {
                if (chs - k <= sns + qms)
                {
                    qms = Math.Min(chs - k, qms);
                    sns = chs - k - qms;
                }
                else
                {
                    possible = false;
                }
            }

            var ans = new StringBuilder();

            if (possible)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '?' && qms > 0)
                    {
                        qms--;
                        ans.Remove(ans.Length - 1, 1);
                    }
                    else if (s[i] == '*' && sns > 0)
                    {
                        sns--;
                        if (chs < k)
                        {
                            for (int j = 0; j < k - chs; j++)
                            {
                                ans.Append(ans[ans.Length - 1]);
                            }
                        }
                        else
                        {
                            ans.Remove(ans.Length - 1, 1);
                        }
                    }
                    else if (s[i] != '?' && s[i] != '*')
                    {
                        ans.Append(s[i]);
                    }
                }
                for (int i = 0; i < ans.Length; i++)
                {
                    Console.Write(ans[i]);
                }
            }
            else
            {
                Console.WriteLine("Impossible");
            }

        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    static class _4032123
    {
        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

        class Node
        {
            public int D { get; set; }
            public int F { get; set; }
            public int T { get; set; }
            public long C { get; set; }
        }
        static void Main(String[] args)
        {
            var n = int.Parse(Console.ReadLine().TrimEnd());
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
            var bob = new long[n,2];
            bob[n - 1, 0] = data[n - 1];
            bob[n - 1, 1] = -data[n - 1];
            var prev = new int[n];
            prev[n - 1] = 1;
            for (var i = n - 2; i >= 0; i--)
            {
                if(bob[i + 1, 0] > bob[i + 1, 1])
                {
                    prev[i] = 0;
                } else
                {
                    prev[i] = 1;
                }
                bob[i, 0] = data[i] - Math.Max(bob[i + 1, 0],bob[i + 1, 1] );
                bob[i, 1] = Math.Max(bob[i + 1, 0], bob[i + 1, 1]) - data[i];
            }
            long bobSum = 0;
            var max = Math.Max(bob[0, 0], bob[0, 1]);
            writer.WriteLine((data.Sum()/2.0 - max/2.0) + " " + (data.Sum() / 2.0 + max / 2.0));
            writer.Flush();

        }
    }
}


using System;

namespace Task_41A
{
    class Program
    {
        /*
         * code
           edoc
         * */
        static void Main(string[] args)
        {
            //string s = Console.ReadLine();
            //string t = Console.ReadLine();
            //string rvc = ReverseString(s);

            //if (t == rvc)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int sLen = s.Length, tLen = t.Length;
            string ans = (sLen == tLen) ? "YES" : "NO";
            for (int i = 0, j = tLen - 1; i < sLen && j >= 0; i++, j--)
            {
                if (s[i] != t[j])
                {
                    ans = "NO";
                    break;

                }
            }
            Console.WriteLine(ans);

        }

        private static string ReverseString(string s)
        {
            string rvs = "";
            for (int i = s.Length - 1; i >= 0; i--)
            {
                rvs += s[i];
            }
            return rvs;

        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int numb_balls = Convert.ToInt32(Console.ReadLine());

            int[] input = new int[numb_balls];

            string ins = Console.ReadLine();
            string[] inputs = ins.Split(' ');
            int[] numbers = new int[numb_balls];
            for (int i = 0; i < numb_balls; i++) {
                numbers[i] = Convert.ToInt32(inputs[i]);
            }

            bool good_set = false;

            int[] unique = numbers.Distinct().ToArray();
            Array.Sort(unique);

            numb_balls = unique.Length;

            for (int i = 0; i < numb_balls - 2; i++)
            {
                int first_ball = unique[i];
                int second_ball = unique[i + 1];
                int third_ball = unique[i + 2];
                if (Math.Abs(first_ball - second_ball) == 1 && Math.Abs(second_ball - third_ball) == 1)
                {
                    good_set = true;
                }
            }
            if (good_set)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


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

namespace Pr1
{
    class Program
    {
        static void Main()
        {
            long n=  Convert.ToInt64(Console.ReadLine());
            long k=n,j=0;
            long sum=0;
            while(k!=0)
            {
                k/=10;
                j++;
            }
            for(long i=j-1;i>0;i--)
            {
                k=(long)Math.Pow(10,i)-1;
                sum+=(n-k)*(i+1);
                n=k;
            }
            sum+=n;
            Console.Write(sum);
        }
    }
}


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

namespace c
{
    class Program
    {
        static long gcd(long x,long y)
        {
            return (y==0)?x:gcd(y,x%y);
        }

        static void Main(string[] args)
        {
            string[] token = Console.ReadLine().Split();
            long a = long.Parse(token[0]);
            long b = long.Parse(token[1]);
            long x = long.Parse(token[2]);
            long y = long.Parse(token[3]);
            long g = gcd(x, y);
            x /= g; y /= g;
            long max = Math.Min(a / x, b / y);
            Console.WriteLine("{0} {1}", max * x, max * y);
        }
    }
}


/*
csc -debug D.cs && mono --debug D.exe <<< "

{ max = 100, ops1 = 382, ops2 = 2182 }
{ max = 100 }
Total counts: 3913
Different GCDs: 382
Max number of divisors: 11 (60 72 84 90 96)

{ max = 1000, ops1 = 6069, ops2 = 61945 }
{ max = 1000 }
Total counts: 391617
Different GCDs: 6069
Max number of divisors: 31 (840)

{ max = 10000, ops1 = 83668, ops2 = 1326800 }
{ max = 10000 }
Total counts: 39205029
Different GCDs: 83668
Max number of divisors: 63 (7560 9240)

{ max = 100000, ops1 = 1066750, ops2 = 24091272 }
{ max = 100000 }
Total counts: 3920698493
Different GCDs: 1066750
Max number of divisors: 127 (83160 98280)
*/

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

public class HelloWorld {
    const ulong MOD = 1000000007ul;

    public static void SolveCodeForces() {
        // ShowStats();
        Solve();
    }

    static void Solve() {
        var max = cin.NextInt();

        var Divs = Helpers.CreateArray(max + 1, _ => new List<int>());
        for (var g = 2; g <= max; g++)
            for (var a = g; a <= max; a += g)
                Divs[a].Add(g);

        var Map = Helpers.CreateArray(max + 1, _ => new Dictionary<int, int>());
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            var divs = Divs[g];

            counter[g] = max / g;
            for (var i = divs.Count - 2; i >= 0; i--) {
                var sum = 0;
                for (var j = i + 1; j < divs.Count; j++)
                    if (divs[j] % divs[i] == 0)
                        sum += counter[divs[j]];
                counter[divs[i]] = max / divs[i] - sum;
            }
        }

// for (var g = 2; g <= max; g++) {
//     System.Console.WriteLine(new {g});
//     foreach (var kvp in Map[g])
//         System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
// }

        var maxU = (ulong)max;
        var anssum = 0ul;
        var F = new ulong[max + 1];
        for (var g = 2; g <= max; g++) {
            var ag = 0;
            var sum = 0ul;
            foreach (var kvp in Map[g]) {
                var gcd = kvp.Key;
                var count = kvp.Value;
                if (gcd == g)
                    ag = count;
                else
                    sum = (sum + F[gcd] * (ulong)count) % MOD;
            }
            F[g] = (maxU + sum) * ModInverse(maxU + MOD - (ulong)ag, MOD) % MOD;
            anssum = (anssum + F[g]) % MOD;

// System.Console.WriteLine(new { g, fg=F[g] });
        }

        var ans = (1ul + anssum * ModInverse(maxU, MOD)) % MOD;
        System.Console.WriteLine(ans);
    }

    public static ulong ModInverse(ulong x, ulong mod) { return ModPow(x, mod - 2L, mod); }

    public static ulong ModPow(ulong x, ulong exp, ulong mod) {
        ulong ret = 1ul;
        while (exp > 0) {
            if (exp % 2 == 1) ret = ret * x % mod;
            x = x * x % mod;
            exp /= 2;
        }
        return ret;
    }

    static void ShowStats() {
        foreach (var max in new[] { 100, 1000, 10000, 100000 }) {
            // var MapBrute = GetGcdsCounter_Brute(max);
            var Map = GetGcdsCounter_InnerLoop(max);
            System.Console.WriteLine(new { max });
            // Compare(Map, MapBrute);
            System.Console.WriteLine("Total counts: " + Map.Sum(c => (long)c.Dict.Values.Sum()));
            System.Console.WriteLine("Different GCDs: " + Map.Sum(c => c.Dict.Count));
            var maxcnt = Map.Max(c => c.Dict.Count);
            System.Console.WriteLine("Max number of divisors: {0} ({1})", maxcnt, Map.Select((c, i) => new { c, i }).Where(a => a.c.Dict.Count == maxcnt).Select(a => a.i).Join());
            System.Console.WriteLine();
        }
    }

    static Counter<int>[] GetGcdsCounter_InnerLoop(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());

        var ops1 = 0;
        for (var g = 2; g <= max; g++) {
            for (var a = g; a <= max; a += g) {
                Map[a][g] = 0;
                ops1++;
            }
        }

        var ops2 = 0;
        for (var g = 2; g <= max; g++) {
            var counter = Map[g];
            counter[g] = max / g;

            var divs = counter.Dict.Keys.ToArray();
            Array.Sort(divs, 0, divs.Length);

            for (var i = divs.Length - 2; i >= 0; i--) {
                var cnt = max / divs[i];
                for (var j = i + 1; j < divs.Length; j++) {
                    if (divs[j] % divs[i] == 0)
                        cnt -= counter[divs[j]];
                }
                counter[divs[i]] = cnt;
            }

            ops2 += divs.Length * divs.Length;
        }

        if (max == 100) {
            for (var g = 1; g <= max; g++) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }

        System.Console.WriteLine(new {max, ops1, ops2});

        return Map;
    }

    static Counter<int>[] GetGcdsCounter_Brute(int max) {
        var Map = Helpers.CreateArray(max + 1, _ => new Counter<int>());
        for (var g = 1; g <= max; g++) {
            for (var x = 1; x <= max; x++) {
                var gcd = (int)GCD((ulong)g, (ulong)x);
                if (gcd > 1)
                    Map[g][gcd]++;
            }
            if (max == 100) {
                System.Console.WriteLine(new {g});
                foreach (var kvp in Map[g].Dict)
                    System.Console.WriteLine("   " + new { gcd=kvp.Key, cnt=kvp.Value });
            }
        }
        return Map;
    }

    private static ulong GCD(ulong a, ulong b) {
        while (a != 0 && b != 0) {
            if (a > b)
                a %= b;
            else
                b %= a;
        }
        return a == 0 ? b : a;
    }

    static void Compare(Counter<int>[] A, Counter<int>[] B) {
        for (var i = 0; i < A.Length; i++) {
            var C = A[i].Dict;
            var D = B[i].Dict;
            if (C.Count != D.Count) {
                System.Console.WriteLine(new { i, ccount = C.Count, dcount = D.Count });
                return;
            }
            if (!C.Keys.OrderBy(c => c).SequenceEqual(D.Keys.OrderBy(c => c))) {
                System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                return;
            }
            foreach (var key in C.Keys) {
                if (C[key] != D[key]) {
                    System.Console.WriteLine(new { i, ckeys=C.Keys.OrderBy(c => c).Join(), dkeys=D.Keys.OrderBy(c => c).Join() });
                    System.Console.WriteLine(new { key, cval=C[key], dval=D[key] });
                }
            }
        }
        System.Console.WriteLine("compare ok");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public class Counter<T> {
    public Dictionary<T, int> Dict;
    public Counter() { Dict = new Dictionary<T, int>(); }
    public Counter(IEnumerable<T> keys) { Dict = new Dictionary<T, int>(); foreach (var k in keys) Add(k, 1); }
    public int this[T key] {
        get { int res; return Dict.TryGetValue(key, out res) ? res : 0; }
        set { Dict[key] = value; }
    }
    public void Add(T key, int add) { int res; if (Dict.TryGetValue(key, out res)) Dict[key] = res + add; else Dict[key] = add; }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

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

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;

namespace Program
{

    public class Solver
    {
        public void Solve()
        {
            var t = sc.Double();
            var s = sc.Double();
            var q = sc.Double();
            var add = 1.0 + (q - 1) / q;
            var cnt = 0;
            while (s < t)
            {
                s *= q;
                cnt++;
            }
            IO.Printer.Out.WriteLine(cnt);

        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


using System;
using System.Collections.Generic;

namespace A_MikeAndPalindrome
{
	static class Program
	{
		public static string Reverse(this string str)
		{
			var charArray = str.ToCharArray();
			Array.Reverse(charArray);
			return new string(charArray);
		}

		/// <summary>
		/// Source string
		/// </summary>
		public static string s;

		/// <summary>
		/// Halfs of source string. Second part should be reversed
		/// </summary>
		public static List<string> halfs = new List<string>();

		/// <summary>
		/// Count of of diffs in halfs
		/// </summary>
		public static int diffs;

		/// <summary>
		/// Constraints:
		/// s - (1 ≤ |s| ≤ 15)
		/// </summary>
		/// <param name="args"></param>
		public static void Main(string[] args)
		{
			s = Console.ReadLine();
			var len = s.Length;

			if (s.Length % 2 == 1)
			{
				halfs.Add(s.Substring(0, (len - 1) / 2));
				halfs.Add(s.Substring((len - 1) / 2 + 1 > len ? (len - 1) / 2 : (len - 1) / 2 + 1, (len - 1)/2).Reverse());
			}
			else
			{
				halfs.Add(s.Substring(0, (len) / 2));
				halfs.Add(s.Substring(len / 2, len/2).Reverse());
			}

			for (var i = 0; i < halfs[0].Length; i++)
			{
				if (halfs[0][i] != halfs[1][i])
				{
					diffs++;
				}
			}

			Console.WriteLine(s.Length % 2 == 1 ? (diffs > 1 ? "NO" : "YES") : (diffs != 1 ? "NO" : "YES"));
		}
	}
}


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

namespace task
{
    class Program
    {
        private static string[] s;
        static void Main(string[] args)
        {
            s = new string[4];
            for (int i = 0; i < 4; ++i)
            {
                s[i] = Console.ReadLine();
            }
            bool ok = false;
            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 4; ++j)
                {
                    string t;
                    if (i + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j], s[i + 2][j]);
                        ok |= CheckString(t);
                    }
                    if (j + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i][j + 1], s[i][j + 2]);
                        ok |= CheckString(t);
                    }
                    if (i + 2 < 4 && j + 2 < 4)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j + 1], s[i + 2][j + 2]);
                        ok |= CheckString(t);
                    }
                    if (i + 2 < 4 && j - 2 >= 0)
                    {
                        t = string.Format("{0}{1}{2}", s[i][j], s[i + 1][j - 1], s[i + 2][j - 2]);
                        ok |= CheckString(t);
                    }
                }
            }
            if (ok)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        private static bool CheckString(string t)
        {
            int cX = 0;
            int cP = 0;
            for (int i = 0; i < t.Length; ++i)
            {
                if (t[i] == 'x')
                    cX++;
                else if (t[i] == '.')
                    cP++;
            }
            return cX == 2 && cP == 1;
        }
    }

}