import std.stdio;

immutable int MOD = 1_000_000_007;

void main ()
{
	int n, m;
	while (readf (" %s %s", &n, &m))
	{
		auto f = new long [] [n + 1];
		foreach (p; 0..n + 1)
		{
			f[p] = new long [m + 1];
		}
		foreach (p; 1..n + 1)
		{
			long cur;
			foreach (d; 2..m + 1)
			{
				cur += f[p - 1][d];
				f[p][d] = f[p][d - 1] + cur;
				if (d == 2)
				{
					f[p][d] += 1;
				}
				f[p][d] %= MOD;
			}
		}

		long res;
		foreach (d; 2..m + 1)
		{
			long cur;
			foreach (p; 1..n + 1)
			{
				cur += f[p][d] *
				       (f[n - p + 1][d] - f[n - p][d]);
				cur %= MOD;
			}
			cur *= m - d + 1;
			res += cur;
		}

		writeln (res % MOD);
	}
}


// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;

immutable long inf = 10L^^13;
long x, y;

void main() {
    scan(x, y);

    auto xf = factrize(x);

    debug {
        writeln("xf:", xf);
    }

    long ans;

    while (y > 0) {
        long g = gcd(x, y);

        if (g == x) {
            ans += y / g;
            break;
        }

        long m = inf;

        foreach (p ; xf) {
            long mp = (y - (y / (p * g)) * p * g) / g;
            if (0 < mp && mp < m) {
                m = mp;
            }
        }

        ans += m;
        y = y - m * g;
    }

    writeln(ans);
}

auto factrize(long x) {
    auto res = new long[](0);

    for (long p = 2; p*p <= x; p++) {
        if (x % p == 0) {
            res ~= p;
            while (x % p == 0) {
                x /= p;
            }
        }
    }

    if (x > 1) {
        res ~= x;
    }

    return res;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


import std.stdio,std.algorithm,std.range,std.conv;

auto lines(dstring[] f){
	dstring[] r;
	foreach(i;0..10){
		foreach(j;0..10){
			if(j+5<=10) r~=f[i][j..j+5];
			if(i+5<=10) r~=f[i..i+5].map!(x=>x[j]).to!dstring;
			if(i+5<=10&&j+5<=10)
				r~=iota(5).map!(x=>f[i+x][j+x]).to!dstring;
			if(i+5<=10&&j>=4)
				r~=iota(5).map!(x=>f[i+x][j-x]).to!dstring;
		}
	}
	return r;
}

void main(){
	auto field=stdin.byLineCopy.map!(to!dstring).array;
	writeln(field.lines.any!(r=>r.count('X')==4&&r.count('.')==1)?"YES":"NO");
}


import std.stdio, std.string, std.math;

int check(long num, long n, long m, long k)
{
    long cnt = 0, i;
    for (i = 1; i <= n && i <= num; ++ i)
    {
        cnt += fmin(num / i, m);
    }
    for (i = 1; i <= m && i <= num; ++ i)
    {
        cnt += fmin(num / i, n);
    }
    cnt >>= 1;
    /*
    if (cnt > k) return 1;
    if (cnt == k) return 0;
    return -1;
    */
    if (cnt >= k) return 1;
    return 0;
}

void solve(int n, int m, long k)
{
    long left = 1, right = cast(long)n * m;
    long ans = -1;
    while (left <= right)
    {
        auto mid = (left + right) >> 1;
        auto res = check(mid, n, m, k);
        /*
        if (res == 0)
        {
            writeln(mid);
            return;
        }
        else if (res < 0)
        {
            left = mid + 1;
        }
        else
        {
            ans = mid;
            right = mid - 1;
        }
        */
        if (res)
        {
            ans = mid;
            right = mid - 1;
        }
        else
        {
            left = mid + 1;
        }
    }
    writeln(ans);
}

void main(string[] args)
{
    int n, m;
    long k;
    while (scanf("%d%d%lld", &n, &m, &k) == 3)
    {
        solve(n, m, k);
    }
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 1_000_000_007;

void add (ref int a, int b)
{
	a += b;
	if (a >= mod)
	{
		a -= mod;
	}
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto s = readln.strip.map !(q{a == '('}).array;
		auto k = s.length.to !(int);
		auto p = new int [2] [k + 1];
		foreach (i; 0..k + 1)
		{
			foreach (bool v; 0..2)
			{
				auto t = s[0..i] ~ v;
				while (t.length > k || t != s[0..t.length])
				{
					t = t[1..$];
				}
				p[i][v] = t.length.to !(int);
			}
		}
		debug {writeln (p.map !(q{a[0]}));}
		debug {writeln (p.map !(q{a[1]}));}

		auto f = new int [2] [] [] [] (n * 2 + 1, n + 1, k + 1);
		f[0][0][0][0] = 1;
		foreach (i; 0..n * 2)
		{
			foreach (b; 0..n + 1)
			{
				foreach (x; 0..k + 1)
				{
					foreach (j; 0..2)
					{
						foreach (v; 0..2)
						{
							auto c = b + v * 2 - 1;
							if (c < 0 || c > n)
							{
								continue;
							}
							auto y = p[x][v];
							auto m = j | (y == k);
							add (f[i + 1][c][y][m],
							    f[i][b][x][j]);
						}
					}
				}
			}
		}
		writeln (sum (f[n * 2][0].map !(q{a[1]}), 0L) % mod);
	}
}


//ahmat
import core.stdc.stdio:scanf,printf,puts;
import core.bitop;
import std.stdio;
import std.string;
import std.algorithm;
import std.functional;
import std.array;
import std.container;
import std.conv;
import std.container;
import std.typecons;
import std.math;
import std.numeric;
pragma(inline,true);

bool isv(ref dchar c){
    return c=='a'||c=='o'||c=='y'||c=='e'||c=='u'||c=='i';
}
void main(){
    auto s=readln.strip
                 .map!(toLower)
                 .filter!((x)=>!isv(x));
    foreach(ref x;s)
        write(".",x);
    writeln;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto da = RD!int;
	auto db = RD!int;

	if (da+1 == db)
	{
		writeln(da, "9 ", db, "0");
	}
	else if (da == db)
	{
		writeln(da, "0 ", db, "1");
	}
	else if (da == 9 && db == 1)
	{
		writeln(da, " ", db, "0");
	}
	else
	{
		writeln(-1);
	}

	stdout.flush();
	debug readln();
}


module Solution;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto a = readln.stripRight.to!(dchar[]);
  sort (a);
  writeln(uniq (a).walkLength % 2 ? "IGNORE HIM!" : "CHAT WITH HER!");
}


import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	long n, k;
	scanf("%lld %lld", &n, &k);
	long half = n / 2;
	half += (n - half * 2);
	long num = (k <= half ? 1 + (k-1)*2 : 2 + (k-half-1)*2);
	printf("%lld", num);
	return 0;
}


import std.stdio;

void main() {
    int n;
    readf("%d\n", &n);

    int result = 0;
    for (int i = 1; n > 0; i <<= 1) {
        int l = n % 10;

        if (l == 4) {
            result += i;
        } else {
            result += i << 1;
        }

        n /= 10;
    }

    writeln(result);
}


import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.math;

