大水题
/*
ID: Jang Lawrence
PROG: dualpal
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
char a[]={"0123456789ABCDEFGHIJKLMN"};
void dfs(int x,int n)
{
if(x>=n) dfs(x/n,n);
putchar(a[x%n]);
}
bool is(int x,int n)
{
char t[30];
int i=0;
while(x)
{
t[i++]=a[x%n];
x/=n;
}
for(int j=0;j<i;++j)
if(t[j]!=t[i-1-j]) return false;
return true;
}
bool isdual(int x)
{
int num=0;
for(int i=2;i<=10;++i)
if(is(x,i))
num++;
return num>=2;
}
int N,s;
int main()
{
freopen("dualpal.in","r",stdin);
freopen("dualpal.out","w",stdout);
scanf("%d%d",&N,&s);
while(N)
{
s++;
if(isdual(s)){
printf("%d\n",s);
N--;
}
}
return 0;
}