PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000203. Phân tích giai thừa thành thừa số nguyên tố (Prime Time)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân tích giai thừa thành thừa số nguyên tố (Prime Time)

Prime Time

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer nn, its factorial n!=1⋅2⋯nn!=1\cdot2\cdots n has a unique prime factorization

n!=p1e1p2e2⋯pkek,n!=p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k},

where p1<p2<⋯<pkp_1<p_2<\cdots<p_k are all primes not exceeding nn, and eie_i is the exponent of pip_i in n!n!.

Print this factorization in increasing prime order. Use the literal character ^ for exponents and the string * between consecutive factors.

Input

The only line contains the integer nn.

Output

Print one line of the form p1^e1 * p2^e2 * ... * pk^ek, with no leading or trailing *.

Subtasks

  • Subtask 1 (20 points): 2≤n≤502\le n\le 50.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le 2000.
  • Subtask 3 (50 points): 2≤n≤100002\le n\le 10000.

Examples

Input

6

Output

2^4 * 3^2 * 5^1

Explanation

We have 6!=720=24⋅32⋅516!=720=2^4\cdot3^2\cdot5^1. The primes are 2,3,52,3,5 with exponents 4,2,14,2,1, respectively. Therefore the required output is 2^4 * 3^2 * 5^1.