#include <bits/stdc++.h>
int w = 0;
int const oo = (int)10e6;
using namespace std;
char vowels[] = {'a', 'o', 'e', 'u', 'i'};
int A[2 * 100000];
long long n, m;
bool cycle = false;
bitset<64> bt;
set<int> st;
vector<bool> comp;
vector<bool> vis;
vector<bool> vis2;
vector<vector<int>> v;
map<int, int> mp;
map<char, int> mp2;
priority_queue<long long, vector<long long>, greater<long long>> pq;
bool viss[100][100] = {0};
int l1, l2;
int saved[100][100];
long long savedans[100000] = {1};
vector<pair<long long, long long>> v2;
vector<pair<int, int>> vv;
vector<long long> vc;
vector<long long> va;
char gr[1000][1000];
bool even(long long x) { return ((n & 1) == 0) ? 1 : 0; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long n, long long m) { return (n * m) / gcd(n, m); }
string toBinary(int n) {
  string r;
  while (n != 0) {
    r = (n % 2 == 0 ? "0" : "1") + r;
    n /= 2;
  }
  return r;
}
bool prime(long long n) {
  if (n == 0 || n == 1) return 1;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
bool isvowels(char a) {
  for (int i = 0; i < 5; i++)
    if (a == vowels[i]) return true;
  return false;
}
long long binary_search(long long x, long long y) {
  int l = 0, r = y, mid;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (mid * (mid + 1) == x)
      break;
    else if (mid * (mid + 1) >= x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (mid * (mid + 1) == x)
    return mid;
  else
    return -1;
}
bool bal(string z) {
  string x = z;
  reverse(x.begin(), x.end());
  if (z == x)
    return true;
  else
    return false;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
bool F(int i, long long sum) {
  if (i == n) return sum % m == 0;
  if (savedans[i] != -1) return savedans[i];
  if (F(i + 1, sum + vc[i]) || F(i + 1, sum - vc[i])) return 1;
  return 0;
}
int FEB(int n) {
  if (n <= 1) return 1;
  if (savedans[n] != -1) return savedans[n];
  return savedans[n] = FEB(n - 1) + FEB(n - 2);
}
int arr1[100005] = {-1}, arr2[100005] = {-1};
long long minn;
void Dfs(int u, int p, int c) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (!vis[v[u][i]]) Dfs(v[u][i], u, c);
  }
  return;
}
int find(int u) {
  if (A[u] == u)
    return u;
  else
    return A[u] = find(A[u]);
}
bool valied(int x, int y) {
  if (x >= n || y >= m || x < 0 || y < 0) return 0;
  return 1;
}
int maxxx(int x, int y) {
  if (!valied) return 0;
  if (saved[x][y] != -1) return saved[x][y];
}
string ok = "YES", no = "NO";
map<pair<int, int>, int> mpp;
int bi_s(int x, int f) {
  int l = 0, r = n - 1, mid;
  if (f != -1) l = f + 1;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (f != -1) {
      if (vc[mid] - vc[f] > x)
        r = mid - 1;
      else if (vc[mid] - vc[f] < x)
        l = mid + 1;
      else
        break;
    } else {
      if (vc[mid] > x)
        r = mid - 1;
      else if (vc[mid] < x)
        l = mid + 1;
      else
        break;
    }
  }
  return mid;
}
bool anns = false;
vector<long long> cost;
long long miiiin = INT_MAX;
void CDfs(int u, int p, int nw) {
  if (vis2[u]) return;
  miiiin = min(miiiin, cost[u]);
  vis2[u] = 1;
  for (int i = 0; i < v[u].size(); i++)
    if (v[u][i] != p) CDfs(v[u][i], u, nw);
}
bool fff = false;
void fs(int u, int p) {
  if (vis[u]) {
    cycle = true;
    return;
  }
  vis[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (comp[v[u][i]]) fff = true;
    if (!vis[v[u][i]]) fs(v[u][i], u);
  }
  comp[u] = true;
}
long long b_search(long long x, long long maa) {
  long long l = 0, r = x, mid, ans = 0;
  while (l <= r) {
    mid = l + (r - l) / 2;
    long long mm = maa;
    long long sum = 0;
    long long c = 0;
    for (int i = 0; i < n; i++) {
      long long md = (v2[i].first * mid);
      if (md <= v2[i].second)
        c++;
      else {
        long long s = v2[i].first * mid - v2[i].second;
        if (sum + s <= mm && s >= 0)
          c++, sum += s;
        else
          break;
      }
    }
    if (c < n) {
      r = mid - 1;
    } else if (c >= n) {
      l = mid + 1;
      if (c == n) ans = max(mid, ans);
    }
  }
  return ans;
}
int main() {
  int t;
  long long a, b, c, s;
  cin >> t;
  for (int i = 0; i < t; i++) {
    scanf("%lld %lld %lld %lld", &s, &a, &b, &c);
    long long aa = s / c;
    cout << aa + (aa / a) * b << "\n";
  }
}

### Prompt

Your task is to create a CPP solution to the following problem:

There is a special offer in Vasya's favourite supermarket: if the customer buys a chocolate bars, he or she may take b additional bars for free. This special offer can be used any number of times.

Vasya currently has s roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs c roubles. Help Vasya to calculate the maximum possible number of chocolate bars he can get!

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of testcases.

Each of the next t lines contains four integers s, a, b, c~(1 ≤ s, a, b, c ≤ 10^9) — the number of roubles Vasya has, the number of chocolate bars you have to buy to use the special offer, the number of bars you get for free, and the cost of one bar, respectively.