int main(string[] argv)
{
	long k, l, m, n, d;
	scanf("%d %d %d %d %d", &k, &l, &m, &n, &d);
	d++;
	long count = 0;
	foreach (long i; 1..d)
	{
		if (i % k == 0
		 || i % l == 0
	     || i % m == 0
		 || i % n == 0)
		{
			count++;
		}
	}
	printf("%d", count);
	return 0;
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

struct ModInt(int M_) {
  import std.conv : to;
  alias M = M_;
  int x;
  this(ModInt a) { x = a.x; }
  this(long a) { x = cast(int)(a % M); if (x < 0) x += M; }
  ref ModInt opAssign(long a) { return (this = ModInt(a)); }
  ref ModInt opOpAssign(string op)(ModInt a) {
    static if (op == "+") { x += a.x; if (x >= M) x -= M; }
    else static if (op == "-") { x -= a.x; if (x < 0) x += M; }
    else static if (op == "*") { x = cast(int)((cast(long)(x) * a.x) % M); }
    else static if (op == "/") { this *= a.inv(); }
    else static assert(false);
    return this;
  }
  ref ModInt opOpAssign(string op)(long a) {
    static if (op == "^^") {
      if (a < 0) return (this = inv()^^(-a));
      ModInt t2 = this, te = ModInt(1);
      for (long e = a; e > 0; e >>= 1) {
        if (e & 1) te *= t2;
        t2 *= t2;
      }
      x = cast(int)(te.x);
      return this;
    } else return mixin("this " ~ op ~ "= ModInt(a)");
  }
  ModInt inv() const {
    int a = x, b = M, y = 1, z = 0, t;
    for (; ; ) {
      t = a / b; a -= t * b;
      if (a == 0) {
        assert(b == 1 || b == -1);
        return ModInt(b * z);
      }
      y -= t * z;
      t = b / a; b -= t * a;
      if (b == 0) {
        assert(a == 1 || a == -1);
        return ModInt(a * y);
      }
      z -= t * y;
    }
  }
  ModInt opUnary(string op: "-")() const { return ModInt(-x); }
  ModInt opBinary(string op, T)(T a) const {
    return mixin("ModInt(this) " ~ op ~ "= a");
  }
  ModInt opBinaryRight(string op)(long a) const {
    return mixin("ModInt(a) " ~ op ~ "= this");
  }
  bool opCast(T: bool)() const { return (x != 0); }
  string toString() const { return x.to!string; }
}

enum MO = 10^^9 + 7;
alias Mint = ModInt!MO;

void main() {
  try {
    for (; ; ) {
      const K = readInt();
      const PA = readInt();
      const PB = readInt();

      const A = Mint(PA) / (PA + PB);
      const B = Mint(PB) / (PA + PB);
      const BInv = B.inv;

      // a, ab
      auto dp = new Mint[][](K + 1, K);
      foreach_reverse (i; 0 .. K + 1) foreach_reverse (j; 0 .. K) {
        if (i + j >= K) {
          // a...ab: (i + l, j + (i + l))
          dp[i][j] = j + i + BInv - 1;
        } else {
          // a: (i + 1, j)
          // b: (i, j + i)
          if (i == 0) {
            // dp[0][j] = A * dp[1][j] + B * dp[0][j];
            dp[0][j] = dp[1][j];
          } else {
            if (j + i >= K) {
              dp[i][j] = A * dp[i + 1][j] + B * (j + i);
            } else {
              dp[i][j] = A * dp[i + 1][j] + B * dp[i][j + i];
            }
          }
        }
      }
      writeln(dp[0][0]);
    }
  } catch (EOFException e) {
  }
}


module main;

import std.stdio, std.string, std.algorithm, std.conv;

static bool greater(T)(T a, T b)
{
    return a > b;
}

void solve(char[] s)
{
    //writeln(s);
    int[] d;
    foreach (i, val; s)
    {
        d ~= val - '0';
    }
    //auto d = to!(int[])(s);
    //sort!(greater)(s);
    sort!(greater)(d);
    /*foreach (i, val; d)
    {
        writeln(val);
    }*/
    int[10] cnt;
    auto t = [[-1], [-1], [2], [3], [2, 2, 3], [5], [3, 5], [7], [2, 2, 2, 7], [2, 3, 3, 7]];
    foreach (i, val; d)
    {
        if (val <= 1) break;
        foreach (j; 0 .. t[val].length)
        {
            ++ cnt[t[val][j]];
        }
    }
    for (int i = 7; i > 1; -- i)
    {
        foreach (j; 0 .. cnt[i])
        {
            writef("%d", i);
        }
    }
    writef("\n");
}

int main(string[] args)
{
    int n;
    char[] buf;
    while (scanf("%d", &n) == 1)
    {
        stdin.readln(buf);
        stdin.readln(buf);
        solve(chomp(buf));
    }
    return 0;
}


import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
    uint n, m; ulong k;
    readf ("%s %s %s", &n, &m, &k);

    if (k < n) {
        writeln(1 + k, ' ', 1);
        return;
    } else if (k == n) {
        writeln(n, ' ', 2);
        return;
    }

    k -= n;
    debug { writeln(k); }
    --m;
    auto rows = k / m;
    auto cols = k % m;
    auto row = n - rows;
    auto col = 1 + (rows % 2 == 0 ? 1 + cols : m - cols);
    writeln(row, ' ', col);
}


import std.stdio, std.conv, std.algorithm, std.array;

void main() {
    long n, k;
    readf("%d %d\n", n, k);
    auto arr = map!(el => to!long(el))(readln.split);
    long maxDiv = 0;
    foreach (a; arr) {
        if (k % a == 0 && a > maxDiv)
            maxDiv = a;
    }
    writeln(k / maxDiv);
}


import std.stdio;
int main()
{
	int a=0;
	int b=0;
	readf(" %d", &a);
	readf(" %d", &b);
	int[] n = new int[a];
	int[] m = new int[b];
	for (int i=0; i<a; i++)
	{
		readf(" %d", &n[i]);
	}
	for (int i=0; i<b; i++)
	{
		readf(" %d", &m[i]);
	}
	for (int i=0; i<a; i++)
	{
		for (int j=0; j<b; j++)
		{
			if (n[i]==m[j])
			{
				writeln(n[i]);
			}
		}
	}
	return 0;
}


import std.stdio, std.conv, std.string, std.algorithm, std.range;

void main() {
    int n = readln.chomp.to!int;
    int[] ans;
    for (int i = 0; n > 0; i++) {
        if ((n & 1) == 1) {
            ans ~= (i + 1);
        }

        n = n >> 1;
    }

    ans.map!(to!string).array.reverse.join(" ").writeln;
}


import std.stdio;
import std.string;
import std.algorithm;

string readline()
{
	string result = readln();
	if (result[result.length - 1] == '\n') result.length--;
	return result;
}

int main(string[] argv)
{
	string word = readline();
	string drow = readline();
	if (word.dup.reverse == drow)
	{
		write("YES");
	} else {
		write("NO");
	}
	return 0;
}


import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
import std.numeric;

auto pmod(T)(T a, T m)
{
  return (a%m + m)%m;
}

struct Interval
{
  long l, h;
}
Interval intersect(Interval a, Interval b)
{
  return Interval(max(a.l, b.l), min(a.h, b.h));
}
bool empty(Interval i)
{
  with(i)
    return l > h;
}
long len(Interval i)
{
  return i.h - i.l + 1;
}

void main(string[] args)
{
  inputFile = stdin;
  debug inputFile = File(args[1]);
  auto la = next!long;
  auto ra = next!long;
  auto ta = next!long;
  auto lb = next!long;
  auto rb = next!long;
  auto tb = next!long;
  auto g = gcd(ta, tb);
  long best = 0;
  foreach(s; [lb + pmod(la - lb, g), lb - pmod(lb - la, g)])
    best = max(best, Interval(s, s + ra - la).intersect(Interval(lb, rb)).len);
  foreach(e; [rb + pmod(ra - rb, g), rb - pmod(rb - ra, g)])
    best = max(best, Interval(e - (ra - la), e).intersect(Interval(lb, rb)).len);
  best.writeln;
}

// INPUT

enum InputStyle
  {
    byChunk, byLine
  };
enum inputStyle = InputStyle.byLine;

File inputFile;
string popWord();
static if (inputStyle == InputStyle.byChunk)
  {
    const chunkSize = 1024 * 1024 * 8;
    const wordSize = 4096;
    char[chunkSize] chunkBuff;
    char[] currChunk;
    void renewChunk()
    {
      if (inputFile.eof)
        currChunk = null;
      else
        currChunk = inputFile.rawRead(chunkBuff);
    }
    char[wordSize] wordBuff;
    char[] word;
    string popWord()
    {
      if (currChunk.length == 0)
        renewChunk;
      assert(currChunk.length > 0);
      while (currChunk[0].isWhite)
        {

          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            renewChunk;
        }
      word = wordBuff[0 .. 0];
      while (!currChunk[0].isWhite)
        {
          word.length++;
          word[$ - 1] = currChunk[0];
          currChunk = currChunk[1 .. $];
          if (currChunk.length == 0)
            {
              renewChunk;
              if (currChunk.length == 0)
                return cast(string) word;
            }
        }
      return cast(string) word;
    }
  }
 else
   {
     DList!string _words;
     string popWord()
     {
       while (_words.empty)
         {
           foreach(w; inputFile.readln.split)
             {
               _words.insertBack(w);
             }
         }
       auto word = _words.front;
       _words.removeFront;
       return word;
     }
   }
T next(T)()
{
  return to!T(popWord);
}
auto next(T, S...)(S s)
{
  static if (S.length == 0)
    {
      return to!T(popWord);
    }
  else
    {
      auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);
      foreach(ref elem; res)
        elem = next!T(s[1 .. $]);
      return res;
    }
}


import std.stdio : readf, writeln;
import std.exception : enforce, ConvException;

bool solve() {
	enum n = 6;
	int[n] a;
	foreach (i; 0..n)
		if (!readf(" %s", &a[i]))
			return false;
	foreach (i; 0..n)
		inner: foreach (j; 0..i) {
			int[] other;
			foreach (t; 0..n)
				if (t != i && t != j)
					other ~= a[t];
			foreach (t; 1..other.length) {
				if (other[t] != other[0])
					continue inner;
			}
			if (a[i] == a[j]) {
				writeln("Elephant");
				return true;
			} else {
				writeln("Bear");
				return true;
			}
		}
	writeln("Alien");
	return true;
}

void main() {
	while (solve()) {}
}


import std.stdio;

int main()
{
	int a=0;
	readf(" %x",&a);
	for (int i=0; i<a; i++)
	{
		int b=0;
		readf(" %x", &b);
		if (b==1)
		{
			writeln("HARD");
			return 0;
		}
	}
	writeln("EASY");
	return 0;
}


import std.algorithm,std.ascii,std.stdio;void main(){auto s=readln;writeln(s.length>5&&s.any!isLower&s.any!isUpper&s.any!isDigit?"Correct":"Too weak");}


