import java.io.*;
import java.util.*;

public class D {
    String fileName = "mountain";
    
    static class Pair implements Comparable<Pair> {
    	long x;
    	long y;
		public Pair(long x, long y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public int compareTo(Pair o) {
			if (this.x != o.x) {
				return this.x < o.x ? -1 : 1;
			}
			if (this.y != o.y) {
				return this.y < o.y ? -1 : 1;
			}
			return 0;
		}
		@Override
		public String toString() {
			return "Pair [x=" + x + ", y=" + y + "]";
		}
    	
    }
    
    public void solve() throws IOException {
    	int n = nextInt(), q = nextInt();
    	long[] x = new long[n + 1];
    	long[] y = new long[n + 1];
    	x[0] = 0;
    	y[0] = 0;
    	long curX = 0; 
    	long curY = 0;
    	for (int i = 1; i < y.length; i++) {
			int d = nextInt();
			int k = nextInt();
			if (k != 1 && k != -1) {
				return;
			}
			curX += d;
			curY += k * d;
			x[i] = curX;
			y[i] = curY;
		}
    	long[] d1 = new long[n + 1];
    	long[] d2 = new long[n + 1];
    	for (int i = 0; i < d2.length; i++) {
			d1[i] = x[i] - y[i];
			d2[i] = x[i] + y[i];
		}
    	
    	TreeMap<Long, Pair> m1 = new TreeMap<>();
    	TreeMap<Long, Pair> m2 = new TreeMap<>();
    	for (int i = 0; i < d2.length; i++) {
    		if (!m1.containsKey(d1[i])) {
    			m1.put(d1[i], new Pair(i, -1));
    		} else {
				m1.put(d1[i], new Pair(m1.get(d1[i]).x, i));
			}
    		if (!m2.containsKey(d2[i])) {
    			m2.put(d2[i], new Pair(i, -1));
    		} else {
				m2.put(d2[i], new Pair(m2.get(d2[i]).x, i));
			}
    	}
    	
    	for (int i = 0; i < q; i++) {
			long v = nextLong(), u = nextLong();
			long cd1 = v - u;
			long cd2 = v + u;
			int ci1 = (int) m1.get(m1.lowerKey(cd1)).y;
			out.print(x[ci1] + " ");
			int ci2 = (int) m2.get(m2.higherKey(cd2)).x;
			out.println(x[ci2]);
		}
    	
    	
    	
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader(fileName + ".in")); 
            out = new PrintWriter(fileName + ".out");

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new D().run();
    }

}