import sys
input = sys.stdin.readline
n = int(input())
board = [[0] * 101 for _ in range(101)]
#x는 열
#y는 행
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
for _ in range(n):
x, y, d, g = map(int, input().split())
board[y][x] = 1
move = [d]
for _ in range(g):
temp = []
for i in range(len(move)):
temp.append((move[-i - 1] + 1) % 4) #reverse, 즉 [::-1]
move.extend(temp)
for i in move:
ny = y + dy[i]
nx = x + dx[i]
board[ny][nx] = 1
y, x = ny, nx
ans = 0
for i in range(100):
for j in range(100):
if board[i][j]:
if board[i+1][j] and board[i][j+1] and board[i+1][j+1]:
ans += 1
print(ans)
0세대 : 0
1세대 : 0 1
2세대 : 0 1 2 1
3세대 : 0 1 2 1 2 3 2 1
4세대 : 0 1 2 1 2 3 2 1 2 3 0 3 2 3 2 1
...