N, K = gets.split.map(&:to_i) if K == 1 puts 'Yes' puts [*1..N].join(' ') exit end if N % K != 0 puts 'No' exit end S = N * (1 + N) / 2 M = N / K if S % K != 0 puts 'No' exit end if N % 2 == 0 && M % 2 != 0 puts 'No' exit end if M == 1 puts 'No' exit end 1.upto(N) do |n| end presents = [*1..N].each_slice(K).to_a puts 'Yes' ans = Array.new(K) { [] } from = 0 if M % 2 != 0 presents[2].reverse_each.with_index do |n, i| ans[i] << n end K.times do |i| ans[i] << (2 * i) % K + 1 end mid = (0..2).map { |x| presents[x][K / 2] }.sum K.times do |i| ans[i] << mid - ans[i].sum end from = 3 end from.upto(M - 1) do |idx| nums = presents[idx] if idx % 2 == 0 0.upto(K - 1) do |k| ans[k] << presents[idx].shift end else 0.upto(K - 1) do |k| ans[k] << presents[idx].pop end end end ans.each do |nums| puts nums.join(' ') end