The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets $$$w$$$ points, and the opposing team gets $$$0$$$ points. If the game results in a draw, both teams get $$$d$$$ points.The manager of the Berland capital team wants to summarize the results of the season, but, unfortunately, all information about the results of each match is lost. The manager only knows that the team has played $$$n$$$ games and got $$$p$$$ points for them.You have to determine three integers $$$x$$$, $$$y$$$ and $$$z$$$ — the number of wins, draws and loses of the team. If there are multiple answers, print any of them. If there is no suitable triple $$$(x, y, z)$$$, report about it.

The first line contains four integers $$$n$$$, $$$p$$$, $$$w$$$ and $$$d$$$ $$$(1 \le n \le 10^{12}, 0 \le p \le 10^{17}, 1 \le d < w \le 10^{5})$$$ — the number of games, the number of points the team got, the number of points awarded for winning a match, and the number of points awarded for a draw, respectively. Note that $$$w > d$$$, so the number of points awarded for winning is strictly greater than the number of points awarded for draw.

If there is no answer, print $$$-1$$$. Otherwise print three non-negative integers $$$x$$$, $$$y$$$ and $$$z$$$ — the number of wins, draws and losses of the team. If there are multiple possible triples $$$(x, y, z)$$$, print any of them. The numbers should meet the following conditions:    $$$x \cdot w + y \cdot d = p$$$,  $$$x + y + z = n$$$.

NoteOne of the possible answers in the first example — $$$17$$$ wins, $$$9$$$ draws and $$$4$$$ losses. Then the team got $$$17 \cdot 3 + 9 \cdot 1 = 60$$$ points in $$$17 + 9 + 4 = 30$$$ games.In the second example the maximum possible score is $$$10 \cdot 5 = 50$$$. Since $$$p = 51$$$, there is no answer.In the third example the team got $$$0$$$ points, so all $$$20$$$ games were lost.

import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;
import std.traits;
import std.array;
void read(T...)(ref T args)
{
  import std.traits;
  static foreach(i; 0 .. T.length)
    static if(isArray!(T[i]) && !is(T[i] == string))
      foreach(ref e; args[i])
    	read(e);
    else static if(isTuple!(T[i]))
      {
	static foreach(n; 0 .. T[i].Types.length)
	  {
	    read(args[i][n]);
	  }
      }
    else
      readf!" %s "(args[i]);
}
auto brange(alias low, alias high, alias pred, bool value)()
{
  return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);
}
auto ftrue(alias low, alias high, alias pred)()
{
  return brange!(low, high, pred, false).length + low;
}
auto itup(alias k, alias F)()
{
  alias T = Parameters!F;
  foreach(i; 0 .. k)
    {
      T t;
      get(t);
      F(t);
    }
}
alias get = read;
void wone(T)(T t, char end)
{
  static if(isArray!T && !is(T == string))
    {
      foreach(i; 0 .. t.length - 1)
	  write(t[i], ' ');
      write(t[$ - 1], end);
    }
  else
      write(t, end);
}
void wr(T...)(T t)
{
  static foreach(i; 0 .. T.length)
    static if(i + 1 < T.length)
      wone(t[i], ' ');
    else
      wone(t[i], '\n');
}
void ans(T...)(T t)
{
  import core.stdc.stdlib;
  wr(t);
  exit(0);
}
struct ModNum(T)
{
  T representative, modulus;
  this(T representative, T modulus)
  {
    this.representative = representative;
    this.modulus = modulus;
  }
  T minimalPositiveRepresentative()
  {
    return ((representative % modulus) + modulus) % modulus;
  }
  T minimalNegativeRepresentative()
  {
    return ((representative % modulus) - modulus) % modulus;
  }
  T maxRepresentative(T upperBound)
  {
    return upperBound - pmod(upperBound - representative, modulus);
  }
}
// minimum possible representative of x modulo m.
T pmod(T)(T x, T m)
{
  return (x % m + m) % m;
}
// solves ax + by = gcd(a, b) and returns gcd(a, b)
T extendedEuclideanAlgorithm(T)(T a, T b, out T x, out T y)
{
  if (a == 0)
    {
      x = 0, y = 1;
      return b;
    }
  T x1, y1;
  auto d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1, y = x1;
  return d;
}
alias egcd = extendedEuclideanAlgorithm;
// solves ax = b (mod m) giving a solution as a modulus class.
bool solveLinearCongruence(T)(T a, T b, T m, out ModNum!T res)
{
  T x, p;
  b = pmod(b, m);
  T y;
  T g = egcd(a, m, x, y);
  if (b % g != 0)
    return false;
  p = m / g;
  x = pmod(x * b / g, p);
  res.representative = x;
  res.modulus = p;
  return true;
}
void main()
{
  alias solve = solveLinearCongruence;
  alias ln = long;
  ln n, p, w, d; get(n, p, w, d);
  auto h = w - d;
  ModNum!ln np;
  if (solve(w, p, h, np))
    {
      ln maxNp = np.maxRepresentative(/*upper bound*/ min(n, p / d));
      ln z = n - maxNp;
      ln y = (w * maxNp - p) / h;
      ln x = maxNp - y;
      if (y >= 0 && x >= 0 && z >= 0)
	  ans(x, y, z);
    }
  ans(-1);
}

