#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    double original_ratio = static_cast<double>(x) / y;

    int n;
    cin >> n;

    int best_width = 0, best_height = 0;
    double min_difference = DBL_MAX;
    int min_area = INT_MAX;

    for (int i = 0; i < n; ++i) {
        int w, h;
        cin >> w >> h;
        double current_ratio = static_cast<double>(w) / h;
        double difference = abs(original_ratio - current_ratio);
        int area = w * h;

        if (difference < min_difference) {
            min_difference = difference;
            min_area = area;
            best_width = w;
            best_height = h;
        } else if (difference == min_difference && area < min_area) {
            min_area = area;
            best_width = w;
            best_height = h;
        }
    }

    cout << best_width << " " << best_height << endl;

    return 0;
}
/**************************************************************
	Problem: 1346
	User: panyuchen
	Language: C++
	Result: Compile Error
****************************************************************/