#include using namespace std; #define ll long long #define MAXN 1000 int a,b,n,m,p,k; int arr[MAXN]; int main() { //cout << 5*5*7*7 << endl; // freopen("C:\\in.txt", "r", stdin); int r; cin >> n >> r; if(n==4){ cout << 1 << endl; return 0; } int arr[3]; int groups = n/4; for(int i=0; i<3; ++i){ arr[i] = n/4; } int c[61]; memset(c, 0, sizeof(c)); for(int i=1; i<=n; ++i){ c[i]++; } bool g_c = false; for(int i=0; i<3; ++i){ for(int j=60; j>=2; --j){ while(j%(i+2)==0 && arr[i] && c[j]){ c[j]--; arr[i]--; c[j/(i+2)]++; } } } for(int j=60; j>=2; --j){ if(c[j] && j%groups==0 && !g_c){ c[j]--; g_c = true; c[j/groups]++; } } bool first = true; for(int j=60; j>=2; --j){ if(c[j]){ c[j]+=r-1; } } for(int i=2; i<9; ++i){ if(c[i]){ if(!first){ cout << "+"; } first = false; cout << i << "^" << c[i]; } } return 0; }