/*
ID:zengzha1
LANG:C++
TASK:dualpal
*/
#include<stdio.h>
int a[110];
int dlp(int n){
int i,j,k,m,f,s=0;
for(i=2;i<=10;i++){
m=0;k=n;f=1;
while(k){
a[++m]=k%i;
k/=i;
}for(j=1;j<=m/2;j++)
if(a[j]!=a[m-j+1]){
f=0;break;
}if(f)s++;
if(s>=2)return 1;
}return 0;
}int main(){
int m,n;
freopen("dualpal.in","r",stdin);
freopen("dualpal.out","w",stdout);
scanf("%d%d",&n,&m);
while(n){
m++;
if(dlp(m)){
printf("%d\n",m);
n--;
}
}return 0;
}
ID:zengzha1
LANG:C++
TASK:dualpal
*/
#include<stdio.h>
int a[110];
int dlp(int n){
int i,j,k,m,f,s=0;
for(i=2;i<=10;i++){
m=0;k=n;f=1;
while(k){
a[++m]=k%i;
k/=i;
}for(j=1;j<=m/2;j++)
if(a[j]!=a[m-j+1]){
f=0;break;
}if(f)s++;
if(s>=2)return 1;
}return 0;
}int main(){
int m,n;
freopen("dualpal.in","r",stdin);
freopen("dualpal.out","w",stdout);
scanf("%d%d",&n,&m);
while(n){
m++;
if(dlp(m)){
printf("%d\n",m);
n--;
}
}return 0;
}