module _template;
import std.stdio;
import std.algorithm;
import std.container;
import std.range;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string read_string() {
                while (tokens.empty) {
                tokens = readln.split;
        }
        auto token = tokens.front;
                tokens.popFront;
                return token;
        }

        int read_int() {
                return read_string.to!int;
        }

        string[] tokens;
}

void main() {
        IO cin;
        int t = 1;
        // int t = cin.read_int;
        while (t--) {
                int n = cin.read_int;
                int[][] mat = new int[][n];
                int sum = 0;
                for (int i = 0; i < n; i++) {
                        mat[i] = new int[n];
                        for (int j = 0; j < n; j++) {
                                mat[i][j] = cin.read_int;
                                if (i == j || i + j == n - 1 || i == n / 2 || j == n / 2) {
                                        sum += mat[i][j];
                                }
                        }
                }
                writeln(sum);
        }
}


import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T read(T)(){ return read.to!T; }
T[] read(T)(long n){ return n.iota.map!(_ => read!T).array; }
T[][] read(T)(long m, long n){ return m.iota.map!(_ => read!T(n)).array; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	int m = read.to!int;
	int r = read.to!int;

	int a = 9999;
	foreach(i; 0 .. n) a = min(a, read.to!int);

	int b = -1;
	foreach(j; 0 .. m) b = max(b, read.to!int);

	int x;
	if(a > b) x = 0;
	else x = r / a;

	int ans = (r - x * a) + (x * b);
	ans.writeln;

}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

enum A = 5 - 1, B = 10 - 1, C = 50 - 1;

