#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N; std::vector A[3]; bool checked[100100]; void f(int x, int y, int z){ std::vector indices(N); std::iota(indices.begin(), indices.end(), 0); std::sort(indices.begin(), indices.end(), [&](int i, int j){return A[x][i] < A[x][j];}); std::reverse(indices.begin(), indices.end()); std::map rects; for(int i=0,j=0;isecond < u){ continue; } checked[indices[k]] = 1; } for(int k=i;ksecond >= u){ continue; } if(it != rects.begin()){ it = std::prev(it); while(it->second <= u){ if(it != rects.begin()){ auto p = std::prev(it); rects.erase(it); it = p; }else{ rects.erase(it); break; } } } rects[t] = u; } } } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N; for(int i=0;i<3;++i){ A[i].resize(N); } for(int i=0;i> A[0][i] >> A[1][i] >> A[2][i]; } f(0, 1, 2); f(1, 2, 0); f(2, 0, 1); for(int i=0;i