#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class People
{
public:
	People(){}
	People(long long int n, long long int pos, bool stopflag) : n(n), pos(pos), stopflag(stopflag){}
	long long int n, pos;
	bool stopflag;
};
bool operator<(const People& p1, const People& p2)
{
	return p1.pos < p2.pos;
}

int main()
{
	long long int n, t, q;
	cin >> n >> t >> q;

	vector<People> left;
	vector<People> right;
	for (int i = 1; i <= n; i++)
	{
		long long int a, d;
		cin >> a >> d;
		if (d == 1) right.push_back(People(i, a, false));
		if (d == 2) left.push_back(People(i, a, false));
	}
	for (int i = right.size() - 1; i >= 0; i--)
	{
		auto itr = lower_bound(begin(left), end(left), right[i]);
		if (itr == end(left)) continue;
		if (itr->stopflag)
		{
			if (right[i].pos + t >= itr->pos)
			{
				right[i].stopflag = true;
				right[i].pos = itr->pos;
			}
		}
		else
		{
			if (right[i].pos + t >= itr->pos - t)
			{
				right[i].stopflag = true;
				itr->stopflag = true;
				long long int p = (right[i].pos + itr->pos) / 2;
				right[i].pos = p;
				itr->pos = p;
			}
		}
	}
	for (int i = 0; i < left.size(); i++)
	{
		if (left[i].stopflag) continue;
		auto itr = lower_bound(begin(right), end(right), left[i]);
		if (itr == begin(right)) continue;
		itr--;
		if (itr->stopflag)
		{
			if (left[i].pos - t <= itr->pos)
			{
				left[i].stopflag = true;
				left[i].pos = itr->pos;
			}
		}
		else
		{
			if (left[i].pos - t <= itr->pos + t)
			{
				left[i].stopflag = true;
				itr->stopflag = true;
				long long int p = (left[i].pos + itr->pos) / 2;
				left[i].pos = p;
				itr->pos = p;
			}
		}
	}
	for (int i = 0; i < left.size(); i++)
	{
		if (!left[i].stopflag) left[i].pos -= t;
	}
	for (int i = 0; i < right.size(); i++)
	{
		if (!right[i].stopflag) right[i].pos += t;
	}

	for (int i = 0; i < q; i++)
	{
		int a;
		cin >> a;
		for (int j = 0; j < left.size(); j++)
		{
			if (left[j].n == a)
			{
				cout << left[j].pos << endl;
				break;
			}
		}
		for (int j = 0; j < right.size(); j++)
		{
			if (right[j].n == a)
			{
				cout << right[j].pos << endl;
				break;
			}
		}
	}

	return 0;
}