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

class Program
{
    static int M;

    static void Main(string[] args)
    {
        long[] q1 = Console.ReadLine().Split(' ').Select(t => Int64.Parse(t)).ToArray();
        long N = q1[0];
        long K = q1[1];
        int L = (int)q1[2];
        M = (int)q1[3];

        int[, , ,] dp = new int[65, 2, 2, 2]; // gen, result, head, tail
        dp[0, 0, 0, 0] = 1;
        dp[0, 0, 1, 1] = 1;

        int[,] accum = null;

        for (int i = 1; i <= 64; ++i)
        {
            int[,] prevAccum = null;
            if (((1L << i - 1) & N) != 0)
            {
                if (accum == null)
                {
                    accum = new int[2, 2]; // result, tail
                    accum[0, 0] = (int)(((long)dp[i - 1, 0, 0, 0] + (long)dp[i - 1, 0, 1, 0]) % M);
                    accum[0, 1] = (int)(((long)dp[i - 1, 0, 0, 1] + (long)dp[i - 1, 0, 1, 1]) % M);
                    accum[1, 0] = (int)(((long)dp[i - 1, 1, 0, 0] + (long)dp[i - 1, 1, 1, 0]) % M);
                    accum[1, 1] = (int)(((long)dp[i - 1, 1, 0, 1] + (long)dp[i - 1, 1, 1, 1]) % M);
                }
                else
                {
                    prevAccum = accum;
                    accum = new int[2, 2];
                }
            }

            for (int leftRes = 0; leftRes <= 1; ++leftRes)
            {
                for (int leftTail = 0; leftTail <= 1; ++leftTail)
                {
                    for (int rightRes = 0; rightRes <= 1; ++rightRes)
                    {
                        for (int rightHead = 0; rightHead <= 1; ++rightHead)
                        {
                            for (int rightTail = 0; rightTail <= 1; ++rightTail)
                            {
                                int res = leftRes | rightRes | (leftTail & rightHead);
                                for (int leftHead = 0; leftHead <= 1; ++leftHead)
                                {
                                    long t = (long)dp[i, res, leftHead, rightTail] +
                                        (long)dp[i - 1, leftRes, leftHead, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];

                                    dp[i, res, leftHead, rightTail] = (int)(t % M);
                                }

                                if (prevAccum != null)
                                {
                                    long t = (long)accum[res, rightTail] +
                                        (long)prevAccum[leftRes, leftTail] * (long)dp[i - 1, rightRes, rightHead, rightTail];
                                    accum[res, rightTail] = (int)(t % M);
                                }
                            }
                        }
                    }
                }
            }
        }

        int total = 1 % M;
        for (int i = 0; i < L; ++i)
        {
            if (((1L << i) & K) != 0)
            {
                total = (int)(((long)total * ((long)accum[1, 0] + (long)accum[1, 1])) % M);
            }
            else
            {
                total = (int)(((long)total * ((long)accum[0, 0] + (long)accum[0, 1])) % M);
            }
        }

        for (int i = L; i < 64; ++i)
        {
            if (((1L << i) & K) != 0)
            {
                total = 0;
                break;
            }
        }

        Console.WriteLine(total);
    }
}


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

namespace Mike_and_Chocolate_Thieves
{
    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 m = long.Parse(reader.ReadLine());

            long l = 1, r = m*10;

            while (l<r)
            {
                long i = (l + r)/2;

                if (m<=Check(i))
                    r = i;
                else l = i + 1;
            }

            if (Check(r)==m)
                writer.WriteLine(r);
            else
            {
                writer.WriteLine("-1");
            }
            writer.Flush();
        }

        static long Check(long i)
        {
            long count = 0;
            for (long j = 2; ; j++)
            {
                long k = j*j*j;
                if (k<=i)
                {
                    count += i/k;
                }
                else break;
            }
            return count;
        }
    }
}


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

namespace Graph_and_String
{
    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)
        {
            int n = Next();
            int m = Next();

            var nn = new int[n][];
            for (int i = 0; i < n; i++)
            {
                nn[i] = new int[n];
            }
            for (int i = 0; i < m; i++)
            {
                int a = Next() - 1;
                int b = Next() - 1;
                nn[a][b] = 1;
                nn[b][a] = 1;
            }

            var color = new int[n];

            for (int i = 0; i < n; i++)
            {
                if (nn[i].Sum() == n - 1)
                    color[i] = 3;
            }

            bool ok = true;

            var st = new Stack<int>();

            int c = 1;
            for (int i = 0; ok && i < n; i++)
            {
                if (color[i] == 0)
                {
                    if (c == 3)
                    {
                        ok = false;
                        break;
                    }
                    color[i] = c;
                    st.Push(i);
                    while (ok && st.Count > 0)
                    {
                        int index = st.Pop();
                        for (int j = 0; j < n; j++)
                        {
                            if (j==index)
                                continue;
                            if (nn[index][j] == 1)
                            {
                                if (color[j] == 3 || color[j] == c)
                                    continue;
                                if (color[j] == 0)
                                {
                                    st.Push(j);
                                    color[j] = c;
                                    continue;
                                }
                                ok = false;
                                break;
                            }
                            if (color[index] == color[j])
                            {
                                ok = false;
                                break;
                            }
                        }
                    }
                    c++;
                }
            }

            if (ok)
            {
                writer.WriteLine("Yes");
                foreach (int i in color)
                {
                    if (i == 1)
                        writer.Write('a');
                    else if (i == 2)
                        writer.Write('c');
                    else
                        writer.Write('b');
                }
            }
            else
            {
                writer.WriteLine("No");
            }
            writer.Flush();
        }

        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.IO;
using System.Linq;

namespace Codeforces.R1355.C
{
    public static class Solver
    {
        public static void Main()
        {
            using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Solve(Console.In, sw);
            }
        }

        public static void Solve(TextReader tr, TextWriter tw)
        {
            WriteAnswer(tw, Parse(tr));
        }

        private static void WriteAnswer(TextWriter tw, long answer)
        {
            tw.WriteLine(answer);
        }

        private static long Parse(TextReader tr)
        {
            var t = tr.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            return Calc(t[0], t[1], t[2], t[3]);
        }

        public static long Calc(long a, long b, long c, long d)
        {
            var res = 0L;

            var arr = new long[Math.Max(b + c, d) + 2];

            for (var x = a; x <= b; ++x)
            {
                ++arr[x + b];
                --arr[x + c + 1];
            }

            var s = new long[arr.Length];

            for (var x = a + b; x <= b + c; ++x)
                s[x] = arr[x] + s[x - 1];

            var pre = new long[arr.Length];
            for (var x = a + b; x < pre.Length; ++x)
                pre[x] = pre[x - 1] + s[x];

            for (var z = c; z <= d; ++z)
            {
                res += pre[b + c] - pre[z];
            }

            return res;
        }

        public static long Calc0(long a, long b, long c, long d)
        {
            var res = 0L;

            for (var x = a; x <= b; ++x)
            {
                for (var y = b; y <= c; ++y)
                {
                    for (var z = c; z <= d; ++z)
                    {
                        if (x + y > z)
                            ++res;
                    }
                }
            }

            return res;
        }
    }
}


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