void main() {
  try {
    for (; ; ) {
      const N = readLong();

      alias Entry = Tuple!(long, "key", int, "val");
      auto ess = new Entry[][C];
      foreach (x; 0 .. C) foreach (y; 0 .. C) {
        if (x + y <= N) {
          const r = cast(int)((A * x + B * y) % C);
          const mn = A * x + B * y;
          const mx = A * x + B * y + C * (N - x - y);
          ess[r] ~= Entry((mn - r) / C, +1);
          ess[r] ~= Entry((mx - r) / C + 1, -1);
        }
      }
      long ans;
      foreach (r; 0 .. C) {
        ess[r].sort;
        int now;
        foreach (j; 0 .. cast(int)(ess[r].length) - 1) {
          now += ess[r][j].val;
          if (now > 0) {
            ans += ess[r][j + 1].key - ess[r][j].key;
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


import std.stdio: writeln, stdin;
import std.regex: split, regex;
import std.string: strip;
import std.conv: to;
import std.algorithm.iteration: map;

void main()
{
  auto nm = stdin.readln.strip.split(regex(` +`)).map!(to!int);
  auto n = nm[0], m = nm[1];
  int d=1;
  while(n>0) {
    if (d%m==0) n++;
    n--;
    d++;
  }
  writeln(d-1);
}


// Cheese-Cracker: cheese-cracker.github.io
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.bigint, std.numeric, std.math, std.random;

alias ll = long;
alias rbt = redBlackTree;
alias tup = Tuple!(long, long);
static long PRIME = 10^^9 + 7;
static string[] inp;
T rd(T = long)(){ while(!inp.length) inp = readln.chomp.split; string res = inp[0]; inp.popFront; return res.to!T; }
T[] rdarr(T = long)(T fix = 0){ auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
/*******************************It's a Me, Mario!*******************************************/

void play(){
    int n, m, k;
    n = rd!int; m = rd!int; k = rd!int;
    ll res = 1;
    int tim = 0;
    if(k == 1 || k > n){
        tim = n;
    }else if (k == n){
        tim = (k + 1)/2;
    }else if(k % 2){
        tim = 2;
    }else{
        tim = 1;
    }
    foreach(i; 0..tim){
        res *= m;
        res %= PRIME;
    }
    writeln(res);
}

int main(){
    long t = 1;
    /* t = rd;        // Toggle! */
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto n = RD!int;
	auto k = RD!int;
	auto x = cast(int)sqrt(cast(double)k);
	long ans;
	foreach (i; x..n+2)
	{
		auto j = cast(long)i;
		auto j2 = cast(long)(i-1);
		auto y = j * j2 / 2;
		if (j * j2 < k) continue;
		if (y - k == n - j2)
		{
			debug writeln(i);
			ans = n - j2;
			break;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


import std.stdio: writeln, stdin;
import std.string: strip;
import std.algorithm.iteration : map, sum;
import std.algorithm.searching: until;
import std.regex;
import std.range;
import std.array;
import std.conv;
import std.typecons;

void main()
{
  auto h = stdin.readln.strip.split(regex(` +`)).map!(to!int);
  auto a=h[0], b=h[1];
  auto c=tuple(a,0);
  writeln(a + generate!(()=>c=tuple((c[0]+c[1])/b, (c[0]+c[1])%b)).map!"a[0]".until!"a==0".sum);
}


//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.random;
import std.datetime.systime : Clock;

class InputReader {
  private:
  ubyte[] p;
  ubyte[] buffer;
  size_t cur;
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
    p = stdin.rawRead (buffer);
  }
  final ubyte skipByte (ubyte lo) {
    while (true) {
      auto a = p[cur .. $];
      auto r = a.find! (c => c >= lo);
      if (!r.empty) {
        cur += a.length - r.length;
        return p[cur++];
      }
      p = stdin.rawRead (buffer);
      cur = 0;
      if (p.empty) return 0;
    }
  }
  final ubyte nextByte () {
    if (cur < p.length) {
       return p[cur++];
    }
    p = stdin.rawRead (buffer);
    if (p.empty) return 0;
    cur = 1;
    return p[0];
  }

  template next(T) if (isSigned!T) {
    final T next ()  {
      T res;
      ubyte b = skipByte (45);
      if (b == 45) {
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    final T next () {
      T res = skipByte (48) - 48;
      while (true) {
        ubyte b = nextByte ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  final T[] nextA(T) (int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto r = new InputReader;
  immutable n = r.next!int;
  auto a = r.nextA!int (n);
  int res;
  foreach (i; 1 .. n) {
    auto x = a[i - 1], y = a[i];
    if (x == 2 && y == 3 || x == 3 && y == 2) {
      writeln ("Infinite");
      return;
    }
    if (x == 1 && y == 2) {
      res += 3;
      if (i >= 2 && a[i - 2] == 3) --res;
    } else if (x == 1 && y == 3) {
      res += 4;
    } else if (x == 2 && y == 1) {
      res += 3;
    } else if (x == 3 && y == 1) {
      res += 4;
    }
    /*
    else if (x == 3 && y == 2) {
      res += 4;
    }
    */
    debug stderr.writeln (x, " ", y, " ", res);
  }
  writeln ("Finite");
  writeln (res);
}


void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.random;

  if(false){
    auto rnd=Random(unpredictableSeed);
    int n=50;
    auto ans=new int[][](n);
    foreach(i; 0..n){
      int[] ks;
      foreach(__; 0..3) ks~=uniform!"[]"(2, 10, rnd);
      // ks~=2; ks~=2; ks~=3; -> yes
      if(check(ks)){
        ans[i]~=ks;
      }
    }
    foreach(i; 0..n)if(ans[i].length>0) writeln(ans[i]);
  }

  auto d=readln.split.to!(int[]);
  if(count(d, 1)){writeln("YES"); return;}
  if(count(d, 2)>=2){writeln("YES"); return;}

  sort(d);
  if(d[0]==2 && d[1]==d[2] && d[2]==4){writeln("YES"); return;}
  if(d[0]==d[1] && d[1]==d[2] && d[2]==3){writeln("YES"); return;}

  writeln("NO");
}

bool check(int[] ks){
  import std.algorithm;
  foreach(x1; 0..10)foreach(x2; 0..10)foreach(x3; 0..10){
    auto ok=new bool[](300);
    for(int i=x1; i<300; i+=ks[0]) ok[i]=true;
    for(int i=x2; i<300; i+=ks[1]) ok[i]=true;
    for(int i=x3; i<300; i+=ks[2]) ok[i]=true;
    bool yes=true;
    for(int i=max(x1, x2, x3); i<300; i++) yes&=ok[i];
    if(yes) return true;
  }
  return false;
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}


import std.stdio;

void main() {
	int[12] array;
	int n;
	readf(" %s", &n);
	for (int i = 0; i < 12; i++)
		readf(" %s", &array[i]);

	array.sort;

	int counter = 0;
	int count = 0;
	foreach_reverse(e; array) {
		if (counter >= n) {
			break;
		}
		counter += e;
		count++;

	}

	if (n > counter)
		writeln(-1);
	else
		writeln(count);
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio      : readln, writeln;
import std.string     : chomp;
import std.array      : split;
import std.conv       : to;
import std.algorithm  : min;

auto gets() { return readln.chomp; }
auto getV(T)() { return gets.to!T; }
auto getVals(T)() { return gets.split.to!(T[]); }

void main() {
    auto nkt = getVals!int;
    auto n = nkt[0], k = nkt[1], t = nkt[2];
    if (t <= k) {
        writeln(t);
        return;
    }
    if (t <= n) {
        writeln(k);
        return;
    }
    writeln(k - (t - n));
}


import std.stdio;

void main() {
    int n, cnt = 0;
    string s;
    readf("%d\n", &n);
    char oldc;
    for (int i = 0; i < n; ++i) {
        char c;
        readf(" %c", &c);
        if (i != 0 && c == oldc) {
            cnt++;
        }
        oldc = c;
    }
    writefln("%d", cnt);
}


import std.stdio;
import std.math;
import std.string;
import std.conv;

void main()
{
	auto a = split(strip(readln));
	int n = to!int(a[0]);
	int b = to!int(a[1]);
	int p = to!int(a[2]);

	auto xn = n;
	int bo;
	while (n >= 2)
	{
		auto po = to!int(log2(n));
		auto k = pow(2, po);
		bo += (k / 2) * (2 * b + 1);
		n = n - k + (k / 2);
		//writeln(k, "\t", n);
	}

	writeln(bo, " ", p * xn);
}


import std.stdio;
import core.stdc.stdio;
import std.algorithm;
import std.math;
import std.array;

int main(string[] argv)
{
	int k, r;
	scanf("%d %d", &k, &r);
	int cr = k % 10;
	int num = 1;
	while (cr != 0 && cr != r)
	{
		cr += k % 10; cr %= 10;
		num++;
	}
	printf("%d", num);
	return 0;
}


import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.ascii;

void main() {
    int n,a,b;
    scan(n,a,b);

    int ans;

    foreach (i ; 1 .. n) {
        ans = max(ans, min(a/i, b/(n-i)));
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto X = readln.chomp.to!long;

    foreach (a; 1..X+1) {
        foreach (b; 1..X+1) {
            if (a % b == 0 && a * b > X && a < b * X) {
                writeln(a, " ", b);
                return;
            }
        }
    }

    writeln(-1);
}


#!/usr/bin/rdmd

import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.regex;
import std.math;
import std.bigint;
import std.numeric;
import std.container;
import std.typecons;
import std.algorithm;
import std.range;

void main() {
  int n = readln().chomp().to!int();
  int[] x = readln().split().map!(to!int)().array();
  bool flag = false;
  for (int i = 0; i < n-1; i++) {
    int a = x[i], b = x[i+1];
    if (a > b) swap(a, b);
    for (int j = 0; j < n-1; j++) {
      int c = x[j], d = x[j+1];
      if (c > d) swap(c, d);
      if (a < c && c < b && b < d) flag = true;
      if (c < a && a < d && d < b) flag = true;
    }
  }
  if (flag) writeln("yes");
  else writeln("no");
}


import std.stdio, std.string, std.container, std.conv, std.numeric, std.range;
import std.array, std.bigint, std.algorithm, std.math, std.typecons, std.random;

byte tie(short a, short b, short c, short d) {

	int sum1 = max(3 * a / 10, a - a / 250 * c);
	int sum2 = max(3 * b / 10, b - b / 250 * d);

	if (sum1 < sum2)
		return 1;
	else if (sum1 > sum2)
		return 2;
	else
		return 0;
}

void main() {

	short a, b, c, d;

	scanf("%hd%hd%hd%hd", &a, &b, &c, &d);

	byte ans = tie(a, b, c, d);

	if (ans == 1)
		writeln("Vasya");
	else if (ans == 2)
		writeln("Misha");
	else
		writeln("Tie");
}


import core.bitop;
import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.range.interfaces;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    auto r = () => readln.chomp.split.map!(to!int);

    auto s1 = r().sum;
    auto s2 = r().sum;

    writeln(s1 >= s2 ? "Yes" : "No");
}


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string read_string() {
                while (tokens.empty) {
                tokens = readln.split;
        }
        auto token = tokens.front;
                tokens.popFront;
                return token;
        }

        int read_int() {
                return read_string.to!int;
        }

        double read_double() {
                return read_string.to!double;
        }

        string[] tokens;
}

void main() {
        IO cin;
        int t = 1;
        // int t = cin.read_int;
        while (t--) {
                int x1 = cin.read_int;
                int y1 = cin.read_int;
                int x2 = cin.read_int;
                int y2 = cin.read_int;

                writeln(max(abs(x2 - x1), abs(y2 - y1)));
        }
}


import std.stdio, std.string, std.math;

bool check(int x, int y, long t, int cnt1, int cnt2)
{
    auto b = x * y;
    auto cnt = t / b, left = t % b;
    auto no1 = y - 1, no2 = x - 1;
    auto sub1 = (x - 1) * cnt + left / y;
    auto sub2 = (y - 1) * cnt + left / x;
    cnt1 -= sub1;
    cnt2 -= sub2;
    if (cnt1 < 0) cnt1 = 0;
    if (cnt2 < 0) cnt2 = 0;
    if (t - cnt - sub1 - sub2 >= cnt1 + cnt2) return true;
    return false;
}

void solve(int cnt1, int cnt2, int x, int y)
{
    long left = 1, right = 1L << 60;
    long ans = -1;
    while (left <= right)
    {
	auto mid = (left + right) >> 1;
	if (check(x, y, mid, cnt1, cnt2))
	{
	    ans = mid;
	    right = mid - 1;
	}
	else
	{
	    left = mid + 1;
	}
    }
    writefln("%d", ans);
}

void main(string[] args)
{
    int cnt1, cnt2, x, y;
    while (scanf("%d%d%d%d", &cnt1, &cnt2, &x, &y) == 4)
    {
	solve(cnt1, cnt2, x, y);
    }
}


import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.numeric;

void read_vars(Args...)(out Args args) {
  auto tokens = readln.idup.split;
  foreach (i, ref arg; args) {
    arg = tokens[i].to!(typeof(arg));
  }
}

void main() {
  int n;
  read_vars(n);
  int x, y;
  for (int i = 0; i * 2 < n; ++i) {
    int j = n - i;
    if (gcd(i, j) == 1) {
      x = i;
      y = j;
    }
  }
  writefln!"%d %d"(x, y);
}


import core.bitop;
import core.checkedint;
import core.simd;
import core.stdc.string;
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.bitmanip;
import std.complex;
import std.container;
import std.conv;
import std.datetime;
import std.functional;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.regex;
import std.stdio;
import std.string;
import std.typecons;
import std.variant;

bool read(T...)(T ptrs) if (ptrs.length > 0) {
    return readf(' ' ~ replicate("%s ", ptrs.length), ptrs) == ptrs.length;
}

void main() {
    int n;
    while (read(&n)) {
        int a, b;
        foreach (i; 0 .. n) {
            int x;
            read(&x);
            if (x == 1)
                a = i;
            else if (x == n)
                b = i;
        }
        if (a > b)
            swap(a, b);
        writeln(max(b, n - a - 1));
    }
}


import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;

void main ()
{
	int n, m;
	while (readf (" %s %s", &n, &m) > 0)
	{
		alias Exam = Tuple
		    !(int, q{s}, int, q{d}, int, q{c}, int, q{num});
		auto exams = new Exam [m];
		foreach (i, ref exam; exams)
		{
			readf (" %s %s %s", &exam.s, &exam.d, &exam.c);
			exam.num = i + 1;
		}
		exams.schwartzSort !(exam => exam.d);

		auto res = new int [n + 1];
		foreach (const ref exam; exams)
		{
			res[exam.d] = m + 1;
		}

		foreach (day; 1..n + 1)
		{
			foreach (ref exam; exams)
			{
				if (res[day] == 0 && exam.c > 0 &&
				    exam.s <= day && day < exam.d)
				{
					res[day] = exam.num;
					exam.c -= 1;
				}
			}
		}

		if (exams.any !(exam => exam.c > 0))
		{
			writeln (-1);
		}
		else
		{
			writefln ("%(%s %)", res.drop (1));
		}
	}
}


import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    string s, t;
    scan(s,t);

    string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

    foreach (i ; 1 .. s.length + 1) {
        foreach (j ; 1 .. t.length + 1) {
            string tmp = s[0 .. i] ~ t[0 .. j];
            if (tmp < ans) {
                ans = tmp;
            }
        }
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


import core.bitop, std.bitmanip;
import std.algorithm, std.functional;
import std.array, std.container;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

immutable int INF = 10L ^^ 9 + 23;
immutable int MD = 10 ^^ 9 + 7;

void main()
{
    long n; int m;
    readf("%s %s", &n, &m);
    readln;

    auto mtrx = new int[][] (m, m);
    mtrx[0][0] = 1;
    mtrx[0][$-1] = 1;

    for (int i = 1; i < m; ++i) mtrx[i][i-1] = 1;

    auto orig = new int[][] (m, m);
    for (int i = 0; i < m; ++i) orig[i][] = mtrx[i][];
    auto tmp = new int[][] (m, m);

    debug { mtrx.writeln; }

    void multMtrx(int[][] mtrx1, int[][] mtrx2) {
        debug { tmp.writeln; mtrx2.writeln; }

        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < m; ++j) {
                int cur = 0;
                for (int k = 0; k < m; ++k) {
                    cur = (cur + (mtrx1[i][k].to!long * mtrx2[k][j] % MD)) % MD;
                }
                tmp[i][j] = cur;
            }
        }

        for (int i = 0; i < m; ++i) mtrx1[i][] = tmp[i][];
    }

    void calcPow(long p) {
        if (p == 1) return;

        calcPow(p/2);
        multMtrx(mtrx, mtrx);

        if (p % 2 == 1) {
            multMtrx(mtrx, orig);
        }
    }

    calcPow(n);

    debug { mtrx.writeln; }

    auto ans = 0;
    for (int i = 0; i < m; ++i) ans = (ans + mtrx[$-1][i]) % MD;

    ans.writeln;
}


import std.stdio, std.conv, std.range, std.algorithm, std.string;
import std.math;

void main() {
    int n, m;
    readf("%d %d\n", &n, &m);
    int[] a = readln.chomp.split.map!(
        a => (a.to!int / cast(double)m).ceil.to!int
        ).array;

    int ma = 0;
    int ans = 0;
    foreach (int i, e; a) {
        if (e >= ma) {
            ans = i + 1;
            ma = e;
        }
    }

    ans.writeln;
}


import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.range;

void main() {
	int c = readln.chomp.split.map!(to!int).reduce!("a + b");
	if (c > 0 && c % 5 == 0) {
		writeln(c / 5);
	} else {
		writeln(-1);
	}
}


import std.stdio;
import std.string;

int main()
{
	int a=0;
	int b=0;
	int c=0;
	int d=0;
	int e=0;
	readf(" %d", &a);
	readf(" %d", &b);
	readf(" %d", &c);
	readf(" %d", &d);
	readf(" %d", &e);
	if (2*d+a*b>2*e+a*c)
	{
		writeln("Second");
	}
	else if (2*d+a*b<2*e+a*c)
	{
		writeln("First");
	}
	else
	{
		writeln("Friendship");
	}
	return 0;
}


// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

void main() {
    auto spinner = "v<^>";

    char s, t;
    int n;

    scan(s, t);
    scan(n);

    n %= 4;

    int b = spinner.countUntil(s);

    bool cw, ccw;

    if (spinner[(b + n) % 4] == t) {
        cw = true;
    }

    if (spinner[(b - n + 4) % 4] == t) {
        ccw = true;
    }

    if (cw && ccw) {
        writeln("undefined");
    }
    else if (cw) {
        writeln("cw");
    }
    else if (ccw) {
        writeln("ccw");
    }
    else {
        assert(0);
    }
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!BigInt);
    auto N = s[0];
    auto K = s[1];

    BigInt hi = N + 1;
    BigInt lo = 0;
    while (hi - lo > 1) {
        auto mid = (hi + lo) / 2;
        if (mid + mid * K > N / 2) hi = mid;
        else lo = mid;
    }

    writeln(lo, " ", lo * K, " ", N - lo * K - lo);
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, k;
    readf("%s %s", &n, &k);
    readln;

    int a, b;
    readf("%s %s", &a, &b);
    readln;

    auto starts = make!(RedBlackTree!int)([1 + a, k+1 - a]);
    auto afterStep = make!(RedBlackTree!long);

    foreach (i; 0 .. n) {
        afterStep.insert(k.to!long*i + 1 + b);
        afterStep.insert(k.to!long*(i+1) + 1 - b);
    }

    //debug { starts.writeln; afterStep.writeln; }

    long tot = n.to!long * k;
    long mn = tot, mx = 1;

    long Calc(long step, long tot) {
        if (step == 0) { step = tot; }
        return tot / gcd(tot, step);
    }

    foreach (start; starts) {
        foreach (nxt; afterStep) {
            long step = abs(start - nxt);
            long cur = Calc(step, tot);
            mn = min(mn, cur);
            mx = max(mx, cur);

            step = tot - abs(start - nxt);
            cur = Calc(step, tot);
            mn = min(mn, cur);
            mx = max(mx, cur);
        }
    }

    writeln(mn, ' ', mx);
}


import std.stdio, std.string;

void solve(int c, int d, int n, int m, int k)
{
    int ans = 1 << 30;
    for (int i = 0; ; ++ i)
    {
        int j = m * n - i * n - k;
        if (j < 0)
        {
            j = 0;
        }
        int total = i * c + j * d;
        ans = total < ans ? total : ans;
        if (i * n + k >= m * n)
        {
            break;
        }
    }
    printf("%d\n", ans);
}

void main(string[] args)
{
    int c, d, m, n, k;
    while (scanf("%d%d%d%d%d", &c, &d, &n, &m, &k) == 5)
    {
        solve(c, d, n, m, k);
    }
}


// https://codeforces.com/problemset/problem/478/B
import std.stdio;

void main() {
    ulong n, m;
    readf("%s %s\n", &n, &m);
    ulong j = n-m;
    ulong maxima = j*(j+1)/2;
    ulong perteam = n/m;
    ulong minima = (m-n%m)*(perteam*(perteam-1)/2) + (n%m)*(perteam*(perteam+1)/2);
    writefln("%s %s", minima, maxima);
}


import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!long);
    auto A = s[0];
    auto B = s[1];
    auto D = abs(A - B);

    long ansv = A * B;
    long ansk = 0;

    long[] cand;

    for (long i = 1; i * i <= D; ++i) {
        if (D % i == 0) {
            cand ~= i;
            cand ~= D / i;
        }
    }

    foreach (g; cand) {
        long diff = (g - A % g) % g;
        long val = (A + diff) * (B + diff) / g;
        if (val < ansv || (val == ansv && diff < ansk)) {
            ansv = val;
            ansk = diff;
        }
    }

    writeln(ansk);
}


import std.c.stdio;
import std.stdio;
void main() {
 long a,b,c,t=0;
    scanf("%lld%lld",&a,&b);
    while(a!=0){
        if(a<b){
            c=a;
            a=b;
            b=c;
        }
        c=a/b;
        a=a-c*b;
        t=t+c;
    }
    printf("%lld\n",t);
}


// Cheese-Cracker: cheese-cracker.github.io

void play(){
    int n;
    n = rd!int;
    ll res = 1;
    for(int i = n-1; i > n/2; --i){
        res *= i;
    }
    foreach(i; 1..(n/2)){
        res *= i;
    }
    writeln(res);
}

int main(){
    long t = 1;
    /* t = rd;        // Toggle! */
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

/**********It's A Me Mario!**********/
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;
static string[] inp;
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }
void show(A...)(A a) { debug{ a.each!(w => write(w, "| ")); writeln; } }
alias ll = long;
alias rbt = redBlackTree;
alias tup = Tuple!(long, long);
T max(T = long)(T a, T b){ return (a > b) ? a : b; }
T min(T = long)(T a, T b){ return (a < b) ? a : b; }


import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(    const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

long calc(long h, long n, long side) {
	if (h == 0) {
		return 0;
	}
	const mid = 1L << (h - 1);
	long ret = 1;
	switch (side) {
		case 0: {
			if (n < mid) {
				ret += calc(h - 1, n, 1);
			} else {
				ret += (1L << h) - 1;
				ret += calc(h - 1, n - mid, 0);
			}
		} break;
		case 1: {
			if (n >= mid) {
				ret += calc(h - 1, n - mid, 0);
			} else {
				ret += (1L << h) - 1;
				ret += calc(h - 1, n, 1);
			}
		} break;
		default: assert(false);
	}
	return ret;
}

long H, N;

void main(string[] args) {
	try {
	for (; ; ) {
		H = readLong;
		N = readLong - 1;

		const res = calc(H, N, 0);
		writeln(res);

	}
	} catch (EOFException) {}
}


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string[] tk;
        string readString() {
                while (tk.empty)
                        tk = readln.split;
                auto tkt = tk.front;
                tk.popFront;
                return tkt;
        }
        int readInt() {
                return readString.to!int;
        }
        double readDouble() {
                return readString.to!double;
        }
}

void main() {
        IO cin;
        int t = 1;
        // t = cin.readInt;
        while (t--) {
                int k = cin.readInt;
                int[10] c = 0;
                for (int i = 0; i < 4; i++) {
                        string s = cin.readString;
                        for (int j = 0; j < 4; j++)
                                if (s[j] != '.') c[s[j] - '0']++;
                }

                for (int i = 0; i < c.length; i++) {
                        if (c[i] > 2 * k) {
                                writeln("NO");
                                return;
                        }
                }
                writeln("YES");
        }
}


import std.stdio;

long M;

long cnt(long x) {
	long ans = 0;
	foreach (long i; 2..cast(long)1e6 + 1) {
		ans += x / (i ^^ 3);
	}
	return ans;
}

void main() {
	readf("%d", &M);
	long low = 1, hi = cast(long)1e18;
	while (low != hi) {
		long mid = (low + hi) >> 1;
		if (cnt(mid) < M) low = mid + 1; else hi = mid;
	}
	if (cnt(low) == M) writeln(low); else writeln(-1);
}


/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.7.3"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    int n;
    sc.read(n);
    int[] res;
    foreach (i; 0..300) {
        int m = n-i;
        int k = m;
        if (m <= 0) break;
        string s = m.to!string;
        foreach (c; s) {
            m += c - '0';
        }
        if (n == m) {
            res ~= k;
        }
    }
    res.sort!"a<b";
    writeln(res.length);
    foreach (d; res) {
        writeln(d);
    }
    return 0;
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/foundation.d */
// module dcomp.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
version (X86) static if (__VERSION__ < 2071) {
    import core.bitop : bsf, bsr, popcnt;
    int bsf(ulong v) {
        foreach (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;
    }
    int bsr(ulong v) {
        foreach_reverse (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;
    }
    int popcnt(ulong v) {
        int c = 0;
        foreach (i; 0..64) {
            if (v & (1UL << i)) c++;
        }
        return c;
    }
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

// import dcomp.array;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    bool f = succW();
                    assert(f);
                    x[i] = line.parse!E;
                }
            } else {
                FastAppender!(E[]) buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }
    int read(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
}

/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/array.d */
// module dcomp.array;

T[N] fixed(T, size_t N)(T[N] a) {return a;}

struct FastAppender(A, size_t MIN = 4) {
    import std.algorithm : max;
    import std.conv;
    import std.range.primitives : ElementEncodingType;
    import core.stdc.string : memcpy;

    private alias T = ElementEncodingType!A;
    private T* _data;
    private uint len, cap;

    @property size_t length() const {return len;}
    bool empty() const { return len == 0; }

    void reserve(size_t nlen) {
        import core.memory : GC;
        if (nlen <= cap) return;

        void* nx = GC.malloc(nlen * T.sizeof);

        cap = nlen.to!uint;
        if (len) memcpy(nx, _data, len * T.sizeof);
        _data = cast(T*)(nx);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void opOpAssign(string op : "~")(T item) {
        if (len == cap) {
            reserve(max(MIN, cap*2));
        }
        _data[len++] = item;
    }

    void insertBack(T item) {
        this ~= item;
    }

    void removeBack() {
        len--;
    }

    void clear() {
        len = 0;
    }
    ref inout(T) back() inout { assert(len); return _data[len-1]; }
    ref inout(T) opIndex(size_t i) inout { return _data[i]; }

    T[] data() {
        return (_data) ? _data[0..len] : null;
    }
}

/*
This source code generated by dcomp and include dcomp's source code.
dcomp's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dcomp)
dcomp's License: MIT License(https://github.com/yosupo06/dcomp/blob/master/LICENSE.txt)
*/


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;

    RedBlackTree!int[] nrs;
    foreach (_; 0 .. 2) { nrs ~= make!(RedBlackTree!int); }

    debug { nrs.writeln; }

    void go(RedBlackTree!int rbt, int[] arr) {
        rbt.insert(0);
        foreach (e; arr) {
            auto old = rbt.array;

            foreach (v; old) { rbt.insert((v + e) % m); }
        }
    }

    go(nrs[0], arr[0 .. n/2]);
    go(nrs[1], arr[n/2 .. $]);

    debug { writeln(nrs[0], ' ', nrs[1]); }

    int ans = 0;
    foreach (e; nrs[0]) {
        while (e + nrs[1].back >= m) { nrs[1].removeBack(); }

        ans = max(ans, e + nrs[1].back);
    }

    ans.writeln;
}


import std.stdio;
import std.bigint;

int main(string[] argv)
{
	int n, t;
	readf("%d %d", &n, &t);
	string num = "";
	foreach (int i; 0..n)
	{
		num ~= "9";
	}
	BigInt number = num;
	int k = number % t;
	number -= k;
	if (number != 0)
	{
		write(number);
		return 0;
	}
	write(-1);
	return 0;
}


import std.stdio;

void write_chars(char[] cs) {
  foreach(c; cs) {
    write(c);
  }
}

char[] chars(string s) {
  char[] cs;
  foreach(c; s) {
    cs ~= c;
  }
  return cs;
}

void swap(char *first, char *second) {
  char t = *first;
  *first = *second;
  *second = t;
}

char[] after_wait(char[] queue) {
  for (int i=0; i < queue.length - 1; i++) {
    if (queue[i] == 'B' && queue[i+1] == 'G') {
      swap(&queue[i], &queue[i+1]);
      i++;
    }
  }
  return queue;
}

void main() {
  int n, t;
  string queue;
  readf("%s %s", &n, &t);
  readf(" %s", &queue);
  auto chars = chars(queue);
  while (t > 0) {
    chars = after_wait(chars);
    t--;
  }
  write_chars(chars);
}


import std.stdio;
import std.string;
import std.algorithm;
import std.exception;
import std.conv;
import std.array;
import std.range;
import std.math;

void main()
{
    auto ilkSatir = stdin.readln.strip.split().map!(a => to!int(a)).array();

	auto minumumSayi = min( ilkSatir[0], ilkSatir[1]);
	int sonuc = 1;
	while ( minumumSayi )
	{
		sonuc *= (minumumSayi--);
	}
	writeln(sonuc);
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }

      const ans = (N % 2 != 0 && A[0] % 2 != 0 && A[N - 1] % 2 != 0);
      writeln(ans ? "Yes" : "No");
    }
  } catch (EOFException e) {
  }
}


import std.stdio;
import std.string;
import std.uni;

void main() {
	int ans = 0;
	readln();
	string[] input = readln().split();
	foreach (string word; input) {
		int counter = 0;
		foreach (char c; word) if (isUpper(c)) counter++;
		if (counter > ans) ans = counter;
	}
	writeln(ans);
}


import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 998244353 ;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!int).array;
    auto K = A.sum;
    auto DT = iota(M).map!(_ => readln.split.map!(to!int).array).array;
    DT.sort!"a[0] < b[0]";

    bool check(int x) {
        auto lb = DT.assumeSorted!"a[0] < b[0]".lowerBound([x+1, 0]).length.to!int;
        if (lb == 0) {
            return x >= 2 * K;
        }
        int day = x;
        int money = x;
        int unused_money = 0;
        int sale = 0;
        auto B = A.dup;
        foreach_reverse (i; 0..lb) {
            day = DT[i][0];
            money = min(day, money);
            if (money && B[DT[i][1]-1] > 0) {
                int amount = min(money, B[DT[i][1]-1]);
                B[DT[i][1]-1] -= amount;
                money -= amount;
                sale += amount;
            }
        }

        return sale + (x - sale) / 2 >= K;
    }

    int ok = 5 * 10^^5;
    int ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    ok.writeln;
}


import std.stdio;

void main()
{
    int n, k;
    readf(" %s %s", n, k);

    while (k > 0)
    {
        k--;

        if (n % 10)
        {
            n--;
        }
        else
        {
            n /= 10;
        }
    }

    writeln(n);
}


//rextester.com:dmd64 2.072.2--codeforces.com:dmd32 2.071.2
import std.stdio,std.math;
void main(){
    double a;readf("%f",&a);a*=2;bool b=false;
    for(int i=1;i<cast(int)sqrt(a);i++){
        double c=a-i*i-i;double d=cast(int)sqrt(c);
        if(d*(d+1)==c)b=true;
    }
    write(b?"YES":"NO");
}


import std.stdio;
import std.conv;
import std.algorithm;
import std.array;
import std.string;
import std.uni;
import std.math;
import std.container.rbtree;
import std.range;
import std.numeric;

void main()
{
    auto t = to!long(readln().chomp);
    OUTER: foreach(_; 0..t)
    {
        auto n = readln().chomp.to!int;
        writeln(100/gcd(n, 100));
    }
}


import std.stdio, std.string;
import std.algorithm;

void calc(int bound, int n, int[] dp)
{
    static const int mod = 998244353;
    long sum = 0;
    dp[0] = 1;
    foreach (i; 1 .. bound + 1)
    {
        sum += dp[i - 1];
        sum %= mod;
        dp[i] = cast(int)sum;
    }
    foreach (i; bound + 1 .. n + 1)
    {
        sum -= dp[i - bound - 1];
        if (sum < 0) sum += mod;
        sum += dp[i - 1];
        sum %= mod;
        dp[i] = cast(int)sum;
    }
}

void solve(int n, int k)
{
    static const int mod = 998244353;
    auto rdp = new int[n + 1];
    auto cdp = new int[n + 1];
    auto ans = 0;
    auto last = 0;
    for (int num = 1; num < k && num <= n; ++ num)
    {
        calc(num, n, rdp);
        auto bound = k / num;
        if (bound > 0 && k % num == 0) -- bound;
        if (bound > n) bound = n;
        calc(bound, n, cdp);
        long cnt = rdp[n] - last;
        if (cnt < 0) cnt += mod;
        cnt <<= 1;
        cnt %= mod;
        cnt *= cdp[n];
        cnt %= mod;
        ans += cnt;
        ans %= mod;
        last = rdp[n];
    }
    writeln(ans);
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        solve(n, k);
    }
    return 0;
}


import std;

void main()
{
    int t;
    scanf("%d", &t);
    getchar();
    long n;
    foreach(_; 0..t)
    {
        auto row1 = readln.split.to!(int[]);
        auto row2 = readln.split.to!(int[]);

        if (sum(row1) == 0 && sum(row2) == 0)
            writeln(0);
        else if (sum(row1) + sum(row2) == 4)
            writeln(2);
        else
            writeln(1);
    }
}


import
		std.math,
		std.conv,
		std.file,
		std.range,
		std.array,
		std.stdio,
		std.string,
		std.bitmanip,
		std.algorithm;

void main()
{
	readln;
	auto s = readln.strip;

	uint c;

	while(s.length)
	{
		if(s.startsWith(`RU`) || s.startsWith(`UR`))
		{
			s = s[2..$];
		}
		else
		{
			s = s[1..$];
		}

		c++;
	}

	c.writeln;
}


/+ dub.sdl:
    name "A"
    dependency "dunkelheit" version=">=0.9.0"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int a;
    sc.read(a);

    writeln(2*(a-1)+1, " ", 2);
    writeln(1, " ", 2);
    return 0;
}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Program/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    bool f = succW();
                    assert(f);
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
    void read(Args...)(auto ref Args args) {
        import std.exception;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }
    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/


import std.stdio;
int main()
{
	int a=0;
	int b=0;
	int c=0;
	readf(" %d", &a);
	readf(" %d", &b);
	readf(" %d", &c);
	int res=0;
	if (a>=b+c)
	{
		res=res+(a-b-c+1);
	}
	if (b>=a+c)
	{
		res=res+(b-a-c+1);
	}
	if (c>=a+b)
	{
		res=res+(c-a-b+1);
	}
	writeln(res);
	return 0;
}


import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const K = readInt();
      auto S = readToken();

      int[char] freq;
      foreach (c; S) {
        ++freq[c];
      }
      bool ans = true;
      foreach (c, f; freq) {
        ans = ans && (f <= K);
      }
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}


import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto n = RD!int;

	auto dp = new long[](n+1);
	dp[0] = 1;
	dp[1] = 1;
	foreach (i; 2..n)
	{
		dp[i] = dp[i-1];
		dp[i].moda(dp[i-2]);
	}

	auto ans = dp[n-1];
	long m = 2;
	m.modpow(n);
	ans.modd(m);

	writeln(ans);
	stdout.flush;
	debug readln;
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.datetime.stopwatch;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

immutable int MX = 3000;

void main()
{
    int n, k, M;
    readf("%s %s %s", &n, &k, &M);
    readln;

    auto t = readln.chomp.split.map!(to!int).array;
    t.sort();

    int tsum = t.sum;

    int ans = 0;
    foreach (tot; 0 .. n+1) {
        long need = tsum.to!long * tot;
        if (need > M) { break; }

        int cur = tot * (k + 1);

        int lfttm = M - need.to!int;
        int lftprobs = n - tot;

        foreach (e; t) {
            int subs = min(lftprobs, lfttm / e);
            cur += subs;
            lfttm -= subs * e;
        }

        ans = max(ans, cur);
    }

    ans.writeln;
}


module main;
import std.c.stdio;
import std.algorithm;

int n, a, b;

char getc() {
    char ch;
    do { scanf("%c", &ch); } while (ch <= ' ');
    return ch;
}

int main(string[] argv) {
    scanf("%d%d%d", &n, &a, &b);
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        char ch = getc();
        if (ch == '1') ++mx;
    }

    long res = -1;
    for (int i = 1; i <= mx; ++i) {
        long sz = n/i, cnt = n-i*sz;
        long cost = (i-cnt) * (a + b*(sz-1)*(sz-1));
        cost += cnt * (a + b*sz*sz);
	    if (res == -1) res = cost;
	    res = min(res, cost);
    }
    printf("%lld\n", res);

    return 0;
}


import std.stdio;

bool solve() {
	long n;
	if (!readf(" %s", &n)) return false;
	long ans = 0;
	long lev = 0;
	long cur = 0;
	while (true) {
		lev++;
		cur += lev * 3 - 1;
		if (cur > n) break;
		if ((n - cur) % 3 == 0) {
			//writeln(lev);
			ans++;
		}
	}
	writeln(ans);
	return true;
}
void main() {
	while (solve()) {}
}


import std.stdio;
import std.algorithm.sorting;
import std.algorithm.comparison;

uint min_distance(uint[] pieces, uint n) {
  auto sorted_pieces = sort(pieces);
  uint min_distance = 1000;
  for (int i = 0; i < sorted_pieces.length - n + 1; i++) {
    auto distance = sorted_pieces[i+n-1] - sorted_pieces[i];
    min_distance = min(distance, min_distance);
  }
  return min_distance;
}

void main() {
  uint n, m, p;
  uint[] pieces;
  readf("%s %s", &n, &m);
  for (int i = 0; i < m; i++) {
    readf(" %s", &p);
    pieces ~= p;
  }
  write(min_distance(pieces, n));
}


module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;

struct IO {
        string read_string() {
                while (tokens.empty) {
                tokens = readln.split;
        }
        auto token = tokens.front;
                tokens.popFront;
                return token;
        }

        int read_int() {
                return read_string.to!int;
        }

        string[] tokens;
}

void main() {
        IO cin;
        int t = 1;
        // int t = cin.read_int;
        while (t--) {
                int n = cin.read_int;
                int m = cin.read_int;

                char c;
                char[3] colors = ['M', 'C', 'Y'];
                bool bnw = true;

                for (int i = 0; i < n; i++) {
                        for (int j = 0; j < m; j++) {
                                readf(" %s", c);
                                if (canFind(colors[0..3], c)) bnw = false;
                        }
                }
                if (bnw) writeln("#Black&White");
                else writeln("#Color");
        }
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod = 10 ^^ 9 + 7;

void main ()
{
	int n;
	while (readf !(" %s") (n) > 0)
	{
		int fact = 1;
		foreach (i; 1..n + 1)
		{
			fact = (fact * 1L * i) % mod;
		}
		int pow2 = 1;
		foreach (i; 0..n - 1)
		{
			pow2 = (pow2 << 1) % mod;
		}
		writeln ((fact - pow2 + mod) % mod);
	}
}


import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;

void main() {
  auto s = readln().strip().map!(c => c - '0').array;
  auto n = s.length;
  s.reverse();
  int r = -1;
  foreach (i; 0..n) {
    auto t = s[i];
    if (t % 8 == 0) {
      r = t;
    }
  }
  foreach (i; 0..n) {
    if (s[i] == 0) continue;
    foreach (j; 0..i) {
      auto t = 10 * s[i] + s[j];
      if (t % 8 == 0) {
        r = t;
      }
    }
  }
  foreach (i; 0..n) {
    if (s[i] == 0) continue;
    foreach (j; 0..i) {
      foreach (k; 0..j) {
        auto t = 100 * s[i] + 10 * s[j] + s[k];
        if (t % 8 == 0) {
          r = t;
        }
      }
    }
  }
  if (r == -1) {
    writeln("NO");
  } else {
    writeln("YES");
    writeln(r);
  }
}


//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;

class InputReader {
  private:
  ubyte[] p;
  ubyte[] buffer;
  size_t cur;
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
    p = stdin.rawRead (buffer);
  }
  final ubyte skipByte (ubyte lo) {
    while (true) {
      auto a = p[cur .. $];
      auto r = a.find! (c => c >= lo);
      if (!r.empty) {
        cur += a.length - r.length;
        return p[cur++];
      }
      p = stdin.rawRead (buffer);
      cur = 0;
      if (p.empty) return 0;
    }
  }
  final ubyte nextByte () {
    if (cur < p.length) {
       return p[cur++];
    }
    p = stdin.rawRead (buffer);
    if (p.empty) return 0;
    cur = 1;
    return p[0];
  }

  template next(T) if (isSigned!T) {
    final T next ()  {
      T res;
      ubyte b = skipByte (45);
      if (b == 45) {
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    final T next () {
      T res = skipByte (48) - 48;
      while (true) {
        ubyte b = nextByte ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  final T[] nextA(T) (int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto r = new InputReader;
  auto a = r.next!int;
  auto b = r.next!int;
  auto c = r.next!int;
  long s;
  int k = min (a, b);
  //ab
  a -= k;
  s += k;
  b -= k;
  s += k;
  s += 2 * c;
  if (a || b) s++;
  writeln (s);
}


import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

void main()
{
    readln;
    auto os = readln.chomp;
    int n;
    foreach (o; os) {
        if (o == '+') {
            ++n;
        } else if (o == '-' && n > 0) {
            --n;
        }
    }
    writeln(n);
}


import core.bitop;
import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.range.interfaces;

void main()
{
    long n, k;
    readf("%s %s", &n, &k);
    readln;

    if (n < k/2 + 1) {
        writeln(0);
        return;
    }

    auto lst = min(k-1, n);
    auto frst = k/2 + 1;

    auto ans = lst - frst + 1;

    ans.writeln;
}


import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.math, std.range;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, const T f) { if (t > f) t = f; }
void chmax(T)(ref T t, const T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(T[] as, bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

immutable long LIM = 100000;

long A, B, K;

void main(string[] args) {
	try {
	for (; ; ) {
		A = readLong;
		B = readLong;
		K = readLong;

		long ans = -1;

		// foreach (phase; 0 .. 2) {
			foreach (x; 0 .. LIM) {
				//	[A / (x + 1)] + [B / (y + 1)]
				const y = K - x;
				if (0 <= x && x < A && 0 <= y && y < B) {
					chmax(ans, (A / (x + 1)) * (B / (y + 1)));
				}
			}

			foreach (a; 1 .. LIM) {
				//	[A / (x + 1)] = a
				/*
					want x to be large
					a <= A / (x + 1) < a + 1
					a (x + 1) <= A < (a + 1) (x + 1)
					A / (a + 1) < x + 1 <= A / a
				*/
				const x = min(A / a - 1, K);
				const y = K - x;
				if (0 <= x && x < A && 0 <= y && y < B) {
					chmax(ans, (A / (x + 1)) * (B / (y + 1)));
				}
			}
			// swap(A, B);
		// }

		writeln(ans);

	}
	} catch (EOFException) {}
}


import std.stdio;

void main() {
    long l, r;
    scanf("%ld%ld", &l, &r);

    auto ans = 0;
    for (long a2=1; a2<=r; a2*=2) {
        for (long a3=1; a3<=r/a2; a3*=3) {
            if (a2 * a3 >= l) ans++;
        }
    }
    writeln(ans);
}


import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;

void main()
{
	int x, y;
	readln.chomp.split.tie(x, y);
	if (x == y) {
		writeln = "=";
	} else {
		real a = y * log10(cast(real)x);
		real b = x * log10(cast(real)y);
		debug verbose(a, b);
		if (abs(a - b) < 1e-9) {
			writeln = "=";
		} else {
			writeln = a < b ? "<" : ">";
		}
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	long a, b;
	while (readf (" %s %s", &a, &b) > 0)
	{
		long res = 1;
		foreach (c; a + 1..b + 1)
		{
			res *= c;
			res %= 10;
			if (res == 0)
			{
				break;
			}
		}
		writeln (res);
	}
}


import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.bigint, std.math, std.range;
import core.thread;

//  Input
string[] tokens;
int tokenId = 0;
string readToken() { for (; tokenId == tokens.length; ) tokens = readln.split, tokenId = 0; return tokens[tokenId++]; }

int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//  chmin/chmax
void chmin(T)(ref T t, T f) { if (t > f) t = f; }
void chmax(T)(ref T t, T f) { if (t < f) t = f; }

int A, B, C;

void main () {
    A = readInt();
    B = readInt();
    C = readInt();

    bool ok = false;

    foreach(int X; 0 .. A + 1) {
        int Y = B - X;
        int Z = C - Y;

        if (Y < 0 || Z < 0) continue;

        if (X + Y == B && X + Z == A && Y + Z == C) {
            writefln("%s %s %s", X, Y, Z);
            ok = true;
            break;
        }
    }

    if (!ok) {
        writeln("Impossible");
    }
}


/+ dub.sdl:
    name "C"
    dependency "dunkelheit" version="1.0.1"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.modint;

alias Mint = ModInt!(998244353);

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int w, h;
    sc.read(w, h);

    writeln(Mint(2) ^^ (w + h));
    return 0;
}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/modint.d */
// module dkh.modint;

// import dkh.numeric.primitive;

struct ModInt(uint MD) if (MD < int.max) {
    import std.conv : to;
    uint v;
    this(int v) {this(long(v));}
    this(long v) {this.v = (v%MD+MD)%MD;}
    static auto normS(uint x) {return (x<MD)?x:x-MD;}
    static auto make(uint x) {ModInt m; m.v = x; return m;}

    auto opBinary(string op:"+")(ModInt r) const {return make(normS(v+r.v));}

    auto opBinary(string op:"-")(ModInt r) const {return make(normS(v+MD-r.v));}

    auto opBinary(string op:"*")(ModInt r) const {return make((ulong(v)*r.v%MD).to!uint);}

    auto opBinary(string op:"/")(ModInt r) const {return this*inv(r);}

    auto opBinary(string op:"^^", T)(T r) const {return pow(this, r, ModInt(1));}
    auto opOpAssign(string op)(ModInt r) {return mixin ("this=this"~op~"r");}

    static ModInt inv(ModInt x) {return x^^(MD-2);};
    string toString() const {return v.to!string;}
}

struct DModInt(string name) {
    import std.conv : to;
    static uint MD;
    uint v;
    this(int v) {this(long(v));}
    this(long v) {this.v = ((v%MD+MD)%MD).to!uint;}
    static auto normS(uint x) {return (x<MD)?x:x-MD;}
    static auto make(uint x) {DModInt m; m.MD = MD; m.v = x; return m;}

    auto opBinary(string op:"+")(DModInt r) const {return make(normS(v+r.v));}

    auto opBinary(string op:"-")(DModInt r) const {return make(normS(v+MD-r.v));}

    auto opBinary(string op:"*")(DModInt r) const {return make((ulong(v)*r.v%MD).to!uint);}

    auto opBinary(string op:"/")(DModInt r) const {return this*inv(r);}
    auto opOpAssign(string op)(DModInt r) {return mixin ("this=this"~op~"r");}

    static DModInt inv(DModInt x) {
        return DModInt(extGcd!int(x.v, MD)[0]);
    }
    string toString() {return v.to!string;}
}

template isModInt(T) {
    const isModInt =
        is(T : ModInt!MD, uint MD) || is(T : DModInt!S, string S);
}

T[] factTable(T)(size_t length) if (isModInt!T) {
    import std.range : take, recurrence;
    import std.array : array;
    return T(1).recurrence!((a, n) => a[n-1]*T(n)).take(length).array;
}

T[] invFactTable(T)(size_t length) if (isModInt!T) {
    import std.algorithm : map, reduce;
    import std.range : take, recurrence, iota;
    import std.array : array;
    auto res = new T[length];
    res[$-1] = T(1) / iota(1, length).map!T.reduce!"a*b";
    foreach_reverse (i, v; res[0..$-1]) {
        res[i] = res[i+1] * T(i+1);
    }
    return res;
}

T[] invTable(T)(size_t length) if (isModInt!T) {
    auto f = factTable!T(length);
    auto invf = invFactTable!T(length);
    auto res = new T[length];
    foreach (i; 1..length) {
        res[i] = invf[i] * f[i-1];
    }
    return res;
}

/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/numeric/primitive.d */
// module dkh.numeric.primitive;

import std.traits, std.bigint;

T lcm(T)(in T a, in T b) {
    import std.numeric : gcd;
    return a / gcd(a,b) * b;
}

Unqual!T pow(T, U)(T x, U n)
if (!isFloatingPoint!T && (isIntegral!U || is(U == BigInt))) {
    return pow(x, n, T(1));
}

Unqual!T pow(T, U, V)(T x, U n, V e)
if ((isIntegral!U || is(U == BigInt)) && is(Unqual!T == Unqual!V)) {
    Unqual!T b = x, v = e;
    Unqual!U m = n;
    while (m) {
        if (m & 1) v *= b;
        b *= b;
        m /= 2;
    }
    return v;
}

T powMod(T, U, V)(T x, U n, V md)
if (isIntegral!U || is(U == BigInt)) {
    T r = T(1);
    Unqual!U m = n;
    while (m) {
        if (m & 1) r = (r*x)%md;
        x = (x*x)%md;
        m >>= 1;
    }
    return r % md;
}

T[3] extGcd(T)(in T a, in T b)
if (!isIntegral!T || isSigned!T)
{
    if (b==0) {
        return [T(1), T(0), a];
    } else {
        auto e = extGcd(b, a%b);
        return [e[1], e[0]-a/b*e[1], e[2]];
    }
}

T invMod(T)(T x, T md) {
    auto r = extGcd!T(x, md);
    assert(r[2] == 1);
    auto z = r[0];
    return (z % md + md) % md;
}

/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    private File f;

    this(File f) {
        this.f = f;
    }
    private char[512] lineBuf;
    private char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    assert(succW());
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }

    void read(Args...)(auto ref Args args) {
        import std.exception : enforce;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }

    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

immutable int mod  = 998_244_353;

bool isPrime (int n)
{
	if (n < 2)
	{
		return false;
	}
	for (int d = 2; d * d <= n; d++)
	{
		if (n % d == 0)
		{
			return false;
		}
	}
	return true;
}

void main ()
{
	int n;
	long m;
	while (readf !(" %s %s") (n, m) > 0)
	{
		int mMod = m % mod;
		int mPowN = 1;
		int whole = 0;
		foreach (i; 0..n)
		{
			mPowN = (mPowN * 1L * mMod) % mod;
			whole = (whole + mPowN) % mod;
		}

		int res = 1;
		long cur = 1;
		int total = 0;
		foreach (i; 0..n)
		{
			if (isPrime (i + 1))
			{
				cur *= i + 1;
			}
			auto good = m / cur;
			res = (res * 1L * (good % mod)) % mod;
			total = (total + res) % mod;
			if (good == 0)
			{
				break;
			}
		}

		total = (whole - total + mod) % mod;
		writeln (total);
	}
}