#include <bits/stdc++.h>
using namespace std;
long long a, b;
long long BS(long long lo, long long hi) {
  long long mid, ret = hi, mx = (hi * a) / b;
  if (mx == 0) return 0;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    long long y = (mid * a) / b;
    if (y == mx)
      hi = mid - 1, ret = min(ret, mid);
    else
      lo = mid + 1;
  }
  return ret;
}
int main() {
  long long n, x;
  cin >> n >> a >> b;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    cout << x - BS(1, x) << " ";
  }
  cout << endl;
  return 0;
}
