#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < ll, ll > pii;
const int M = 1e5 + 10;
pii a[M], b[M];
ll n, m, q;
ll gmin[M], sum[M];
void work() {
cin >> n >> q;
for (int i = 1; i <= n; i ++)
cin >> a[i].first >> a[i].second;
int lstpos = 0, pos = 0;
for (int i = 1; i <= n; i ++) {
if (a[i].first == lstpos) {
lstpos ++, pos = i;
} else {
break ;
}
}
for (int i = 2; i <= n; i ++) {
a[i].second = min(a[i].second, a[i - 1].second);
}
for (int i = 1; i <= pos; i ++) sum[i] = 0;
for (int i = 1; i <= pos; i ++) b[i] = a[i];
sort(b + 1, b + 1 + pos, greater < pii > ());
for (int i = 1; i <= pos; i ++) {
sum[i] = sum[i - 1] + (b[i].first + 1) * (b[i].second - b[i - 1].second);
}
for (int i = 1; i <= pos; i ++)
cout << sum[i] << " ";
cout << "\n";
while (q --) {
cin >> m;
if (lstpos == 0) {
if (m == 0) {
cout << "1\n";
continue ;
} else {
cout << "-1\n";
continue ;
}
}
if (m > sum[pos]) {
cout << "-1\n";
continue ;
}
ll l = 1, r = pos, ans = 0;
while (l <= r) {
ll mid = (l + r) >> 1;
if (sum[mid] >= m) {
ans = mid;
r = mid - 1;
} else
l = mid + 1;
}
cout << "ans = " << ans << "\n";
if (!ans) cout << "-1\n";
else {
ll val = b[ans - 1].second + (m - sum[ans - 1] - 1) / b[ans].first + 1;
cout << val << "\n";
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while (t --) work();
return 0;
}