Segment Tree with set at each node
@ SuppressWarnings ( " unchecked " ) static HashSet < Integer > [ ] Tree = new HashSet [ 6 * N ] ; static { for ( int i = 0 ; i < 6 * N ; i ++ ) Tree [ i ] = new HashSet < > ( ) ; }