P18135 [NWRRC 2026] Divide and Count

Description

The International Cardboard and Paper Corporation produces all kinds of paper: plain sheets in formats such as A4 for problem statements and D5 for clarification requests, as well as intricate shapes for packaging. Late at night, a designer at the corporation is preparing a cutting pattern for a new customer. The technical side is simple: the designer provides a drawing, and the cutting machine follows every line, straight or curved. Seven intersecting lines? No problem. The outline of a kitten? Just as easy. This time, however, the drawing consists of just two circles. Yet one question keeps the designer awake: how many pieces of paper will the cuts produce? The designer is working with a rectangular sheet of paper lying in the plane. The first circle has center $(x_1, y_1)$ and radius $r_1$, and the second one has center $(x_2, y_2)$ and radius $r_2$. Both circles lie strictly inside the sheet and do not touch its boundary. There are no restrictions on the relative positions of the two circles; in particular, they may intersect, touch, or coincide. The paper is cut along both circles. The exact dimensions of the sheet do not matter. Help the designer find the number of resulting pieces of paper.

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows. The only line of each test case contains six integers $x_1$, $y_1$, $r_1$, $x_2$, $y_2$, and $r_2$, denoting the centers and radii of the two circles ($-200 \le x_i, y_i \le 200$; $1 \le r_i \le 200$). Both circles lie strictly inside the sheet and do not touch its boundary.

Output Format

For each test case, print the number of pieces of paper produced.

Explanation/Hint

The figures show the three test cases, which produce $3$, $2$, and $4$ pieces, respectively. The rectangles show the sheets of paper, and the marked points are the centers of the circles. ![](https://cdn.luogu.com.cn/upload/image_hosting/x6qgvxtp.webp)