Under construction

Still being built. Things may change

Curling

Interview

Time limit2sMemory limit1024 MB

Summary
For each end, find the team with the stone closest to the origin and count its stones closer than every opposing stone, then print the totals as a:b.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Curling (from the Scots word curr) is a team sport played on an ice sheet.

Wikipedia

Curling has been an Olympic sport since 1998. While watching the Winter Olympics in Vancouver, the Prime Minister of Flatland became very interested in the sport. He decided that Flatland must take part in curling competitions at the 2014 Olympics, for both the women's and the men's events.

Later it turned out that the country had no curling rinks at all. The Prime Minister took the matter seriously and ordered at least one rink to be built in each large city. The first rink to be built is in the center of Sen-Flatburg, the capital. It is almost finished, and the largest scoreboard available has already been bought, but no software has been written for it yet. Your task is to write a program that calculates the current score of a curling game.

Two teams play curling. A game consists of ten periods called ends. If the score is tied after ten ends, an extra eleventh end is played. In each end, the teams take turns playing stones. During an end, some stones may leave the playing area, and they are then removed from the sheet.

After each team has played all eight stones, the end is scored. The team whose stone is closest to the center of the house wins the end. That team gets one point for each of its stones that is strictly closer to the center than any stone of the opponent. The current score is the sum of the points from all completed ends.

Several ends have been played in a game. For each end, the final positions of the stones still in play are given. Determine the current score.

Input

The first line contains a single integer nn (1≤n≤111 \le n \le 11), the number of completed ends. Each end follows in this format.

The first line of an end contains two integers mm and kk (1≤m,k≤81 \le m, k \le 8), the numbers of stones still in play that belong to the first and second teams. The next mm lines each contain two integers, the coordinates of a stone of the first team. The next kk lines each contain two integers, the coordinates of a stone of the second team. All coordinates have absolute values not greater than 1000. No two stones in one end are at the same point.

The center of the house is at the origin (0,0)(0, 0).

Output

Print the current score in the form a:b, where aa is the current score of the first team and bb is the current score of the second team.

Examples2

  1. Example 1

    Input
    2
    2 2
    1 1
    2 2
    0 1
    -1 -1
    2 2
    0 0
    1 0
    -1 -1
    100 100
    
    Expected output
    2:1
    
  2. Example 2

    Input
    1
    1 1
    10 0
    0 10
    
    Expected output
    0:0