# https://leetcode.com/problems/perfect-rectangle # n * (x, y, w, h) bricks = [tuple(map(int, input().split())) for _ in range(int(input()))] min_x = min_y = float('inf') max_x = max_y = float('-inf') corners = set() brick_area = 0 # count the corners of every brick # if an 'internal' corner appears an odd number of times, there's a gap/overlap # only the four corners of the whole wall will remain for 'perfect' brickwork for x0, y0, w, h in bricks: x1, y1 = x0 + w, y0 + h brick_area += w * h min_x, min_y = min(min_x, x0), min(min_y, y0) max_x, max_y = max(max_x, x1), max(max_y, y1) for corner in [(x0, y0), (x0, y1), (x1, y0), (x1, y1)]: if corner in corners: corners.remove(corner) else: corners.add(corner) # need to track area, consider case of two identically sized + placed bricks wall_area = (max_x - min_x)*(max_y - min_y) wall_corners = {(min_x, min_y), (min_x, max_y), (max_x, min_y), (max_x, max_y)} if brick_area == wall_area and corners == wall_corners: print("yes") else: print("no")