#include<iostream>
#include<cmath>
using namespace std;
int n,p,v,best=9999999;
int main(){
cin>>n;
while(cin>>p>>v){
if(n%p==n){best=min(best,p*v);continue;}
else if(n%p==0){best=min(best,v*(n/p));}
else if(n%p!=0){
best=min(best,v*(n/p+1));
}
}
cout<<best;
return 0;
}