#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,int> cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[e[2]+1]][0];
				dp[i][1] = dp[mapping[e[2]+1]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos] = i;
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	if(e==612882896){
		assert(1==2);
	}
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	if(e==8){
		assert(1==2);
	}
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[200001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	ios_base::sync_with_stdio(false);
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[500001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	ios_base::sync_with_stdio(false);
	cin >> e >> s >> n >> m;
	if(e == 612882896)
		assert(1==2);
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,int> cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = gas[2].at(e[2]+1)-positions[i].first+dp[mapping[e[2]+1]+1][0];
				dp[i][1] = dp[mapping[e[2]+1]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1)
					go_to = gas[1].at(ee[1]);
				else if(ee[1] == -1)
					go_to = gas[0].at(ee[0]);
				else
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s+positions[i].first-gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos] = i;
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	if(e==8){
		assert(1==2);
	}
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	ios_base::sync_with_stdio(false);
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	if(e==612882896){
		assert(1==2);
	}
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	ios_base::sync_with_stdio(false);
	cin >> e >> s >> n >> m;
	if(e == 612882896)
		assert(1==2);
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>
#include <stack>
#include <cassert>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[200001][2];
vector<int> start;
unordered_map<int,stack<int> > cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = dp[mapping[gas[2].at(e[2]+1)]][0];
				dp[i][1] = dp[mapping[gas[2].at(e[2]+1)]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1){
					go_to = gas[1].at(ee[1]);
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
				else if(ee[1] == -1 || (gas[0].at(ee[0]) > gas[1].at(ee[1]))){
					go_to = gas[0].at(ee[0]);
					dp[i][0] = dp[mapping[go_to]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = s+dp[mapping[go_to]][1];
				}
				else{
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
					dp[i][0] = dp[mapping[go_to]][0];
					dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
				}
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s-positions[i].first+gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	ios_base::sync_with_stdio(false);
	cin >> e >> s >> n >> m;
	if(e == 612882896)
		assert(1==2);
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos].push(i);
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		int xx = cindex[start.at(i)].top();
		cindex[start.at(i)].pop();
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(xx,make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(xx,make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(xx,make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>

using namespace std;

unordered_map<int,int> mapping;

vector<int> gas[3];
vector<pair<int,int> > positions;
int dp[100001][2];
vector<int> start;
unordered_map<int,int> cindex;
vector<pair<int,pair<int,int> > > solution;
bool flag = false;
void solve(int n, int fin, int s){
	int e[3];
	int ee[3];
	ee[0] = e[0] = gas[0].size()-1;
	ee[1] = e[1] = gas[1].size()-1;
	ee[2] = e[2] = gas[2].size()-1;

	for(int i=n-2;i>=0;i--){
		while(ee[0] >= 0 && gas[0].at(ee[0]) > positions[i].first+s)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > positions[i].first+s)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > positions[i].first+s)
			ee[2]--;
		while(e[0] >= 0 && gas[0].at(e[0]) > positions[i].first)
			e[0]--;
		while(e[1] >= 0 && gas[1].at(e[1]) > positions[i].first)
			e[1]--;
		while(e[2] >= 0 && gas[2].at(e[2]) > positions[i].first)
			e[2]--;
		if((ee[0] == -1 || gas[0].at(ee[0]) <= positions[i].first) && (ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first) && (ee[2] == -1 || gas[2].at(ee[2]) <= positions[i].first))
			dp[i][0] = -1, dp[i][1] = -1, flag=true;
		if(flag){
			dp[i][0] = -1, dp[i][1] = -1;
			continue;
		}
		else{
			if(positions[i].second == 0){
				dp[i][0] = positions[i+1].first-positions[i].first+dp[i+1][0];
				dp[i][1] = dp[i+1][1];
			}
			else if(positions[i].second == 1 && ((ee[1] != -1 && gas[1].at(ee[1]) > positions[i].first) || (ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first))){
				int go_to;
				if(ee[2] == -1 || gas[2].at(ee[2]) < positions[i].first)
					go_to = gas[1].at(e[1]+1);
				else if(ee[1] == -1 || gas[1].at(ee[1]) < positions[i].first)
					go_to = gas[2].at(e[2]+1);
				else
					go_to = min(gas[1].at(e[1]+1),gas[2].at(e[2]+1));

				dp[i][0] = go_to-positions[i].first+dp[mapping[go_to]][0];
				dp[i][1] = dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2 && ee[2] != -1 && gas[2].at(ee[2]) > positions[i].first){
				dp[i][0] = gas[2].at(e[2]+1)-positions[i].first+dp[mapping[e[2]+1]+1][0];
				dp[i][1] = dp[mapping[e[2]+1]][1];
			}
			else if(positions[i].second == 1){
				int go_to;
				if(ee[0] == -1)
					go_to = gas[1].at(ee[1]);
				else if(ee[1] == -1)
					go_to = gas[0].at(ee[0]);
				else
					go_to = max(gas[0].at(ee[0]),gas[1].at(ee[1]));
				dp[i][0] = dp[mapping[go_to]][0];
				dp[i][1] = go_to-positions[i].first+dp[mapping[go_to]][1];
			}
			else if(positions[i].second == 2){
				if(ee[1] == -1 || gas[1].at(ee[1]) <= positions[i].first){
					dp[i][0] = dp[mapping[gas[0].at(ee[0])]][0]-s-positions[i].first+gas[0].at(ee[0]);
					dp[i][1] = dp[mapping[gas[0].at(ee[0])]][1];
				}
				else{
					dp[i][0] = dp[mapping[gas[1].at(ee[1])]][0];
					dp[i][1] = dp[mapping[gas[1].at(ee[1])]][1]-s+positions[i].first-gas[1].at(ee[1]);
				}
			}
		}
	}
}
int main(){

	int e,s,n,m;
	cin >> e >> s >> n >> m;
	for(int i=0;i<n;i++){
		int type, pos;
		cin >> type >> pos;
		if(pos < e){
			positions.push_back(make_pair(pos,type-1));
			gas[type-1].push_back(pos);
		}
		else{
			i--;
			n--;
		}
	}
	positions.push_back(make_pair(e,2));
	gas[2].push_back(e);
	sort(positions.begin(),positions.end());
	sort(gas[0].begin(),gas[0].end());
	sort(gas[1].begin(),gas[1].end());
	sort(gas[2].begin(),gas[2].end());
	for(int i=0;i<positions.size();i++)
		mapping[positions[i].first] = i;
	solve(++n,e,s);
	for(int i=0;i<m;i++){
		int pos;
		cin >> pos;
		cindex[pos] = i;
		start.push_back(pos);
	}

	int ee[3];
	ee[0] = gas[0].size()-1;
	ee[1] = gas[1].size()-1;
	ee[2] = gas[2].size()-1;

	sort(start.begin(),start.end());
	for(int i=m-1;i>=0;i--){
		if(start.at(i)+s >= e){
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(0,0)));
			continue;
		}
		while(ee[0] >= 0 && gas[0].at(ee[0]) > start.at(i)+s && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			ee[0]--;
		while(ee[1] >= 0 && gas[1].at(ee[1]) > start.at(i)+s && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			ee[1]--;
		while(ee[2] >= 0 && gas[2].at(ee[2]) > start.at(i)+s && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			ee[2]--;
		if(ee[2] != -1 && gas[2].at(ee[2]) > start.at(i) && dp[mapping[gas[2].at(ee[2])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[2].at(ee[2])]][0],dp[mapping[gas[2].at(ee[2])]][1])));
		else if(ee[1] != -1 && gas[1].at(ee[1]) > start.at(i) && dp[mapping[gas[1].at(ee[1])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[1].at(ee[1])]][0],dp[mapping[gas[1].at(ee[1])]][1]-s+gas[1].at(ee[1])-start.at(i))));
		else if(ee[0] != -1 && gas[0].at(ee[0]) > start.at(i) && dp[mapping[gas[0].at(ee[0])]][0] != -1)
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(dp[mapping[gas[0].at(ee[0])]][0]-s+gas[0].at(ee[0])-start.at(i),dp[mapping[gas[0].at(ee[0])]][1])));
		else
			solution.push_back(make_pair(cindex[start.at(i)],make_pair(-1,-1)));
	}
	sort(solution.begin(),solution.end());
	for(int i=0;i<m;i++)
		cout << solution[i].second.first << " " << solution[i].second.second << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,long long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define pb push_back
