#include <bits/stdc++.h>
using namespace std;
template<typename dataT>
struct nodeT{
    dataT val;
    nodeT<dataT> *left, *right;
    nodeT(){
        left = nullptr;
        right = nullptr;
        val = dataT();
    }
    nodeT(dataT v){
        nodeT();
        val = v;
    }
    dataT get_val(){
        return val;
    }
    void set_val(dataT x){
        val = x;
    }
    void add_to_val(dataT x){
        val = val + x;
    }
    void update(){
        val = dataT();
        if(left) val = val + left->get_val();
        if(right) val = val + right->get_val();
    }
};
template<typename dataT, typename boundT = int, boundT leftBound = 0, boundT rightBound = 100100>
struct dynamic_tree{
    using node = nodeT<dataT>;
    virtual node * get_node(node * before){
        if(before) return before;
        node * new_node = new node();
        return new_node;
    }
    node * root;
    void clear(){
        root = nullptr;
    }
    dynamic_tree(){
        clear();
    }
    node * get_root(){
        return root;
    }
    node * set_pos(node * cur, boundT l, boundT r, boundT pos, dataT val){
        cur = get_node(cur);
        if(l == r) cur->set_val(val);
        else{
            boundT mid = (l + r)>>1;
            if(pos <= mid) cur->left = set_pos(cur->left, l, mid, pos, val);
            else cur->right = set_pos(cur->right, mid + 1, r, pos, val);
            cur->update();
        }
        return cur;
    }
    node * set_pos(boundT pos, dataT val){
        root = set_pos(root, leftBound, rightBound, pos, val);
        return root;
    }
    node * set_pos(node * rt, boundT pos, dataT val){
        return set_pos(rt, leftBound, rightBound, pos, val);
    }
    node * add_to_pos(node * cur, boundT l, boundT r, boundT pos, dataT val){
        cur = get_node(cur);
        if(l == r) cur->add_to_val(val);
        else{
            boundT mid = (l + r)>>1;
            if(pos <= mid) cur->left = add_to_pos(cur->left, l, mid, pos, val);
            else cur->right = add_to_pos(cur->right, mid + 1, r, pos, val);
            cur->update();
        }
        return cur;
    }
    node * add_to_pos(boundT pos, dataT val){
        root = add_to_pos(root, leftBound, rightBound, pos, val);
        return root;
    }
    node * add_to_pos(node * rt, boundT pos, dataT val){
        return add_to_pos(rt, leftBound, rightBound, pos, val);
    }
    dataT query(node * cur, boundT l, boundT r, boundT x, boundT y){
        if(cur == nullptr || l > y || r < x) return dataT();
        if(x <= l && r <= y) return cur->get_val();
        boundT mid = (l + r)>>1;
        if(y <= mid) return query(cur->left, l, mid, x, y);
        if(x > mid) return query(cur->right, mid + 1, r, x, y);
        return query(cur->left, l, mid, x, y) + query(cur->right, mid + 1, r, x, y);
    }
    dataT query(boundT x, boundT y){
        return query(root, leftBound, rightBound, x, y);
    }
    dataT query(node * rt, boundT x, boundT y){
        return query(rt, leftBound, rightBound, x, y);
    }
};
const int maxn = 123456;
int main(){
	long long n, l, t; cin >> n >> l >> t;
	vector<long long> x(n), w(n);
	for(int i = 0; i < n; i++) cin >> x[i] >> w[i];
	dynamic_tree<long long, long long, 0, (long long)(1e9)> mv[2];
	for(int i = 0; i < n; i++){
		w[i]--;
		mv[w[i]].set_pos(x[i], 1);
	}
	vector<long long> ans(n);
	for(int i = 0; i < n; i++){
		int stp = 0;
		if(w[i] == 0){
			stp += mv[1].query(0, l) * (2 * t / l) % n;
			int from = x[i], to = (x[i] + (2 * t % l)) % l;
			if(from <= to) stp += mv[1].query(from, to);
			else stp += mv[1].query(0, to) + mv[1].query(from, l);
			ans[(i + stp) % n] = (x[i] + t) % l;
		} else {
			stp = n - (mv[0].query(0, l) * (2 * t / l) % n); stp %= n;
			int from = (x[i] - (2 * t % l) + l) % l, to = x[i];
			if(from <= to) stp += n - mv[0].query(from, to);
			else stp += n - (mv[0].query(0, to) + mv[0].query(from, l));
			stp %= n;
			ans[(i + stp) % n] = (x[i] + l - (t%l)) % l;
		}
	}
	for(int i = 0; i < n; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 48640