#include <iostream>
#include <fstream>
using namespace std;
int m,n,i,k;

void docfile()
{
	ifstream fi;
	fi.open("TUONGDUONG.INP",ios::in);
	fi>>m;fi>>n;
	fi.close();	
}
void ghifile()
{
	ofstream fo;
	fo.open("TUONGDUONG.OUT",ios::app);
	if( m<n)
	{
		k=m;m=n;n=k;
	}
	i=1;k=0;
	do
	{
		i++;
		if((m % i==0)	and (n % i==0))
		{
			if(k==0)
			{
				fo<<"TUONG DUONG"<<endl;
			}
			k=1;
			fo<<i<<" ";
			while((m % i ==0) and (n %i ==0))
			{
				m=m/i; n=n/i;
			}
		}
	}
	while(i<n);
	if(k==0)
	{
		fo<<"KHONG TUONG DUONG";
	}
	fo.close();
}

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() 
{
	docfile();
	ofstream fo;
	fo.open("TUONGDUONG.OUT",ios::out);
	fo.close();
	ghifile();
	return 0;
}
