Hint

* One grid may be filled more than once
* Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments.



Sample Input 1
Formula for Sample Input 1.

Sample Input 2
Sample Input 2 formula. Another character may get inside the smallest rectangle that covers one character, such as the "-7" part.

Constraints

The input satisfies the following conditions.

* 1 ≤ N ≤ 150
* 0 ≤ Xi1, Yi1, Xi2, Yi2 ≤ 200 (1 ≤ i ≤ N)
* Xi1 = Xi2 or Yi1 = Yi2 (1 ≤ i ≤ N)
* Numbers appearing in the middle of the calculation and in the result fit in a signed 32-bit integer

Input


N
X11 Y11 X12 Y12
X21 Y21 X22 Y22
::
XN1 YN1 XN2 YN2


The first line is given one integer N that represents the number of line segments. Next, the line segment information is given in N lines. Four integers Xi1, Yi1, Xi2, Yi2 are given on the i-th line of the line segment information, separated by blanks. Represents the X and Y coordinates of the first endpoint of the line segment, and the X and Y coordinates of the second endpoint, respectively.

Output

Output the calculation result of each case on one line.

Examples

Input

4
1 1 1 5
3 3 5 3
4 2 4 4
7 1 7 5


Output

2


Input

23
1 1 3 1
3 1 3 3
3 3 1 3
1 3 1 5
1 5 3 5
5 2 7 2
7 2 7 4
7 4 5 4
5 4 5 6
5 6 7 6
11 4 13 4
13 0 15 0
15 0 15 4
18 2 18 2
21 5 23 5
21 5 21 7
21 7 23 7
23 7 23 9
23 9 21 9
24 0 26 0
24 0 24 4
24 4 26 4
26 0 26 4


Output

-328
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 155

struct LOC{
	LOC(int arg_y,int arg_x){
		y = arg_y;
		x = arg_x;
	}
	int y,x;
};

struct Info{

	Info(int arg_loc,char arg_ch){
		loc = arg_loc;
		ch = arg_ch;
	}
	bool operator<(const struct Info &arg) const{

		return loc < arg.loc;
	}

	char ch;
	int loc;
};

int N;
int H = 210,W = 210;
int small_H = 5,small_W = 3;

char MAP[215][215];
char words[9][5][4] = {
   {"###",
	"#.#",
	"#.#",
	"#.#",
	"###",}
	,
   {"###",
	"..#",
	"###",
	"#..",
	"###",}
	,
   {"###",
	"..#",
	"###",
	"..#",
	"###",}
   ,
   {"#.#",
	"#.#",
	"###",
	"..#",
	"..#",}
	,
   {"###",
	"#..",
	"###",
	"..#",
	"###",}
	,
   {"###",
	"#..",
	"###",
	"#.#",
	"###",}
	,

   {"###",
	"#.#",
	"###",
	"#.#",
	"###",}
   ,
   {"###",
   	"#.#",
   	"###",
   	"..#",
   	"###",}
   ,
   {"###",
  	"..#",
  	"..#",
  	"..#",
  	"..#",}
  	,
   	};
char table[9] = {'0','2','3','4','5','6','8','9','7'};
char line[SIZE],work_line[SIZE];
int diff[13] =   {0,1,0,0,0,0,0,0,0,0,0,0,1};
int ans_len = -1;

int calc_E(int left,int right);
int calc_T(int left,int right);
int calc_F(int left,int right);
int calc_NUM(int left,int right);


int calc_E(int left,int right){

	int depth = 0;
	queue<int> Q;

	//深さ0の、プラスまたは-を探す
	for(int i = left; i <= right; ){
		if(line[i] == '(')depth++;
		else if(line[i] == ')')depth--;

		if(depth != 0){
			i++;
		}else if(line[i] != '+' && line[i] != '-'){
			i++;
		}else{
			if(line[i] == '+'){
				Q.push(i);
				i++;
			}else{ //line[i] == '-'
				if((i != left) && ((line[i-1] >= '0' && line[i-1] <= '9') || line[i-1] == ')')){ //-は、depthが0でもnegの場合あり
					Q.push(i);
				}
				while(i <=right && line[i] == '-')i++; //negの-が続いている場合があるので、読み飛ばす
			}
		}
	}

	if(Q.empty()){ //深さ0の+-がない
		return calc_T(left,right);
	}

	int tmp = calc_E(left,Q.front()-1),tmp_right;

	if(tmp == BIG_NUM)return BIG_NUM;

	while(!Q.empty()){
		int loc = Q.front();
		Q.pop();

		if(Q.empty()){
			tmp_right = calc_T(loc+1,right);
		}else{
			tmp_right = calc_T(loc+1,Q.front()-1);
		}

		if(tmp_right == BIG_NUM){
			return BIG_NUM;
		}

		if(line[loc] == '+'){
			tmp += tmp_right;
		}else{
			tmp -= tmp_right;
		}
	}

	return tmp;
}

