A215419:=proc(q, x)
local a, b, c, d, i, n, ok;
for n from 1 to q do
a:=ithprime(n); b:=0; while a>0 do b:=b+1; a:=trunc(a/10); od;
a:=ithprime(n); ok:=1;
for i from 0 to b do
c:=a+9*10^i*trunc(a/10^i)+10^i*x; if not isprime(c) then ok:=0; break; fi;
od;
if ok=1 then print(ithprime(n)); fi;
od; end:
A215419(1000, 3);
# Alternative:
approved
editing