import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); long d = sc.nextLong(); int q = sc.nextInt(); TreeMap works = new TreeMap<>(); works.put(-10L, -10L); works.put(d + 10, d + 10); long max = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { long left = sc.nextLong(); long right = sc.nextLong(); long key; while (true) { key = works.floorKey(left); if (works.get(key) + 1 >= left) { right = Math.max(works.get(key), right); left = key; works.remove(key); } else { break; } } while (true) { key = works.higherKey(left); if (right + 1 >= key) { right = Math.max(works.get(key), right); works.remove(key); } else { break; } } works.put(left, right); max = Math.max(max, right - left + 1); sb.append(max).append("\n"); } System.out.print(sb); } }