# include<iostream>

int main()
{
	const int NumOfCup = 2;

	char exchange[NumOfCup];

	char conma, BallIn='A';

	while(std::cin >> exchange[0] >> conma >> exchange[1])
	{
		std::cout << exchange[0] << ',' << exchange[1] << '\n';

		for(int i=0; i<NumOfCup; ++i)
		{
			if(BallIn == exchange[i])
			{
				std::cout << "OK!";

				BallIn = exchange[(i+1)%2];

				break;
			}
		}
	}

	std::cout << BallIn << '\n';

}