Problem:
Score : 300 points

Problem Statement

There are N integers a_1, a_2, ..., a_N not less than 1.
The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.

Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.

Constraints

1 \leq N \leq 10^{12}

1 \leq P \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N P

Output

Print the answer.

Sample Input 1

3 24

Sample Output 1

2

The greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and a_3=2.

Sample Input 2

5 1

Sample Output 2

1

As a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4 = a_5 = 1.

Sample Input 3

1 111

Sample Output 3

111

Sample Input 4

4 972439611840

Sample Output 4

206

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 100002;
const int MOD = 998244353;

int n, m, a[MAX_N], b[MAX_N];
bool mark[MAX_N];
map<int, int> cell[MAX_N];

void readInput() {
	cin >> n >> m;
	for (int i=1; i<=m; ++i) {
		int c;
		cin >> a[i] >> b[i] >> c;
		cell[a[i]][b[i]] = c;
	}
}

int64_t pw(int64_t n, int64_t k) {
	if (k==0)
		return 1;
	int64_t tmp = pw(n, k/2);
	return k%2 ? tmp*tmp%MOD*n%MOD : tmp*tmp%MOD;
}

void solve() {
	int64_t res = 1;

	int cnt = 0;
	for (int i=1; i<=m; ++i) {
		if (abs(a[i]-b[i])<3)
			continue;
		if (a[i]<b[i] || !cell[b[i]].count(a[i]))
			++cnt;
		if (cell[b[i]].count(a[i])) {
			if ((cell[a[i]][b[i]] + cell[b[i]][a[i]]) % 2) {
				cout << 0;
				return;
			}
		}
	}
	res = res * pw(2, 1LL*n*(n-1)/2 - (n-1) - (n-2) - cnt) % MOD;

	for (int i=2; i<n; ++i) {
		int tmp = cell[i-1].count(i+1) + cell[i+1].count(i-1);
		if (tmp==2) {
			if (cell[i].count(i) && cell[i][i]!=(cell[i-1][i+1]+cell[i+1][i-1])%2) {
				cout << 0;
				return;
			}
			cell[i][i] = (cell[i-1][i+1] + cell[i+1][i-1]) % 2;
		}
		else if (tmp==0) {
			res = res * 2 % MOD;
		}
	}

	for (int i=1; i<n; ++i) {
		int tmp = cell[i].count(i+1) + cell[i+1].count(i);
		if (tmp==2) {
			if (cell[i].count(i) && cell[i+1].count(i+1)
				&& (cell[i+1][i+1]+cell[i][i])%2!=(cell[i][i+1]+cell[i+1][i])%2) {
				cout << 0;
				return;
			}
			mark[i] = true;
		}
		else if (tmp==0) {
			res = res * 2 % MOD;
		}
	}
	for (int i=1; i<=n; ++i) {
		if (!cell[i].count(i) && !mark[i-1])
			res = res * 2 % MOD;
	}

	cout << res;
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	readInput();
	solve();
}