N, M = gets.split.map(&:to_i) E = Hash.new { |h, k| h[k] = [] } if M < N - 1 puts "NO" exit end m = M cur = 0 (N - 1).times do |u| E[u] << u + 1 m -= 1 end while m > 0 && cur < N es = E[cur].size v = cur + 2 * es + 1 if v < N E[cur] << v m -= 1 else cur += 1 end end if m > 0 puts "NO" else puts "YES" puts [*1..N].map { |v| v.even? ? v : 1_000_000 - v }.join(' ') E.each do |u, nums| nums.each do |v| puts "#{u + 1} #{v + 1}" end end end