#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int>> minHeap;
#define inputArray(a, n) \
for (int i = 0; i < n; i++) cin >> a[i];
#define printArray(a, n) \
for (int i = 0; i < n; i++) cout << a[i] << endl;
typedef pair<int, int> pii;
#define endl "\n"
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define int long long
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define clr(val, val1) memset(val, val1, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OnlineJudge \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define FastIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
void additionals() {
FastIO;
OnlineJudge;
}
const int n = 100001;
bitset<n> x;
vector<int> primes;
void seive() {
x.set();
x[0] = x[1] = 0;
// primes.clear();
for (int i = 2; i * i <= n; i++) {
if (x[i]) {
int k = i * i;
while (k <= n) {
x[k] = 0;
k += i;
}
}
}
for (int i = 0; i <= n; i++) {
if (x[i]) primes.PB(i);
}
}
int32_t main() {
additionals();
int a, b;
cin >> a >> b;
seive();
int segment[b - a + 1];
memset(segment, 1, sizeof(segment));
for (auto i : primes) {
if (i * i > b) break;
int start = (a / i) * i;
if (i >= a and i <= b) {
start = i * 2;
}
for (int j = start; j <= n; j += i) {
segment[j - a] = 0;
}
}
cout << "Result:" << endl;
for (int i = a; i <= b; i++) {
if (segment[i - a]) cout << i << " ";
}
cout << endl;
// for (auto i : primes) {
// cout << i << " ";
// }
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIHZlY3RvcjxpbnQ+IHZpOwp0eXBlZGVmIHByaW9yaXR5X3F1ZXVlPGludD4gbWF4SGVhcDsKdHlwZWRlZiBwcmlvcml0eV9xdWV1ZTxpbnQsIHZlY3RvcjxpbnQ+LCBnc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EwMDAwMTsKYml0c2V0PG4+IHg7CnZlY3RvcjxpbnQ+IHByaW1lczsKCnZvaWQgc2VpdmUoKSB7CiAgICB4LnNldCgpOwogICAgeFswXSA9IHhbMV0gPSAwOwogICAgLy8gcHJpbWVzLmNsZWFyKCk7CiAgICBmb3IgKGludCBpID0gMjsgaSAqIGkgPD0gbjsgaSsrKSB7CiAgICAgICAgaWYgKHhbaV0pIHsKICAgICAgICAgICAgaW50IGsgPSBpICogaTsKICAgICAgICAgICAgd2hpbGUgKGsgPD0gbikgewogICAgICAgICAgICAgICAgeFtrXSA9IDA7CiAgICAgICAgICAgICAgICBrICs9IGk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gbjsgaSsrKSB7CiAgICAgICAgaWYgKHhbaV0pIHByaW1lcy5QQihpKTsKICAgIH0KfQppbnQzMl90IG1haW4oKSB7CiAgICBhZGRpdGlvbmFscygpOwogICAgaW50IGEsIGI7CiAgICBjaW4gPj4gYSA+PiBiOwogICAgc2VpdmUoKTsKICAgIGludCBzZWdtZW50W2IgLSBhICsgMV07CgogICAgbWVtc2V0KHNlZ21lbnQsIDEsIHNpemVvZihzZWdtZW50KSk7CgogICAgZm9yIChhdXRvIGkgOiBwcmltZXMpIHsKICAgICAgICBpZiAoaSAqIGkgPiBiKSBicmVhazsKCiAgICAgICAgaW50IHN0YXJ0ID0gKGEgLyBpKSAqIGk7CiAgICAgICAgaWYgKGkgPj0gYSBhbmQgaSA8PSBiKSB7CiAgICAgICAgICAgIHN0YXJ0ID0gaSAqIDI7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIGZvciAoaW50IGogPSBzdGFydDsgaiA8PSBuOyBqICs9IGkpIHsKICAgICAgICAgICAgc2VnbWVudFtqIC0gYV0gPSAwOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgIlJlc3VsdDoiIDw8IGVuZGw7CiAgICBmb3IgKGludCBpID0gYTsgaSA8PSBiOyBpKyspIHsKICAgICAgICBpZiAoc2VnbWVudFtpIC0gYV0pIGNvdXQgPDwgaSA8PCAiICI7CiAgICB9CiAgICBjb3V0IDw8IGVuZGw7CgogICAgLy8gZm9yIChhdXRvIGkgOiBwcmltZXMpIHsKICAgIC8vICAgICBjb3V0IDw8IGkgPDwgIiAiOwogICAgLy8gfQoKICAgIHJldHVybiAwOwp9