QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#17942. The Best Chocolate Pilgrimage

الإحصائيات

Coco Village is famous for having many chocolate shops. In this village, there is one chocolate shop at each coordinate $(x, y)$ for every integer $x$ and $y$ such that $1 \le x \le N$ and $1 \le y \le 2$. Among these are Coco's shop and Hanbyeol's shop; Coco's shop is at $(a, b)$ and Hanbyeol's shop is at $(c, d)$. The roads in Coco Village are somewhat unique: there is a road between any two shops if the difference in their $x$-coordinates and the difference in their $y$-coordinates are both at most $1$, allowing travel between them.

Coco is planning a chocolate pilgrimage course to take with Hanbyeol. A valid pilgrimage course is defined as follows:

  • It starts at Coco's shop and ends at Hanbyeol's shop, moving only along the roads.
  • Upon arriving at a location with a chocolate shop, one must visit that shop, and each chocolate shop is visited at most once.

Coco has assigned a score to the taste of the chocolate sold at every shop in the village. The score of a pilgrimage course is the sum of the scores of the chocolates from all visited shops, including Coco's and Hanbyeol's shops. Help Coco calculate the maximum possible score for a pilgrimage course.

Input

The first line contains the number of test cases $T$ $(1 \le T \le 1\,000)$.

For each test case, the first line contains the integer $N$ $(1 \le N \le 200\,000)$.

The next two lines contain the scores of the chocolates sold at each shop. Let $s_{(x, y)}$ be the score of the shop at coordinate $(x, y)$. The first line contains $N$ integers $s_{(1, 1)}, s_{(2, 1)}, \dots, s_{(N, 1)}$, and the second line contains $N$ integers $s_{(1, 2)}, s_{(2, 2)}, \dots, s_{(N, 2)}$, separated by spaces. $(-1\,000 \le s_{(x, y)} \le 1\,000)$

The following line contains $a, b, c, d$ representing the locations of Coco's shop and Hanbyeol's shop, respectively, separated by spaces. $(1 \le a, c \le N;$ $1 \le b, d \le 2;$ $(a, b) \neq (c, d))$

The sum of $N$ over all test cases does not exceed $1\,000\,000$.

Output

For each test case, output the score of the pilgrimage course with the highest score among all possible courses on a single line.

Examples

Input 1

1
5
0 10 20 30 40
-40 -30 -20 -10 0
1 1 5 2

Output 1

100

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.