Time limit
2s
Memory limit
256 MB
Junsu bought a new air gun as a birthday present, and stacked beer cans in several columns to test it.
Each can is black, gray, or white. In every column, cans are stacked only in this order from bottom to top: black, then gray, then white. A column may contain none of some color, but no column breaks this color order.
After stacking the cans, Junsu chooses a height and fires the air gun. When he shoots a height, every can currently at that height falls out, and the cans above it come straight down while keeping their order.
For each shot height in order, Junsu wants to know the score he gets. A fallen black can is worth 1 point, a gray can is worth 2 points, and a white can is worth 5 points. The score of one shot is the sum of the scores of all cans that fall during that shot.

The figure above shows the initial stack. If height 2 is shot, the stacks become as follows.

Three black cans, two gray cans, and one white can fall, so the score is 12. If height 4 is then shot from this new state, the stacks become as follows and the score is 7.

Given the initial stacks and the shot heights in order, compute the score obtained from each shot.
The first line contains the number of columns N (1 ≤ N ≤ 300,000).
The second line contains N integers: the number of black cans in each column.
The third line contains N integers: the number of gray cans in each column.
The fourth line contains N integers: the number of white cans in each column.
Every can count is a nonnegative integer not greater than 10^6.
The next line contains the number of shots M (1 ≤ M ≤ 300,000).
The next line contains M integers, the shot heights in order.
For each shot, in order, print the score obtained by shooting that height on its own line.