The first line contains four integers $w_1$, $w_2$, $w_3$, $w_4$ ($1 \leq w_i \leq 10^6$) --- the weights of each of the four items.

The second line contains four integers $t_1$, $t_2$, $t_3$, $t_4$ ($1 \leq t_i \leq 2$) --- the box numbers in which the corresponding items are located.