import std.algorithm;
import std.range;
import std.stdio;
import std.typecons;
import std.traits;
import std.array;
void read(T...)(ref T args)
{
  import std.traits;
  static foreach(i; 0 .. T.length)
    static if(isArray!(T[i]) && !is(T[i] == string))
      foreach(ref e; args[i])
    	read(e);
    else static if(isTuple!(T[i]))
      {
	static foreach(n; 0 .. T[i].Types.length)
	  {
	    read(args[i][n]);
	  }
      }
    else
      readf!" %s "(args[i]);
}
auto brange(alias low, alias high, alias pred, bool value)()
{
  return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);
}
auto ftrue(alias low, alias high, alias pred)()
{
  return brange!(low, high, pred, false).length + low;
}
auto itup(alias k, alias F)()
{
  alias T = Parameters!F;
  foreach(i; 0 .. k)
    {
      T t;
      get(t);
      F(t);
    }
}
alias get = read;
alias wr = writeln;

T egcd(T)(T a, T b, out T x, out T y)
{
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T x1, y1;
  auto d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}

void solve(ln a, ln b, ln m, out ln x, out ln p, out bool hassol)
{
  b %= m;
  ln y = 0;
  ln g = egcd(a, m, x, y);
  if (b % g != 0)
    {
      hassol = false;
      return;
    }
  hassol = true;
  x *= b / g;
  p = m / g;
  x %= p;
  x += p;
  x %= p;
  return;
}

alias ln = long;

