#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  pair<int, int> l, r;
  for (int i = 0; i < (1 << (n - 1)); ++i) {
    int a;
    cin >> a;
    l = max(l, make_pair(a, i));
  }
  for (int i = 0; i < (1 << (n - 1)); ++i) {
    int a;
    cin >> a;
    r = max(r, make_pair(a, (1 << (n - 1)) + i));
  }
  if (l.first > r.first) {
    cout << r.second + 1 << "\n";
  } else {
    cout << l.second + 1 << "\n";
  }
  return 0;
}

#include<bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif
using namespace std;
//using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    pair<ll, int> a{0, -1};
    pair<ll, int> b{0, -1};
    rep(i, pow(2, n-1)){
        ll v;
        cin >> v;
        if(a.first < v){
            a.first = v;
            a.second = i+1;
        }
    }
    rep(i, pow(2, n-1)){
        ll v;
        cin >> v;
        if(b.first < v){
            b.first = v;
            b.second = i+1+pow(2, n-1);
        }
    }
    cout << min(a, b).second << endl;
}