#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i=a;i<(ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
void YN(bool a) { cout << (a ? "Yes" : "No") << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
void show(){ cout << endl; }
template <class Head, class... Tail>
void show(Head&& head, Tail&&... tail){ cout << head << " "; show(std::forward<Tail>(tail)...); }
template<class T> inline void showall(T& a) { for(auto v:a) cout<<v<<" "; cout<<endl; }

void solve()
{
  ll t;
  cin >> t;
  rep(ti, t)
  {
    ll l, r;
    cin >> l >> r;

    ll ans = 0;
    if (r < l * 2) ans = 0;
    else if (r == l * 2) ans = 1;
    else {
      r -= (l - 1) * 2 + 1;
      ans = (r) * (r + 1) / 2;
    }
    show(ans);
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}
#include <bits/stdc++.h>
/*#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <sstream>*/

#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ep emplace_back

using namespace std;

const long long MOD = 1e9+7;
const long long N = 1e9+5;
const long long Nlog = 17;
const long long Hash = 257;

const double PI = 2.0*acos(0.0);//<cmath>
//const double PI = 3.141592653;
const double E = 2.718281828;

bool cmp(pair<ll, int> a, pair<ll, int> b){
    return a.X<b.X;
}

void solve(){
    
    int k;
    ll n, m;
    cin >> k >> n >> m;
    ll a[k];
    fop(i,0,k) cin >> a[i];
    
    ll l[k], num = m;
    pair<ll, int> c[k];
    fop(i,0,k){
        l[i] = m*a[i]/n;
        c[i].X = (n*l[i])-(m*a[i]);
        c[i].Y = i;
        num-=l[i];
    }
    
    ll ans[k];
    fop(i,0,k) ans[i] = l[i];
    sort(c, c+k, cmp);
    fop(i,0,num) ans[c[i].Y]++;
    
    fop(i,0,k) cout << ans[i] << ' ';
    
}


int main()
{
    fastIO;

    int t=1;
    //cin >> t;
    while(t--) solve();

    return 0;
}