lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end n, m = read_line.split.map(&.to_i) a = (1..n).map { read_line.split.map(&.to_i64) } (0...m).each do |i| sum = (0...n).sum { |j| a[j][i] } (0...n).each { |j| a[j][i] *= sum } end puts a.map(&.sum).sort.reverse.each_slice(2).reduce({0i64, 0i64}) { |acc, x| {acc[0] + x[0], acc[1] + x[1]} }.try { |(x, y)| x - y }