namespace CodeForces.Solutions.c319_189_1
{
	public class Program1
    {
        public static void Main()
        {
            checked
            {
	            var str = Console.ReadLine();
	            var n = str.Length;

	            var mult1 = 1L;
	            var mod = 1000000007;
	            var res = 0L;
				for (var i = 0; i < n ; i++)
				{
					if (str[i] == '1')
					{
						var mult2 = 1L;
						for (var j = i + 1; j < n; j++)
							mult2 = (mult2*4)%mod;

						res = (res + mult1 * mult2) % mod;
					}

					mult1 = (mult1*2)%mod;
				}

	            Console.Write(res);
            }
        }
    }
}


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

class TEST{
	static void Main(){
		Player[] P=new Player[4];
		for(int i=0;i<4;i++){
			var s=Console.ReadLine().Split(' ');
			P[i]=new Player(int.Parse(s[1]),int.Parse(s[0]));
		}

		int[][] Score=new int[2][];
		for(int i=0;i<2;i++)Score[i]=new int[2];

		int off1=0;
		int off2=0;
		int def1=0;
		int def2=0;

		for(int i=0;i<2;i++){
			if(i==0){off1=P[0].Off;def1=P[1].Def;}
			if(i==1){off1=P[1].Off;def1=P[0].Def;}

			for(int j=0;j<2;j++){
				if(j==0){off2=P[2].Off;def2=P[3].Def;}
				if(j==1){off2=P[3].Off;def2=P[2].Def;}

				if(off1>def2 && def1>off2){Score[i][j]=1;continue;}
				if(off1<def2 && def1<off2){Score[i][j]=2;continue;}
				Score[i][j]=3;
			}
		}
		bool chk1=false;
		for(int i=0;i<2;i++){
			if(Score[i][0]==1 &&Score[i][1]==1)chk1=true;
		}

		bool chk2=true;
		for(int i=0;i<2;i++){
			if(Score[i][0]!=2 &&Score[i][1]!=2)chk2=false;
		}

		Console.WriteLine(chk1?"Team 1":(chk2?"Team 2":"Draw"));

	}
}

struct Player{
	public int Off;
	public int Def;
	public Player(int o,int d){
		Off=o;Def=d;
	}
}


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

namespace ConsoleApp1
{
    class Point
    {
        public long X;
        public long Y;

        public Point(long x, long y)
        {
            X = x;
            Y = y;
        }
    }

    class Rectangle
    {
        public Point LeftDawn;
        public Point LeftUp;
        public Point RightUpper;
        public Point RightDanwn;

        public Rectangle(Point ld, Point ru)
        {
            LeftDawn = ld;
            LeftUp = new Point(ld.X, ru.Y);
            RightUpper = ru;
            RightDanwn = new Point(ru.X, ld.Y);
        }

        public long S()
        {
            return (RightUpper.X - LeftDawn.X) * (RightUpper.Y - LeftDawn.Y);
        }

        public Rectangle Intersec(Rectangle other)
        {
            var interX = Intersec(new long[] { LeftUp.X, RightUpper.X },
                new long[] { other.LeftDawn.X, other.RightDanwn.X });
            if (interX == null)
                return null;
            var interY = Intersec(new long[] { LeftDawn.Y, RightUpper.Y },
                new long[] { other.LeftDawn.Y, other.RightUpper.Y });
            if (interY == null)
                return null;

            return new Rectangle(new Point(interX[0], interY[0]), new Point(interX[1], interY[1]));
        }

        private long[] Intersec(long[] s1, long[] s2)
        {
            var left = s1;
            var right = s2;
            if (s2[0] < s1[0])
            {
                left = s2;
                right = s1;
            }

            if (left[1] < right[0])
                return null;
            if (right[0] <= left[1] && left[1] <= right[1])
                return new long[] { right[0], left[1] };
            return right;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var white = new Rectangle(new Point(data[0], data[1]), new Point(data[2], data[3]));

            data = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var black1 = new Rectangle(new Point(data[0], data[1]), new Point(data[2], data[3]));

            data = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var black2 = new Rectangle(new Point(data[0], data[1]), new Point(data[2], data[3]));

            var inter1 = white.Intersec(black1);
            var inter2 = white.Intersec(black2);
            var totalS = 0L;
            if (inter1 != null)
                totalS += inter1.S();
            if (inter2 != null)
                totalS += inter2.S();

            if(inter1 != null && inter2 != null)
            {
                var inter = inter1.Intersec(inter2);
                if (inter != null)
                    totalS -= inter.S();
            }

            var whiteS = white.S();
            if(whiteS > totalS)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Solution
{
    static void Main(string[] args)
    {
           var arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);
        long n = arr[0];
        long k = arr[1];
        arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), Convert.ToInt32);
        long s1 = arr[0];
        long s2 = arr[1];

        long d1 = s2 -s1 ;
        d1 = d1>0?d1:d1+k;
        long d2 = k - s2 - s1;
        d2 = d2>0?d2:d2+k;

        long d3 = s1-s2;
        d3 = d3>0?d3:d3+k;
        long d4 = s2+s1;
        d4 = d4>0?d4:d4+k;

        var minGcd = long.MaxValue;
        var maxGcd = long.MinValue;
        for(int i =0; i<n;i++)
        {
            minGcd = Math.Min(GCD.Euclidean(n*k, d1+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d2+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d3+i*k), minGcd );
            minGcd = Math.Min(GCD.Euclidean(n*k, d4+i*k), minGcd );

            maxGcd = Math.Max(GCD.Euclidean(n*k, d1+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d2+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d3+i*k), maxGcd );
            maxGcd = Math.Max(GCD.Euclidean(n*k, d4+i*k), maxGcd );
        }
        Console.Write((n*k) / maxGcd);
        Console.Write(" ");
        Console.WriteLine((n*k) / minGcd);

    }

      public class GCD
    {
		public static long Euclidean(long n1, long n2)
		{
			if (n1 == n2) return n1;
			else if (n1 < n2)
			{
				var tmp = n1;
				n1 = n2;
				n2 = tmp;
			}

			while (n1 % n2 > 0)
			{
				var tmp = n2;
				n2 = n1 % n2;
				n1 = tmp;
			}
			return n2;
		}
	}

}


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

namespace ProgrammingContest.Codeforces.Round85 {
    class C {
        static int[] ReadInts() { return Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss)); }

        static int popcount(int n) { int res = 0; for (; n > 0; n &= n - 1)res++; return res; }

        static int n, m;
        static bool check(int v, int j) {
            int mask = (1 << m) - 1;
            return ((v | (v << 1) | (v >> 1) | j) & mask) == mask;
        }

        static void Main() {
            var xs = ReadInts();
            n = xs.Max();
            m = xs.Min();

            if (m == 1 && false) {
                Console.WriteLine(n == (n + 1) / 2);
                return;
            }

            var dp = new int[][,] { new int[1 << m, 1 << m], new int[1 << m, 1 << m] };

            for (int v = 0; v < 1 << m; v++)
                for (int j = 0; j < 1 << m; j++)
                    dp[0][v, j] = 1 << 29;

            dp[0][(1 << m) - 1, 0] = 0;

            int a = 0;
            for (int i = 0; i <= n; i++, a ^= 1) {
                var cur = dp[a];
                var next = dp[a ^ 1];

                for (int v = 0; v < 1 << m; v++)
                    for (int j = 0; j < 1 << m; j++)
                        next[v, j] = 1 << 29;

                for (int v = 0; v < 1 << m; v++) {
                    for (int j = 0; j < 1 << m; j++) {
                        for (int k = 0; k < 1 << m; k++) {
                            if (check(v, j | k)) {
                                next[v, k] = Math.Min(cur[j, v] + popcount(k), next[v, k]);
                            }
                        }
                    }
                }
            }

            int res = 1000000000;
            for (int v = 0; v < 1 << m; v++)
                for (int j = 0; j < 1 << m; j++)
                    res = Math.Min(res, dp[a][v, j]);
            Console.WriteLine(n * m - res);
        }
    }
}


