#include <bits/stdc++.h>
using namespace std;

// template {{{
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define sort_by(x, y) sort(all(x), [&](const auto& a, const auto& b) { return y; })

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

namespace __algorithm {
    template<typename T> void dedup(vector<T>& v) {
        sort(all(v)); v.erase(unique(all(v)), v.end());
    }
    template<typename T> typename vector<T>::iterator find(vector<T>& v, const T& x) {
        auto it = lower_bound(all(v), x); return it != v.end() && *it == x ? it : v.end();
    }
    template<typename T> int index(vector<T>& v, const T& x) {
        auto it = find(v, x); assert(it != v.end() && *it == x); return int(it - v.begin());
    }
    template<typename C, typename T, typename OP> vector<T> prefixes(const C& v, T id, OP op) {
        vector<T> r(sz(v)+1, id); F0R (i, sz(v)) r[i+1] = op(r[i], v[i]); return r;
    }
    template<typename C, typename T, typename OP> vector<T> suffixes(const C& v, T id, OP op) {
        vector<T> r(sz(v)+1, id); F0Rd (i, sz(v)) r[i] = op(v[i], r[i+1]); return r;
    }
}
using namespace __algorithm;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
struct monostate {
    friend istream& operator>>(istream& is, const monostate& ms) { return is; }
    friend ostream& operator<<(ostream& os, const monostate& ms) { return os; }
    friend monostate operator+(const monostate& a, const monostate& b) { return a; }
} ms;
#pragma GCC diagnostic pop

namespace __io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.precision(15);
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
    }
}
using namespace __io;
// }}}

ll compute(ll t, ll l, ll d) {
    // cout << t << " " << l << " " << d << " (Compute) " << endl;
    ll ans = 2 * (t / l);
    t %= l;
    if (2*t < d) {
        return ans;
    } else if (2*t < d + l) {
        return ans + 1;
    } else {
        return ans + 2;
    }
}

int main() {
    setIO();
    
    ll N, L, T;
    cin >> N >> L >> T;

    vll X(N);
    vi W(N);

    for (int i=0;i<N;i++) cin >> X[i] >> W[i];

    ll num_coll = 0;
    for (int i=1;i<N;i++) {
        if (W[0] != W[i]) {
            ll d = X[i] - X[0];
            if (W[0] == 2) d = L - d;
            num_coll += compute(T, L, d);
        }
    }

    // cout << num_coll << endl;

    vpll npos(N);
    for (int i=0;i<N;i++) {
        ll nx = 0;
        if (W[i] == 1) {
            nx = (X[i] + T) % L;
        } else {
            nx = (X[i] - T) % L;
            nx = (nx + L) % L;
        }
        npos[i] = mp(nx, -W[i]);
    }
    auto p0 = npos[0];
    // cout << p0.first << " " << p0.second << endl;
    sort(npos.begin(), npos.end());

    ll C = (num_coll % N);
    if (W[0] == 2) C = N-C;
    vll ans(N);

    for (int i=0;i<N;i++) {
        if (npos[i] == p0) {
            for (int j=0;j<N;j++) {
                ans[(C+j) % N] = npos[(i+j) % N].first;
            }

            for (int j=0;j<N;j++) cout << ans[j] << "\n";

            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4736