dx = [0,1,0,-1,1,-1]
dy = [1,0,-1,0,1,-1]
loop do
    t, n = gets.split.map(&:to_i)2
    break if t == 0 && n == 0
    blocks = n.times.map{gets.split.map{|c| c.to_i}}
    sy, sx = gets.split.map(&:to_i)
    q = [[sy,sx]]
    visited = Array.new(200).map{Array.new(200,false)}
    visited[sy+50][sx+50] = true
    count = 1
    t.times do
        q2 = []
        q.each do |sy,sx|
            for i in 0..5
                cy = sy + dy[i]
                cx = sx + dx[i]
                if !blocks.include?([cy,cx]) && !visited[cy+50][cx+50]
                    q2.push([cy,cx])
                    visited[cy+50][cx+50] = true
                    count += 1
                end
            end
        end
        q = q2
    end
    puts count
end