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

#SP0000272. Phân tích thừa số nguyên tố (15 chữ số) (Integer Factorization (15 digits))

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Phân tích thừa số nguyên tố (15 chữ số) (Integer Factorization (15 digits))

Integer Factorization (15 digits)

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer NN, factor it into primes. For each distinct prime pp, let ee be its multiplicity in the factorization. Print every pep^e in ascending order of pp, including the exponent 11 when it occurs.

Input

One line contains the positive integer NN.

Output

Print one line of pairs p^e, one for each distinct prime factor pp with its exponent ee. Sort the pairs by increasing pp, separating adjacent pairs by one space. Always print the exponent, including ^1.

Subtasks

  • Subtask 1 (20 points): 2≤N≤10000002\le N\le 1000000.
  • Subtask 2 (30 points): 2≤N≤100000000002\le N\le 10000000000.
  • Subtask 3 (50 points): 2≤N≤9999999999999992\le N\le 999999999999999.

Examples

Example 1

Input

3111989

Output

317^1 9817^1

Explanation

Starting from 31119893111989, divide successively by prime factors: 3111989÷317=98173111989\div 317=9817; 9817÷9817=19817\div 9817=1. Sort distinct prime factors in increasing order, writing each exponent including 11, and separate the pairs by spaces. The output line is 317^1 9817^1.

Example 2

Input

13091989

Output

17^2 89^1 509^1

Explanation

Starting from 1309198913091989, divide successively by prime factors: 13091989÷17=77011713091989\div 17=770117; 770117÷17=45301770117\div 17=45301; 45301÷89=50945301\div 89=509; 509÷509=1509\div 509=1. Sort distinct prime factors in increasing order, writing each exponent including 11, and separate the pairs by spaces. The output line is 17^2 89^1 509^1.

Example 3

Input

77145199750673

Output

328439^1 234884407^1

Explanation

Starting from 7714519975067377145199750673, divide successively by prime factors: 77145199750673÷328439=23488440777145199750673\div 328439=234884407; 234884407÷234884407=1234884407\div 234884407=1. Sort distinct prime factors in increasing order, writing each exponent including 11, and separate the pairs by spaces. The output line is 328439^1 234884407^1.