import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
/**
* @author 은서파
* @since 2021. 11. 15.
* @see https://www.acmicpc.net/problem/15685
* @performance 12124 84
* @category #시뮬레이션, #규
* @memo
*/
public class BJ_G4_15685_드래곤커브 {
static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder output = new StringBuilder();
static StringTokenizer tokens;
static int N;
// 커브의 방향 매핑 : 인덱스를 기존 방향으로, 값을 새롭게 대체될 방향으로
static int [] curveMap = {1, 2, 3, 0};
static int [][] deltas = {{0, 1},{-1, 0},{0, -1},{1, 0}};
static boolean [][] map = new boolean[101][101];
public static void main(String[] args) throws IOException {
input = new BufferedReader(new StringReader(src));
N = Integer.parseInt(input.readLine());
for(int n=0; n<N; n++) {
tokens = new StringTokenizer(input.readLine());
int x = Integer.parseInt(tokens.nextToken());
int y = Integer.parseInt(tokens.nextToken());
int d = Integer.parseInt(tokens.nextToken());
int g = Integer.parseInt(tokens.nextToken());
makeCurve(x, y, d, g);
}
// 입력 완료
// 커브 작성 완료
int cnt = 0;
for(int r=0; r<100; r++) {
for(int c=0; c<100; c++) {
if(map[r][c] && map[r+1][c] && map[r][c+1] && map[r+1][c+1]) {
cnt++;
}
}
}
System.out.println(cnt);
}
private static void makeCurve(int x, int y, int d, int g) {
// 출발점
map[y][x]=true;
// 0세대의 끝점
int endR = y + deltas[d][0];
int endC = x + deltas[d][1];
int endD = curveMap[d];
// 0세대 작성 끝!!!
List<Point> points = new ArrayList();
points.add(new Point(endR, endC, endD));
for(int i=0; i<g; i++) {
// 리스트에 담긴 것의 역 순으로 소진시켜주기
for(int j=points.size()-1; j>=0; j--) {
Point last = points.get(j);
// 기존의 마지막 점에서 계속 그려나가기
endR+=deltas[last.d][0];
endC+=deltas[last.d][1];
endD = curveMap[last.d];
points.add(new Point(endR, endC, endD));
}
}
}
static class Point{
int r, c, d;
public Point(int r, int c, int d) {
this.r = r;
this.c= c;
this.d = d;
// 생성되면 지도에 표시된다.!!
map[r][c] = true;
}
}
// REMOVE_START
private static String src = "4\r\n"
+ "50 50 0 10\r\n"
+ "50 50 1 10\r\n"
+ "50 50 2 10\r\n"
+ "50 50 3 10";
// REMOVE_END
}