#P1968D. Permutation Game

    ID: 9191 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 4 Uploaded By: Tags>brute forcedfs and similargamesgraphsgreedymath*1300

Permutation Game

No submission language available for this problem.

Description

Bodya and Sasha found a permutation p1,,pnp_1,\dots,p_n and an array a1,,ana_1,\dots,a_n. They decided to play a well-known "Permutation game".

A permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Both of them chose a starting position in the permutation.

The game lasts kk turns. The players make moves simultaneously. On each turn, two things happen to each player:

  • If the current position of the player is xx, his score increases by axa_x.
  • Then the player either stays at his current position xx or moves from xx to pxp_x.
The winner of the game is the player with the higher score after exactly kk turns.

Knowing Bodya's starting position PBP_B and Sasha's starting position PSP_S, determine who wins the game if both players are trying to win.

The first line contains a single integer tt (1t1041\le t\le 10^4) — the number of testcases.

The first line of each testcase contains integers nn, kk, PBP_B, PSP_S (1PB,PSn21051\le P_B,P_S\le n\le 2\cdot 10^5, 1k1091\le k\le 10^9) — length of the permutation, duration of the game, starting positions respectively.

The next line contains nn integers p1,,pnp_1,\dots,p_n (1pin1 \le p_i \le n) — elements of the permutation pp.

The next line contains nn integers a1,,ana_1,\dots,a_n (1ai1091\le a_i\le 10^9) — elements of array aa.

It is guaranteed that the sum of values of nn over all test cases does not exceed 21052 \cdot 10^5.

For each testcase output:

  • "Bodya" if Bodya wins the game.
  • "Sasha" if Sasha wins the game.
  • "Draw" if the players have the same score.

Input

The first line contains a single integer tt (1t1041\le t\le 10^4) — the number of testcases.

The first line of each testcase contains integers nn, kk, PBP_B, PSP_S (1PB,PSn21051\le P_B,P_S\le n\le 2\cdot 10^5, 1k1091\le k\le 10^9) — length of the permutation, duration of the game, starting positions respectively.

The next line contains nn integers p1,,pnp_1,\dots,p_n (1pin1 \le p_i \le n) — elements of the permutation pp.

The next line contains nn integers a1,,ana_1,\dots,a_n (1ai1091\le a_i\le 10^9) — elements of array aa.

It is guaranteed that the sum of values of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each testcase output:

  • "Bodya" if Bodya wins the game.
  • "Sasha" if Sasha wins the game.
  • "Draw" if the players have the same score.

Sample Input 1

10
4 2 3 2
4 1 2 3
7 2 5 6
10 8 2 10
3 1 4 5 2 7 8 10 6 9
5 10 5 1 3 7 10 15 4 3
2 1000000000 1 2
1 2
4 4
8 10 4 1
5 1 4 3 2 8 6 7
1 1 2 1 2 100 101 102
5 1 2 5
1 2 4 5 3
4 6 9 4 2
4 2 3 1
4 1 3 2
6 8 5 3
6 9 5 4
6 1 3 5 2 4
6 9 8 9 5 10
4 8 4 2
2 3 4 1
5 2 8 7
4 2 3 1
4 1 3 2
6 8 5 3
2 1000000000 1 2
1 2
1000000000 2

Sample Output 1

Bodya
Sasha
Draw
Draw
Bodya
Sasha
Sasha
Sasha
Sasha
Bodya

Note

Below you can find the explanation for the first testcase, where the game consists of k=2k=2 turns.

TurnBodya's positionBodya's scoreBodya's moveSasha's positionSasha's scoreSasha's move
first330+a3=0+5=50 + a_3 = 0 + 5 = 5stays on the same position220+a2=0+2=20 + a_2 = 0 + 2 = 2moves to p2=1p_2=1
second335+a3=5+5=105 + a_3 = 5 + 5 = 10stays on the same position112+a1=2+7=92 + a_1 = 2 + 7 = 9stays on the same position
final results3310101199

As we may see, Bodya's score is greater, so he wins the game. It can be shown that Bodya always can win this game.