defmodule Main do def main do [n, m] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) nm = for i <- 0..(m - 1) do IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) end solve(n, m, nm) |> IO.puts end def solve(n, m, matrix) when 1 <= n and 0 <= m and m <= 100_000 and is_list(matrix) do matrix |> Enum.reduce({true, {0, 0}}, fn [ti, pi], {true, {ct, cp}} -> dt = ti - ct dp = abs(cp - pi) if dp <= dt and pi < n do {true, {ti, pi}} else false end _, false -> false end) |> (fn false -> "No" {true, _} -> "Yes" end).() end def solve(_n, _m, _matrix), do: "No" end