#pragma comment(linker, "/Stack:512000000")
#define	_CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef double dbl;

#define all(x) (x).begin(), (x).end()

const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const dbl EPS = 1e-9;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#elif 1
#define PROB "mountain"
	freopen(PROB".in", "r", stdin);
	freopen(PROB".out", "w", stdout);
#endif
	cin.tie(0);
	cin.sync_with_stdio(0);

  int n, q;
  cin >> n >> q;

  vector<pair<LL, LL>> p(n + 3);
  p[0] = { -1, -INF * 1ll * INF };

  for (int i = 1; i <= n; ++i) {
    LL d, k;
    cin >> d >> k;
    p[i + 1].first = p[i].first + d;
    p[i + 1].second = p[i].second + k * d;
  }

  p[n + 2].first = p[n + 1].first + 1;
  p[n + 2].second = -INF * 1ll * INF;

  for (int i = 0; i < q; ++i) {
    pair<LL, LL> t;
    cin >> t.first >> t.second;
    
    int lj, rj;

    int j = 0;
    while (j < n + 1 && t.first >= p[j].first) j++;
    rj = j;

    j = n + 2;
    while (j > 1 && t.first <= p[j].first) j--;
    lj = j;

    while (lj > 1) {
      dbl dx = t.first - p[lj - 1].first;
      dbl dy = (t.second - p[lj - 1].second) / dx;

      dbl y = t.second - (t.first - p[lj].first) * dy;

      if (y < p[lj].second)
        break;

      --lj;
    }

    while (rj < n + 1) {
      dbl dx = -t.first + p[rj + 1].first;
      dbl dy = (t.second - p[rj + 1].second) / dx;

      dbl y = t.second + (t.first - p[rj].first) * dy;

      if (y < p[rj].second)
        break;

      ++rj;
    }
    
    cout << p[lj].first << ' ' << p[rj].first << endl;
  }

	return 0;
}