#include<iostream>
#include<conio.h>
using namespace std;
class BakhshPazirClass
{
	public :
		int IsBakhshPazir(int num)
		{
			if(num % 7 == 0 && num % 3 != 0)
				return 1;
			else
				return 0;
		}
};

int main()
{
	BakhshPazirClass A;
	int i;
	for(i = 1000; i <= 9999; i++)
		if(A.IsBakhshPazir(i) == 1)
			cout << i << " ";
	getch();
}