using System;
using System.IO;
using Kattis.IO;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;

public class Program
{
    private static int n, a, b, k;
    private static long MOD = 1000000007;
    public static void Main(string[] args)
    {
        var cin = new Tokenizer(Console.OpenStandardInput());
        var cout = new BufferedStdoutWriter();

        n = int.Parse(cin.Next());
        a = int.Parse(cin.Next());
        b = int.Parse(cin.Next());
        k = int.Parse(cin.Next());

        long[] f = new long[n + 1];
        f[a] = 1;
        for (int t = 0; t < k; t++)
        {
            long[] g = new long[n + 1];
            long[] prefix = new long[n + 1];
            for (int i = 1; i <= n; i++)
            {
                if (i == b) continue;
                int l = 0, r = 0;
                if (i < b)
                {
                    r = b - 1;
                    l = 2 * i - r;
                }
                else
                {
                    l = b + 1;
                    r = 2 * i - l;
                }
                l = Math.Max(l, 1);
                r = Math.Min(r, n);

                // [l, i)
                if (l < i)
                {
                    prefix[i - 1] = (prefix[i - 1] + f[i]) % MOD;
                    prefix[l - 1] = (prefix[l - 1] + MOD - f[i]) % MOD;
                }

                // (i, r]
                if (i < r)
                {
                    prefix[r] = (prefix[r] + f[i]) % MOD;
                    prefix[i] = (prefix[i] + MOD - f[i]) % MOD;
                }
            }
            g[n] = prefix[n];
            for (int i = n - 1; i >= 1; i--) g[i] = (g[i + 1] + prefix[i]) % MOD;
            f = g;
        }

        long ans = 0;
        for (int i = 1; i <= n; i++) ans = (ans + f[i]) % MOD;

        cout.WriteLine(ans);
        cout.Close();
    }
}

namespace Kattis.IO
{
    public class NoMoreTokensException : Exception
    {
    }

    public class Tokenizer
    {
        string[] tokens = new string[0];
        private int pos;
        StreamReader reader;

        public Tokenizer(Stream inStream)
        {
            var bs = new BufferedStream(inStream);
            reader = new StreamReader(bs);
        }

        public Tokenizer()
            : this(Console.OpenStandardInput())
        {
            // Nothing more to do
        }

        private string PeekNext()
        {
            if (pos < 0)
                // pos < 0 indicates that there are no more tokens
                return null;
            if (pos < tokens.Length)
            {
                if (tokens[pos].Length == 0)
                {
                    ++pos;
                    return PeekNext();
                }
                return tokens[pos];
            }
            string line = reader.ReadLine();
            if (line == null)
            {
                // There is no more data to read
                pos = -1;
                return null;
            }
            // Split the line that was read on white space characters
            tokens = line.Split(null);
            pos = 0;
            return PeekNext();
        }

        public bool HasNext()
        {
            return (PeekNext() != null);
        }

        public string Next()
        {
            string next = PeekNext();
            if (next == null)
                throw new NoMoreTokensException();
            ++pos;
            return next;
        }
    }

    public class Scanner : Tokenizer
    {

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

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

        public float NextFloat()
        {
            return float.Parse(Next());
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }
    }

    public class BufferedStdoutWriter : StreamWriter
    {
        public BufferedStdoutWriter()
            : base(new BufferedStream(Console.OpenStandardOutput()))
        {
        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = v[0], a = v[1], x = v[2], b = v[3], y = v[4];
        int t=x>a?x-a:x+n-a;
        t=Math.Min(t,y>b?b+n-y:b-y);
        while(t-->-1)
        {
            if(a == b)
            {
                Console.WriteLine( "YES" );
                return;
            }
            else
            {
                a = a == n ? 1 : a+1;
                b = b == 1 ? n : b-1;
            }
        }
        Console.WriteLine( "NO" );

    }
}


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

class Codeforces
{
    static void Main()
    {
        var tmp = Console.ReadLine().Split(' ');
        int px = int.Parse(tmp[0]);
        int py = int.Parse(tmp[1]);

        tmp = Console.ReadLine().Split(' ');
        int fx = int.Parse(tmp[0]);
        int fy = int.Parse(tmp[1]);

        var a = dist(px, py, fx, fy + 1);
        a = Math.Max(a, dist(px, py, fx, fy - 1));
        a = Math.Max(a, dist(px, py, fx + 1, fy));
        a = Math.Max(a, dist(px, py, fx - 1, fy));
        a = Math.Max(a, dist(px, py, fx + 1, fy - 1));
        a = Math.Max(a, dist(px, py, fx + 1, fy + 1));
        a = Math.Max(a, dist(px, py, fx - 1, fy - 1));
        a = Math.Max(a, dist(px, py, fx - 1, fy + 1));
        if (px == fx || py == fy) a++;
        Console.WriteLine(2 * a);
    }

    private static int dist(int px, int py, int fx, int fy)
    {
        return Math.Abs(px - fx) + Math.Abs(py - fy);
    }
}


// Problem: 1185A - Ropewalkers
// Author: Gusztav Szmolik

using System;

class Ropewalkers
    {
    public static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        char[] delims = new char[] {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != 4)
            return -1;
        uint a;
        if (!ReadInputNumber (words[0], out a))
            return -1;
        uint b;
        if (!ReadInputNumber (words[1], out b))
            return -1;
        uint c;
        if (!ReadInputNumber (words[2], out c))
            return -1;
        uint d;
        if (!ReadInputNumber (words[3], out d))
            return -1;
        uint[] initPositions = new uint[] {a,b,c};
        Array.Sort (initPositions);
        uint ans = 0;
        uint dist1 = initPositions[1]-initPositions[0];
        uint dist2 = initPositions[2]-initPositions[1];
        if (dist1 < d)
            ans += d-dist1;
        if (dist2 < d)
            ans += d-dist2;
        Console.WriteLine (ans);
        return 0;
        }

    static bool ReadInputNumber (string s, out uint num)
        {
        if (!UInt32.TryParse (s, out num))
            return false;
        if (num < 1 || num > 1000000000)
            return false;
        return true;
        }
    }


using System;

namespace MafiaGame
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            int c = Int32.Parse(input[2]);
            int d = Int32.Parse(input[3]);
            int e = Int32.Parse(input[4]);
            int f = Int32.Parse(input[5]);

            if (d == 0)
            {
                Console.WriteLine("Hermione");
                return;
            }
            if (c == 0)
            {
                Console.WriteLine("Ron");
                return;
            }
            if (b == 0)
            {
                Console.WriteLine("Hermione");
                return;
            }
            if (a == 0)
            {
                Console.WriteLine("Ron");
                return;
            }
            if (f == 0)
            {
                Console.WriteLine("Hermione");
                return;
            }
            if (e == 0)
            {
                Console.WriteLine("Ron");
                return;
            }
            double zoloto = ((double)d * b) / c;
            double pesok = (double)f * zoloto / e;
            if (pesok > a)
                Console.WriteLine("Ron");
            else
                Console.WriteLine("Hermione");
        }
    }
}


using System;

namespace Rucksack
{
    class Program
    //{
    //    static Dictionary<ParamKey, int> cache = new Dictionary<ParamKey, int>();

    //    static Bun[] buns;

