n = gets.chomp.to_i                                                                                                                                                                                                                                                             
x, y, t = [], [], []                                                                                                                                                                                                                                                            
0.upto(n-1) do |i|                                                                                                                                                                                                                                                              
  t[i], x[i], y[i] = gets.chomp.split(" ").map(&:to_i)                                                                                                                                                                                                                          
end                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                
now_x = 0                                                                                                                                                                                                                                                                       
now_y = 0                                                                                                                                                                                                                                                                       
now_t = 0                                                                                                                                                                                                                                                                       
t.each.with_index do |time, i|                                                                                                                                                                                                                                                  
  d_x = (x[i] - now_x).abs                                                                                                                                                                                                                                                      
  if d_x <= (time - now_t) && (y[i] - now_y).abs <= (time - now_t - d_x) && (y[i] - now_y).abs.odd? == (time - now_t - d_x).odd?                                                                                                                                                
    now_x = x[i]                                                                                                                                                                                                                                                                
    now_y = y[i]                                                                                                                                                                                                                                                                
    now_t = time                                                                                                                                                                                                                                                                
  else                                                                                                                                                                                                                                                                          
    break                                                                                                                                                                                                                                                                       
  end                                                                                                                                                                                                                                                                           
end                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                
if now_x == x.last && now_y == y.last                                                                                                                                                                                                                                           
  puts "Yes"                                                                                                                                                                                                                                                                    
else                                                                                                                                                                                                                                                                            
  puts "No"                                                                                                                                                                                                                                                                     
end

Measured memory_bytes: 4292