#include <iostream>
using namespace std;
bool check(int x){
for(int i=2;i<x;i++){
if(x%i==0){
return false;
}
}
return true;
}
int a(int x){
int b=0;
while(x){
b=b*10+x%10;
x/=10;
}
return b;
}
int main(){
int m,n,j=0;
cin>>m>>n;
for(int i=m;i<=n;i++){
if(check(i)&&check(a(i))){
j++;
if(j==1){
cout<<i;
continue;
}
cout<<','<<i;
}
}
return 0;
}