import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long d = sc.nextLong(); int n = sc.nextInt(); TreeMap days = new TreeMap<>(); StringBuilder sb = new StringBuilder(); long max = 0; for (int i = 0; i < n; i++) { long left = sc.nextLong(); long right = sc.nextLong(); Long prev = days.floorKey(left); if (prev != null && days.get(prev) >= left - 1) { left = prev; right = Math.max(right, days.get(prev)); } days.put(left, right); Long next; while ((next = days.higherKey(left)) != null) { if (right + 1 < next) { break; } right = Math.max(right, days.get(next)); days.put(left, right); days.remove(next); } max = Math.max(max, right - left + 1); sb.append(max).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }