#include [[nodiscard]] static inline constexpr std::vector> solve([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t M, const std::vector& A) noexcept { std::vector> ans; ans.reserve(M); uint_fast32_t cur_first = A[0], cur_length = 1; for (uint_fast32_t i = 1; i != M; ++i) { if (A[i - 1] + 1 == A[i]) ++cur_length; else ans.emplace_back(cur_first, cur_length), cur_first = A[i], cur_length = 1; } ans.emplace_back(cur_first, cur_length); return ans; } static inline void output(const std::vector>& ans) noexcept { std::cout << ans.size() << '\n'; for (const auto& [S, L] : ans) std::cout << S << ' ' << L << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M; std::cin >> N >> M; std::vector A(M); for (auto& a : A) std::cin >> a; output(solve(N, M, A)); return 0; }