import std.stdio, std.string, std.conv;

immutable hurui = (int n){
    bool[] table = new bool[](n + 1);
    table[] = true;
    table[1] = false;
    for(int i = 2; i * i <= n; ++i)
    {
        for(int j = i + i; j <= n; j += i)
        {
            table[j] = false;
        }
    }
    return table;
}(50000);

void main()
{
    while(true)
    {
        string line = readln.chomp;
        if(line is null)break;
        auto num = line.chomp.to!int;
        for(int i = num - 1; i >= 0; --i)
        {
            if(hurui[i])
            {
                write(i, " ");
                break;
            }
        }

        for(int i = num + 1; i <= 50000; ++i)
        {
            if(hurui[i])
            {
                i.writeln;
                break;
            }
        }
    }
}