#include #include #include #include #include using namespace std; template inline void R(Type &x) { int c = getchar(); bool neg = 0; for (; c < 48 || c > 57; c = getchar())if (c == '-')neg = true; for (x = 0; c > 47 && c < 58; x = (Type) 10 * x + c - 48, c = getchar()); if (neg)x = -x; } const int INF = 0x3f3f3f3f; int T, n, m, x[101], y[101]; int main() { R(T); while (T--) { int ans = INF; R(n); R(m); for (int i = 1; i <= n; ++i) { R(x[i]); R(y[i]); int tmp = m / x[i]; if (m % x[i]) ans = min(ans, (tmp + 1) * y[i]); else ans = min(ans, tmp * y[i]); } printf("%d\n", ans); } return 0; }