import sys # 방향은 우 상 좌 하 순서 table = [[0]*101 for i in range(101)] def path_list(d,g): path= [d] for gen in range(g): for i in range(len(path)-1, -1, -1): path.append((path[i] + 1)%4) ## 돌아가는 순서 잘못됨 return path def count_square(): global table cnt = 0 for r in range(100): for c in range(100): if (table[r][c] == 1 and table[r+1][c] == 1 and table[r][c+1] == 1 and table[r+1][c+1] == 1): cnt += 1 return cnt def plot_curves(curves): global table dr = [0,-1,0,1] dc = [1,0,-1,0] for (c,r,d,g) in curves: path = path_list(d,g) table[r][c] = 1 for i in path: r, c = r + dr[i], c + dc[i] table[r][c] = 1 if __name__ == '__main__': turn_in = 1 if turn_in ==0: sys.stdio = open('test_case.txt') N = int(sys.stdio.readline()) curves = [list(map(int, sys.stdio.readline().split())) for i in range(N)] else: N = int(sys.stdin.readline()) curves = [list(map(int, sys.stdin.readline().split())) for i in range(N)] plot_curves(curves) print(count_square())