#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update>
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
    for (auto x : V)    cout << x << ' ' ;
    cout << '\n';
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 1500+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int a[N][N], vis[N][N][2], col[N][N];
int h, w, n, m;

void travH (int x, int y)
{
    for (int ny = y + 1; ny < w; ny++) {
        if (vis[x][ny][0] or a[x][ny] == -1) {
            break;
        } else {
            vis[x][ny][0] = col[x][ny] = 1;
        } 
    }
    for (int ny = y - 1; ny >= 0; ny--) {
        if (vis[x][ny][0] or a[x][ny] == -1) {
            break;
        } else {
            vis[x][ny][0] = col[x][ny] = 1;
        } 
    }
}

void travV (int x, int y)
{
    for (int nx = x - 1; nx >= 0; nx--) {
        if (vis[nx][y][1] or a[nx][y] == -1) {
            break;
        } else {
            vis[nx][y][1] = col[nx][y] = 1;
        }
    }
    for (int nx = x + 1; nx < h; nx++) {
        if (vis[nx][y][1] or a[nx][y] == -1) {
            break;
        } else {
            vis[nx][y][1] = col[nx][y] = 1;
        }
    }
}

int32_t main()
{
    SYNC    
    cin >> h >> w >> n >> m;
    rep(i,0,n) {
        int x, y; cin >> x >> y;
        x--, y--;
        a[x][y] = 1;
    }
    rep(i,0,m) {
        int x, y; cin >> x >> y;
        x--, y--;
        a[x][y] = -1;
    }

    rep(i,0,h) {
        rep(j,0,w) {
            if (a[i][j] == 1) {
                col[i][j] = 1;
                travV(i, j);
                travH(i, j);
            }
        }
    }

    // rep(i,0,h) {
    //     rep(j,0,w) {
    //         cout << a[i][j] << ' ';
    //     } cout << '\n';
    // }
    // cout << '\n';
    // rep(i,0,h) {
    //     rep(j,0,w) {
    //         cout << col[i][j] << ' ';
    //     } cout << '\n';
    // }


    int ans = 0;
    rep(i,0,h) {
        rep(j,0,w) {
            ans += col[i][j];
        }
    }
    cout << ans;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
bool _DD = false;
#define _D(a)if(_DD)cout<<#a<<':'<<a<<" | ";
#define DBG(a){_D(a);if(_DD)cout<<'\n';}
#define DBG2(a,b){_D(a);_D(b);if(_DD)cout<<'\n';}
#define DBG3(a,b,c){_D(a);_D(b);_D(c);if(_DD)cout<<'\n';}
#define DBG4(a,b,c,d){_D(a);_D(b);_D(c);_D(d);if(_DD)cout<<'\n';}
#define DBG5(a,b,c,d,e){_D(a);_D(b);_D(c);_D(d);_D(e);if(_DD)cout<<'\n';}
#define DBG6(a,b,c,d,e,f){_D(a);_D(b);_D(c);_D(d);_D(e);_D(f);if(_DD)cout<<'\n';}
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<vb> vvb;typedef vector<string> vs;typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vc> vvc;
#define unmp unordered_map

const lli PRIME = 1000000007ll;
const lli PRIME2 = 998244353ll;

inline void debugORfast(bool a=0,bool b=1){
    if(a) _DD=1;
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
}

//Question Link 

int main(int argc,char* argv[]) 
{
    if(argc>1 and strcmp(argv[1],"1")==0) debugORfast(1,1);
    else debugORfast(0,1);

	int n; cin>>n;
	int len = (1<<n);
	inp(len,v,int);
	vb vis(len,false);
	f(i,0,n-1){
		int fir = -1;
		int ptr = 0;
		while(ptr<len){
			if(vis[ptr]==false){
				if(fir==-1){
					fir=ptr;
				}else{
					int val1 = v[fir];
					int val2 = v[ptr];
					if(val1>val2){
						vis[ptr] = true;
					}else{
						vis[fir] = true;
					}
					fir=-1;
				}
			}
			++ptr;
		}
	}
	//f(i,0,vis.SZ) cout<<vis[i]<<' '; cout<<endl;
	int ansid=-1,ansval=1e9+1;
	f(i,0,len){
		if(!vis[i] and v[i]<ansval){
			ansval = v[i];
			ansid = i;
		}
	}
	cout<<ansid+1<<endl;
    return 0;
}