    //    static int n, m;
    //    static int[] a;

    //    static int c0, d0;

    //    static void Main(string[] args)
    //    {
    //        /*В первой строке содержатся 4 целых числа n, m, c0 и d0 (1 ≤ n ≤ 1000, 1 ≤ m ≤ 10, 1 ≤ c0, d0 ≤ 100).
    //        В каждой из последующих m строк содержится по 4 целых числа.
    //        В i-ой из них находятся числа ai, bi, ci и di (1 ≤ ai, bi, ci, di ≤ 100).*/

    //        string[] words = Console.ReadLine().Split(' ');

    //        n = int.Parse(words[0]);
    //        m = int.Parse(words[1]);
    //        c0 = int.Parse(words[2]);
    //        d0 = int.Parse(words[3]);

    //        float result = f(n, a);

    //        Console.WriteLine(result);

    //        Console.ReadLine();

    //    }

    //    static int f(int n, int[] a)
    //    {
    //        ParamKey paramKey = new ParamKey { n = n, a = a };

    //        if (cache.ContainsKey(paramKey))
    //            return cache[paramKey];

    //        int maxCost = 0;

    //        for (int i = 0; i < buns.Length; ++i)
    //        {
    //            if (n - buns[i].c >= 0 && a[i] - buns[i].b >= 0)
    //            {
    //                int[] tempA = new int[a.Length];

    //                a.CopyTo(tempA, 0);

    //                tempA[i] -= buns[i].b;

    //                int cost = f(n - buns[i].c, tempA) + buns[i].d;

    //                if (cost > maxCost) maxCost = cost;
    //            }
    //        }

    //        cache[paramKey] = maxCost;
    //        return maxCost;
    //    }
    //}

    //struct Bun
    //{
    //    /// <summary>
    //    /// Необходимое число начинки
    //    /// </summary>
    //    public int b;

    //    /// <summary>
    //    /// Необходимое число теста
    //    /// </summary>
    //    public int c;

    //    /// <summary>
    //    /// Стоимость
    //    /// </summary>
    //    public int d;
    //}

    //struct ParamKey
    //{
    //    public int n;
    //    public int[] a;

    //    public override bool Equals(object obj)
    //    {
    //        if (obj == null || GetType() != obj.GetType())
    //        {
    //            return false;
    //        }

    //        return GetHashCode() == ((ParamKey)obj).GetHashCode();
    //    }

    //    public override int GetHashCode()
    //    {
    //        int hash = n;

    //        foreach (int e in a)
    //            hash ^= e;

    //        return hash;
    //    }
    //}
    {
        static int n, m, d0, c0, i, j, k, maxCost;
        static int[] a, b, c, d;
        static int[,] dp;

        static void Main(string[] args)
        {
            string[] words = Console.ReadLine().Split(' ');

            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
            c0 = int.Parse(words[2]);
            d0 = int.Parse(words[3]);

            a = new int[m + 1];
            b = new int[m + 1];
            c = new int[m + 1];
            d = new int[m + 1];

            c[0] = c0; d[0] = d0;

            for (i = 1; i <= m; ++i)
            {
                words = Console.ReadLine().Split(' ');

                a[i] = int.Parse(words[0]);
                b[i] = int.Parse(words[1]);
                c[i] = int.Parse(words[2]);
                d[i] = int.Parse(words[3]);
            }

            dp = new int[n + 1, m + 1];

            for (i = 1; i <= n; ++i)
            {
                for (j = 1; j <= m; ++j)
                {
                    maxCost = 0;

                    for (k = 0; k <= a[j] / b[j]; ++k)
                    {
                        if (i - c[j] * k >= 0)
                        {
                            if (dp[i - c[j] * k, j - 1] + d[j] * k > maxCost)
                                maxCost = dp[i - c[j] * k, j - 1] + d[j] * k;
                        }
                    }

                    dp[i, j] = maxCost;
                }
            }

            maxCost = 0;
            for (k = 0; k <= n; ++k)
            {
                if (dp[k, m] + ((n - k) / c0) * d0 > maxCost)
                    maxCost = dp[k, m] + ((n - k) / c0) * d0;
            }

            Console.WriteLine(maxCost);
        }
    }
}


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

namespace CodeForces
{
    class Program
    {
        const int MOD = 1000000007;
        static long[] fac = new long[1000010];
        static long mod_pow(long num, long pow, long mod)
        {
            long  ret = 1;
            while (pow>0)
             {
                if (pow%2>0)
                {
                   ret = (ret*num)%mod;
                }
                pow>>=1;
                num = (num*num)%mod;
            }
            return ret;
        }
        static void precalc()
        {
            fac[0] = 1;
            for (int i = 1; i <= 1000000; i++)
            {
                fac[i] = i * fac[i - 1];
                fac[i] %= MOD;
            }
        }
        static long mod_inv(long num, long mod)
        {
             return mod_pow(num, mod-2, mod);
        }
        // (A/B) mod M = (A mod M) * mod_inv(B mod M, M)
        static long C(int n, int k)
        {
            long up = fac[n];
            long down = fac[k] * fac[n - k] % MOD;
            return up * mod_inv(down, MOD);
        }
        static long solve(int a, int b, int i, int n)
        {
            if ((i - a * n) % (b-a) > 0) return 0;
            int y = (i - a * n) / (b-a);
            if (y < 0) return 0;
            if (y > n) return 0;
            return C(n, y);
        }
        static void Main(string[] args)
        {
            precalc();
            int a, b, n;
            string[] s = Console.ReadLine().Split();
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            n = int.Parse(s[2]);
            long ans=0;
            for (int i = 1; i <= 9*n; i++)
            {
                bool good = true;
                int j = i;
                int numofc = 0;
                while (j > 0)
                {
                    numofc++;
                    int last = j % 10;
                    j /= 10;
                    if (last != a && last != b) {good = false; break;}
                }
                if (!good) continue;
                //Console.WriteLine(i.ToString());
                ans += solve(a, b, i,n);
                ans %= MOD;
            }
            Console.WriteLine(ans.ToString());
        }
    }
}


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

namespace Codeforces._272
{
    public class Solver
    {
        public static void Main()
        {
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            new Solver().Solve(Console.In, sw);
            sw.Flush();
        }

        public void Solve(TextReader tr, TextWriter tw)
        {
            var tokens = tr.ReadLine().Split();
            var n = int.Parse(tokens[0]);
            var m = int.Parse(tokens[1]);

            var ab = new int[m, 2];
            for (int i = 0; i < m; ++i)
            {
                var p = tr.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
                ab[i, 0] = p[0];
                ab[i, 1] = p[1];
            }

            var res = Solve(n, ab);
            tw.WriteLine(res);
        }

        public string Solve(int n, int[,] ab)
        {
            var edges = Utils.CreateListArray<int>(n);
            for (var i = 0; i < ab.GetLength(0); ++i)
            {
                edges[ab[i, 0]].Add(ab[i, 1]);
                edges[ab[i, 1]].Add(ab[i, 0]);
            }

            var res = new bool[n];

            for (var updated = true; updated;)
            {
                updated = false;
                for (int i = 0; i < n; ++i)
                {
                    if (edges[i].Count(e => res[i] == res[e]) >= 2)
                    {
                        res[i] = !res[i];
                        updated = true;
                    }
                }
            }

            return new string(res.Select(x => x ? '1' : '0').ToArray());
        }
    }