int main()
{
  ln n, p, w, d; get(n, p, w, d);
  auto h = w - d;
  ln np;
  ln period;
  bool hassol;
  solve(w, p, h, np, period, hassol);
  if (hassol)
    {
      ln top = min(n, p / d);
      ln delta = top - np;
      np += (delta / period) * period;
      ln z = n - np;
      ln y = (w * np - p) / h;
      ln x = np - y;
      if (y >= 0 && x >= 0 && z >= 0)
	{
	  wr(x, " ", y, " ", z);
	}
      else
	{
	  wr(-1);
	}
    }
  else
    {
      wr(-1);
    }
  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 = 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 n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cast(long)cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (x < 0 || z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

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

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 n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cast(long)cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

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

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 n = RD;
	auto p = RD;
	auto w = RD!int;
	auto d = RD!int;

	auto r = p % w;
	auto used = new bool[](10^^5);
	int a;
	int cnt = -1;
	foreach (i; 0..10^^5)
	{
		if (a == r)
		{
			cnt = i;
			break;
		}
		else if (used[a] == true)
			break;
		used[a] = true;

		a += d;
		a %= w;
	}

	if (cnt == -1)
		writeln(-1);
	else
	{
		auto y = cnt;
		auto x = (p - y*d) / w;
		auto z = n - x - y;
		if (z < 0)
			writeln(-1);
		else
			writeln(x, " ", y, " ", z);
	}

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


Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $$$w$$$, and the height of the screen is $$$h$$$, then the following condition should be met: $$$\frac{w}{h} = \frac{x}{y}$$$.There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers $$$w$$$ and $$$h$$$ there is a TV set with screen width $$$w$$$ and height $$$h$$$ in the shop.Monocarp isn't ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers $$$w$$$ and $$$h$$$, beforehand, such that $$$(w \le a)$$$, $$$(h \le b)$$$ and $$$(\frac{w}{h} = \frac{x}{y})$$$.In other words, Monocarp wants to determine the number of TV sets having aspect ratio $$$\frac{x}{y}$$$, screen width not exceeding $$$a$$$, and screen height not exceeding $$$b$$$. Two TV sets are considered different if they have different screen width or different screen height.

The first line contains four integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ ($$$1 \le a, b, x, y \le 10^{18}$$$) — the constraints on the screen width and height, and on the aspect ratio.

Print one integer — the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.

NoteIn the first example, there are $$$3$$$ possible variants: $$$(5, 3)$$$, $$$(10, 6)$$$, $$$(15, 9)$$$.In the second example, there is no TV set meeting the constraints.In the third example, there is only one variant: $$$(3, 2)$$$.

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

  long a, b, x, y; rd(a, b, x, y);

  auto g=gcd(x, y);
  x/=g; y/=g;
  writeln(min(a/x, b/y));
}

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


One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.Can you help him?

The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.

Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got. Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.

NoteIn the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.

import std.stdio,
	std.algorithm;

void main() {
	int a, b;
	readf!` %s %s`(a, b);
	writeln(min(a, b), ' ', (max(a, b) - min(a, b)) / 2);
}

import std.stdio;

int main(string[] argv)
{
	int a, b;
	readf("%d %d", &a, &b);
	if (a < b) { int t = a; a = b; b = t; }
	int t = a - b;
	write(b, " ", t / 2);
	return 0;
}

import std.stdio;
int min(int a, int b)
{
	if (a<b)
	{
		return a;
	}
	else
	{
		return b;
	}
}
int max(int a, int b)
{
	if (a>b)
	{
		return a;
	}
	else
	{
		return b;
	}
}
int main()
{
	int a=0;
	int b=0;
	readf(" %d", &a);
	readf(" %d", &b);
	writeln(min(a,b));
	int c=a-min(a,b);
	int d=b-min(a,b);
	int e=max(c,d);
	writeln(e/2);
	return 0;
}


Makoto has a big blackboard with a positive integer $$$n$$$ written on it. He will perform the following action exactly $$$k$$$ times:Suppose the number currently written on the blackboard is $$$v$$$. He will randomly pick one of the divisors of $$$v$$$ (possibly $$$1$$$ and $$$v$$$) and replace $$$v$$$ with this divisor. As Makoto uses his famous random number generator (RNG) and as he always uses $$$58$$$ as his generator seed, each divisor is guaranteed to be chosen with equal probability.He now wonders what is the expected value of the number written on the blackboard after $$$k$$$ steps.It can be shown that this value can be represented as $$$\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are coprime integers and $$$Q \not\equiv 0 \pmod{10^9+7}$$$. Print the value of $$$P \cdot Q^{-1}$$$ modulo $$$10^9+7$$$.

The only line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^{15}$$$, $$$1 \leq k \leq 10^4$$$).

Print a single integer — the expected value of the number on the blackboard after $$$k$$$ steps as $$$P \cdot Q^{-1} \pmod{10^9+7}$$$ for $$$P$$$, $$$Q$$$ defined above.

NoteIn the first example, after one step, the number written on the blackboard is $$$1$$$, $$$2$$$, $$$3$$$ or $$$6$$$ — each occurring with equal probability. Hence, the answer is $$$\frac{1+2+3+6}{4}=3$$$.In the second example, the answer is equal to $$$1 \cdot \frac{9}{16}+2 \cdot \frac{3}{16}+3 \cdot \frac{3}{16}+6 \cdot \frac{1}{16}=\frac{15}{8}$$$.

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

