lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end h, w, q = read_line.split.map(&.to_i64) a = Hash(Int64, Int64).new(h) sum = h * w q.times do |i| y, x = read_line.split.map(&.to_i64.pred) if a[x] > y sum -= a[x] - y a[x] = y end puts sum end