Problem:
Problem A: Everlasting...?

Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008.
Fans have been looking forward to a new title of Everlasting Sa-Ga.

Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everlasting Sa-Ga
and is attempting to reach the end of the game before his friends. However, he is facing difficulty
solving the riddle of the first maze in this game -- Everlasting Sa-Ga is notorious in extremely
hard riddles like Neverending Fantasy and Forever Quest.

The riddle is as follows. There are two doors on the last floor of the maze: the door to the
treasure repository and the gate to the hell. If he wrongly opens the door to the hell, the game
is over and his save data will be deleted. Therefore, he should never open the wrong door.

So now, how can he find the door to the next stage? There is a positive integer given for each
door -- it is a great hint to this riddle. The door to the treasure repository has the integer that
gives the larger key number. The key number of a positive integer n is the largest prime factor
minus the total sum of any other prime factors, where the prime factors are the prime numbers
that divide into n without leaving a remainder. Note that each prime factor should be counted
only once.

As an example, suppose there are doors with integers 30 and 20 respectively. Since 30 has three
prime factors 2, 3 and 5, its key number is 5 - (2 + 3) = 0. Similarly, since 20 has two prime
factors 2 and 5, its key number 20 is 5 - 2 = 3. Jimmy therefore should open the door with 20.

Your job is to write a program to help Jimmy by solving this riddle.

Input

The input is a sequence of datasets. Each dataset consists of a line that contains two integers a
and b separated by a space (2 ≤ a, b ≤ 106 ). It is guaranteed that key numbers of these integers
are always different.

The input is terminated by a line with two zeros. This line is not part of any datasets and thus
should not be processed.

Output

For each dataset, print in a line ‘a’ (without quotes) if the door with the integer a is connected
to the treasure repository; print ‘b’ otherwise. No extra space or character is allowed.

Sample Input

10 15
30 20
0 0

Output for the Sample Input

a
b

Solution in C++ (judge verdict: Accepted)

#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

/* ?????°?????´??°x??\????????¨???????´???°???????????¢??° */
/* ?????????????´???°????????°????????°???????????????????´???°???????´???????. */
int era (int x, int *array)
{
	int search[x];
	int len = 0;
	search[0] = search[1] = 0;
	for (int i = 2; i < x; i++)
		search[i] = 1;
	double root_x = sqrt(x);
	for (int i = 0; ; i++) {
		int num = search[i];
		if (num == 1) {
			if (root_x <= i)
				break;
			else {
				array[len++] = i;
				for (int j = i; j < x; j+=i)
					search[j] = 0;
			}
		}
	}
	for (int i = 0; i < x; i++) {
		if (search[i] == 1) {
			array[len++] = i;
			search[i] = 0;
		}
	}
	return len;
}

/* ?????°????´??????°????±?????????¢??°  */
int p_list(int a, int *list, int *primes, int len)
{
	int a_len = 0;
	int i = 0;
	while (primes[i] <= a) 
	{
		if (a % primes[i] == 0)
			list[a_len++] = primes[i];
		i++;
		if (len <= i)
			break;
	}
	return a_len++;
}

int key(int *list, int len)
{
	int sum = 0;
	if (len == 1)
		return list[0];
	for (int i = 0; i < len - 1; i++) 
		sum += list[i];
	return list[len-1] - sum;


}

int main (void)
{
	int *primes;
	int len;
	primes = (int *)malloc(sizeof(int) * 1000000);
	len = era(1000000, primes);	
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0)
			break;
		int a_pri[a/2], b_pri[b/2];
		int a_len, b_len;
		a_len = p_list(a, a_pri, primes, len);
		b_len = p_list(b, b_pri, primes, len);
#ifdef DEBUG
		cout << a_len << " " << b_len << endl;
		for (int i = 0; i < a_len; i++)
			cout << a_pri[i] << endl;
		for (int i = 0; i < b_len; i++)
			cout << b_pri[i] << endl;
#endif
		int a_key, b_key;
		a_key = key(a_pri, a_len);
		b_key = key(b_pri, b_len);
#ifdef DEBUG
		cout << "a " << a_key << endl;
		cout << "b " << b_key << endl;
#endif
		if (a_key > b_key)
			cout << "a" << endl;
		else
			cout << "b" << endl;
	}
	free(primes);
	return 0;
}