#include<bits/stdc++.h>
using namespace std;
void kt(int l, int r)
{
bool prime[r - l + 1];
memset(prime,true,sizeof(prime));
for (long long i = 2; i * i <= r; ++i)
{
for (long long j = max(i * i, (l + (i - 1)) / i * i); j <= r; j += i)
{
prime[j - l] = false;
}
}
long long j=0,csi,csj,maxx=0,minn=1e11;
for (long long i = max(l, 2); i <= r; ++i)
{
if (prime[i - l])
{
if (j==0) j=i;
else
{
if (i-j<minn)
{
minn=i-j;
csi=i;
csj=j;
}
j=i;
}
}
}
if (minn!=1e11)
{
cout<<csj<<","<<csi<<" are closest";
}
for (long long i = max(l, 2); i <= r; ++i)
{
if (prime[i - l])
{
if (j==0) j=i;
else
{
if (i-j>maxx)
{
maxx=i-j;
csi=i;
csj=j;
}
j=i;
}
}
}
if (maxx!=0)
{
cout<<", ";
cout<<csj<<","<<csi<<" are most distant." <<endl;
return ;
}
cout<<"There are no adjacent primes."<<endl;
}
int main()
{
long long a,b,t;
while(cin>>a>>b)
{
kt(a,b);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQga3QoaW50IGwsIGludCByKQp7CiAgICBib29sIHByaW1lW3IgLSBsICsgMV07CiAgICBtZW1zZXQocHJpbWUsdHJ1ZSxzaXplb2YocHJpbWUpKTsKICAgIGZvciAobG9uZyBsb25nIGkgPSAyOyBpICogaSA8PSByOyArK2kpCiAgICAgICAgewogICAgICAgIGZvciAobG9uZyBsb25nIGogPSBtYXgoaSAqIGksIChsICsgKGkgLSAxKSkgLyBpICAqIGkpOyBqIDw9IHI7IGogKz0gaSkKICAgICAgICB7CiAgICAgICAgICAgIHByaW1lW2ogLSBsXSA9IGZhbHNlOwogICAgICAgIH0KICAgIH0KICAgIGxvbmcgbG9uZyBqPTAsY3NpLGNzaixtYXh4PTAsbWlubj0xZTExOwogICAgIGZvciAobG9uZyBsb25nIGkgPSBtYXgobCwgMik7IGkgPD0gcjsgKytpKQogICAgewogICAgICAgIGlmIChwcmltZVtpIC0gbF0pCiAgICAgICAgewogICAgICAgICAgICBpZiAoaj09MCkgaj1pOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChpLWo8bWlubikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBtaW5uPWktajsKICAgICAgICAgICAgICAgICAgICBjc2k9aTsKICAgICAgICAgICAgICAgICAgICBjc2o9ajsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGo9aTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGlmIChtaW5uIT0xZTExKQogICAgewogICAgICAgIGNvdXQ8PGNzajw8IiwiPDxjc2k8PCIgYXJlIGNsb3Nlc3QiOwogICAgfQogICAgZm9yIChsb25nIGxvbmcgaSA9IG1heChsLCAyKTsgaSA8PSByOyArK2kpCiAgICB7CiAgICAgICAgaWYgKHByaW1lW2kgLSBsXSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChqPT0wKSBqPWk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKGktaj5tYXh4KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIG1heHg9aS1qOwogICAgICAgICAgICAgICAgICAgIGNzaT1pOwogICAgICAgICAgICAgICAgICAgIGNzaj1qOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaj1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgaWYgKG1heHghPTApCiAgICB7CiAgICAgICAgY291dDw8IiwgIjsKICAgICAgICBjb3V0PDxjc2o8PCIsIjw8Y3NpPDwiIGFyZSBtb3N0IGRpc3RhbnQuIiA8PGVuZGw7CiAgICAgICAgcmV0dXJuIDsKICAgIH0KICAgIGNvdXQ8PCJUaGVyZSBhcmUgbm8gYWRqYWNlbnQgcHJpbWVzLiI8PGVuZGw7Cn0KaW50IG1haW4oKQp7CiAgICBsb25nIGxvbmcgYSxiLHQ7CiAgICB3aGlsZShjaW4+PmE+PmIpCiAgICB7CiAgICAgICAga3QoYSxiKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==