#include <iostream>

using namespace std;

const int MAX_P = 50001;
bool p[MAX_P];  // prime table

void init()
{
    for (int i = 0; i < MAX_P; i++)
        p[i] = true;

    p[0] = p[1] = false;
    for (int i = 2; i * i < MAX_P; i++) {
        if (p[i]) {
            for (int j = i * 2; j < MAX_P; j += i)
                p[j] = false;
        }
    }
}

int main()
{
    int n;

    init();

    while (cin >> n) {
        int min, max;

        min = max = n;
        while (--min >= 2) 
            if (p[min])
                break;
        while (++max <= MAX_P) 
            if (p[max])
                break;

        cout << min << " " << max << endl;
    }

    return 0;
}