immutable int mod = 10 ^^ 9 + 7;
immutable int small = 100;

int powMod (int a, int b)
{
	int res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * 1L * a) % mod;
		}
		a = (a * 1L * a) % mod;
		b >>= 1;
	}
	return res;
}

int invMod (int a)
{
	return powMod (a, mod - 2);
}

void main ()
{
	long n;
	int k;
	while (readf (" %s %s", &n, &k) > 0)
	{
		int [] primes;
		int [] powers;
		int [] [] prob;
		int total = 0;
		for (int d = 2; d * 1L * d <= n; d++)
		{
			if (n % d == 0)
			{
				int num = 0;
				do
				{
					n /= d;
					num += 1;
				}
				while (n % d == 0);
				primes ~= d;
				powers ~= num;
				total += 1;
			}
		}
		if (n > 1)
		{
			primes ~= n % mod;
			powers ~= 1;
			total += 1;
		}

		auto inv = new int [small];
		foreach (i; 1..small)
		{
			inv[i] = invMod (i);
		}

		foreach (i; 0..total)
		{
			int limit = powers[i];
			auto f = new int [] [] (2, limit + 1);
			int b = 0;
			f[b][] = 0;
			f[b][limit] = 1;
			foreach (j; 0..k)
			{
				b ^= 1;
				f[b][] = 0;
				foreach (u; 0..limit + 1)
				{
					foreach (v; 0..u + 1)
					{
						f[b][v] = (f[b][v] +
						    f[!b][u] * 1L *
						    inv[u + 1]) % mod;
					}
				}
			}
			debug {writeln (primes[i], ": ", f[b]);}
			prob ~= f[b];
		}

		int res = 0;

		void recur (int i, int cur)
		{
			debug {writeln ("recur ", i, " ", cur);}
			if (i == total)
			{
				res = (res + cur) % mod;
				return;
			}
			int temp = cur;
			foreach (u; 0..powers[i] + 1)
			{
				recur (i + 1, (temp * 1L * prob[i][u]) % mod);
				temp = (temp * 1L * primes[i]) % mod;
			}
		}

		recur (0, 1);
		writeln (res);
	}
}

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

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[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

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

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(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) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }

immutable MO = 10L^^9 + 7;
immutable LIM = 10^^5 + 10;

long[] inv;
void prepare() {
  inv = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;
  }
}

long N;
int K;

