#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <cctype>

using namespace std;
typedef pair<int, int> pii;
struct Line {
	int x1, y1, x2, y2;
};

const int INF = 1000000000;
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, -1, 0, 1 };

const int table[13][5][3] = {
	{
		{ 1, 1, 1 },
		{ 1, 0, 1 },
		{ 1, 0, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 0, 0 },
		{ 1, 0, 0 },
		{ 1, 0, 0 },
		{ 1, 0, 0 },
		{ 1, 0, 0 }
	},
	{
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 1, 1, 1 },
		{ 1, 0, 0 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 0, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 0, 0, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 1, 0, 0 },
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 1, 0, 0 },
		{ 1, 1, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 0, 0, 1 },
		{ 0, 0, 1 },
		{ 0, 0, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 1, 1, 1 },
		{ 1, 0, 1 },
		{ 1, 1, 1 },
		{ 0, 0, 1 },
		{ 1, 1, 1 }
	},
	{
		{ 0, 1, 0 },
		{ 1, 1, 1 },
		{ 0, 1, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 }
	},
	{
		{ 1, 1, 1 },
		{ 0, 0, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 }
	},
	{
		{ 1, 0, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 },
		{ 0, 0, 0 }
	}
};

pii lex_expr(const char *s, int p);
pii lex_term(const char *s, int p);
pii lex_number(const char *s, int p);

pii lex_expr(const char *s, int p){
	pii r = lex_term(s, p);
	p = r.second;
	while(s[p] == '+' || s[p] == '-'){
		pii q = lex_term(s, p + 1);
		if(s[p] == '+'){
			r.first += q.first;
		}else{
			r.first -= q.first;
		}
		p = q.second;
	}
	r.second = p;
	return r;
}
pii lex_term(const char *s, int p){
	pii r = lex_number(s, p);
	p = r.second;
	while(s[p] == '*'){
		pii q = lex_number(s, p + 1);
		r.first *= q.first;
		p = q.second;
	}
	r.second = p;
	return r;
}
pii lex_number(const char *s, int p){
	int x = 0;
	while(isdigit(s[p])){
		x = (x * 10) + s[p++] - '0';
	}
	return pii(x, p);
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector< vector<int> > grid(210, vector<int>(210));
	for(int i = 0; i < n; ++i){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 > x2){ swap(x1, x2); }
		if(y1 > y2){ swap(y1, y2); }
		if(y1 == y2){
			for(int x = x1; x <= x2; ++x){ grid[y1][x] = 1; }
		}else{
			for(int y = y1; y <= y2; ++y){ grid[y][x1] = 1; }
		}
	}
	string s;
	for(int j = 0; j < grid[0].size(); ++j){
		for(int i = 0; i < grid.size(); ++i){
			if(grid[i][j] == 0){ continue; }
			int mx = j, my = i;
			vector<pii> ps;
			queue<pii> q;
			q.push(pii(i, j));
			ps.push_back(pii(i, j));
			grid[i][j] = 0;
			while(!q.empty()){
				const pii p = q.front();
				q.pop();
				for(int d = 0; d < 4; ++d){
					const int y = p.first + dy[d], x = p.second + dx[d];
					if(y < 0 || x < 0 || grid[y][x] == 0){ continue; }
					grid[y][x] = 0;
					ps.push_back(pii(y, x));
					q.push(pii(y, x));
					mx = min(mx, x);
					my = min(my, y);
				}
			}
			int p[5][3] = { { 0 } };
			for(int k = 0; k < ps.size(); ++k){
				p[ps[k].first - my][ps[k].second - mx] = 1;
			}
			int c = -1;
			for(int k = 0; k < 13; ++k){
				bool match = true;
				for(int y = 0; y < 5; ++y){
					for(int x = 0; x < 3; ++x){
						if(p[y][x] != table[k][y][x]){ match = false; }
					}
				}
				if(match){ c = k; }
			}
			if(0 <= c && c < 10){
				s += '0' + c;
			}else if(c == 10){
				s += '+';
			}else if(c == 11){
				s += '-';
			}else if(c == 12){
				s += '*';
			}
		}
	}
	cout << lex_expr(s.c_str(), 0).first << endl;
	return 0;
}
