#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


bool table[210][210];


const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string S;
size_t cur=0;

int term();
int expression();

int digit(){
//	assert(isdigit(S[cur])); 
	int n = S[cur] - '0'; 
	cur++; 
	return n;
}

int number(){
	int n=digit();
	while(cur <S.size() && isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

int factor() {
	if (S[cur] != '(') return number();
	cur += 1;
	int n = expression();
//	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int term(){
	int sum = factor();
	while(S[cur] == '*' || S[cur] == '/'){
		char op = S[cur];
		cur += 1;
		int b = factor();
		if( op == '*')
			sum*=b;
		else {
//			assert(b);
			sum/=b;
		}
	}
	return sum;
}

int expression(){
	int sum = term();
	while(S[cur] == '+' || S[cur] == '-'){
		char op = S[cur];
		cur += 1;
		int b = term();
		if( op == '+')
			sum+=b;
		else 
			sum-=b;
	}
	return sum;
}


int main(void){
	int n;
	cin >> n;
	rep(i,n){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1==x2){
			if(y1>y2) swap(y1,y2);
			for(int j=y1;j<=y2;j++)
				table[x1][j]=true;
		}else{
			if(x1>x2) swap(x1,x2);
			for(int j=x1;j<=x2;j++)
				table[j][y1]=true;
		}
	}
	S="";
	rep(i,200+1)rep(j,200+1){
			if(table[i][j]){
				int rec=0;
				rep(k,3)rep(l,5){ rec+=table[i+k][j+l]; }
				
				int tmp=table[i+1][j+1]+table[i+1][j+3];
				
				if(rec==13&&tmp==0){
					S+='8';
					rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
				}else if(rec==12){
					if(tmp+table[i+1][j+2]==0){
						S+='0';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}else if(tmp+table[i][j+3]==0){
						S+='9';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}else if(tmp+table[i+2][j+1]==0){
						S+='6';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}
				}else if(rec==11){
					if(tmp+table[i][j+1]+table[i+2][j+3]==0){
						S+='2';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}else if(tmp+table[i][j+1]+table[i][j+3]==0){
						S+='3';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}else if(tmp+table[i+2][j+1]+table[i][j+3]==0){
						S+='5';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}
				}else if(rec==9){
					if(tmp+table[i+1][j]+table[i][j+3]+table[i][j+4]+table[i+1][j+4]==0){
						S+='4';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}
				}else if(rec==7){
					if(tmp+table[i][j+1]+table[i][j+2]+table[i+1][j+2]+table[i][j+3]+table[i][j+4]+table[i+1][j+4]==0){
						S+='7';
						rep(k,3)rep(l,5){ table[i+k][j+l]=false;}
					}
				}else{
					if(table[i][j]+table[i][j+1]+table[i][j+2]+table[i][j+3]+table[i][j+4]==5){
						S+='1';
						rep(l,5){ table[i][j+l]=false;}
					}else if(table[i][j]+table[i+1][j-1]+table[i+1][j]+table[i+1][j+1]+table[i+2][j]==5){
						S+='+';
						table[i][j]=false;
						table[i+1][j-1]=false;
						table[i+1][j]=false;
						table[i+1][j+1]=false;
						table[i+2][j]=false;
					}else if(table[i][j]+table[i+1][j]+table[i+2][j]==3){
						S+='-';
						table[i][j]=false;
						table[i+1][j]=false;
						table[i+2][j]=false;
					}else{ 
						S+='*';
						table[i][j]=false;
					}
				}
			}
	}
	cout << expression() << endl;
	return 0;
}


Measured memory_bytes: 1244