P18138 [NWRRC 2026] Goin' Round

Description

A narrow circular road is divided into $n$ equal segments, numbered clockwise from $1$ to $n$. The next segment clockwise from segment $n$ is segment $1$. There are some golf carts on the road. Each cart occupies exactly one segment, no two carts occupy the same segment, and at least one segment is empty. All carts face clockwise. Anya and Borya are playing a game. They make moves alternately, with Anya going first. On each move, the player chooses any cart and advances it clockwise by one or more segments. The cart may neither pass another cart nor stop on a segment occupied by another cart. A player wins if, after their move, there are at least $g$ consecutive empty segments on the circular road. Initially, the road has no $g$ consecutive empty segments. If no player has won after a total of $2^n$ moves by the two players, the game is declared a draw. Determine the outcome if both players play optimally, preferring a win to a draw and a draw to a loss.

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows. The first line of each test case contains two integers $n$ and $g$, denoting the number of segments on the road and the number of consecutive empty segments needed to win ($3 \le n \le 3 \cdot 10^5$; $2 \le g < n$). The second line contains a string $s$ of length $n$, describing the initial positions of the carts. Character $s_i$ is `.` if segment $i$ is empty, or `>` if it contains a cart. Initially, the circular road has at least two carts on it and at least one empty segment, but no $g$ consecutive empty segments. It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$.

Output Format

For each test case, print “`Anya`” if Anya wins, “`Borya`” if Borya wins, or “`Draw`” if the game is a draw, assuming both players play optimally.

Explanation/Hint

#### Sample 1 Explanation In the first test case, Anya can win the game on her first move by advancing the cart from segment $5$ to segment $2$, leaving segments $4$, $5$, and $1$ empty. In the figure below, black triangles represent carts. The three consecutive empty segments after the move are hatched. ![](https://cdn.luogu.com.cn/upload/image_hosting/h8ufkbeg.webp)