void main() {
  prepare();

  try {
    for (; ; ) {
      N = readLong();
      K = readInt();
      Tuple!(long, int)[] ps;
      long n = N;
      for (long d = 2; d * d <= n; ++d) {
        if (n % d == 0) {
          int e;
          do {
            ++e;
            n /= d;
          } while (n % d == 0);
          ps ~= tuple(d, e);
        }
      }
      if (n > 1) {
        ps ~= tuple(n, 1);
      }
      debug {
        writeln("ps = ", ps);
      }
      long ans = 1;
      foreach (entry; ps) {
        const p = entry[0];
        const e = entry[1];
        auto dp = new long[][](K + 1, e + 1);
        dp[0][0] = 1;
        foreach (i; 1 .. e + 1) {
          dp[0][i] = (dp[0][i - 1] * p) % MO;
        }
        foreach (k; 1 .. K + 1) {
          long sum;
          foreach (i; 0 .. e + 1) {
            (sum += dp[k - 1][i]) %= MO;
            dp[k][i] = (sum * inv[i + 1]) % MO;
          }
        }
        (ans *= dp[K][e]) %= MO;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

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

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[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

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

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(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) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }

immutable MO = 10L^^9 + 7;
immutable LIM = 10^^5 + 10;

long[] inv;
void prepare() {
  inv = new long[LIM];
  inv[1] = 1;
  foreach (i; 2 .. LIM) {
    inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;
  }
}

long N;
int K;

void main() {
  prepare();

  try {
    for (; ; ) {
      N = readLong();
      K = readInt();
      Tuple!(long, int)[] ps;
      long n = N;
      for (long d = 2; d * d <= n; ++d) {
        int e;
        do {
          ++e;
          n /= d;
        } while (n % d == 0);
        ps ~= tuple(d, e);
      }
      if (n > 1) {
        ps ~= tuple(n, 1);
      }
      debug {
        writeln("ps = ", ps);
      }
      long ans = 1;
      foreach (entry; ps) {
        const p = entry[0];
        const e = entry[1];
        auto dp = new long[][](K + 1, e + 1);
        dp[0][0] = 1;
        foreach (i; 1 .. e + 1) {
          dp[0][i] = (dp[0][i - 1] * p) % MO;
        }
        foreach (k; 1 .. K + 1) {
          long sum;
          foreach (i; 0 .. e + 1) {
            (sum += dp[k - 1][i]) %= MO;
            dp[k][i] = (sum * inv[i + 1]) % MO;
          }
        }
        (ans *= dp[K][e]) %= MO;
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin take a flight to the contest and back.Jinotega's best friends, team Base have found a list of their itinerary receipts with information about departure and arrival airports. Now they wonder, where is Jinotega now: at home or at some competition far away? They know that:   this list contains all Jinotega's flights in this year (in arbitrary order),  Jinotega has only flown from his hometown to a snooker contest and back,  after each competition Jinotega flies back home (though they may attend a competition in one place several times),  and finally, at the beginning of the year Jinotega was at home. Please help them to determine Jinotega's location!

In the first line of input there is a single integer n: the number of Jinotega's flights (1 ≤ n ≤ 100). In the second line there is a string of 3 capital Latin letters: the name of Jinotega's home airport. In the next n lines there is flight information, one flight per line, in form "XXX->YYY", where "XXX" is the name of departure airport "YYY" is the name of arrival airport. Exactly one of these airports is Jinotega's home airport. It is guaranteed that flights information is consistent with the knowledge of Jinotega's friends, which is described in the main part of the statement.

If Jinotega is now at home, print "home" (without quotes), otherwise print "contest".

4
SVO
SVO->CDG
LHR->SVO
SVO->LHR
CDG->SVO

NoteIn the first sample Jinotega might first fly from SVO to CDG and back, and then from SVO to LHR and back, so now they should be at home. In the second sample Jinotega must now be at RAP because a flight from RAP back to SVO is not on the list.

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();
      readToken();
      foreach (_; 0 .. N) {
        readToken();
      }

      writeln((N % 2 != 0) ? "contest" : "home");
    }
  } catch (EOFException e) {
  }
}


Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U', 'R', 'D', or 'L' — instructions to move a single square up, right, down, or left, respectively. How many ways can Calvin execute a non-empty contiguous substrings of commands and return to the same square he starts in? Two substrings are considered different if they have different starting or ending indices.

The first line of the input contains a single positive integer, n (1 ≤ n ≤ 200) — the number of commands. The next line contains n characters, each either 'U', 'R', 'D', or 'L' — Calvin's source code.

Print a single integer — the number of contiguous substrings that Calvin can execute and return to his starting square.

NoteIn the first case, the entire source code works, as well as the "RL" substring in the second and third characters.Note that, in the third case, the substring "LR" appears three times, and is therefore counted three times to the total result.

import std.stdio;

void main()
{
	int n;
	int res = 0;
	char[200 + 1] s;

	scanf("%d%s", &n, &s[0]);
	for (int i = 0; i < n; i++) {
		int vertical = 0;
		int horizontal = 0;
		for (int j = i; j < n; j++) {
			if (s[j] == 'U')
				vertical--;
			if (s[j] == 'D')
				vertical++;
			if (s[j] == 'L')
				horizontal--;
			if (s[j] == 'R')
				horizontal++;

			if (vertical == 0 && horizontal == 0)
				res++;
		}
	}

	printf("%d\n", res);
}

import std.stdio;
import std.string;

immutable int[] dx = [-1, 0, 1, 0];
immutable int[] dy = [0, -1, 0, 1];
immutable string dir = "LURD";

void main() {
  int n;
  readf(" %s", &n);
  readln;
  auto s = readln.strip;
  int ans = 0;
  foreach (i; 0..n) {
    foreach (j; i..n) {
      int x = 0;
      int y = 0;
      foreach (k; i..j + 1) {
        x += dx[dir.indexOf(s[k])];
        y += dy[dir.indexOf(s[k])];
      }
      if (x == 0 && y == 0) {
        ans++;
      }
    }
  }
  writeln(ans);
}

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

auto f (string t)
{
	return t.count ('U') == t.count ('D') &&
		t.count ('L') == t.count ('R');
}

void main ()
{
	readln;
	auto s = readln.strip;
	s.length.iota.map !(x =>
		x.iota.map !(y =>
			f (s[y..x + 1])
		).sum
	).sum.writeln;
}

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

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		readln;
		auto s = readln.strip;
		int res = 0;
		foreach (i; 0..n)
		{
			foreach (j; i..n)
			{
				auto t = s[i..j + 1];
				if (t.count ('U') == t.count ('D') &&
				    t.count ('L') == t.count ('R'))
				{
					res++;
				}
			}
		}
		writeln (res);
	}
}


Polycarp knows that if the sum of the digits of a number is divisible by $$$3$$$, then the number itself is divisible by $$$3$$$. He assumes that the numbers, the sum of the digits of which is divisible by $$$4$$$, are also somewhat interesting. Thus, he considers a positive integer $$$n$$$ interesting if its sum of digits is divisible by $$$4$$$.Help Polycarp find the nearest larger or equal interesting number for the given number $$$a$$$. That is, find the interesting number $$$n$$$ such that $$$n \ge a$$$ and $$$n$$$ is minimal.

The only line in the input contains an integer $$$a$$$ ($$$1 \le a \le 1000$$$).

Print the nearest greater or equal interesting number for the given number $$$a$$$. In other words, print the interesting number $$$n$$$ such that $$$n \ge a$$$ and $$$n$$$ is minimal.

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

  int a;
  rd(a);

  int digit_sum(int x) {
    int ret = 0;
    while (x) {
      ret += x % 10;
      x /= 10;
    }
    return ret;
  }

  for (int n = a;; n++) {
    if (digit_sum(n) % 4 == 0) {
      writeln(n);
      break;
    }
  }

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}

import std.stdio;
int sum(int a)
{
	int s=0;
	while(a!=0)
	{
		s=s+a%10;
		a=a/10;
	}
	return s;
}
int main()
{
	int a=0;
	readf(" %d", &a);
	int i=a;
	while (true)
	{
		if (sum(i)%4==0)
		{
			writeln(i);
			return 0;
		}
		i=i+1;
	}
	return 0;
}


After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks.An intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stick.In the grid shown below, n = 3 and m = 3. There are n + m = 6 sticks in total (horizontal sticks are shown in red and vertical sticks are shown in green). There are n·m = 9 intersection points, numbered from 1 to 9.  The rules of the game are very simple. The players move in turns. Akshat won gold, so he makes the first move. During his/her move, a player must choose any remaining intersection point and remove from the grid all sticks which pass through this point. A player will lose the game if he/she cannot make a move (i.e. there are no intersection points remaining on the grid at his/her move).Assume that both players play optimally. Who will win the game?

The first line of input contains two space-separated integers, n and m (1 ≤ n, m ≤ 100).

Print a single line containing "Akshat" or "Malvika" (without the quotes), depending on the winner of the game.

NoteExplanation of the first sample:The grid has four intersection points, numbered from 1 to 4.  If Akshat chooses intersection point 1, then he will remove two sticks (1 - 2 and 1 - 3). The resulting grid will look like this.  Now there is only one remaining intersection point (i.e. 4). Malvika must choose it and remove both remaining sticks. After her move the grid will be empty.In the empty grid, Akshat cannot make any move, hence he will lose.Since all 4 intersection points of the grid are equivalent, Akshat will lose no matter which one he picks.

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 n = cin.readInt;
                int m = cin.readInt;
                writeln(min(n, m) % 2 ? "Akshat" : "Malvika");
        }
}

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)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int ww = 1;
	while (n > 0 && m > 0)
	{
		n--; m--;
		ww++;
		ww %= 2;
	}
	printf((ww == 0 ? "Akshat" : "Malvika"));
	return 0;
}

