#include <bits/stdc++.h>
using namespace std;
int same(int x1, int y1, int x2, int y2) {
  if (x1 == x2) {
    if (x1 == 0)
      return 1;
    else if ((1 << __builtin_ctz(x1)) > (y1 ^ y2))
      return 1;
  }
  if (y1 == y2) {
    if (y1 == 0)
      return 1;
    else if ((1 << __builtin_ctz(y1)) > (x1 ^ x2))
      return 1;
  }
  return 0;
}
struct event {
  int x, y, t;
};
bool comp(event a, event b) {
  if (a.x + a.y == b.x + b.y)
    return a.t < b.t;
  else
    return a.x + a.y < b.x + b.y;
}
vector<event> events;
map<int, int> x, y;
set<int> S;
int add(int d) {
  if (d < 0) return 0;
  if (S.count(d))
    S.erase(d);
  else
    S.insert(d);
  return 0;
}
int main() {
  int i;
  int m, x1, y1, x2, y2;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    while (!same(x1, y1, x2, y2)) {
      int n1, n2;
      if (x1 == 0)
        n1 = y1 - 1;
      else if (y1 == 0)
        n1 = x1 - 1;
      else
        n1 = 1 << min(__builtin_ctz(x1), __builtin_ctz(y1));
      if (x2 == 0)
        n2 = y2 - 1;
      else if (y2 == 0)
        n2 = x2 - 1;
      else
        n2 = 1 << min(__builtin_ctz(x2), __builtin_ctz(y2));
      if (x1 + y1 - n1 < x2 + y2 - n2) swap(x1, x2), swap(y1, y2);
      if (x1 == 0) {
        events.push_back((event){x1, 1, 2});
        events.push_back((event){x1, y1 + 1, -2});
        y1 = 0;
      } else if (y1 == 0) {
        events.push_back((event){1, y1, 1});
        events.push_back((event){x1 + 1, y1, -1});
        x1 = 0;
      } else {
        if (__builtin_ctz(x1) < __builtin_ctz(y1)) {
          events.push_back((event){x1 - (1 << __builtin_ctz(x1)) + 1, y1, 1});
          events.push_back((event){x1 + 1, y1, -1});
          x1 -= (1 << __builtin_ctz(x1));
        } else {
          events.push_back((event){x1, y1 - (1 << __builtin_ctz(y1)) + 1, 2});
          events.push_back((event){x1, y1 + 1, -2});
          y1 -= (1 << __builtin_ctz(y1));
        }
      }
    }
    if (x1 + y1 > x2 + y2) swap(x1, x2), swap(y1, y2);
    if (x1 == x2)
      events.push_back((event){x1, y1, 2}),
          events.push_back((event){x2, y2 + 1, -2});
    else
      events.push_back((event){x1, y1, 1}),
          events.push_back((event){x2 + 1, y2, -1});
  }
  sort(events.begin(), events.end(), comp);
  events.push_back((event){(int)1e9 + 5, (int)1e9 + 5, 0});
  int num = 0;
  for (i = 0; i < events.size() - 1; i++) {
    if (events[i].t > 0) {
      if (events[i].t == 1) {
        y[events[i].y]++;
        if ((y[events[i].y] == 1) && x.count(events[i].x)) num++;
      } else {
        x[events[i].x]++;
        if ((x[events[i].x] == 1) && y.count(events[i].y)) num++;
      }
    } else {
      if (events[i].t == -1) {
        if (y[events[i].y] == 1)
          y.erase(events[i].y);
        else
          y[events[i].y]--;
      } else {
        if (x[events[i].x] == 1)
          x.erase(events[i].x);
        else
          x[events[i].x]--;
      }
    }
    if (events[i + 1].x + events[i + 1].y != events[i].x + events[i].y) {
      if ((x.size() + y.size() + num) & 1)
        add(events[i].x + events[i].y), add(events[i].x + events[i].y - 1);
      if ((x.size() + y.size()) & 1)
        add(events[i + 1].x + events[i + 1].y - 1),
            add(events[i].x + events[i].y);
      num = 0;
    }
  }
  printf("%d\n", S.size());
  return 0;
}
