시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 256 MB 166 30 23 32.857%

문제

준수는 생일선물을 맞아 새로운 공기총을 샀다. 그리고 공기총의 성능을 시험해보기 위해 맥주캔을 쌓아놓고 시험해보기로 하였다.

맥주캔은 총 검은색, 회색, 흰색으로 총 3가지 종류가 있다. 그리고 이를 N개의 열에 따라 쌓아올렸다. 쌓아올릴 때 순서는 아래에서부터 검은캔, 회색캔, 흰캔 순서로 쌓아올렸다. (한 열에 어느 색 캔이 모두 없을 수는 있지만 색깔 순서에 위배되도록 캔을 쌓는 일은 없다.)

이렇게 맥주캔을 쌓아올린 뒤 준수는 어느 높이를 정하여 공기총을 발사하였다. 이 공기총은 성능이 뛰어나기에 어느 한 높이를 쏘면 해당 높이의 캔들은 모두 바깥으로 떨어지고 위쪽의 캔들이 쓰러지지 않은채 그대로 내려온다.

준수는 성능 시험을 위해 각 높이를 쏘았을 때 점수를 구하고자 한다. 점수 구하는 법은 검은캔을 1점, 회색캔을 2점, 흰캔을 5점이라 할 때 해당높이의 캔 점수의 총 합으로 구해진다.

위 그림은 초기에 맥주캔을 쌓은 상태라고 하자. 여기서 만약 2번 높이를 총으로 쏜다면 아래와 같이 된다.

여기서 검은캔이 3개, 회색캔이 2개, 흰캔이 1개 쓰러졌으므로 총 12점을 얻게 된다. 또한 현 상태에서 4번 높이에 총을 쏘면 아래와 같이 된다.

마찬가지로 계산하면 4번 높이를 쏘았을 때는 7점을 얻게 된다.

초기 캔을 쌓은 정보와 쏘는 높이를 순서대로 입력하면 각 높이를 쏠 때 얻어지는 점수를 구하여보자.

입력

첫째 줄에 열의 개수 N(1 ≤ N ≤ 300,000)이 주어진다. 두 번째 줄에는 각 열에 쌓인 검은 캔의 개수를 나타내는 N개의 정수가 주어진다. 세 번째 줄에는 각 열에 쌓인 회색 캔의 개수를 나타내는 N개의 정수가 주어진다. 네 번째 줄에는 각 열에 쌓인 흰 캔의 개수를 나타내는 N개의 정수가 주어진다. 모든 수는 106이하이다. 다음 줄에는 준수가 쏘는 횟수 M(1 ≤ M ≤ 300,000)이 주어진다. 다음 줄에는 차례대로 준수가 쏘는 높이를 나타내는 M개의 정수가 입력된다.

출력

첫째 줄부터 M번째 줄까지 해당 높이를 쐈을 때 얻어지는 점수를 차례대로 출력한다.

예제 입력 1

6
2 1 2 0 3 1
1 2 2 2 2 0
1 0 1 2 0 3
2
2 4

예제 출력 1

12
7
W3sicHJvYmxlbV9pZCI6IjEyNzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMwZjciLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzkwMFx1YzIxOFx1YjI5NCBcdWMwZGRcdWM3N2NcdWMxMjBcdWJiM2NcdWM3NDQgXHViOWRlXHVjNTQ0IFx1YzBjOFx1Yjg1Y1x1YzZiNCBcdWFjZjVcdWFlMzBcdWNkMWRcdWM3NDQgXHVjMGMwXHViMmU0LiBcdWFkZjhcdWI5YWNcdWFjZTAgXHVhY2Y1XHVhZTMwXHVjZDFkXHVjNzU4IFx1YzEzMVx1YjJhNVx1Yzc0NCBcdWMyZGNcdWQ1ZDhcdWQ1NzRcdWJjZjRcdWFlMzAgXHVjNzA0XHVkNTc0IFx1YjllNVx1YzhmY1x1Y2U5NFx1Yzc0NCBcdWMzMTNcdWM1NDRcdWIxOTNcdWFjZTAgXHVjMmRjXHVkNWQ4XHVkNTc0XHViY2Y0XHVhZTMwXHViODVjIFx1ZDU1OFx1YzYwMFx1YjJlNC48XC9wPlxyXG5cclxuPHA+XHViOWU1XHVjOGZjXHVjZTk0XHVjNzQwIFx1Y2QxZCBcdWFjODBcdWM3NDBcdWMwYzksIFx1ZDY4Y1x1YzBjOSwgXHVkNzcwXHVjMGM5XHVjNzNjXHViODVjIFx1Y2QxZCAzXHVhYzAwXHVjOWMwIFx1Yzg4NVx1Yjk1OFx1YWMwMCBcdWM3ODhcdWIyZTQuIFx1YWRmOFx1YjlhY1x1YWNlMCBcdWM3NzRcdWI5N2MgT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