    public static class Utils
    {
        public static List<T>[] CreateListArray<T>(int n)
        {
            var res = new List<T>[n];
            for (int i = 0; i < n; ++i)
            {
                res[i] = new List<T>();
            }
            return res;
        }
    }
}


using System;

namespace CSharp
{
    class _900B
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            int a = int.Parse(tokens[0]);
            int b = int.Parse(tokens[1]);
            int c = int.Parse(tokens[2]);

            for (int i = 1; i <= b; i++)
            {
                a %= b;
                a *= 10;

                if (a / b == c)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}


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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var n = ReadLong();
            if (n == 0)
                return 0;
            if (n == 1)
                return 1;
            var l = ReadLong() - 1;
            var r = ReadLong() - 1;
            long cur = n;
            var info = new List<Pair>();
            while(cur != 1)
            {
                var p = new Pair { Val = cur / 2, Rem = cur % 2 };
                info.Add(p);
                cur = cur / 2;
            }
            long count1 = 1L;
            long len = 1L;
            for (int i = info.Count - 1; i >= 0; i--)
            {
                len = len * 2 + 1;
                info[i].Len = len;
                count1 = count1 * 2 + info[i].Rem;
                info[i].Count1 = count1;
            }
            return Recursive(info, l, r, 0, 0);
        }

        long Recursive(List<Pair> info, long l, long r, int depth, long myLeft)
        {
            var currentPair = info[depth];
            var myRight = myLeft + currentPair.Len - 1;
            if (myLeft >= l && myRight <= r)
                return currentPair.Count1;
            if (myLeft > r || myRight < l)
                return 0;
            if (depth == info.Count - 1)
            {
                long result = 0;
                if (myLeft >= l && myLeft <= r)
                    result++;
                if (myRight >= l && myRight <= r)
                    result++;
                if (myLeft + 1 >= l && myLeft + 1<= r)
                    result += currentPair.Rem;
                return result;
            }
            var first = Recursive(info, l, r, depth + 1, myLeft);
            var sec = Recursive(info, l, r, depth + 1, myLeft + info[depth + 1].Len + 1);
            var mid = myLeft + currentPair.Len / 2;
            var res = first + (mid >= l && mid <= r ? currentPair.Rem : 0) + sec;
            return res;
        }

        class Pair
        {
            public long Val;
            public long Rem;
            public long Count1;
            public long Len;
        }

        Node FindDeepest(Node current, long target, Node bad)
        {
            Node result = null;
            for (int i = 0; i < current.Children.Count; i++)
            {
                if (current.Children[i] == bad)
                    continue;
                result = FindDeepest(current.Children[i], target, bad);
                if (result != null)
                {
                    break;
                }
            }
            if (current.parent != -1 && result == null && current.sum == target)
                return current;
            return result;
        }

        long CalcSum(Node current)
        {
            var sum = current.t;
            for (int i = 0; i < current.Children.Count; i++)
            {
                sum += CalcSum(current.Children[i]);
            }
            current.sum = sum;
            return sum;
        }

        class Node {
            public long parent;
            public long index;
            public long t;
            public long sum;
            public List<Node> Children;
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
}


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string []ast = s.Split(new char[]{' '});
            int a = int.Parse(ast[0]);
            int b = int.Parse(ast[1]);
            int c = int.Parse(ast[2]);
            int n = int.Parse(ast[3]);

            int otv = n - ((a - c) + (b - c) + c);
            if((otv > 0) && (n > c) && (a >= c) && (b >= c))
            Console.WriteLine(otv);
            else
            Console.WriteLine("-1");
        }
    }
}


using System; namespace _569C { class Program { const int MAX = 1180000; static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int p = Int32.Parse(input[0]); int q = Int32.Parse(input[1]); int n1 = 0; int n2 = 0; int n = 1; int count = 0; for (int i = 1; i < MAX; i++) { if (isPrime(i) == true) n1++; if (IsPalindrome(i.ToString()) == true)                         n2++; if (n1 > n2 * p / q && count==0) {  n = i - 1;  count++; } if (count == 1 && n1 <= n2 * p / q) {  count = 0; } } Console.WriteLine(n == MAX ? "Palindromic tree is better than splay tree" : n.ToString()); } static bool isPrime(int n) { if (n == 1) return false; if (n == 2) return true; if (n == 3) return true; if (n % 2 == 0) return false; if (n % 3 == 0) return false; int i = 5; int w = 2; while (i * i <= n) { if (n % i == 0)                     return false; i += w; w = 6 - w; } return true; } static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } } }


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
{
    class _4032
    {
        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 : IComparable
        {
            public long X { get; set; }
            public long Y { get; set; }
            public int CompareTo(object obj)
            {
                if (this.Y > ((Node)obj).Y)
                {
                    return 1;
                }
                if (this.Y == ((Node)obj).Y)
                {
                    return 0;
                }
                return -1;
            }
        }

        static bool isBig(long n, long s)
        {
            long sum = 0;
            var st = n.ToString();
            for (var i=0;i< st.Length; i++)
            {
                sum += long.Parse(st[i].ToString());
            }
            return n - sum >= s;
        }
        static void Main(String[] args)
        {
            var data = Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
            var n = data[0];
            var s = data[1];
            long l = 0;
            long r = n;
            while (l <= r)
            {
                long m = (l + r) / 2;
                if (!isBig(m,s)) l = m + 1; else r = m - 1;
            }

            Console.WriteLine(n - r);

        }

    }
}


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

