pp = [];

{
	[i,j] = [4,5];	\\ i <= j
	lim = 1217955766609;

	for (a=1, oo,
		ai = a^i;
		if (ai>lim, break);
		for (b=if (i==j, a, 1), oo,
			p = ai + b^j;
			if (p>lim, break,
			    isprime(p), pp = concat(pp, [p]);
			);
		);
	);

	apply(p -> 
		for (a=1, oo,
			if (ispower(p-a^i, j),
				print (n++ " " a);
				break;
			);
		)
	, Set(pp));
}

quit