import std.stdio;
import std.string;
import std.bigint;
import std.array;
import std.ascii;
import std.math;
import std.numeric;
import std.algorithm;
import std.container;
import core.bitop;

alias Int = long;

void main() {
  Int n, m;
  readf(" %s", &n);
  readf(" %s", &m);
  if ( min(n, m) % 2 == 0 ) {
    writeln("Malvika");
  } else {
    writeln("Akshat");
  }
}

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

int M, N;

void main(string[] args) {
	try {
	for (; ; ) {
		M = readInt;
		N = readInt;
		bool ans = (min(M, N) % 2 != 0);
		writeln(ans ? "Akshat" : "Malvika");
	}
	} catch (EOFException) {}
}

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)
{
	int n, m;
	scanf("%d %d", &n, &m);
	int s = n + m;
	int ww = 1;
	while (s > 1)
	{
		s -= 2;
		ww++;
		ww %= 2;
	}
	printf((ww == 0 ? "Akshat" : "Malvika"));
	return 0;
}


Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on. Iahub has the following scheme of painting: he skips x - 1 consecutive bricks, then he paints the x-th one. That is, he'll paint bricks x, 2·x, 3·x and so on red. Similarly, Floyd skips y - 1 consecutive bricks, then he paints the y-th one. Hence he'll paint bricks y, 2·y, 3·y and so on pink.After painting the wall all day, the boys observed that some bricks are painted both red and pink. Iahub has a lucky number a and Floyd has a lucky number b. Boys wonder how many bricks numbered no less than a and no greater than b are painted both red and pink. This is exactly your task: compute and print the answer to the question.

