/*************************************************************************
> File Name: 10140.cpp
> Author: Toy
> Mail: ycsgldy@163.com
> Created Time: 2013年06月01日 星期六 09时52分32秒
************************************************************************/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
const int INF = 0x7fffffff;
typedef pair<int,int> II;
typedef vector<int> IV;
typedef vector<II> IIV;
typedef vector<bool> BV;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned int u32;
#define For(t,v,c) for(t::const_iterator v=c.begin(); v!=c.end(); ++v)
#define IsComp(n) (_c[n>>6]&(1<<((n>>1)&31)))
#define SetComp(n) _c[n>>6]|=(1<<((n>>1)&31))
const int MAXP = 46341;
const int SQRP = 216;
int _c[(MAXP>>6)+1];
IV primes;
IV prime;
void prime_sieve ( ) {
for ( int i = 3; i <= SQRP; i += 2 )
if ( !IsComp ( i ) ) for ( int j = i * i; j <= MAXP; j += i + i ) SetComp ( j );
primes.push_back ( 2 );
for ( int i = 3; i <= MAXP; i += 2 ) if ( !IsComp ( i ) ) primes.push_back ( i );
}
void prime_seg_sieve ( i64 a, i64 b, IV &seg_primes ) {
BV pmap ( b - a + 1, true );
i64 sqr_b = sqrt ( b );
For ( IV, it, primes ) {
int p = *it;
if ( p > sqr_b ) break;
for ( i64 j = ( a + p - 1 ) / p, v = ( j == 1 ? p + p : j * p ); v <= b; v += p ) pmap[v - a] = false;
}
seg_primes.clear();
if ( a == 1 ) pmap[0] = false;
for ( int i = 0, I = b - a + 1; i < I; ++i ) if ( pmap[i] ) seg_primes.push_back ( a + i );
}
long long L, U;
int C1, C2, D1, D2, cnt;
int main ( ) {
prime_sieve ( );
while ( scanf ( "%lld%lld", &L, &U ) == 2 ) {
prime_seg_sieve ( L, U, prime );
cnt = prime.size();
if ( cnt < 2 ) printf ( "There are no adjacent primes.\n" );
else {
int min = INF, max = 0;
for ( int i = 1; i < cnt; ++i ) {
int tmp = prime[i] - prime[i - 1];
if ( tmp < min ) min = tmp, C1 = prime[i - 1], C2 = prime[i];
if ( tmp > max ) max = tmp, D1 = prime[i - 1], D2 = prime[i];
}
printf ( "%d,%d are closest, %d,%d are most distant.\n", C1, C2, D1, D2 );
}
}
return 0;
}