int calc_T(int left,int right){

	int depth = 0;
	queue<int> Q;

	//深さ0の、*,/を探す
	for(int i = left; i <= right; ){
		if(line[i] == '(')depth++;
		else if(line[i] == ')')depth--;

		if(depth != 0){
			i++;
		}else if(line[i] != '*' && line[i] != '/'){
			i++;
		}else{
			Q.push(i);
			i++;
		}
	}

	if(Q.empty()){ //深さ0の*がない
		return calc_F(left,right);
	}

	int tmp = calc_T(left,Q.front()-1),tmp_right;

	if(tmp == BIG_NUM)return BIG_NUM;

	while(!Q.empty()){
		int loc = Q.front();
		Q.pop();

		if(Q.empty()){
			tmp_right = calc_F(loc+1,right);
		}else{
			tmp_right = calc_F(loc+1,Q.front()-1);
		}

		if(tmp_right == BIG_NUM){
			return BIG_NUM;
		}

		if(line[loc] == '*'){
			tmp *= tmp_right;
		}else{
			tmp /= tmp_right;
		}
	}
	return tmp;
}

int calc_F(int left,int right){

	if(line[left] >= '0' && line[left] <= '9'){
		return calc_NUM(left,right);
	}else if(line[left] == '-'){
		return -1*calc_F(left+1,right);
	}else if(line[left] == '('){

		int depth = 0;
		int close_pos = BIG_NUM;

		for(int i = left; i <= right; i++){
			if(line[i] == '(')depth++;
			else if(line[i] == ')'){
				depth--;
				if(depth == 0){
					close_pos = i;
					break;
				}
			}
		}

		if(close_pos == BIG_NUM || close_pos != right)return BIG_NUM;

		return calc_E(left+1,close_pos-1);
	}else{
		return BIG_NUM;
	}
}

int calc_NUM(int left,int right){

	int ret = 0;
	for(int i = left; i <= right; i++){
		ret = 10*ret+line[i]-'0';
	}
	return ret;
}

