#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>

namespace lib
{
	template<std::uint64_t Mod>struct modnum;
	template<class T>constexpr T pow(T base, std::size_t p)
	{
		if (p == 0)
		{
			return T(1);
		}
		else if (p == 1)
		{
			return base;
		}
		else if (p == 2)
		{
			return base*base;
		}
		else if (p % 2 == 0)
		{
			return pow(pow(base, p / 2), 2);
		}
		else
		{
			return pow(pow(base, p / 2), 2)*base;
		}
	}
	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);

	template<std::uint64_t Mod>struct modnum
	{
		static constexpr auto mod = Mod;
		std::uint64_t val;
		modnum() = default;
		constexpr modnum(std::uint64_t v) :val(v%Mod)
		{

		}

		constexpr modnum& operator+=(modnum const& v)
		{
			val += v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator-=(modnum const& v)
		{
			val += mod - v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator*=(modnum const& v)
		{
			val *= v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator/=(modnum const& v)
		{
			return operator*=(inverse(v));
		}
	};
	template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs += rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs -= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs *= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs /= rhs;
	}

	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
	{
		return pow(base, Mod - 2);
	}

	template<class T>constexpr auto clamp(T v)
	{
		return std::max(v, T());
	}
	template<class T>void sort(std::vector<T>& vec)
	{
		std::sort(vec.begin(), vec.end());
	}

	template<class T>auto lower_bound(std::vector<T>const& vec, T v)
	{
		return std::distance(vec.begin(), std::lower_bound(vec.begin(), vec.end(), v));
	}
	template<class T>auto upper_bound(std::vector<T>const& vec, T v)
	{
		return std::distance(vec.begin(), std::upper_bound(vec.begin(), vec.end(), v));
	}


	template<class Tag>struct dmod
	{
		std::uint64_t val;
		static std::uint64_t mod;
		dmod(std::uint64_t v = 0) :val(v%mod)
		{

		}
		dmod& operator+=(dmod const& rhs)
		{
			val += rhs.val;
			val %= mod;
			return *this;
		}
		dmod& operator-=(dmod const& rhs)
		{
			val += mod - rhs.val;
			val %= mod;
			return *this;
		}
		dmod& operator*=(dmod const& rhs)
		{
			val *= rhs.val;
			val %= mod;
			return *this;
		}
	};
	template<class Tag>dmod<Tag> operator+(dmod<Tag> lhs, dmod<Tag> const& rhs)
	{
		return lhs += rhs;
	}
	template<class Tag>dmod<Tag> operator-(dmod<Tag> lhs, dmod<Tag> const& rhs)
	{
		return lhs -= rhs;
	}
	template<class Tag>dmod<Tag> operator*(dmod<Tag> lhs, dmod<Tag> const& rhs)
	{
		return lhs *= rhs;
	}
	template<class Tag>std::uint64_t dmod<Tag>::mod;

	struct scope_exit
	{
		std::function<void(void)> func;
		scope_exit(std::function<void(void)> f) :func(f)
		{

		}
		~scope_exit()
		{
			func();
		}
	};

	template<int val>using int_tag = std::integral_constant<int, val>;
}

void Main();
int main()	
{
	std::cin.tie(nullptr);
	std::cin.sync_with_stdio(false);
	Main();
}

typedef lib::modnum<1000000007> mod_t;

typedef lib::dmod<lib::int_tag<0>> N_t;
typedef lib::dmod<lib::int_tag<1>> L_t;
typedef lib::dmod<lib::int_tag<2>> L2_t;
int count(L_t x, L_t y, L_t T)
{
	auto d = T.val - (y - x).val / 2.0;
	return 2 * d / T.mod + 1;
}
void Main()
{
	std::int64_t N, L, T, X, W;
	std::cin >> N >> L >> T >> X >> W;
	L_t::mod = L;
	N_t::mod = N;
	L2_t::mod = 2 * L;
	std::vector<std::int64_t> result;
	if (W == 1)
	{
		result.emplace_back((L_t(X) + L_t(T)).val);
	}
	else
	{
		result.emplace_back((L_t(X) - L_t(T)).val);
	}
	auto start = result.front();
	N_t h{};
	for (int i = 1; i < N; ++i)
	{
		std::int64_t x;
		int w;
		std::cin >> x >> w;
		if (w == 1)
		{
			result.emplace_back((L_t(x) + L_t(T)).val);
			if (W == 2)
			{
				h -= count(x, X, T) + (2 * (T / L));
			}
		}
		else
		{
			result.emplace_back((L_t(x) - L_t(T)).val);
			if (W == 1)
			{
				h += count(X, x, T) + (2 * (T / L));
			}
		}
	}
	lib::sort(result);
	std::int64_t s = lib::lower_bound(result, start);
	std::int64_t x = lib::upper_bound(result, start);
	if (x - s == 2 && W == 1)
	{
		s += 1;
	}
	for (int i{}; i < N; ++i)
	{
		std::cout << result[(N_t(s) - h + N_t(i)).val] << std::endl;
	}
	//std::cout << start << " " << h.val << " " << s << std::endl;
}

Measured memory_bytes: 2164