#include<bits/stdc++.h>
using namespace std;
int a,b,a1,b1,l;
int fun(int x,int y)
{
cin>>x>>y;
while(x%y!=0)
{
int t=x;
x=y;
y=x%y;
}
return y;
}
int main()
{
cin>>a>>b>>l;
for(int i=1;i<=l;i++)
{
for(int j=1;j<=l;j++)
{
if(fun(i,j)==1&&(i*1.0/j>=a*1.0/b))
{
if(a1==0)
{
a1=i;b1=j;
}
else if((i*1.0/j)<(a1*1.0/b1))
{
a1=i;b1=j;
}
}
}
}
cout<<a1<<" "<<b1<<endl;
return 0;
}
球条