#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl '\n'
using ll = long long;
#define pb push_back
#define eb emplace_back
#define pF first
#define pS second
#define SP << " " <<
const ll mod7 = 10007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool isprime(ll n) {
if (n == 2) return true;
if (n % 2 == 0) return false;
for (int i = 3; i*i <= n; i+=2) {
if (!(n % i)) return false;
}
return true;
}
int main() {
ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
ll a, b; cin >> a >> b;
bool swp = 0;
if (a > b) swap(a, b), swp = 1;
vector<ll> v;
bool good = 1;
for (ll i = a; i <= b; i += 2) {
if (v.size() > 30) good = 0;
if (isprime(i)) v.pb(i);
else {
good = 0;
break;
}
}
if (good && v.size() <= 30) {
cout << v.size() << endl;
if (swp) { reverse(v.begin(), v.end()); }
for (auto i: v) cout << i << " ";
exit(0);
}
v.clear();
good = 0;
if (a != 2) {
for (ll i = a; i <= b; i += 2) {
if (v.size() > 30) break;
if (isprime(i)) v.pb(i);
else break;
if (isprime(i - 2)) {
good = 1;
v.pb(2);
break;
}
}
if (!good) {
cout << -1 << endl;
exit(0);
}
} else {v.pb(2); good = 1;}
vector<ll> vb;
for (ll i = b; i <= 1e15; i += 2) {
if (v.size() + vb.size() > 30) break;
if (isprime(i)) vb.pb(i);
else {good = 0;break;}
if (isprime(i - 2)) break;
}
reverse(vb.begin(), vb.end());
for (auto i: vb) v.pb(i);
if (good && v.size() <= 30) {
cout << v.size() << endl;
if (swp) reverse(v.begin(), v.end());
for (auto i: v) cout << i << " ";
exit(0);
}
cout << -1 << endl;
}