The input will have a single line containing four integers in this order: x, y, a, b. (1 ≤ x, y ≤ 1000, 1 ≤ a, b ≤ 2·109, a ≤ b).

Output a single integer — the number of bricks numbered no less than a and no greater than b that are painted both red and pink.

NoteLet's look at the bricks from a to b (a = 6, b = 18). The bricks colored in red are numbered 6, 8, 10, 12, 14, 16, 18. The bricks colored in pink are numbered 6, 9, 12, 15, 18. The bricks colored in both red and pink are numbered with 6, 12 and 18.

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

void main() {
    int x, y, a, b;
    readf("%d %d %d %d\n", &x, &y, &a, &b);
    int z = x * y / gcd(x, y);
    int f = (a + z - 1) / z;
    int t = b / z;
    //writeln(f, " ", t);
    writef("%d\n", t - f + 1);
}

module main;

import std.stdio,std.numeric;

int main(string[] args)
{
    ulong x,y,a,b;
    readf(" %s %s %s %s",&x,&y,&a,&b);
    auto l=lcm(x,y);
    writefln("%s",(b/l-a/l)+(a%l?0:1));
    return 0;
}

T lcm(T)(T a, T b)
{
    return (a/gcd(a,b))*b;
}

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

void main() {
    int x, y, a, b;
    readf("%d %d %d %d\n", &x, &y, &a, &b);
    int z = x * y / gcd(x, y);
    int f = (a + z - 1) / z;
    int t = (b + z - 1) / z;
    writef("%d\n", t - f + 1);
}


Given a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.

The first line contains two integers n and k (2 ≤ n ≤ 100000, 1 ≤ k ≤ 20).

If it's impossible to find the representation of n as a product of k numbers, print -1. Otherwise, print k integers in any order. Their product must be equal to n. If there are multiple answers, print any of them.

