#include <bits/stdc++.h>   using namespace std;   const int N = 6e6 + 500;   int pt[N << 1], tn, m;   pair<int, pair<int, int> > seg1[N], seg2[N];   int n1, n2;   int getdep(const pair<int, int> &u) { return u.first + u.second; }   int lowbit(const int &x) {     if (!x) return 1 << 30;     return x & -x;   }   pair<int, int> getfa(const pair<int, int> &u) {     if (!u.first || !u.second) return make_pair(0, 0);     return lowbit(u.first) < lowbit(u.second) ? make_pair(u.first - 1, u.second)                                               : make_pair(u.first, u.second - 1);   }   pair<int, int> gettop(const pair<int, int> &u) {     if (!u.first || !u.second) return make_pair((u.first != 0), (u.second != 0));     if (lowbit(u.first) < lowbit(u.second)) {       return make_pair(1 + (u.first & (~(lowbit(u.second) - 1))), u.second);     } else {       return make_pair(u.first, 1 + (u.second & (~(lowbit(u.first) - 1))));     }   }   void ins(pair<int, int> u, pair<int, int> v) {     pair<int, int> tpu, tpv;     while ((tpu = gettop(u)) != (tpv = gettop(v))) {       if (getdep(tpu) > getdep(tpv)) {         if (lowbit(u.second) < lowbit(u.first))           seg1[++n1] = make_pair(u.first, make_pair(tpu.second, u.second));         else           seg2[++n2] = make_pair(u.second, make_pair(tpu.first, u.first));         u = getfa(tpu);       } else {         if (lowbit(v.second) < lowbit(v.first))           seg1[++n1] = make_pair(v.first, make_pair(tpv.second, v.second));         else           seg2[++n2] = make_pair(v.second, make_pair(tpv.first, v.first));         v = getfa(tpv);       }     }     if (getdep(u) > getdep(v)) swap(u, v);     if (lowbit(u.second) < lowbit(u.first))       seg1[++n1] = make_pair(u.first, make_pair(u.second, v.second));     else       seg2[++n2] = make_pair(u.second, make_pair(u.first, v.first));   }   int main() {     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       pair<int, int> u, v;       scanf( %d%d%d%d , &u.first, &u.second, &v.first, &v.second);       ins(u, v);     }     sort(seg1 + 1, seg1 + n1 + 1), sort(seg2 + 1, seg2 + n2 + 1);     for (int i = 1, j; i <= n1; i = j + 1) {       j = i;       while (j + 1 <= n1 && seg1[j + 1].first == seg1[j].first) ++j;       int l = seg1[i].second.first, r = seg1[i].second.second;       for (int k = i + 1; k <= j; k++) {         int tl = seg1[k].second.first, tr = seg1[k].second.second;         if (tl <= r + 1)           r = max(r, tr);         else           pt[++tn] = l + seg1[i].first, pt[++tn] = r + seg1[i].first + 1, l = tl,           r = tr;       }       pt[++tn] = l + seg1[i].first, pt[++tn] = r + seg1[i].first + 1;     }     for (int i = 1, j; i <= n2; i = j + 1) {       j = i;       while (j + 1 <= n2 && seg2[j + 1].first == seg2[j].first) ++j;       int l = seg2[i].second.first, r = seg2[i].second.second;       for (int k = i + 1; k <= j; k++) {         int tl = seg2[k].second.first, tr = seg2[k].second.second;         if (tl <= r + 1)           r = max(r, tr);         else           pt[++tn] = l + seg2[i].first, pt[++tn] = r + seg2[i].first + 1, l = tl,           r = tr;       }       pt[++tn] = l + seg2[i].first, pt[++tn] = r + seg2[i].first + 1;     }     sort(pt + 1, pt + tn + 1);     int ans = 0;     for (int i = 1, j; i <= tn; i = j + 1) {       j = i;       if (!pt[i]) continue;       while (j + 1 <= tn && pt[j + 1] == pt[i]) ++j;       if (((j - i + 1) & 1)) ++ans;     }     cout << ans << endl;   }