extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};
use std::fmt::{Display, Formatter, Error};
use ::State::Either;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
#[derive(Copy, Clone, Eq, PartialEq)]
enum State {
    Black, White, Either
}
impl Display for State  {
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
        match self {
            &State::Black => write!(f, "B"),
            &State::White => write!(f, "W"),
            &State::Either => write!(f, "E"),
        }
    }
}
fn is_match(state: &[[bool; 201]; 201], x: usize, y: usize, character: &[[State; 5]; 7]) -> bool {
    for i in 0 .. 7 {
        for j in 0 .. 5 {
            match character[i][j] {
                State::Black if x + j < 1 || 201 < x + j || y + i < 1 || 201 < y + i || state[y + i - 1][x + j - 1] == false => return false,
                State::White if 1 <= x + j && x + j <= 201 && 1 <= y + i && y + i <= 201 && state[y + i - 1][x + j - 1] => return false,
                _ => {}
            }
        }
    }
    true
}
fn to_pattern(character: &[[bool; 3]; 5]) -> [[State; 5]; 7] {
    let mut result = [[State::Either; 5]; 7];
    for y in 1 .. 6 {
        for x in 1 .. 4 {
            if character[y - 1][x - 1] {
                result[y][x] = State::Black;
                if result[y + 1][x] != State::Black {
                    result[y + 1][x] = State::White;
                }
                if result[y - 1][x] != State::Black {
                    result[y - 1][x] = State::White;
                }
                if result[y][x + 1] != State::Black {
                    result[y][x + 1] = State::White;
                }
                if result[y][x - 1] != State::Black {
                    result[y][x - 1] = State::White;
                }
            }
        }
    }
    result
}
fn parse(state: &[[bool; 201];201]) -> Vec<char> {
    let zero = to_pattern( &[[true, true, true], [true, false, true], [true, false, true], [true, false, true], [true, true, true]]);
    let one = to_pattern(&[[true, false, false],[true, false, false],[true, false, false],[true, false, false],[true, false, false]]);
    let two = to_pattern(&[[true, true, true], [false, false, true], [true, true, true], [true, false, false], [true, true, true]]);
    let three = to_pattern(&[[true, true, true], [false, false, true], [true, true, true], [false, false, true], [true, true, true]]);
    let four = to_pattern(&[[true, false, true], [true, false, true], [true, true, true], [false, false, true], [false, false, true]]);
    let five = to_pattern(&[[true, true, true], [true, false, false], [true, true, true], [false, false, true], [true, true, true]]);
    let six = to_pattern(&[[true, true, true], [true, false, false], [true, true, true], [true, false, true], [true, true, true]]);
    let seven = to_pattern(&[[true, true, true], [false, false, true], [false, false, true], [false, false, true], [false, false, true]]);
    let eight = to_pattern(&[[true, true, true], [true, false, true], [true, true, true], [true, false, true], [true, true, true]]);
    let nine = to_pattern(&[[true, true, true], [true, false, true], [true, true, true], [false, false, true], [true, true, true]]);
    let plus = to_pattern(&[[false, true, false], [true, true, true], [false, true, false], [false, false, false], [false, false, false]]);
    let minus = to_pattern(&[[true, true, true], [false, false, false], [false, false, false], [false, false, false], [false, false, false]]);
    let times = to_pattern(&[[true, false, false], [false, false, false], [false, false, false], [false, false, false], [false, false, false]]);
    let mut result = Vec::new();
    for x in 0 .. 201 {
        for y in 0 .. 201 {
            if is_match(state, x, y,&zero) {
                result.push('0');
            }else if is_match(state, x, y, &one) {
                result.push('1');
            }else if is_match(state, x, y, &two) {
                result.push('2');
            }else if is_match(state, x, y, &three) {
                result.push('3');
            }else if is_match(state, x, y, &four) {
                result.push('4');
            }else if is_match(state, x, y, &five) {
                result.push('5');
            }else if is_match(state, x, y, &six) {
                result.push('6');
            }else if is_match(state, x, y, &seven){
                result.push('7');
            }else if is_match(state, x, y, &eight) {
                result.push('8');
            }else if is_match(state, x, y, &nine) {
                result.push('9');
            }else if is_match(state, x, y, &plus) {
                result.push('+');
            }else if is_match(state, x, y, &minus) {
                result.push('-');
            }else if is_match(state, x, y, &times) {
                result.push('*');
            }
        }
    }
    result
}
fn parse_i32(state: &Vec<char>, position: usize) -> Option<(i32, usize)> {
    if state.len() <= position || !state[position].is_digit(10) {
        return None
    }
    let mut result = 0;
    for i in position .. state.len() {
        if let Some(d) = state[i].to_digit(10) {
            result *= 10;
            result += d as i32;
        }else {
            return Some((result, i))
        }
    }
    Some((result, state.len()))
}
fn parse_term(state: &Vec<char>, position: usize) -> Option<(i32, usize)> {
    if let Some((value, next)) = parse_i32(state, position) {
        let mut pos = next;
        let mut result = value;
        while pos < state.len() && state[pos] == '*' {
            if let Some((v, n)) = parse_i32(state, pos + 1) {
                result *= v;
                pos = n;
            } else {unreachable!()}
        }
        Some((result, pos))
    }else {
        None
    }
}
fn parse_expression(state: &Vec<char>) -> i32 {
    if let Some((value, position)) = parse_term(state, 0) {
        let mut pos = position;
        let mut result = value;
        while pos < state.len() {
            match state[pos] {
                '+' => {
                    if let Some((v, p)) = parse_term(state, pos + 1) {
                        pos = p;
                        result += v;
                    }else {unreachable!()}
                }
                '-' => {
                    if let Some((v, p)) = parse_term(state, pos + 1){
                        pos = p;
                        result -= v;
                    }else {unreachable!()}
                }
                _ => unreachable!()
            }
        }
        result
    }else {
        unreachable!()
    }
}
fn main() {
    let mut state: [[bool; 201]; 201] = [[false; 201]; 201];
    let_all!(n: usize);
    for _ in 0 .. n {
        let_all!(fx: usize, fy: usize, tx: usize, ty: usize);
        for x in min(fx, tx) .. max(fx, tx) + 1 {
            for y in min(fy, ty) .. max(fy, ty) + 1 {
                state[y][x] = true;
            }
        }
    }
    println!("{}", parse_expression(&parse(&state)));
}



Measured memory_bytes: 5076