import std.bigint,std.container,std.array,std.algorithm,std.conv,
	std.functional,std.math,std.numeric,std.string,std.range,std.complex,
	std.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,
	core.stdc.stdio : freopen;
import core.stdc.stdlib : system;
//import core.stdc.stdio;
alias RedBlackTree Rbt;alias redBlackTree rbt;alias BigInt big;
alias pair(X,Y)=Tuple!(X,"fi",Y,"se");
alias pair!(int,int) pii;alias pair!(long,long) pll;alias BoyerMooreFinder strfind;
alias long lint;
alias make_pair mp;alias binary_search bins;alias gcd=std.numeric.gcd;
immutable int mod=1000000007;
pure nothrow
{
	T lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}
	pair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,"fi",Y,"se")(x_,y_);}
	big gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}
	@property X sqr(X)(in X a_) {return a_*a_;}
	@property X cub(X)(in X a_) {return a_*a_*a_;}
	size_t lowb(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (!(a[l]<g))?l:r;
	}
	size_t upb(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		if(pos==a.length)return pos;
		else return a[pos]==g?pos+1:pos;
	}
	size_t binf(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		return (g==a[pos])?pos:a.length;
	}
	bool binary_search(T,X)(in T a,auto ref X g)
	 if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		return binf(a,g)!=a.length;
	}
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(in X a,in size_t n=a.length,in size_t m=a.front.length)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in size_t n)
{bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	return s==ptrs.length;
}
bool read(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	readln;
	return s==ptrs.length;
}
nothrow auto inf(in char* name) {return freopen(name,"r",core.stdc.stdio.stdin);}
nothrow auto ouf(in char* name) {return freopen(name,"w",core.stdc.stdio.stdout);}
@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}
//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin
//cumulativeFold schwartzSort multiSort partialSort heapify join filter
//------------------------------------------program beginning--------------------------------------------

void main()
{
	version(ONLINE_JUDGE){}
	else
	{
		assert(freopen("input.txt","r",core.stdc.stdio.stdin));
		assert(freopen("output.txt","w",core.stdc.stdio.stdout));
	}
	int n,k;
	//writeln("hello");
loop:while(read(n,k))
	{
		int[int] q;
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				q[i]++;
				n/=i;
			}
		}
		if(n>1)q[n]++;
		auto s=q.byValue.sum;
		if(s<k)writeln(-1);
		else
		{
			int[] del;
			foreach(d,f;q)
			{
				foreach(i;0..f)del~=d;
			}
			int g=1;
			while(del.length>=k)
			{
				g*=del.front;
				del.popFront;
			}
			write(g,' ');
			foreach(x;del)write(x,' ');
			writeln;
		}
	}
	//debug system("pause");
}

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

int n, k;

void main() {
    scan(n, k);

    if (k == 1) {
        writeln(n);
        return;
    }

    int[] ans;
    int cnt;

    for (int p = 2; p <= n/p; ++p) {
        while (n % p == 0) {
            ans ~= p;
            cnt++;
            n /= p;

            if (cnt == k - 1 && n > 1) {
                ans ~= n;
                cnt++;
                n = 1;
                break;
            }
        }

        if (cnt == k) break;
    }

    if (n > 1) {
        ans ~= n;
        cnt++;
    }

    if (cnt == k) {
        writefln("%(%s %)", ans);
    }
    else {
        writeln(-1);
    }
}

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

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

immutable int inf = 10^^9 + 7;

int n, k;

void main() {
    scan(n, k);

    if (k == 1) {
        writeln(n);
        return;
    }

    auto primes = new int[](0);
    int cnt;

    for (int p = 2; p*p <= n; ++p) {
        while (n % p == 0) {
            n /= p;
            primes ~= p;
            cnt++;

            if (cnt == k - 1 && n > 1) {
                cnt++;
                primes ~= n;
                n = 1;
                break;
            }
        }

        if (cnt == k) break;
    }

    if (n > 1) {
        cnt++;
        primes ~= n;
    }

    if (cnt == k) {
        writefln("%(%s %)", primes);
    }
    else {
        writeln(-1);
    }
}

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