w, d, n = gets.chomp.split.map(&:to_i)
measured = []
n.times{measured << gets.chomp.split.map(&:to_i)}
no = false
for i in (0..(n - 2))
    for j in ((i + 1)..(n - 1))
        if (measured[i][0] - measured[j][0]).abs + (measured[i][1] - measured[j][1]).abs < (measured[i][2] - measured[j][2]).abs
            no = true
            break
        end
    end
    break if no
end
if no
    puts "No"
else
    top = nil
    map = Array.new(d){[]}
    altitude = Hash.new{|h, k| h[k] = []}
    measured.each{|x, y, z|
        map[y - 1][x - 1] = z
        altitude[z] << [x, y]
        top = z if top.nil? || top < z
    }
    while !altitude.empty?
        altitude[top].each{|x, y|
            [[0, 1], [0, -1], [1, 0], [-1, 0]].each{|addx, addy|
                if (x + addx).between?(1, w) && (y + addy).between?(1, d) && map[y+addy-1][x+addx-1].nil?
                    map[y+addy-1][x+addx-1] = top - 1
                    altitude[top - 1] << [x+addx, y+addy]
                end
            } 
        }
        altitude.delete(top)
        top -= 1
    end
    total = 0
    map.each{|mp| total += mp.inject(:+)}
    puts total
end

