#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;

int dx[7] = { -1,0,1,0,-1,0,1 };
int dy[7] = { 0,1,0,-1,0,1,0 };

bool memo[64][16][4][64][16][4];


vector <vector<bool>>mp;

struct aa {
	int fx;
	int fy;
	int fway;
	int tx;
	int ty;
	int tway;
};
int gx, gy;

vector<aa>astack;

bool cangoal;

int gway;

bool check(int fx, int fy,int fway, int tx, int ty, int tway) {

	if (memo[fx][fy][fway][tx][ty][tway])return false;
	memo[fx][fy][fway][tx][ty][tway] =true;
	
	//else{

		int nfy = fy + dy[fway];
		int nfx = fx + dx[fway];
		while (1) {
			
			if (mp[nfy][nfx]) {
				nfx -= dx[fway];
				nfy -= dy[fway];
				break;
			}
			nfy = nfy + dy[fway];
			nfx = nfx + dx[fway];

		}

		int nty = ty;
		int ntx = tx;
		while (1) {

			if (mp[nty][ntx]) {
				ntx -= dx[tway];
				nty -= dy[tway];
				break;
			}

			if (mp[nty + dy[tway + 1]][ntx + dx[tway + 1]]) {
				int afway = (fway + 3) % 4;
				int atway = (tway + 3) % 4;
				if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
					if (tway == (gway + 2) % 4)
						return true;
				}
				if (fx == gx&&fy == gy) {
					cangoal = true;
				}
				if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
					astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
				}
			}

			if (mp[nty + dy[tway + 3]][ntx + dx[tway + 3]]) {
				int afway = (fway + 1) % 4;
				int atway = (tway + 1) % 4;
				if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
					if (tway == (gway + 2) % 4)
						return true;
				}
				if (fx == gx&&fy == gy) {
					cangoal = true;
				}
				if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
					astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
				}
			}

			nty = nty + dy[tway];
			ntx = ntx + dx[tway];
		}
		if (mp[nty + dy[tway + 1]][ntx + dx[tway + 1]]) {
			int afway = (fway + 3) % 4;
			int atway = (tway + 3) % 4;
			if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
				if (tway == (gway + 2) % 4)
					return true;
			}
			if (fx == gx&&fy == gy) {
				cangoal = true;
			}
			if (!memo[nfx][nfy][afway][ntx][nty][atway]) {
				
				astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });
			}
		}

		if (mp[nty + dy[tway + 3]][ntx + dx[tway + 3]]) {
			int atway = (tway + 1) % 4;
			int afway = (fway + 1) % 4;
			if (nfx == gx&&nfy == gy&&ntx == gx&&nty == gy) {
				if (tway == (gway + 2) % 4)
					return true;
			}
			if (fx == gx&&fy == gy) {
				cangoal = true;
			}
			if (!memo[nfx][nfy][afway][ntx][nty][atway]) {	
				astack.push_back(aa{ nfx,nfy,afway,ntx,nty,atway });

			}
		}

	//}
	return false;
}

bool memo2[64][16][4];

bool check2(int fx, int fy, int fway) {
	if (memo2[fx][fy][fway])return false;
	memo2[fx][fy][fway] = true;

	if (fx == gx&&fy == gy)return true;
	int nfy = fy + dy[fway];
	int nfx = fx + dx[fway];
	while (1) {

		if (mp[nfy][nfx]) {
			nfy -= dy[fway];
			nfx -= dx[fway];
			break;
		}
		nfy = nfy + dy[fway];
		nfx = nfx + dx[fway];
	}
	return (check2(nfx, nfy, (fway + 1) % 4) || check2(nfx, nfy, (fway + 3) % 4));
}

bool isso(int num) {
	const int now = num;
	int k = 6;
	bool satu = true;
	vector<int>ans;
	while (k < sqrt(now) + 1) {
		if (!(now%k)) {
			return false;
		}
		if (satu)k += 2;
		else k += 5;
		satu = !satu;
	}
	return true;
}


int main() {
	while (1) {
		int n; cin >> n;
		if (n == 1)break;

		int now = n;
		int k = 6;
		bool satu = true;
		vector<int>ans;
		while (k <= now) {
			if(!(now%k)) {
				if ((now / k) % 7 == 1 || (now / k) % 7 == 6) {
					ans.push_back(k);
				}
			}
			if (satu)k += 2;
			else k += 5;
			satu = !satu;
		}
		if (now != 1)ans.push_back(now);
		ans.resize(unique(ans.begin(), ans.end()) - ans.begin());

		vector<int>nans;
		for (int i = 0; i < ans.size(); ++i) {
			if (isso(ans[i])) {
				nans.push_back(ans[i]);
			}
		}
		cout << n << ": ";
		for (int i = 0; i < nans.size()-1; ++i) {
			cout << nans[i] <<" ";
		}
		cout << nans.back() << endl;
	}

	return 0;
}

Measured memory_bytes: 3072