namespace _630M_Turn
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());

            if (Math.Abs(x) > 360)
                x %= 360;
            if (x < 0)
                x += 360;
            if (x <= 45 || x >= 315 )
                Console.WriteLine("0");
            else if (x > 45 && x <= 135)
                Console.WriteLine("1");
            else if (x > 135 && x <= 225)
                Console.WriteLine("2");
            else
                Console.WriteLine("3");
        }
    }
}


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] str = Console.ReadLine().Split(new char[] { ' ' });

			int n = Convert.ToInt32(str[0]);
			int m = Convert.ToInt32(str[1]);

			long tmp = Binpow(2, m) - 1;
			tmp = Binpow(tmp, n);

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

		public static long Binpow(long a, int n)
		{
			if (n == 0)
				return 1;
			if (n % 2 == 1)
				return (Binpow(a, n - 1) * a) % 1000000007;
			else
			{
				long b = Binpow(a, n / 2);
				return (b * b) % 1000000007;
			}
		}
	}
}


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

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

    public void Solve()
    {
        int n = ReadInt();
        int d = ReadInt();
        var a = ReadIntArray();

        var dp = new bool[MAX + 1];
        dp[0] = true;
        for (int i = 0; i < n; i++)
        {
            for (int j = MAX; j >= 0; j--)
                if (dp[j])
                    dp[j + a[i]] = true;
        }

        int x = 0;
        int ans = 0;
        while (true)
        {
            int y = Math.Min(x + d, MAX);
            while (!dp[y])
                y--;
            if (x == y)
                break;
            ans++;
            x = y;
        }

        Write(x, ans);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

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

    #endregion

    #region Read / Write

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;
namespace Iran{
        class amir
        {
                public static void Main()
                {
                        int x,y,s;
                        string[] input=Console.ReadLine().Split(' ');
                        x=Int32.Parse(input[0]);
                        y=Int32.Parse(input[1]);
                        s=Int32.Parse(input[2]);
                        long yek,dow;
                        if(x%s==0)
                                yek=x;
                        else
                        {
                                yek=(x%s)*(x/s+1);
                        }
                        if(y%s==0)
                                dow=y;
                        else
                        {
                                dow=(y%s)*(y/s+1);
                        }
                        long ans=dow*yek;
                        Console.WriteLine(ans);

                }
        }
}


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

namespace Codeforces
{
   class B
   {
     static void Main(string[] args)
     {
        string[] token = Console.ReadLine().Split();

        int n = int.Parse(token[0]);
        int d = int.Parse(token[1]);

        int[] x = new int[n];
        string[] token2 = Console.ReadLine().Split();

        for(int i=0;i<n;i++){
          x[i] = int.Parse(token2[i]);
        }

        Array.Sort(x);

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

        for(int i=0;i<n;i++){
          for(int j=i+1;j<n;j++){
            if(Math.Abs(x[j]-x[i])<=d)
             list.Add(Math.Abs(i-j));
          }
        }
        list.Sort();

        if(list.Count==0)
        Console.WriteLine(n-1);
        else
        Console.WriteLine(n-(list[list.Count-1]+1));

     }

   }
}


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

class Modular
{
    private const int M = 998244353;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    public static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    public static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r) ? 0
        : (n == r) ? 1
        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

class MyClass
{
    public static void Solve()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Modular n = input[0];
        Modular m = input[1];
        var k = input[2];
        if (input[0] == 1)
        {
            Console.WriteLine((int)Modular.Pow(n, k));
            return;
        }
        var dp = new Modular[k + 1];
        var poly = new Modular[k + 1];
        for (int i = 0; i < k + 1; i++)
        {
            poly[i] = 0;
        }
        poly[1] = 1;
        for (int i = 1; i < k + 1; i++)
        {
            var num = Modular.Pow(1 / m, i);
            for (int j = 0; j < i; j++)
            {
                num *= n - j;
            }
            for (int j = 1; j < i; j++)
            {
                num -= poly[j] * dp[j];
            }
            dp[i] = num;
            if (i == k)
            {
                break;
            }
            poly[i + 1] = 1;
            for (int j = i; j >= 1; j--)
            {
                poly[j] = -i * poly[j] + poly[j - 1];
            }
        }
        Console.WriteLine((int)dp[k]);
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    private int[] dr = {1, 0, -1, 0};
    private int[] dc = {0, 1, 0, -1};

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadLines(n);

        int nt = 0, nb = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                if (char.IsDigit(a[i][j]))
                    nt = Math.Max(nt, a[i][j] - '0');
                else if (a[i][j] == 'B')
                    nb++;
        if (nt == 0)
        {
            Write(0);
            return;
        }
        var price = ReadAndTransposeIntMatrix(nt)[0];

        var pos = new int[nt + nb][];
        nb = 0;
        int sr = 0, sc = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                if (char.IsDigit(a[i][j]))
                    pos[a[i][j] - '1'] = new[] { i, j };
                else if (a[i][j] == 'B')
                    pos[nt + nb++] = new[] { i, j };
                else if (a[i][j] == 'S')
                {
                    sr = i;
                    sc = j;
                }

        var f = new bool[n,m,1 << nt + nb];
        f[sr, sc, 0] = true;
        var q = new Queue<Tuple<int, int, int>>();
        q.Enqueue(Tuple.Create(sr, sc, 0));
        int ans = 0;
        int step = 0;
        int badSubMask = ((1 << nb) - 1) << nt;
        while (q.Count > 0)
        {
            var nq = new Queue<Tuple<int, int, int>>();
            while (q.Count > 0)
            {
                int r = q.Peek().Item1;
                int c = q.Peek().Item2;
                int mask = q.Dequeue().Item3;

                if (r == sr && c == sc && (mask & badSubMask) == 0)
                {
                    int s = 0;
                    for (int i = 0; i < nt; i++)
                        if ((mask >> i & 1) == 1)
                            s += price[i];
                    ans = Math.Max(ans, s - step);
                }

                for (int i = 0; i < 4; i++)
                {
                    int nr = r + dr[i];
                    int nc = c + dc[i];
                    if (nr < 0 || nr == n || nc < 0 || nc == m || a[nr][nc] != '.' && a[nr][nc] != 'S')
                        continue;
                    int nmask = mask;
                    if (i == 0)
                    {
                        for (int j = 0; j < nt + nb; j++)
                            if (nr == pos[j][0] && nc < pos[j][1])
                                nmask ^= 1 << j;
                    }
                    else if (i == 2)
                    {
                        for (int j = 0; j < nt + nb; j++)
                            if (nr == pos[j][0] - 1 && nc < pos[j][1])
                                nmask ^= 1 << j;
                    }
                    if (!f[nr, nc, nmask])
                    {
                        f[nr, nc, nmask] = true;
                        nq.Enqueue(Tuple.Create(nr, nc, nmask));
                    }
                }
            }
            q = nq;
            step++;
        }

        Write(ans);
    }

    #region Main

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

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() {return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);}
    public static string ReadToken(){while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine());return currentLineTokens.Dequeue();}
    public static int ReadInt(){return int.Parse(ReadToken());}
    public static long ReadLong(){return long.Parse(ReadToken());}
    public static double ReadDouble(){return double.Parse(ReadToken(), CultureInfo.InvariantCulture);}
    public static int[] ReadIntArray(){return ReadAndSplitLine().Select(int.Parse).ToArray();}
    public static long[] ReadLongArray(){return ReadAndSplitLine().Select(long.Parse).ToArray();}
    public static double[] ReadDoubleArray(){return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();}
    public static int[][] ReadIntMatrix(int numberOfRows){int[][] matrix = new int[numberOfRows][];for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray();return matrix;}
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows){int[][] matrix = ReadIntMatrix(numberOfRows);int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++){ret[i] = new int[numberOfRows];for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i];}return ret;}
    public static string[] ReadLines(int quantity){string[] lines = new string[quantity];for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim();return lines;}
    public static void WriteArray<T>(IEnumerable<T> array){writer.WriteLine(string.Join(" ", array));}
    public static void Write(params object[] array){WriteArray(array);}
    public static void WriteLines<T>(IEnumerable<T> array){foreach (var a in array)writer.WriteLine(a);}
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>{public new TValue this[TKey key]{
        get { return ContainsKey(key) ? base[key] : default(TValue); }set { base[key] = value; }}}
    private static T[] Init<T>(int size) where T : new(){var ret = new T[size];for (int i = 0; i < size; i++)ret[i] = new T();return ret;}
    #endregion
}


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

namespace checkForSplit
{

    class Program
    {

