#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
typedef pair<int,int> P;

namespace NS {
  string s;
  int p;
  int exp();
  int term();
  int fact();
  
  int exp() {
    int x = term();
    while(s[p] == '+' || s[p] == '-') {
      if(s[p] == '+') {
        ++p;
        x += term();
      } else {
        ++p;
        x -= term();
      }
    }
    return x;
  }
  
  int term() {
    int x = fact();
    while(s[p] == '*') {
      ++p;
      x *= fact();
    }
    return x;
  }
  
  int fact() {
    string num = "";
    while(isdigit(s[p])) {
      num += s[p++];
    }
    return atoi(num.c_str());
  }
}

int parse(string s) {
  NS::s = s + "$";
  NS::p = 0;
  int res = NS::exp();
  assert(NS::p+1 == NS::s.size());
  return res;
}


const int MAXH = 221;
const int MAXW = 221;
const int MH = 7;
const int MW = 5;
int N;
char G[MAXH][MAXW];


const string F[13][MH] = {
  {
    ".....",
    ".###.",
    ".#.#.",
    ".#.#.",
    ".#.#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".#...",
    ".#...",
    ".#...",
    ".#...",
    ".#...",
    "....."
  },
  {
    ".....",
    ".###.",
    "...#.",
    ".###.",
    ".#...",
    ".###.",
    "....."
  },
  {
    ".....",
    ".###.",
    "...#.",
    ".###.",
    "...#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".#.#.",
    ".#.#.",
    ".###.",
    "...#.",
    "...#.",
    "....."
  },
  {
    ".....",
    ".###.",
    ".#...",
    ".###.",
    "...#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".###.",
    ".#...",
    ".###.",
    ".#.#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".###.",
    "...#.",
    "...#.",
    "...#.",
    "...#.",
    "....."
  },
  {
    ".....",
    ".###.",
    ".#.#.",
    ".###.",
    ".#.#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".###.",
    ".#.#.",
    ".###.",
    "...#.",
    ".###.",
    "....."
  },
  {
    ".....",
    ".....",
    "..#..",
    ".###.",
    "..#..",
    ".....",
    "....."
  },
  {
    ".....",
    ".....",
    ".....",
    ".###.",
    ".....",
    ".....",
    "....."
  },
  {
    ".....",
    ".....",
    ".....",
    ".#...",
    ".....",
    ".....",
    "....."
  }
};

void show(int w = 101, int h = 101) {
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      cout << G[i][j];
    }
    cout << endl;
  }
}

int main() {
  cin >> N;
  fill(G[0], G[MAXH], '.');
  for(int k = 0; k < N; ++k) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b == d) {
      for(int i = min(a,c); i <= max(a,c); ++i) G[10+b][10+i] = '#';
    } else {
      for(int i = min(b,d); i <= max(b,d); ++i) G[10+i][10+a] = '#';
    }
  }

  vector<pair<int,int> > id;
  for(int k = 0; k < 13; ++k) {
    pair<int,int> p(0, k);
    for(int a = 0; a < MH; ++a) {
      for(int b = 0; b < MW; ++b) {
        p.first -= F[k][a][b] == '#';
      }
    }
    id.push_back(p);
  }
  sort(id.begin(), id.end());

  vector<pair<int,int> > v;
  for(int t = 0; t < 13; ++t) {
    int k = id[t].second;
    for(int i = 0; i+MH <= MAXH; ++i) {
      for(int j = 0; j+MW <= MAXW; ++j) {
        try {
          for(int a = 0; a < MH; ++a) {
            for(int b = 0; b < MW; ++b) {
              if(G[i+a][j+b] == '.' && F[k][a][b] == '#') throw 0;
            }
          }
          for(int a = 0; a < MH; ++a) {
            for(int b = 0; b < MW; ++b) {
              if(F[k][a][b] == '#') G[i+a][j+b] = '.';
            }
          }
          v.push_back(make_pair(j, k));
        } catch(...) {}
      }
    }
  }

  sort(v.begin(), v.end());
  
  string s;
  for(int i = 0; i < v.size(); ++i) {
    if(v[i].second == 10) {
      s += '+';
    } else if(v[i].second == 11) {
      s += '-';
    } else if(v[i].second == 12) {
      s += '*';
    } else {
      s += '0'+v[i].second;
    }
  }
  //cout << s << endl;
  cout << parse(s) << endl;
  return 0;
}


Measured memory_bytes: 1348