#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, j, m, a, s, c, b, n, x, y, ar[1001];     cin >> n;     while (n--) {       cin >> s >> a >> b >> c;       x = s / c;       y = x / a * b;       cout << x + y << endl;     }     return 0;   }   