        static void Main(string[] args)
        {
            char[] ch = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
                        'o','p','q','r','s','t','u','v','w','x','y','z'};
            int [] am = new int[26];
            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            string ans = "";
            for (int i = 0; i < str.Length/2; i++)
            {
                if (str[i] != '?' && str[str.Length - i - 1] != '?')
                {
                    if (str[i] != str[str.Length - i - 1])
                        { Console.WriteLine("IMPOSSIBLE"); return; }
                    else ans += str[i];
                }
                else
                    if (str[i] == '?' && str[str.Length - i - 1] == '?')
                    {
                        ans+='?';
                    }
                    else {
                        if (str[i] == '?')
                            ans += str[str.Length - i - 1];
                        else ans += str[i];
                    }

            }
            if (str.Length % 2 != 0)
            {
                ans += str[str.Length / 2];
            }
            List<char> lst = new List<char>();
            int quest=0;
            foreach (var i in ans)
            {
                if (i == '?') quest++;
                else if (!lst.Contains(i)) lst.Add(i);
            }
            if (lst.Count > n)
            {
                Console.WriteLine("IMPOSSIBLE"); return;
            }
            string aa = "";
            if (quest != 0)
            {
                int kol = n - lst.Count();
                int curQ = 0;
                foreach (var i in ans)
                {
                    if (i == '?')
                    {
                        if (quest <= kol)
                        {
                            bool b = false;
                            for (int ii = 0; ii < n; ii++)
                            {
                                if (!lst.Contains(ch[ii]))
                                {
                                    aa += ch[ii];
                                    lst.Add(ch[ii]);
                                    b = true;
                                    break;
                                }

                            }
                            if (!b) aa += 'a';
                        }
                        else aa += "a";
                        quest--;

                    }
                    else aa += i;

                }
            }
            else
                aa = ans;
            lst = new List<char>();
                foreach (var i in aa)
                {
                    bool b = false;
                    if (!lst.Contains(i)) lst.Add(i);
                    for (int ii = 0; ii < n; ii++)
                    {
                        if (i == ch[ii])
                        {
                            b = true;
                            break;
                        }
                    }
                    if(!b)
                    {
                        Console.WriteLine("IMPOSSIBLE"); return;
                    }
                }
                if (lst.Count != n)
                {
                    Console.WriteLine("IMPOSSIBLE"); return;
                }
                Console.Write(aa);
                if (str.Length % 2 != 0) { aa= aa.Substring(0, aa.Length - 1); }

                for (int i = aa.Length-1; i >= 0; i--)
                {
                    Console.Write(aa[i]);
                }
                Console.WriteLine();

        }
    }

}


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

namespace Cave_Painting
{
    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) ? "Yes" : "No");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            long n = Next();
            long k = Next();

            var h = new HashSet<long>();
            for (int i = 1; i <= k; i++)
            {
                if (!h.Add(n%i))
                    return false;
            }

            return true;
        }

        private static long Next()
        {
            int c;
            long 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.IO;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

class Program
{
    class T
    {
        public int X;
        public int Y;

        public T(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    //////////////////////////////////////////////////

    /// <summary>
    /// Получает следующую перестановку элементов. Элементы не обязаны быть уникальными.
    /// Должно гарантироваться, что на вход подается одна из перестановок.
    /// Возвращает true, если была получена следующая перестановка, иначе - false.
    /// </summary>
    bool NextPermutation(IList<long> a)
    {
        var n = a.Count;
        for (int ind = n - 2; ind >= 0; ind--)
            if (a[ind] < a[ind + 1])
                for (int i = ind + 2; ; i++)
                    if (i == n || a[ind] >= a[i])
                    {
                        swap(a, ind, i - 1);
                        var m = (n - 1 - ind) >> 1;
                        for (int j = 1; j <= m; j++)
                            swap(a, ind + j, n - j);
                        return true;
                    }
        return false;
    }

    int tutu(int[,] a, List<char> s, int from, int to)
    {
        if (a[from, to] == 0)
        {
            var res = int.MaxValue;

            if (s[from] == s[to])
            {
                res = tutu(a, s, from + 1, to);
            }
            else
            {
                for (int i = from; i < to; i++)
                {
                    var l = tutu(a, s, from, i);
                    var r = tutu(a, s, i + 1, to);
                    var z = l + r;
                    if (s[from] == s[i + 1] || s[i] == s[to])
                        z--;
                    res = Math.Min(res, z);
                }
            }
            a[from, to] = res;
        }
        return a[from, to];
    }

    //////////////////////////////////////////////////
    void Solution()
    {
        var n = ri;
        var s = rs;
        var a = new List<char>(n) { s[0] };
        for (int i = 1; i < n; i++)
            if (s[i - 1] != s[i])
                a.Add(s[i]);

        var b = new int[n, n];
        for (int i = 0; i < n; i++)
            b[i, i] = 1;
        wln(tutu(b, a, 0, a.Count - 1));

    }
    //////////////////////////////////////////////////

    struct P : IComparable<P>
    {
        public long X;
        public long Y;

        public P(long x, long y)
        {
            X = x;
            Y = y;
        }

        public int CompareTo(P other) => X != other.X ? X.CompareTo(other.X) : Y.CompareTo(other.Y);
        public static int Comparison(P p1, P p2) => p1.CompareTo(p2);

        public static bool operator ==(P p1, P p2) => (p1.X == p2.X) && (p1.Y == p2.Y);
        public static bool operator !=(P p1, P p2) => (p1.X != p2.X) || (p1.Y != p2.Y);

        public static P operator +(P p1, P p2) => new P(p1.X + p2.X, p1.Y + p2.Y);
        public static P operator -(P p1, P p2) => new P(p1.X - p2.X, p1.Y - p2.Y);
    }

    void swap<T>(ref T o1, ref T o2) { var o = o1; o1 = o2; o2 = o; }
    void swap<T>(IList<T> a, int from, int to) { var buf = a[from]; a[from] = a[to]; a[to] = buf; }
    long gcd(long a, long b) => (b != 0) ? gcd(b, a % b) : a;
    long lcm(long a, long b) => a / gcd(a, b) * b;

    long rast2(long x1, long y1, long x2, long y2) => (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    long rast2(P p1, P p2) => (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
    long ccw(P p1, P p2, P p3) => p1.X * p2.Y + p1.Y * p3.X + p2.X * p3.Y - p2.Y * p3.X - p3.Y * p1.X - p1.Y * p2.X;

    StringBuilder _sb = new StringBuilder();
    void wln() { _sb.AppendLine(); }
    void wln<T>(T o) { _sb.AppendLine(o.ToString()); }
    void wsp<T>(T o) { _sb.Append(o).Append(" "); }
    void wrt<T>(T o) { _sb.Append(o); }
    void wln(double o) { _sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }
    void wsp(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12} ", o)); }
    void wrt(double o) { _sb.Append(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o)); }

    List<P> rpa(int n)
    {
        var res = new List<P>(n);
        for (int i = 0; i < n; i++)
            res.Add(new P(rl, rl));
        return res;
    }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    // Читает строку без пробелов
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { var res = _str.Substring(_ind); _count = 0; _ind = 0; return res; }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    List<int> ria(int n)
    {
        var res = new List<int>(n);
        for (int i = 0; i < n; i++)
            res.Add(ri);
        return res;
    }
    List<long> rla(int n)
    {
        var res = new List<long>(n);
        for (int i = 0; i < n; i++)
            res.Add(rl);
        return res;
    }
    List<double> rda(int n)
    {
        var res = new List<double>(n);
        for (int i = 0; i < n; i++)
            res.Add(rd);
        return res;
    }
    // Читает строки без пробелов
    List<string> rsa(int n)
    {
        var res = new List<string>(n);
        for (int i = 0; i < n; i++)
            res.Add(rs);
        return res;
    }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main(string[] args) { new Program().Main(); }
    void Main()
    {
        //Console.SetIn(new StreamReader("input.txt")); Console.SetOut(new StreamWriter("output.txt"));
        Solution();
        Console.Write(_sb);
        //Console.In.Close(); Console.Out.Close();
    }
}


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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }

        object Solve()
        {
            checked
            {
                var n = ReadLong();
                var cr = ReadLongs().Select(x => x - 1).ToArray();
                var visited = new bool[n];
                var lens = new List<int>();
                for (long i = 0; i < n; i++)
                {
                    if (!visited[i])
                    {
                        var current = i;
                        var len = 0;
                        do
                        {
                            visited[current] = true;
                            current = cr[current];
                            len++;
                        } while (!visited[current]);
                        if (current != i)
                            return -1;
                        lens.Add(len);
                    }
                }
                for (int i = 0; i < lens.Count; i++)
                {
                    if (lens[i] % 2 == 0)
                        lens[i] /= 2;
                }
                long res = 1;
                for (int i = 0; i < lens.Count; i++)
                {
                    res = res * lens[i]/Nod(res, lens[i]);
                }
                return res;
            }
        }

        public long Nod(long a, long b)
        {
            if (b == 0)
                return a;
            return Nod(b, a % b);
        }

        List<Tuple<long, long>> GetVariants(int[][] groups, int current, long[] bs, long[] ws)
        {
            var result = new List<Tuple<long, long>>();
            long Wsum = 0;
            long Bsum = 0;
            for (int i = 0; i < groups[current].Length; i++)
            {
                var x = groups[current][i];
                result.Add(Tuple.Create(ws[x], bs[x]));
                Wsum += ws[x];
                Bsum += bs[x];
            }
            result.Add(Tuple.Create(Wsum, Bsum));
            return result;
        }

        long Pow(long b, long p)
        {
            if (p == 0)
                return 1;
            if (p == 1)
                return b;
            if (p % 2 == 0)
                return (Pow((b * b) % 10, p / 2)) % 10;
            return (b * Pow(b, p - 1)) % 10;
        }

        int GetLargestPrime(int n)
        {
            if (TestPrime(n))
                return n;

            var current = n % 2 == 0 ? n - 3 : n - 2;
            while (!TestPrime(current))
            {
                current -= 2;
            }
            return current;
        }

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

        class Node
        {
            public long Parent;
            public List<long> Children;
            public int Index;
        }
        //int BS(long[][] cuts, int left, int right)
        //{
        //    if (right - left == 1)
        //        return left;
        //    var half = (left + right) / 2;

        //}

        //void Check(long[][] cuts, long value)
        //{

        //}

        struct Segment
        {
            public Segment(long left, long rigth)
            {
                Left = left;
                Right = rigth;
            }

            public long Left;
            public long Right;
            public long Size() { return Right - Left; }
            public long Ships(long size) { return Size() / size; }
            public List<long> GetPositions(long shipSize) {
                var result = new List<long>();
                for (var i = Left + shipSize - 1; i < Right; i+=shipSize)
                {
                    result.Add(i);
                }
                return result;
            }
        }

        struct Second
        {
            public Second(long count, long mana)
            {
                Mana = mana;
                Count = count;
            }

            public long Mana;
            public long Count;
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
    class DSU
    {
        private int[] arr;
        private Random r = new Random();
        public DSU(int n)
        {
            arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i;
            }
        }

        public int Find(int x)
        {
            if (arr[arr[x]] == arr[x])
                return arr[x];
            var y = Find(arr[x]);
            arr[x] = y;
            return y;
        }

        public void Union(int x, int y)
        {
            var p1 = Find(x);
            var p2 = Find(y);
            if (p1 == p2)
                return;
            if (r.NextDouble() < 0.5)
                arr[p1] = p2;
            else
                arr[p2] = p1;
        }

        public int[][] Enumerate()
        {
            return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => e.Select(y => y.i).ToArray()).ToArray();
        }
    }
}


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

namespace INTERCALC
{
    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)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            writer.WriteLine(nn.Max() ^ nn[n - 1]);
            writer.Flush();
        }

        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.Linq;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    int N, K;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();

        /*
         * n行n列　タイル　白or黒
         * 隣接する行 すべて同じか違うかつ
         * k個以上の単色のタイルの長方形が存在しないならbeautiful
         *
         * beautifulなパターン数
         *
         */

        /*
         * 最大の連続がxの列
         *
         * O(n^3)で調べる
         *
         */

        // iまで見る、現在連続j 最大連続k

        // iは2で割ったあまり
        var dp = new ModInt[2, N + 1, N + 1];
        dp[1, 1, 1] = 1;

        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= i + 1; j++)
            {
                for (int k = 1; k <= i + 1; k++)
                {
                    dp[(i + 1) & 1, j, k] = 0;
                }
            }
            for (int j = 1; j <= i; j++)
            {
                for (int k = j; k <= i; k++)
                {
                    dp[(i + 1) & 1, j + 1, Math.Max(j + 1, k)] += dp[i & 1, j, k];
                    dp[(i + 1) & 1, 1, k] += dp[i & 1, j, k];
                }
            }
        }

        ModInt[] t = new ModInt[N + 1];
        for (int x = 1; x <= N; x++)
        {
            for (int j = 1; j <= x; j++)
            {
                t[x] += dp[N & 1, j, x];
            }
        }
        ModInt ans = 0;

        for (int x = 1; x * x < K && x <= N; x++)
        {
            // 横最大x個連続
            ModInt s = t[x];

            for (int y = x + 1; x * y < K && y <= N; y++)
            {
                // 縦最大y個連続
                // x < y
                ModInt u = t[y];
                // 縦横交換、色反転
                ans += s * u * 4;
            }

            // 縦横x
            // 色反転
            ans += s * s * 2;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int)1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;
        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }
        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }
        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Linq;