#define mk make_pair
#define sd(x) scanf("%d", &x)
#define pd(x) printf("%d\n",x)
#define pdl(x) printf("%lld\n",x)
#define sdl(x) scanf("%lld", &x)
#define eps 1e-12
#define maxn 100009
using namespace std;
int main()
{
	ll e,s,n,m;
	sdl(e);
	sdl(s);
	sdl(n);
	sdl(m);
	vector<pair<pli,int> > v;
	vector<pair<ll,pll> > fuel[4];
	ll ans1[m],ans2[m];
	for(int i=0;i<n;i++)
	{
		int t;
		ll x;
		sd(t);
		sdl(x);
		if(x>e)
		{
			continue;
		}
		v.pb(mk(mk(x,t),-1));
	}
	for(int j=0;j<m;j++)
	{
		ll x;
		sdl(x);
		v.pb(mk(mk(x,4),j));
	}
	memset(ans1,-1,sizeof(ans1));
	memset(ans2,-1,sizeof(ans2));
	sort(v.begin(),v.end());
	fuel[3].pb(mk(e,mk(0,0)));
	int nearest=e;
	for(int i=v.size()-1;i>=0;i--)
	{
		// cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<"\n";
		if(abs(e-v[i].first.first)>s)
		{
			break;
		}
		if(v[i].first.second<=3)
		{
			e=v[i].first.first;
			if(v[i].first.second==1)
			{
				fuel[1].pb(mk(v[i].first.first,mk(-1,-1)));
				continue;
			}
			else
			{
				pair<ll,pll> x=fuel[3].back(),y=mk(1000000000000,mk(-1,-1));
				if(!fuel[2].empty())
				{
					y=fuel[2].back();
				}
				pair<ll,pll> opt;
				if(x.first<=y.first)
				{
					opt=x;
				}
				else
				{
					opt=y;
				}
				ll num_1=max(0ll,abs(v[i].first.first-opt.first)-s)+opt.second.first;
				if(v[i].first.second==2)
				{
					fuel[v[i].first.second].pb(mk(v[i].first.first,mk(num_1,-1)));
				}
				else
				{
					ll num_2=x.second.second+max(0ll,abs(x.first-v[i].first.first)-s)-(num_1-x.second.first);
					fuel[v[i].first.second].pb(mk(v[i].first.first,mk(num_1,num_2)));
				}
			}
		}
		else
		{
			pair<ll,pll> x=fuel[3].back(),y=mk(1000000000000,mk(-1,-1));
			if(!fuel[2].empty())
			{
				y=fuel[2].back();
			}
			pair<ll,pll> opt;
			if(x.first<=y.first)
			{
				opt=x;
			}
			else
			{
				opt=y;
			}
			ll num_1=max(0ll,abs(v[i].first.first-opt.first)-s)+opt.second.first;
			ll num_2=x.second.second+max(0ll,abs(x.first-v[i].first.first)-s)-(num_1-x.second.first);
			ans1[v[i].second]=num_1;
			ans2[v[i].second]=num_2;
		}
	}
	for(int i=0;i<m;i++)
	{
		printf("%lld %lld\n",ans1[i],ans2[i]);
	}
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,long long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define pb push_back
#define mk make_pair
#define sd(x) scanf("%d", &x)
#define pd(x) printf("%d\n",x)
#define pdl(x) printf("%lld\n",x)
#define sdl(x) scanf("%lld", &x)
#define eps 1e-12
#define maxn 100009
using namespace std;
int main()
{
	ll e,s,n,m;
	sdl(e);
	sdl(s);
	sdl(n);
	sdl(m);
	vector<pair<pli,int> > v;
	vector<pair<ll,pll> > fuel[4];
	ll ans1[m],ans2[m];
	for(int i=0;i<n;i++)
	{
		int t;
		ll x;
		sd(t);
		sdl(x);
		v.pb(mk(mk(x,t),-1));
	}
	for(int j=0;j<m;j++)
	{
		ll x;
		sdl(x);
		v.pb(mk(mk(x,4),j));
	}
	memset(ans1,-1,sizeof(ans1));
	memset(ans2,-1,sizeof(ans2));
	sort(v.begin(),v.end());
	fuel[3].pb(mk(e,mk(0,0)));
	int nearest=e;
	for(int i=v.size()-1;i>=0;i--)
	{
		// cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<"\n";
		if(abs(e-v[i].first.first)>s)
		{
			break;
		}
		if(v[i].first.second<=3)
		{
			e=v[i].first.first;
			if(v[i].first.second==1)
			{
				fuel[1].pb(mk(v[i].first.first,mk(-1,-1)));
				continue;
			}
			else
			{
				pair<ll,pll> x=fuel[3].back(),y=mk(1000000000000,mk(-1,-1));
				if(!fuel[2].empty())
				{
					y=fuel[2].back();
				}
				pair<ll,pll> opt;
				if(x.first<=y.first)
				{
					opt=x;
				}
				else
				{
					opt=y;
				}
				ll num_1=max(0ll,abs(v[i].first.first-opt.first)-s)+opt.second.first;
				if(v[i].first.second==2)
				{
					fuel[v[i].first.second].pb(mk(v[i].first.first,mk(num_1,-1)));
				}
				else
				{
					ll num_2=x.second.second+max(0ll,abs(x.first-v[i].first.first)-s)-(num_1-x.second.first);
					fuel[v[i].first.second].pb(mk(v[i].first.first,mk(num_1,num_2)));
				}
			}
		}
		else
		{
			pair<ll,pll> x=fuel[3].back(),y=mk(1000000000000,mk(-1,-1));
			if(!fuel[2].empty())
			{
				y=fuel[2].back();
			}
			pair<ll,pll> opt;
			if(x.first<=y.first)
			{
				opt=x;
			}
			else
			{
				opt=y;
			}
			ll num_1=max(0ll,abs(v[i].first.first-opt.first)-s)+opt.second.first;
			ll num_2=x.second.second+max(0ll,abs(x.first-v[i].first.first)-s)-(num_1-x.second.first);
			ans1[v[i].second]=num_1;
			ans2[v[i].second]=num_2;
		}
	}
	for(int i=0;i<m;i++)
	{
		printf("%lld %lld\n",ans1[i],ans2[i]);
	}
}


#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

// Basic idea is that from position of gas station, this type
// of gas will last for s miles. Higher quality gas segments
// will override lower quality ones, for example if at x=0
// there is a premium station and s=100, and at x=10 a regular
// one, at 0-100 we have a premium segment and 100-110 a regular
// one. When we begin driving, we skip s km forward and calculate
// lengths of different segments until destination.
int main() {
    int f, e, s, n, m, t, x, l;
    vector<pair<int,int>> g;

    S(e); S(s); S(n); S(m);

    REP(n) {
        S(t); S(x);
        g.push_back({x,t});
    }

    sort(g.begin(), g.end());
    g.push_back({Inf,0});

    // Gas of three types and unobtanium at bottom
    int gas[4] = {2*Inf,0,0,0}, pos = -Inf;
    vector<tuple<int,int,int>> xlt; // pos, len, type

    for(auto p : g) {
        x = p.first; t = p.second;

        for(int t1=3, dx=0; t1>=0 && pos+dx < x; t1--) { // Emit all segments before x
            if(gas[t1] <= dx) {
                gas[t1] = 0;
            } else {
                l = MIN(gas[t1]-dx, x-pos-dx);
                //cout << "Going " << l << " km from " << pos+dx << " to " << pos+dx+l << " with " << t1 << endl;
                xlt.push_back(make_tuple(pos+dx, l, t1));
                dx += l;
                gas[t1] -= l;
            }
        }

        pos = x;
        gas[t] = s;
    }
    xlt.push_back(make_tuple(Inf, 0, 0));

    vector<vector<int>> need(4, vector<int>(1));

    for(auto t : xlt)
        FOR(i,0,4) need[i].push_back(need[i].back() + (get<2>(t)==i ? get<1>(t) : 0));

    FOR(i,0,xlt.size()) {
        //cout << get<0>(xlt[i]) << " " << get<1>(xlt[i]) << " " << get<2>(xlt[i]) << " ";
        //FOR(j,0,4) cout << need[j][i] << " ";
        //cout << endl;
    }

    //cout << endl;

    int end = lower_bound(xlt.begin(), xlt.end(), make_tuple(e, 0, 0)) - xlt.begin();
    int endtype = get<2>(xlt[end-1]);

    //cout << "Johanna's segment is: " << end << endl;
    //cout << "Station before is of type " << endtype << endl;

    // f < e and we handle e-f <= s separately so begin != end
    need[endtype][end] -= get<0>(xlt[end]) - e;
    //FOR(j,0,4) cout << need[j][end] << " "; cout << endl;

    REP(m) {
        S(f);
        if(e-f <= s) { // Enough fuel
            cout << "0 0" << endl;
            continue;
        }
        int start = lower_bound(xlt.begin(), xlt.end(), make_tuple(f+s+1, 0, 0)) - xlt.begin() - 1;
        int starttype = get<2>(xlt[start]);

        if(starttype == 0 || endtype == 0 || need[0][end] != need[0][start]) {
            cout << "-1 -1" << endl; // unobtanium needed
            continue;
        }

        int need1 = need[1][end] - need[1][start];
        int need2 = need[2][end] - need[2][start];

        if(starttype == 1) need1 -= f+s - get<0>(xlt[start]);
        if(starttype == 2) need2 -= f+s - get<0>(xlt[start]);

        //cout << "Relevant segment is: " << start << endl;
        //cout << "Station before is of type " << starttype << endl;
        //FOR(j,0,4) cout << need[j][start] << " "; cout << endl;

        cout << need1 << " " << need2 << endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

// Basic idea is that from position of gas station, this type
// of gas will last for s miles. Higher quality gas segments
// will override lower quality ones, for example if at x=0
// there is a premium station and s=100, and at x=10 a regular
// one, at 0-100 we have a premium segment and 100-110 a regular
// one. When we begin driving, we skip s km forward and calculate
// lengths of different segments until destination.
int main() {
    int f, e, s, n, m, t, x, l;
    vector<pair<int,int>> g;

    S(e); S(s); S(n); S(m);

    REP(n) {
        S(t); S(x);
        g.push_back({x,t});
    }

    sort(g.begin(), g.end());
    g.push_back({Inf,0});

    // Gas of three types and unobtanium at bottom
    int gas[4] = {2*Inf,0,0,0}, pos = -Inf;
    vector<tuple<int,int,int>> xlt; // pos, len, type

    for(auto p : g) {
        x = p.first; t = p.second;
        //cout << x << " " << t << " (at " << pos << ": " << gas[1] << "/" << gas[2] << "/" << gas[3] << ")" << endl;

        for(int t1=3, dx=0; t1>=0; t1--) { // Emit all segments before x
            //cout << "  gas[" << t1 << "] = " << gas[t1] << " vs. " << dx  << endl;
            l = MIN(gas[t1], x-pos);
            //cout << "  take " << l << " liters" << endl;
            gas[t1] -= l;
            if(l > dx) {
                //cout << "Going " << l << " km from " << pos+dx << " to " << pos+dx+l << " with " << t1 << endl;
                xlt.push_back(make_tuple(pos+dx, l-dx, t1));
                dx = l;
            }
        }

        pos = x;
        gas[t] = s;
        //cout << x << " " << t << " (at " << pos << ": " << gas[1] << "/" << gas[2] << "/" << gas[3] << ")" << endl;
    }
    xlt.push_back(make_tuple(Inf, 0, 0));

    vector<vector<int>> need(4, vector<int>(1));

    for(auto t : xlt)
        FOR(i,0,4) need[i].push_back(need[i].back() + (get<2>(t)==i ? get<1>(t) : 0));

    FOR(i,0,xlt.size()) {
        //cout << get<0>(xlt[i]) << ": " << get<1>(xlt[i]) << "*" << get<2>(xlt[i]) << " ";
        //FOR(j,0,4) cout << need[j][i] << " ";
        //cout << endl;
    }

    //cout << endl;

    int end = lower_bound(xlt.begin(), xlt.end(), make_tuple(e, 0, 0)) - xlt.begin();
    int endtype = get<2>(xlt[end-1]);

    //cout << "Johanna's segment is: " << end << endl;
    //cout << "Station before is of type " << endtype << endl;

    // f < e and we handle e-f <= s separately so begin != end
    need[endtype][end] -= get<0>(xlt[end]) - e;
    //FOR(j,0,4) cout << need[j][end] << " "; cout << endl;

    REP(m) {
        S(f);
        if(e-f <= s) { // Enough fuel
            cout << "0 0" << endl;
            continue;
        }
        int start = lower_bound(xlt.begin(), xlt.end(), make_tuple(f+s+1, 0, 0)) - xlt.begin() - 1;
        int starttype = get<2>(xlt[start]);

        if(starttype == 0 || endtype == 0 || need[0][end] != need[0][start]) {
            cout << "-1 -1" << endl; // unobtanium needed
            continue;
        }

        int need1 = need[1][end] - need[1][start];
        int need2 = need[2][end] - need[2][start];

        if(starttype == 1) need1 -= f+s - get<0>(xlt[start]);
        if(starttype == 2) need2 -= f+s - get<0>(xlt[start]);

        //cout << "Relevant segment is: " << start << endl;
        //cout << "Station before is of type " << starttype << endl;
        //FOR(j,0,4) cout << need[j][start] << " "; cout << endl;

        cout << need1 << " " << need2 << endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 107

// Basic idea is that from position of gas station, this type
// of gas will last for s miles. Higher quality gas segments
// will override lower quality ones, for example if at x=0
// there is a premium station and s=100, and at x=10 a regular
// one, at 0-100 we have a premium segment and 100-110 a regular
// one. When we begin driving, we skip s km forward and calculate
// lengths of different segments until destination.
int main() {
    int f, e, s, n, m, t, x, l;
    vector<pair<int,int>> g;

    S(e); S(s); S(n); S(m);

    REP(n) {
        S(t); S(x);
        g.push_back({x,t});
    }

    sort(g.begin(), g.end());
    g.push_back({Inf,0});

    // Gas of three types and unobtanium at bottom
    int gas[4] = {2*Inf,0,0,0}, pos = -Inf;
    vector<tuple<int,int,int>> xlt; // pos, len, type

    for(auto p : g) {
        x = p.first; t = p.second;

        for(int t1=3, dx=0; t1>=0 && pos+dx < x; t1--) { // Emit all segments before x
            if(gas[t1] <= dx) {
                gas[t1] = 0;
            } else {
                l = MIN(gas[t1]-dx, x-pos-dx);
                //cout << "Going " << l << " km from " << pos+dx << " to " << pos+dx+l << " with " << t1 << endl;
                xlt.push_back(make_tuple(pos+dx, l, t1));
                dx += l;
                gas[t1] -= l;
            }
        }

        pos = x;
        gas[t] = s;
    }
    xlt.push_back(make_tuple(Inf, 0, 0));

    vector<vector<int>> need(4, vector<int>(1));

    for(auto t : xlt)
        FOR(i,0,4) need[i].push_back(need[i].back() + (get<2>(t)==i ? get<1>(t) : 0));

    FOR(i,0,xlt.size()) {
        //cout << get<0>(xlt[i]) << " " << get<1>(xlt[i]) << " " << get<2>(xlt[i]) << " ";
        //FOR(j,0,4) cout << need[j][i] << " ";
        //cout << endl;
    }

    //cout << endl;

    int end = lower_bound(xlt.begin(), xlt.end(), make_tuple(e, 0, 0)) - xlt.begin();
    int endtype = get<2>(xlt[end-1]);

    //cout << "Johanna's segment is: " << end << endl;
    //cout << "Station before is of type " << endtype << endl;

    // f < e and we handle e-f <= s separately so begin != end
    need[endtype][end] -= get<0>(xlt[end]) - e;
    //FOR(j,0,4) cout << need[j][end] << " "; cout << endl;

    REP(m) {
        S(f);
        if(e-f <= s) { // Enough fuel
            cout << "0 0" << endl;
            continue;
        }
        int start = lower_bound(xlt.begin(), xlt.end(), make_tuple(f+s+1, 0, 0)) - xlt.begin() - 1;
        int starttype = get<2>(xlt[start]);

        if(starttype == 0 || endtype == 0 || need[0][end] != need[0][start]) {
            cout << "-1 -1" << endl; // unobtanium needed
            continue;
        }

        int need1 = need[1][end] - need[1][start];
        int need2 = need[2][end] - need[2][start];

        if(starttype == 1) need1 -= f+s - get<0>(xlt[start]);
        if(starttype == 2) need2 -= f+s - get<0>(xlt[start]);

        //cout << "Relevant segment is: " << start << endl;
        //cout << "Station before is of type " << starttype << endl;
        //FOR(j,0,4) cout << need[j][start] << " "; cout << endl;

        cout << need1 << " " << need2 << endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

// Basic idea is that from position of gas station, this type
// of gas will last for s miles. Higher quality gas segments
// will override lower quality ones, for example if at x=0
// there is a premium station and s=100, and at x=10 a regular
// one, at 0-100 we have a premium segment and 100-110 a regular
// one. When we begin driving, we skip s km forward and calculate
// lengths of different segments until destination.
int main() {
    int f, e, s, n, m, t, x, l;
    vector<pair<int,int>> g;

    S(e); S(s); S(n); S(m);

    REP(n) {
        S(t); S(x);
        g.push_back({x,t});
    }

    sort(g.begin(), g.end());
    g.push_back({Inf,0});

    // Gas of three types and unobtanium at bottom
    int gas[4] = {2*Inf,0,0,0};
    vector<tuple<int,int,int>> xlt; // pos, len, type

    x = -Inf;
    for(auto p : g) {
        int xn = p.first; t = p.second;

        for(int t1=3, dx=0; t1>=0; t1--) { // Emit all segments before x
            l = MIN(gas[t1], xn-x);
            gas[t1] -= l;
            if(l > dx) {
                xlt.push_back(make_tuple(x+dx, l-dx, t1));
                dx = l;
            }
        }

        x = xn;
        gas[t] = s;
    }
    xlt.push_back(make_tuple(Inf, 0, 0));

    vector<vector<int>> need(4, vector<int>(1));

    for(auto t : xlt)
        FOR(i,0,4) need[i].push_back(need[i].back() + (get<2>(t)==i ? get<1>(t) : 0));

    int end = lower_bound(xlt.begin(), xlt.end(), make_tuple(e, 0, 0)) - xlt.begin();
    int endtype = get<2>(xlt[end-1]);

    // f < e and we handle e-f <= s separately so begin != end
    need[endtype][end] -= get<0>(xlt[end]) - e;

    REP(m) {
        S(f);
        if(e-f <= s) { // Enough fuel
            cout << "0 0" << endl;
            continue;
        }
        int start = lower_bound(xlt.begin(), xlt.end(), make_tuple(f+s+1, 0, 0)) - xlt.begin() - 1;
        int starttype = get<2>(xlt[start]);

        if(starttype == 0 || endtype == 0 || need[0][end] != need[0][start]) {
            cout << "-1 -1" << endl; // unobtanium needed
            continue;
        }

        int need1 = need[1][end] - need[1][start];
        int need2 = need[2][end] - need[2][start];

        if(starttype == 1) need1 -= f+s - get<0>(xlt[start]);
        if(starttype == 2) need2 -= f+s - get<0>(xlt[start]);

        cout << need1 << " " << need2 << endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)
#define FOR(i,a,b) for(__typeof(b) i=a; i<b; ++i)
#define FORE(i,a,b) for(__typeof(b) i=a; i<=b; ++i)
#define S(x) scanf("%d", &(x))

typedef long long LL;

#define MAX(a,b) ((a)<(b) ? (b) : (a))
#define MIN(a,b) ((a)>(b) ? (b) : (a))
#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }

#define Inf 1000000007

// Basic idea is that from position of gas station, this type
// of gas will last for s miles. Higher quality gas segments
// will override lower quality ones, for example if at x=0
// there is a premium station and s=100, and at x=10 a regular
// one, at 0-100 we have a premium segment and 100-110 a regular
// one. When we begin driving, we skip s km forward and calculate
// lengths of different segments until destination.
int main() {
    int f, e, s, n, m, t, x, l;
    vector<pair<int,int>> g;

    S(e); S(s); S(n); S(m);

    REP(n) {
        S(t); S(x);
        g.push_back({x,t});
    }

    sort(g.begin(), g.end());
    g.push_back({Inf,0});

    // Gas of three types and unobtanium at bottom
    int gas[4] = {2*Inf,0,0,0};
    vector<tuple<int,int,int>> xlt; // pos, len, type

    x = -Inf
    for(auto p : g) {
        int xn = p.first; t = p.second;

        for(int t1=3, dx=0; t1>=0; t1--) { // Emit all segments before x
            l = MIN(gas[t1], xn-x);
            gas[t1] -= l;
            if(l > dx) {
                xlt.push_back(make_tuple(x+dx, l-dx, t1));
                dx = l;
            }
        }

        x = xn;
        gas[t] = s;
    }
    xlt.push_back(make_tuple(Inf, 0, 0));

    vector<vector<int>> need(4, vector<int>(1));

    for(auto t : xlt)
        FOR(i,0,4) need[i].push_back(need[i].back() + (get<2>(t)==i ? get<1>(t) : 0));

    int end = lower_bound(xlt.begin(), xlt.end(), make_tuple(e, 0, 0)) - xlt.begin();
    int endtype = get<2>(xlt[end-1]);

    // f < e and we handle e-f <= s separately so begin != end
    need[endtype][end] -= get<0>(xlt[end]) - e;

    REP(m) {
        S(f);
        if(e-f <= s) { // Enough fuel
            cout << "0 0" << endl;
            continue;
        }
        int start = lower_bound(xlt.begin(), xlt.end(), make_tuple(f+s+1, 0, 0)) - xlt.begin() - 1;
        int starttype = get<2>(xlt[start]);

        if(starttype == 0 || endtype == 0 || need[0][end] != need[0][start]) {
            cout << "-1 -1" << endl; // unobtanium needed
            continue;
        }

        int need1 = need[1][end] - need[1][start];
        int need2 = need[2][end] - need[2][start];

        if(starttype == 1) need1 -= f+s - get<0>(xlt[start]);
        if(starttype == 2) need2 -= f+s - get<0>(xlt[start]);

        cout << need1 << " " << need2 << endl;
    }

    return 0;
}


#include<stdio.h>
#define fi first
#define se second
#define M 200000
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int , int> ii;
int e , s , n , m;
ii petrol[M + 5];
vector<ii> type[5];
ii f[M + 5];
void input(){
    scanf("%d %d %d %d",&e,&s,&n,&m);
    for(int i = 1 ; i <= n ; i++){
        int x , t;
        scanf("%d %d",&petrol[i].se,&petrol[i].fi);
    }
    n++;
    petrol[n] = ii(e , 4);
    sort(petrol + 1 , petrol + 1 + n);
    for(int i = 1 ; i <= n ; i++)   type[petrol[i].se].push_back(ii(petrol[i].fi , i));
    for(int i = 1 ; i <= n ; i++)   if(petrol[i].se == 4){
        n = i;
        break;
    }
}
int goRight(int t,int x){
    if(type[t].size() == 0) return -1;
    if(type[t].back().fi < x + 1)   return -1;
    int id = lower_bound(type[t].begin() , type[t].end() , ii(x + 1 , 0)) - type[t].begin();
    if(type[t][id].fi > x + s)  return -1;
    return type[t][id].se;
}
int goRight1(int t,int x){
    if(type[t].size() == 0) return -1;
    if(type[t][0].fi > x)   return -1;
    int id = upper_bound(type[t].begin() , type[t].end() , ii(x , M + 55)) - type[t].begin();
    id--;
    return type[t][id].se;
}
ii cal(int id,int x){
    if(id == n) return ii(0 , 0);
    ii cost = ii(0 , 0);
    int min_val = 1e9 + 99;
    int id_val  = -1;
    for(int i = petrol[id].se ; i <= 4 ; i++){
        int toRight = goRight(i , petrol[id].fi);
        if(toRight == -1)   continue;
        if(petrol[toRight].fi < min_val){ min_val = petrol[toRight].fi ; id_val = toRight; }
    }
    if(id_val != -1){
            if(petrol[id].se == 1)  cost.fi += (petrol[id_val].fi - petrol[id].fi - x);
            else if(petrol[id].se == 2) cost.se += (petrol[id_val].fi - petrol[id].fi - x);
            ii ret = f[id_val];
            if(ret.fi == -1)    return ii(-1 , -1);
            return ii(cost.fi + ret.fi , cost.se + ret.se);
    }
    if(petrol[id].se == 1) cost.fi += (s - x);
    else if(petrol[id].se == 2) cost.se += (s - x);
    for(int i = petrol[id].se - 1 ; i >= 1 ; i--){
        int IDright = goRight1(i , petrol[id].fi + s);
        if(IDright == -1)   continue;
        if(petrol[IDright].fi <= petrol[id].fi)  continue;
        ii val = cal(IDright , s - (petrol[IDright].fi - petrol[id].fi));
        if(val == ii(-1 , -1)) return val;
        return ii(val.fi + cost.fi , val.se + cost.se);
    }
    return ii(-1 , -1);
}
void optimize(){
    f[n] = ii(0 , 0);
    for(int i = n - 1 ; i >= 1 ; i--)   f[i] = cal(i , 0);
}
void query(int x){
    if(x == e){
        printf("%d %d\n",0,0);
        return ;
    }
    int id = -1;
    for(int i = 4 ; i >= 1 ; i--){
        int IDright = goRight1(i , x + s);
        if(IDright == -1 || petrol[IDright].fi < x) continue;
        id = IDright;
        break;
    }
    if(id == -1){
        printf("-1 -1\n");
        return ;
    }
    ii res = cal(id , s - (petrol[id].fi - x));
    printf("%d %d\n",res.fi,res.se);
}
main(){
    //freopen("test.inp","r",stdin);
//  freopen("test.out","w",stdout);
    input();
    optimize();
    while(m > 0){
        int u;
        scanf("%d",&u);
        query(u);
        m--;
    }
}


#include<stdio.h>
#define fi first
#define se second
#define M 100000
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int , int> ii;
int e , s , n , m;
ii petrol[M + 5];
vector<ii> type[5];
ii f[M + 5];
void input(){
    scanf("%d %d %d %d",&e,&s,&n,&m);
    for(int i = 1 ; i <= n ; i++){
        int x , t;
        scanf("%d %d",&petrol[i].se,&petrol[i].fi);
    }
    n++;
    petrol[n] = ii(e , 4);
    sort(petrol + 1 , petrol + 1 + n);
    for(int i = 1 ; i <= n ; i++)   type[petrol[i].se].push_back(ii(petrol[i].fi , i));
    for(int i = 1 ; i <= n ; i++)   if(petrol[i].se == 4){
        n = i;
        break;
    }
}
int goRight(int t,int x){
    if(type[t].size() == 0) return -1;
    if(type[t][0].fi > x)   return -1;
    int id = upper_bound(type[t].begin() , type[t].end() , ii(x , M + 55)) - type[t].begin();
    id--;
    return type[t][id].se;
}
ii cal(int id,int x){
//	printf("%d %d\n",id,x);
    ii cost = ii(0 , 0);
    for(int i = 4 ; i >= petrol[id].se ; i--){
        int IDright = goRight(i , petrol[id].fi + s);
        if(IDright == -1)   continue;
        if(petrol[IDright].fi <= petrol[id].fi)  continue;
        if(petrol[id].se == 1)  cost.fi += (petrol[IDright].fi - petrol[id].fi - x);
        else if(petrol[id].se == 2) cost.se += (petrol[IDright].fi - petrol[id].fi - x);
        if(f[IDright] != ii(-1 , -1)) return ii(f[IDright].fi + cost.fi , f[IDright].se + cost.se);
        return ii(-1 , - 1);
    }
    if(petrol[id].se == 1) cost.fi += (s - x);
    else if(petrol[id].se == 2) cost.se += (s - x);
    for(int i = petrol[id].se - 1 ; i >= 1 ; i--){
        int IDright = goRight(i , petrol[id].fi + s);
        if(IDright == -1)   continue;
        if(petrol[IDright].fi <= petrol[id].fi)  continue;
        ii val = cal(IDright , s - (petrol[IDright].fi - petrol[id].fi));
        if(val == ii(-1 , -1)) return val;
        return ii(val.fi + cost.fi , val.se + cost.se);
    }
    return ii(-1 , -1);
}
void optimize(){
	f[n] = ii(0 , 0);
	for(int i = n - 1 ; i >= 1 ; i--)	f[i] = cal(i , 0);
}
void query(int x){
	int id = lower_bound(petrol + 1 , petrol + 1 + n , ii(x , 0)) - (petrol);
	if(s - (petrol[id].fi - x) < 0)	{
		printf("%d %d\n",-1,-1);
		return ;
	}
	ii res = cal(id , s - (petrol[id].fi - x));
	printf("%d %d\n",res.fi,res.se);
}
main(){
//	freopen("test.inp","r",stdin);
	input();
	optimize();
	while(m > 0){
		int u;
		scanf("%d",&u);
		query(u);
		m--;
	}
}


#include<stdio.h>
#define fi first
#define se second
#define M 100000
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int , int> ii;
int e , s , n , m;
ii petrol[M + 5];
vector<ii> type[5];
ii f[M + 5];
void input(){
    scanf("%d %d %d %d",&e,&s,&n,&m);
    for(int i = 1 ; i <= n ; i++){
        int x , t;
        scanf("%d %d",&petrol[i].se,&petrol[i].fi);
    }
    n++;
    petrol[n] = ii(e , 4);
    sort(petrol + 1 , petrol + 1 + n);
    for(int i = 1 ; i <= n ; i++)   type[petrol[i].se].push_back(ii(petrol[i].fi , i));
    for(int i = 1 ; i <= n ; i++)   if(petrol[i].se == 4){
        n = i;
        break;
    }
}
int goRight(int t,int x){
    if(type[t].size() == 0) return -1;
    if(type[t][0].fi > x)   return -1;
    int id = upper_bound(type[t].begin() , type[t].end() , ii(x , M + 55)) - type[t].begin();
    id--;
    return type[t][id].se;
}
ii cal(int id,int x){
	if(id == n) return ii(0 , 0);
    ii cost = ii(0 , 0);
    for(int i = 3 ; i >= petrol[id].se - 1 ; i--){
    	int IDright;
        if(i >= petrol[id].se) IDright = goRight(i , petrol[id].fi + s);
        else IDright = goRight(4 , petrol[id].fi + s);
		if(IDright == -1)   continue;
        if(petrol[IDright].fi <= petrol[id].fi)  continue;
        if(petrol[id].se == 1)  cost.fi += (petrol[IDright].fi - petrol[id].fi - x);
        else if(petrol[id].se == 2) cost.se += (petrol[IDright].fi - petrol[id].fi - x);
        if(f[IDright] != ii(-1 , -1)) return ii(f[IDright].fi + cost.fi , f[IDright].se + cost.se);
        return ii(-1 , - 1);
    }
    if(petrol[id].se == 1) cost.fi += (s - x);
    else if(petrol[id].se == 2) cost.se += (s - x);
    for(int i = petrol[id].se - 1 ; i >= 1 ; i--){
        int IDright = goRight(i , petrol[id].fi + s);
        if(IDright == -1)   continue;
        if(petrol[IDright].fi <= petrol[id].fi)  continue;
        ii val = cal(IDright , s - (petrol[IDright].fi - petrol[id].fi));
        if(val == ii(-1 , -1)) return val;
        return ii(val.fi + cost.fi , val.se + cost.se);
    }
    return ii(-1 , -1);
}
void optimize(){
	f[n] = ii(0 , 0);
	for(int i = n - 1 ; i >= 1 ; i--)	f[i] = cal(i , 0);
}
void query(int x){
	if(x == e){
		printf("%d %d\n",0,0);
		return ;
	}
	int id = -1;
	for(int i = 4 ; i >= 1 ; i--){
		int IDright = goRight(i , x + s);
        if(IDright == -1 || petrol[IDright].fi < x)	continue;
        id = IDright;
        break;
	}
	if(id == -1){
		printf("-1 -1\n");
		return ;
	}
	ii res = cal(id , s - (petrol[id].fi - x));
	printf("%d %d\n",res.fi,res.se);
}
main(){
//	freopen("test.inp","r",stdin);
//	freopen("test.out","w",stdout);
	input();
	optimize();
	while(m > 0){
		int u;
		scanf("%d",&u);
		query(u);
		m--;
	}
}