// Arup Guha
// 5/8/2019
// Solution to 2019 FHSPS Playoff Problem: One Dimensional k-Rooks

import java.util.*;

public class onedim {
	
	public static void main(String[] args) {
		
		long start = System.currentTimeMillis();
		
		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();
		
		// Process all cases.
		for (int loop=0; loop<numCases; loop++) {
			
			// Get board length and number of rooks.
			long n = stdin.nextLong();
			int numR = stdin.nextInt();
			
			// Each event is either an "on" event or an "off" event, with some number
			// of rooks turning on their range or off their range at that x mark. 
			// I store an on event at x as 2*x+1 and an off event at x as 2*x, so I process
			// off events first.
			TreeMap<Long,Integer> events = new TreeMap<Long,Integer>();
			
			// Go through rooks.
			for (int i=0; i<numR; i++) {
				
				long middle = stdin.nextLong();
				long range = stdin.nextLong();
				long left = Math.max(3, 2*(middle-range) + 1);
				long right = Math.min(2*(n+1),2*(middle+range+1));
				
				if (middle < 1 || middle > n) System.out.println("ERROR");
				
				// Mark left event (on), put new mapping if necessary.
				if (!events.containsKey(left))
					events.put(left, 1);
				else
					events.put(left, events.get(left)+1);
				
				// Do same for the right.
				if (!events.containsKey(right))
					events.put(right, 1);
				else
					events.put(right, events.get(right)+1);
			}
			
			// Now sweep through events, keeping track of best seen.
			int cur = 0, max = 0;
			long numSq = 0, prev = 0;
			
			// Go through events.
			while (events.size() > 0) {
				
				// Poll the next entry.
				Map.Entry<Long,Integer> tmp = events.pollFirstEntry();
				long item = tmp.getKey();
				int freq = tmp.getValue();
				long x = (item >> 1);
				
				// On event.
				if ((item & 1) == 1) {
					
					// Update how many rooks can attack here.
					cur += freq;
					
					// If this is a new high, we must reset both max and how many squares have this.
					if (cur > max) {
						max = cur;
						numSq = 0;
					}
				}
				
				// Off event.
				else {
					
					// Update number of squares, if necessary.
					if (cur == max) numSq += (x-prev);
					
					// Now, these are off.
					cur -= freq;
				}
				
				// Update prev.
				prev = x;
			}
			
			// Ta da!
			System.out.println(max+" "+numSq);
		}
	}
}