2017-09-04 12:07



In China, people use a pair of chopsticks to get food on the table, as we all know, the pair of chopsticks are of the same, but Miss Sundance is a bit different, as a lazy girl, she pluses a spoon to the end of one of her chopsticks, thus she can drink her favorite soup more easily.
But it comes to a serious problem. The lengths of the two chopsticks are now different. As you may guess, the length of them should be as close as possible. To make things clearer, for the set of chopsticks with lengths A, B (A <= B), (A - B) ^ 2 is called the 'badness' of the set.

It's September 11th, Miss Sundance��s birthday! She invited many people to join her birthday party, and would like to introduce her way of using chopsticks. So, She should prepare as many sets of chopsticks as possible. But Miss Sundance suddenly discovered that her chopsticks are of quite different lengths! She should find a way of composing the most sets of chopsticks, with the total badness (<= 2 ^ 31 - 1) of all the sets is minimized.


The first line in the input contains a single integer T, indicating the number of test cases. Each test case contains two lines. The first line begins with an positive integer N1 (1 =< N1 <= 500), the number of chopsticks with spoon, then N1 numbers follow, which denote the lengths of correspondent chopsticks, the second line, describes the normal chopsticks�� lengths, is the same format as the first one. (1 =< N2 <= 500)


For each test case in the input, print a line containing the minimal total badness of all the sets.

Sample Input

2 1 2
2 1 2

Sample Output


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答