#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 10;   long long q, x, v, u, w, ans;   map<long long, long long> len;   int main() {     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> x >> v >> u;       if (x == 1) {         cin >> w;         while (v != u) {           if (v > u) {             len[v] += w;             v = v / 2;           } else {             len[u] += w;             u = u / 2;           }         }       } else {         ans = 0;         while (v != u) {           if (v > u) {             ans += len[v];             v = v / 2;           } else {             ans += len[u];             u = u / 2;           }         }         cout << ans <<   n ;       }     }     return 0;   }   