#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, n;
  cin >> n >> a >> b;
  while (n--) {
    long long w;
    cin >> w;
    long long get = w * a / b;
    long long dum = get * b / a;
    while (dum * a / b != get) dum++;
    cout << w - dum << (n ? " " : "\n");
  }
}
