#include using namespace std; template void read(T &t) { t=0; char ch=getchar(); int f=1; while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f; } int T,n,m,x,y,ans,tmp; int main() { //freopen("1.txt","r",stdin); read(T); while (T--) { read(n); read(m); ans=(1e9); for (int i=1;i<=n;i++) { read(x); read(y); if (m%x==0) tmp=m/x*y; else tmp=(m/x+1)*y; ans=min(ans,tmp); } printf("%d\n",ans); } return 0; } /* 0. Enough array size? Enough array size? Enough array size? Interger overflow? 1. Think TWICE, Code ONCE! Are there any counterexamples to your algo? 2. Be careful about the BOUNDARIES! N=1? P=1? Something about 0? 3. Do not make STUPID MISTAKES! Time complexity? Memory usage? Precision error? */