import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	immutable MAX = 1000000;

	bool p[MAX];
	p[] = 1;
	p[0..2] = 0;
	foreach (i; 2..sqrt(MAX*1.0).ceil.to!int) {
		if (p[i]) {
			foreach (j; iota(i*2, MAX, i))
				p[j] = 0;
		}
	}

	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (x[0] == -1) break;
		int cnt;
		int[] plist;
		foreach (i; x[0]+1..MAX) {
			if (p[i]) {
				cnt++;
				plist ~= i;
				if (cnt == 100) break;
			}
		}
		int[] res;
		foreach (i, e; plist) {
			auto a = plist[i..$].dup;
			a[] += e;
			res ~= a;
		}
		res.sort[x[1]-1].writeln;
	}
}