Output

Print t lines. i-th line should contain the maximum possible number of chocolate bars Vasya can get in i-th test.

Example

Input

2
10 3 1 1
1000000000 1 1000000000 1


Output

13
1000000001000000000

Note

In the first test of the example Vasya can buy 9 bars, get 3 for free, buy another bar, and so he will get 13 bars.

In the second test Vasya buys 1000000000 bars and gets 1000000000000000000 for free. So he has 1000000001000000000 bars.

### Response

```cpp
#include <bits/stdc++.h>
int w = 0;
int const oo = (int)10e6;
using namespace std;
char vowels[] = {'a', 'o', 'e', 'u', 'i'};
int A[2 * 100000];
long long n, m;
bool cycle = false;
bitset<64> bt;
set<int> st;
vector<bool> comp;
vector<bool> vis;
vector<bool> vis2;
vector<vector<int>> v;
map<int, int> mp;
map<char, int> mp2;
priority_queue<long long, vector<long long>, greater<long long>> pq;
bool viss[100][100] = {0};
int l1, l2;
int saved[100][100];
long long savedans[100000] = {1};
vector<pair<long long, long long>> v2;
vector<pair<int, int>> vv;
vector<long long> vc;
vector<long long> va;
char gr[1000][1000];
bool even(long long x) { return ((n & 1) == 0) ? 1 : 0; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long n, long long m) { return (n * m) / gcd(n, m); }
string toBinary(int n) {
  string r;
  while (n != 0) {
    r = (n % 2 == 0 ? "0" : "1") + r;
    n /= 2;
  }
  return r;
}
bool prime(long long n) {
  if (n == 0 || n == 1) return 1;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
bool isvowels(char a) {
  for (int i = 0; i < 5; i++)
    if (a == vowels[i]) return true;
  return false;
}
long long binary_search(long long x, long long y) {
  int l = 0, r = y, mid;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (mid * (mid + 1) == x)
      break;
    else if (mid * (mid + 1) >= x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (mid * (mid + 1) == x)
    return mid;
  else
    return -1;
}
bool bal(string z) {
  string x = z;
  reverse(x.begin(), x.end());
  if (z == x)
    return true;
  else
    return false;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
bool F(int i, long long sum) {
  if (i == n) return sum % m == 0;
  if (savedans[i] != -1) return savedans[i];
  if (F(i + 1, sum + vc[i]) || F(i + 1, sum - vc[i])) return 1;
  return 0;
}
int FEB(int n) {
  if (n <= 1) return 1;
  if (savedans[n] != -1) return savedans[n];
  return savedans[n] = FEB(n - 1) + FEB(n - 2);
}
int arr1[100005] = {-1}, arr2[100005] = {-1};
long long minn;
void Dfs(int u, int p, int c) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (!vis[v[u][i]]) Dfs(v[u][i], u, c);
  }
  return;
}
int find(int u) {
  if (A[u] == u)
    return u;
  else
    return A[u] = find(A[u]);
}
bool valied(int x, int y) {
  if (x >= n || y >= m || x < 0 || y < 0) return 0;
  return 1;
}
int maxxx(int x, int y) {
  if (!valied) return 0;
  if (saved[x][y] != -1) return saved[x][y];
}
string ok = "YES", no = "NO";
map<pair<int, int>, int> mpp;
int bi_s(int x, int f) {
  int l = 0, r = n - 1, mid;
  if (f != -1) l = f + 1;
  while (l <= r) {
    mid = l + (r - l) / 2;
    if (f != -1) {
      if (vc[mid] - vc[f] > x)
        r = mid - 1;
      else if (vc[mid] - vc[f] < x)
        l = mid + 1;
      else
        break;
    } else {
      if (vc[mid] > x)
        r = mid - 1;
      else if (vc[mid] < x)
        l = mid + 1;
      else
        break;
    }
  }
  return mid;
}
bool anns = false;
vector<long long> cost;
long long miiiin = INT_MAX;
void CDfs(int u, int p, int nw) {
  if (vis2[u]) return;
  miiiin = min(miiiin, cost[u]);
  vis2[u] = 1;
  for (int i = 0; i < v[u].size(); i++)
    if (v[u][i] != p) CDfs(v[u][i], u, nw);
}
bool fff = false;
void fs(int u, int p) {
  if (vis[u]) {
    cycle = true;
    return;
  }
  vis[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (comp[v[u][i]]) fff = true;
    if (!vis[v[u][i]]) fs(v[u][i], u);
  }
  comp[u] = true;
}
long long b_search(long long x, long long maa) {
  long long l = 0, r = x, mid, ans = 0;
  while (l <= r) {
    mid = l + (r - l) / 2;
    long long mm = maa;
    long long sum = 0;
    long long c = 0;
    for (int i = 0; i < n; i++) {
      long long md = (v2[i].first * mid);
      if (md <= v2[i].second)
        c++;
      else {
        long long s = v2[i].first * mid - v2[i].second;
        if (sum + s <= mm && s >= 0)
          c++, sum += s;
        else
          break;
      }
    }
    if (c < n) {
      r = mid - 1;
    } else if (c >= n) {
      l = mid + 1;
      if (c == n) ans = max(mid, ans);
    }
  }
  return ans;
}
int main() {
  int t;
  long long a, b, c, s;
  cin >> t;
  for (int i = 0; i < t; i++) {
    scanf("%lld %lld %lld %lld", &s, &a, &b, &c);
    long long aa = s / c;
    cout << aa + (aa / a) * b << "\n";
  }
}

```