#include<iostream>
#include<conio.h>
using namespace std;
class TajzieClass
{
	private :
		int i, k;
	public :
		int n;
		int Calculate()
		{
			for(i = 2; i <= n; i++)
			{
				for(k = 0; n % i == 0; k++)
					n /= i;
				if(k > 0)
					cout << i << " ^ " << k << endl;
			}
		}
};

int main()
{
	TajzieClass A;
	cout << "n = ";
	cin >> A.n;
	A.Calculate();
	getch();
}

