import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    auto ns = stdin.byLine().map!(to!int).array();
    immutable m = ns.reduce!max()*2;
    auto p = new bool[m];
    foreach(i;2..m) if(!p[i])
        for(int j=2; i*j<m; ++j) p[i*j]=true;
    int search(int n,int d)
    {
        for(int i=n+d; 0<=i && i<m; i+=d)
            if(!p[i]) return i;
        return -1;
    }
    ns.map!(n=>[search(n,-1),search(n,1)].map!(to!string).join(" ")).join("\n").writeln();
}