import std.algorithm, std.conv, std.range, std.stdio, std.string; const mod = 10 ^^ 9 + 7; alias FactorRing!(mod, true) mint; void main() { auto rd = readln.split.to!(size_t[]), n = rd[0], k = rd[1]; auto a = readln.split.to!(int[]); auto p = primes(a.maxElement.nsqrt+1); auto f = new int[int][](n); foreach (i; 0..n) { auto ai = a[i]; while (ai > 1) { auto fi = ai.factor(p); ++f[i][fi]; ai /= fi; } } int[] q; foreach (fi; f) q ~= fi.keys; q = q.sort().uniq.array; auto r = mint(1); foreach (qi; q) { int[] s; foreach (i; 0..n) if (qi in f[i]) s ~= f[i][qi]; s.sort!"a > b"; r *= repeatedSquare(mint(qi), s.take(k).sum); } writeln(r); } pure T[] primes(T)(T n) { import std.algorithm, std.bitmanip, std.conv, std.range; auto sieve = BitArray(); sieve.length((n + 1) / 2); sieve = ~sieve; foreach (p; 1..((nsqrt(n) - 1) / 2 + 1)) if (sieve[p]) for (auto q = p * 3 + 1; q < (n + 1) / 2; q += p * 2 + 1) sieve[q] = false; auto r = sieve.bitsSet.map!(to!T).map!("a * 2 + 1").array; r[0] = 2; return r; } pure T factor(T)(T n, const T[] pi) { auto ma = nsqrt(n) + 1; foreach (p; pi) if (p > ma) return n; else if (n % p == 0) return p; return n; } pure T nsqrt(T)(T n) { import std.algorithm, std.conv, std.range, core.bitop; if (n <= 1) return n; T m = 1 << (n.bsr / 2 + 1); return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; } struct FactorRing(int m, bool pos = false) { long v; @property int toInt() { return v.to!int; } alias toInt this; this(T)(T _v) { v = mod(_v); } ref FactorRing!(m, pos) opAssign(int _v) { v = mod(_v); return this; } pure auto mod(long _v) const { static if (pos) return _v % m; else return (_v % m + m) % m; } pure auto opBinary(string op: "+")(long rhs) const { return FactorRing!(m, pos)(v + rhs); } pure auto opBinary(string op: "-")(long rhs) const { return FactorRing!(m, pos)(v - rhs); } pure auto opBinary(string op: "*")(long rhs) const { return FactorRing!(m, pos)(v * rhs); } pure auto opBinary(string op)(FactorRing!(m, pos) rhs) const if (op == "+" || op == "-" || op == "*") { return opBinary!op(rhs.v); } auto opOpAssign(string op: "+")(long rhs) { v = mod(v + rhs); } auto opOpAssign(string op: "-")(long rhs) { v = mod(v - rhs); } auto opOpAssign(string op: "*")(long rhs) { v = mod(v * rhs); } auto opOpAssign(string op)(FactorRing!(m, pos) rhs) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(rhs.v); } } T repeatedSquare(T, alias pred = "a * b", U)(T a, U n) { return repeatedSquare(a, n, T(1)); } T repeatedSquare(T, alias pred = "a * b", U)(T a, U n, T init) { import std.functional; alias predFun = binaryFun!pred; if (n == 0) return init; auto r = init; while (n > 0) { if ((n & 1) == 1) r = predFun(r, a); a = predFun(a, a); n >>= 1; } return r; }