namespace ConsoleProject
{
    class Program
    {
        private static int[] ReadIntArray => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        private static long[] ReadLongArray => Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        private static char[] ReadCharArray => Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
        private static string[] ReadStringArray => Console.ReadLine().Split(' ').Select(str => str).ToArray();
        private static int ReadInt => int.Parse(Console.ReadLine());
        private static long ReadLong => long.Parse(Console.ReadLine());
        private static string ReadString => Console.ReadLine();
        struct Point
        {
            public string s;
            public int i;
            public Point(int i, string s)
            {
                this.i = i;
                this.s = s;
            }
        }
        static void Main()
        {
            long b = ReadLong;

            long a = 0;

            for (long i = 1; i <= Math.Sqrt(b); i++)
            {
                if (b % i == 0)
                {
                    a += 2;
                }
                if (i * i == b) a--;
            }

            Console.WriteLine(a);

            Console.ReadLine();
        }
        private static long S(long v)
        {
            long sum = 0;
            while (v != 0)
            {
                sum += v % 10;
                v /= 10;
            }
            return sum;
        }
        private static long F(long v)
        {
            long sum = 0;
            while (v >= 10)
            {
                v /= 10;
                sum *= 10;
                sum += 9;
            }
            return sum;
        }
    }
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader sr = Console.In;
            //StreamReader sr = new StreamReader("3.txt");
            int n = Convert.ToInt32(sr.ReadLine());
            string ss = sr.ReadLine();
            List<char> str = new List<char>();
            for (int ii = 0; ii < n; ii++)
            {
                str.Add(ss[ii]);
            }
            int i = 0;
            int res = 0;
            char b = 'z';
            while (true)
            {
                if (i == str.Count())
                {
                    i = 0;
                    b--;
                    if (b < 'a') break;
                    else continue;
                }
                if (str[i] == b)
                {
                    if ((i > 0) && (str[i - 1] == (b - 1)))
                    {
                        str.RemoveAt(i);
                        res++;
                    }
                    else if ((i < str.Count - 1) && (str[i + 1] == (b - 1)))
                    {
                        str.RemoveAt(i);
                        res++;
                        if (i > 0) i--;
                    }
                    else
                    {
                        i++;
                    }
                }
                else
                {
                    i++;
                }
            }
            Console.WriteLine(res.ToString());
        }
    }
}