Biggest square in a grid Challenge

Given a grid like this,

  1 2 3 4 5 6 7 8
1 . . . . . . . .
2 . # . . . # . .
3 . . . . . . . .
4 . . . . . . . .
5 . . . . . . . .
6 . . # . . . . .
7 . . . . . . . .
8 . . . . . . . .


write a piece of code that can determine the size of the largest square that does not include a '#'. (The answer to this input is 5x5 as the bottom right 5x5 grid is the biggest square possible). 

The square must have sides parallel to the x and y axes.

As some small details: the original grid is always a square and its side length is given to you. The coordinates of the '#' symbols are also given to you.

Input Details

First line: N (1 &lt;= N &lt;= 1000), the side length of the square grid, and T (1 &lt;= T &lt;= 10,000) the number of '#' signs.

Next T Lines: The coordinates of each of the T #'s

Test Cases

Input #1:

8 3
2 2
2 6
6 3


Result #1: 5

================

Input #2:

8 4
1 1
1 8
8 1
8 8


Result #2: 6

================

Input #3: 

5 1
3 3


Result #3: 2

This is a fastest-code problem, so the fastest code tested on the rextester compiler wins.

Have fun!
Node.js
Takes input as (w, l), where w is the width and l is an array of coordinates [x, y]. (This may be changed if the input format really is as strict as described.) Works in O(w²).

f = (w, l) =&gt; {
  var x, y,
      W = w * w,
      a = new Uint16Array(W),
      best = 0;

  l.forEach(([x, y]) =&gt; a[(y - 1) * w + x - 1] = 1);

  for(y = w; y &lt; W; y += w) {
    for(x = y + 1; x &lt; y + w; x++) {
      if(a[x]) {
        a[x] = 0;
      }
      else {
        best = Math.max(
          best,
          a[x] = Math.min(a[x - 1], a[x - w], a[x - w - 1]) + 1
        );
      }
    }
  }

  return best;
}

Try it online!