bool recursive(int col,int index){

	if(col == W){//探索完了

		for(int i = 0; i < index; i++){

			line[i] = work_line[i];
		}
		ans_len = index;

		return true;
	}

	//この列の黒マス数を調べる
	int num_black = 0;

	for(int row = 0; row < H; row++){
		if(MAP[row][col] == '#'){

			num_black++;
		}
	}

	if(num_black == 0){ //この行には'#'がないので、次の行へ行く

		return recursive(col+1,index);
	}

	//どの文字かを調べる

	for(int row = 0; row < H; row++){
		if(MAP[row][col] == '.')continue;

		int match_word = -1;
		vector<LOC> V_LOC;

		//まずはわかりやすい9種でチェック
		for(int a = 0; a < 9; a++){
			bool FLG = true;
			V_LOC.clear();
			for(int y = 0; y < small_H; y++){
				for(int x = 0; x < small_W; x++){
					if(MAP[row+y][col+x] != words[a][y][x]){
						FLG = false;
						break;
					}
					if(MAP[row+y][col+x] == '#'){
						V_LOC.push_back(LOC(row+y,col+x)); //塗られている場所を保存
					}
				}
				if(!FLG)break;
			}
			if(!FLG)continue;

			match_word = a;
			break;
		}

		if(match_word != -1){ //一致する文字あり

			//とりあえず、黒マスを消す
			for(int k = 0; k < V_LOC.size(); k++){

				MAP[V_LOC[k].y][V_LOC[k].x] = '.';
			}

			//この列の黒マスが全て消えたかを調べる
			for(int tmp_row = 0; tmp_row < H; tmp_row++){
				if(MAP[tmp_row][col] == '#'){

					//状態を復元し、falseを返す
					for(int k = 0; k < V_LOC.size(); k++){

						MAP[V_LOC[k].y][V_LOC[k].x] = '#';
					}

					return false;
				}
			}

			//この列の黒マスは全て消えた

			work_line[index] = table[match_word];

			if(recursive(col+1,index+1)){

				return true; //trueなら復元不要

			}else{
				//falseなら復元
				for(int k = 0; k < V_LOC.size(); k++){

					MAP[V_LOC[k].y][V_LOC[k].x] = '#';
				}
				return false;
			}
		}

		if(MAP[row+1][col] == '#'){ //1しか該当するものがない場合

			if(num_black != 5)return false;

			for(int tmp_row = 0; tmp_row < 5; tmp_row++){ //とりあえず黒マスを消す

				if(MAP[row+tmp_row][col] == '#'){

					V_LOC.push_back(LOC(row+tmp_row,col));
				}

				MAP[row+tmp_row][col] = '.';
			}

			//この列の黒マスが全て消えたかを調べる
			for(int tmp_row = 0; tmp_row < H; tmp_row++){
				if(MAP[tmp_row][col] == '#'){

					//状態を復元し、falseを返す
					for(int k = 0; k < V_LOC.size(); k++){

						MAP[V_LOC[k].y][V_LOC[k].x] = '#';
					}
					return false;
				}
			}

			//この列の黒マスは全て消えた
			work_line[index] = '1';

			if(recursive(col+1,index+1)){

				return true; //trueなら復元不要

			}else{
				//falseなら復元
				for(int k = 0; k < V_LOC.size(); k++){

					MAP[V_LOC[k].y][V_LOC[k].x] = '#';
				}
				return false;
			}

		}else{ //[+,-,*]のいずれか

			if(num_black != 1)return false;

			//+
			if(MAP[row-1][col+1] == '#' && MAP[row][col+1] == '#' && MAP[row+1][col+1] == '#' && MAP[row][col+2] == '#'){

				//とりあえず黒マスを消す
				MAP[row][col] = '.';
				MAP[row-1][col+1] = '.';
				MAP[row][col+1] = '.';
				MAP[row+1][col+1] = '.';
				MAP[row][col+2] = '.';

				work_line[index] = '+';

				if(recursive(col+1,index+1)){

					return true; //trueなら復元不要

				}else{
					//falseなら復元
					MAP[row][col] = '#';
					MAP[row-1][col+1] = '#';
					MAP[row][col+1] = '#';
					MAP[row+1][col+1] = '#';
					MAP[row][col+2] = '#';
				}
			}

			//-
			if(MAP[row][col+1] == '#' && MAP[row][col+2] == '#'){

				//とりあえず黒マスを消す
				MAP[row][col] = '.';
				MAP[row][col+1] = '.';
				MAP[row][col+2] = '.';

				work_line[index] = '-';

				if(recursive(col+1,index+1)){

					return true; //trueなら復元不要

				}else{
					//falseなら復元
					MAP[row][col] = '#';
					MAP[row][col+1] = '#';
					MAP[row][col+2] = '#';
				}
			}

			//*
			//とりあえず黒マスを消す
			MAP[row][col] = '.';

			work_line[index] = '*';

			if(recursive(col+1,index+1)){

				return true; //trueなら復元不要

			}else{
				//falseなら復元
				MAP[row][col] = '#';
			}
		}
		break;
	}
	return false;
}

int main(){

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			MAP[row][col] = '.';
		}
	}

	scanf("%d",&N);

	int x1,y1,x2,y2;

	//マップを塗る
	for(int loop = 0; loop < N; loop++){

		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);

		if(x1 == x2){ //縦

			for(int y = min(y1,y2); y <= max(y1,y2); y++){

				MAP[y][x1] = '#';
			}

		}else{ //y1 == y2:横

			for(int x = min(x1,x2); x <= max(x1,x2); x++){

				MAP[y1][x] = '#';
			}
		}
	}

	recursive(0,0);

	printf("%d\n",calc_E(0,ans_len-1));

	return 0;
}

