L = 10
table = [a = [[0, 0], [0, -1], [1, 0], [0, 1], [-1, 0]],
         b = a + [[1, -1], [1, 1], [-1, 1], [-1, -1]],
         b + [[0, -2], [2, 0], [0, 2], [-2, 0]]]
field = Array.new(L) {Array.new(L, 0)}

set = ->(x, y) {
  return if x < 0 or x >= L or y < 0 or y >= L
  field[y][x] += 1
}

$<.readlines.map {|l| l.split(",").map(&:to_i)}.each do |x, y, s|
  table[s - 1].each {|dx, dy| set.(x + dx, y + dy)}
end
f = field.flatten
puts f.count(0)
puts f.max
