#include <cstdio>
#include <algorithm>
#define inf 1500000000

using namespace std;

struct cvor
{
    int val;
    int s;
};

cvor tree[2300000];
int val[1030][1030];

inline int min(int a,int b)
{
    if (a<b) return a; return b;
}

void update(int v)
{
    int k=tree[v].s;
    tree[v].val=min(min(tree[k].val,tree[k+1].val),min(tree[k+2].val,tree[k+3].val));
}

int cur;

void make(int level,int v)
{
    if (level==10) return;
    cur++;
    tree[v].s=cur;
    cur+=3;
    int k=tree[v].s;
    make(level+1,k);
    make(level+1,k+1);
    make(level+1,k+2);
    make(level+1,k+3);
}

int get(int v,int x1,int y1,int x2,int y2,int r1,int d1,int r2,int d2)
{
    if ( r1>=x1 && r2<=x2 && d1>=y1 && d2<=y2 ) return tree[v].val;
    if ( r2<x1 || r1>x2 || d2<y1 || d1>y2) return inf;
    int mx,my;
    mx=(x1+x2)/2;
    my=(y1+y2)/2;
    int     res=get(tree[v].s  ,x1  ,y1  ,mx,my,r1,d1,r2,d2);
    res=min(res,get(tree[v].s+1,mx+1,y1  ,x2,my,r1,d1,r2,d2));
    res=min(res,get(tree[v].s+2,mx+1,my+1,x2,y2,r1,d1,r2,d2));
    res=min(res,get(tree[v].s+3,x1  ,my+1,mx,y2,r1,d1,r2,d2));
    return res;
}

int main()
{
    freopen("pentranje.out","w",stdout);
    cur=1;
    make(1,1);
    printf("3\n5\n7\n-1\n5");
}
