AlgoChief Sprint Round 2
A. Penalty Kick
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Alice and Bob are watching the World Cup Final. After the match ends in a draw, the result will be decided by a penalty shootout, featuring $$$n$$$ players from both Team A and Team B.

Each player's penalty kick success is determined by their shooting power $$$x_i$$$. A player scores a goal if their shooting power is greater than or equal to half the goalkeeper's height. Otherwise, they miss.

The team with the most goals wins. If both teams score the same number of goals, the winner is determined by the highest individual shooting power from the players on each team.

Alice believes that Team A will win, while Bob thinks Team B will come out on top. Your task is to determine who is correct.

Input

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 500$$$) — the number of testcases

  • The first line contains three integers, $$$n$$$ ($$$1 \le n \le 100$$$), $$$m$$$ and $$$k$$$ ($$$1 \le m, k \le 1000$$$), where $$$n$$$ is the number of players on each team, $$$m$$$ is the height of the goalkeeper on Team A, and $$$k$$$ is the height of the goalkeeper on Team B.
  • The second line contains $$$n$$$ integers, $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 1000$$$), representing the shooting powers of the players on Team A.
  • The third line contains $$$n$$$ integers, $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 1000$$$), representing the shooting powers of the players on Team B.

It is guaranteed that everyones shooting power is distinct

Output

If team A wins print Alice else print Bob

Example
Input
2
5 4 6
1 6 4 8 7
2 3 9 5 10
5 4 6
1 2 3 4 5
6 7 8 9 10
Output
Bob
Bob

B. Card Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are playing a card game with $$$n$$$ cards, with each card having a value positive or negative. You need to choose a non - empty subsequence of cards such that the total value of the cards is maximum.

Now your evaluator likes the number k so much. He will only like your sequence if you can divide the number of cards into groups of k. Hence you need to choose such a subsequence of cards which he likes.

A subsequence $$$a$$$ is a subsequence of a sequence $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by the deletion of several(possibly zero) elements.

Input

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of testcases

  • The first line contains two integers, $$$n$$$ ($$$1 \le n \le 1000$$$), and $$$k$$$ ($$$1 \le k \le 1000$$$), where $$$n$$$ is the number of cards and $$$k$$$ is your evaluators favourite number
  • The second line contains $$$n$$$ integers, $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$), the values of the cards
Output

For each test, print the best value you can achieve

Example
Input
4
2 1
1 2
5 4
-1 -2 -3 -4 -5
6 2
4 -5 6 -3 4 -6
1 1
0
Output
3
-10
11
0

C. Fat Burner II
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

After successfully tackling the rest and work balance last week, now you want to know exactly which exercises you must do on a particular training plan to burn the most fat.

You also have been browsing the internet, so you are learning about new exercises. So each day you are learning about some exercises. Here is how u can use them.

If you learn about a new exercise on day $$$i$$$, you can use it once to burn fat anytime between day $$$i$$$ and $$$n$$$

Also some exercises might make u gain fat instead of losing fat, they are identified by a negative fat burn.

You have n working days ahead of you, and your goal is to burn the most amount of fat after all n working days. Each day u need to choose atmost one exercise to perform. To balance the workload, you can perform an exercise only once throughout the n days.

Input

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 50$$$) — the number of testcases

  • The first line contains a single integer, $$$n$$$ ($$$1 \leq n \leq 100$$$), the number of days
  • Then follow $$$n$$$ lines, each line first has an integer $$$k$$$, followed by $$$k$$$ integers, the fat burned by the exercises you have learned on day $$$i$$$. ($$$0 \leq k \leq 10^5$$$), ($$$-10^9 \leq fat \leq 10^9$$$)

It is guaranteed that sum of $$$k$$$ over all days does not exceed $$$10^5$$$

Output

For each test, print the maximum fat u can burn

Example
Input
1
5
2 5 10
2 9 4
2 11 3
2 20 1
1 35
Output
85

D. Matchmaker
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are playing Matchmaker, in this version of the game, two people are considered a match made in heaven only if both have everything in similar.

Once a match is made, those people cannot partipate in other matches (of course)

You are playing this game on a string. So two letters exactly equal can be considered as a match. But being a good matchmaker, you want the number of matches to be as much as possible. Hence you can perform one type of operation on the string

  • Choose any index $$$i$$$ and replace it with a lowercase letter of your choice.

Since this task is very easy, you need to perform this on a particular substring of the string

You are given a string $$$s$$$ and $$$q$$$ queries to be answered on the string. For each query l, r you need to find that how many (minimum) characters between s[l], s[l + 1], s[l + 2].....s[r] must be changed such that you can create maximum number of matches between s[l], s[l + 1], s[l + 2].....s[r]

Input

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 500$$$) — the number of testcases

  • The first line contains two integers, $$$n$$$ ($$$1 \le n \le 10^5$$$) and $$$q$$$ ($$$1 \le q \le 10^5$$$), where $$$n$$$ is the number of letters in the string and $$$q$$$ is the number of queries to be answered
  • The second line contains the string
  • $$$n$$$ lines follow, each containing 2 numbers $$$l$$$ and $$$r$$$, the substring on which the query is to be answered ($$$1 \le l, r \le n$$$)

It is guaranteed that sum of all $$$n + q$$$ among tests do not exceed $$$2 * 10^5$$$

Output

For each test, print the answer of each query

Example
Input
2
6 4
abcdef
1 6
2 2
3 6
1 4
6 3
aaabbb
1 3
4 6
1 6
Output
3
0
2
2
0
0
1