Read problems statements in Mandarin Chinese  and Russian. 

In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass.

People in this world employ various techniques to increase the number of likes. One of the famous ones is to dis-like and re-like their own article once per day. On doing so you can assume that the number of likes for the post increase by a constant factor C.

So if one starts with S likes on Day-1, he would have D2 = S + C * S likes on Day-2,    D3 = D2 + D2 * C on Day-3 etc. You are to answer if the person would survive at the end of Day-D or not.

Input

First line contains a single positive integer T denoting the number of test cases. The following T lines represent a test case each. Each test case contains 4 space-separated integers L, D, S and C.

Output

For each test case, print a single line containing “ALIVE AND KICKING” if the person would live, otherwise print, “DEAD AND ROTTING”.

Constraints

1 ≤ T ≤ 1000
1 ≤ L ≤ 1000000000
1 ≤ D ≤ 1000000000
1 ≤ S ≤ 1000000000
1 ≤ C ≤ 1000000000

----- Sample Input 1 ------ 
2
5 1 5 1
10 2 2 2
----- Sample Output 1 ------ 
ALIVE AND KICKING
DEAD AND ROTTING

----- explanation 1 ------ 
In the first case by the end of Day-1 we would be having S that is 5 number of likes, as it is ? L, the answer is ALIVE AND KICKING.
In the second case, D2 =S + C*S, therefore D2 = 2 + 2 * 2 = 6, as 6 is less than 10, the answer is DEAD AND ROTTING.

Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
a = int(input(''))
for i in range(a):
	(l, d, s, c) = [int(x) for x in input('').split()]
	t1 = 0
	for j in range(d):
		if s >= l:
			t1 = 1
			break
		else:
			s = s + s * c
	if t1 == 0:
		print('DEAD AND ROTTING')
	else:
		print('ALIVE AND KICKING')


def value(l, d, s, c):
	if d <= 1 or s >= l:
		return s
	else:
		s += s * c
		return value(l, d - 1, s, c)
for case in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	if value(l, d, s, c) >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


t = int(input())
for test in range(t):
	(l, d, s, c) = map(int, input().split())
	d1 = s
	for i in range(d - 1):
		d1 = d1 + c * d1
		if d1 >= l:
			c = 1
			break
	if d1 >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


for x in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	for y in range(d - 1):
		s = s + s * c
		if s >= l:
			break
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


for i in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	for j in range(d - 1):
		s = s + s * c
		if s >= l:
			break
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


def solve(l, d, s, c):
	like = s
	for i in range(2, d + 1):
		like = like + like * c
		if like > l:
			break
	if like < l:
		return 'DEAD AND ROTTING'
	else:
		return 'ALIVE AND KICKING'
for _ in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	print(solve(l, d, s, c))


for t in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		while s < l:
			s = s + s * c
			d -= 1
			if d == 0:
				print('DEAD AND ROTTING')
		if d > 0:
			print('ALIVE AND KICKING')


t = int(input())
for _ in range(t):
	(L, D, S, C) = map(int, input().split())
	answer = S
	for day in range(2, D + 1):
		answer = answer * (C + 1)
		if answer >= L:
			break
	if answer >= L:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


test = int(input())
while test > 0:
	l = list(map(int, input().split()))
	ans = l[2]
	while l[1] - 1 > 0:
		ans += ans * l[3]
		if ans >= l[0]:
			break
		l[1] -= 1
	if ans >= l[0]:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')
	test -= 1


for _ in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	count = 0
	if d == 1:
		if s >= l:
			count += 1
	else:
		for i in range(d - 1):
			if s + s * c >= l:
				count += 1
				break
			else:
				s = s + s * c
	if count == 0:
		print('DEAD AND ROTTING')
	else:
		print('ALIVE AND KICKING')


import math
tests = int(input())
for i in range(tests):
	(l, d, s, c) = map(int, input().split())
	l = l / s
	required = math.log(l, c + 1)
	if required > d - 1:
		print('DEAD AND ROTTING')
	else:
		print('ALIVE AND KICKING')


t = int(input())
for i in range(t):
	(L, D, S, C) = map(int, input().split())
	if D == 1:
		if S >= L:
			print('ALIVE AND KICKING')
		else:
			print('DEAD AND ROTTING')
	else:
		for i in range(D - 1):
			S = S + S * C
			if S >= L:
				print('ALIVE AND KICKING')
				break
		else:
			print('DEAD AND ROTTING')


t = int(input())
for i in range(0, t):
	(l, m, s, c) = map(int, input().split(' '))
	for j in range(m - 1):
		s = s + s * c
		if s >= l:
			break
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	(l, d, s, c) = list(map(int, input().split()))
	if log(l / s, 1 + c) <= d - 1:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


import math
t = int(input())
for i in range(t):
	li = list(map(int, input().split(' ')))
	(l, d, s, c) = (li[0], li[1], li[2], li[3])
	if math.log(l / s, 1 + c) > d - 1:
		print('DEAD AND ROTTING')
	else:
		print('ALIVE AND KICKING')


t = int(input())
for _ in range(t):
	(l, d, s, c) = map(int, input().split())
	i = 2
	m = s
	while i <= d:
		m = m + m * c
		if m >= l:
			break
		i = i + 1
	if m >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


for _ in range(int(input())):
	(base, day, start, incr) = map(int, input().split())
	tot = start
	for i in range(day - 1):
		tot += tot * incr
		if tot >= base:
			break
	if tot >= base:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


test_case = int(input())
for _ in range(test_case):
	(l, d, s, c) = map(int, input().split())
	n = 2
	count = s
	flag = False
	if d == 1 and s >= l:
		flag = True
	else:
		while n <= d:
			count += count * c
			if count >= l:
				flag = True
				break
			n += 1
	if flag is True:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


import math
t = int(input())
for _ in range(t):
	(l, d, s, c) = map(int, input().split())
	k = s
	for i in range(1, d):
		k = k + k * c
		if k >= l:
			break
	if k >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


n = int(input())
for i in range(n):
	A = []
	(L, D, S, C) = map(int, input().split(' '))
	A.append(S)
	for j in range(D - 1):
		G = A[j] * (1 + C)
		A.append(G)
		if G >= L:
			break
	if A[-1] >= L:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


for _ in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	for day in range(2, d + 1):
		s = s * (c + 1)
		if s >= l:
			break
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


tests = int(input())
for i in range(tests):
	(l, d, s, c) = map(int, input().split())
	dead = True
	ans = s
	for j in range(d - 1):
		ans += ans * c
		if ans >= l:
			dead = False
			break
	if ans >= l:
		dead = False
	if dead:
		print('DEAD AND ROTTING')
	else:
		print('ALIVE AND KICKING')


t = int(input())
for t in range(t):
	(l, d, s, c) = [int(i) for i in input().split()]

	def summ(d, s, c, l):
		likes = s
		day = 2
		while day <= d:
			likes = likes + likes * c
			day += 1
			if likes >= l:
				break
		return likes
	ans = summ(d, s, c, l)
	if ans >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


t = int(input())
for i in range(t):
	(a, b, s, d) = map(int, input().split())
	for j in range(b - 1):
		s = s + s * d
		if s >= a:
			break
	if s >= a:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


T = int(input())
for i in range(T):
	a = input()
	h = a.split()
	s = int(h[2])
	l = int(h[0])
	d = int(h[1])
	c = int(h[3])
	for j in range(d - 1):
		s = s + s * c
		if s >= l:
			break
	if s >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


for case in range(int(input())):
	(least_no, days, start, constant) = map(int, input().split())
	if days == 1:
		if start >= least_no:
			print('ALIVE AND KICKING')
		else:
			print('DEAD AND ROTTING')
	else:
		for i in range(days - 1):
			start = start + start * constant
			if start >= least_no:
				print('ALIVE AND KICKING')
				break
		else:
			print('DEAD AND ROTTING')


test_cases = int(input())
while test_cases:
	(l, d, s, c) = map(int, input().split())
	i = 2
	sum1 = s
	flag = 0
	while i <= d:
		sum1 = sum1 * (1 + c)
		if sum1 >= l:
			flag = 1
			break
		i += 1
	if sum1 >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')
	test_cases -= 1


def like(l, d, s, c):
	if d == 1:
		if s >= l:
			return 'ALIVE AND KICKING'
		return 'DEAD AND ROTTING'
	for _ in range(d - 1):
		s = s * (1 + c)
		if s >= l:
			return 'ALIVE AND KICKING'
	return 'DEAD AND ROTTING'
for _ in range(int(input())):
	(l, d, s, c) = map(int, input().split())
	print(like(l, d, s, c))


t = int(input())
for _ in range(t):
	(l, d, s, c) = map(int, input().split())
	k = 0
	k = s
	flag = False
	for i in range(d):
		if i != 0:
			k = k + k * c
		if l <= k:
			flag = True
			break
	if flag:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')


t = int(input())
for ni in range(t):
	(l, d, s, c) = map(int, input().split())
	for i in range(d):
		if s >= l:
			print('ALIVE AND KICKING')
			break
		else:
			s = s + s * c
	else:
		print('DEAD AND ROTTING')


def main(l, d, s, c):
	if d == 1:
		if s >= l:
			return 'ALIVE AND KICKING'
		return 'DEAD AND ROTTING'
	for _ in range(d - 1):
		s = s * (1 + c)
		if s >= l:
			return 'ALIVE AND KICKING'
	return 'DEAD AND ROTTING'
tests = int(input())
for test in range(tests):
	(l, d, s, c) = list(map(int, input().split()))
	print(main(l, d, s, c))


from sys import stdin, stdout
import math
t = int(stdin.readline().rstrip())
while t > 0:
	(l, d, s, c) = map(int, stdin.readline().rstrip().split())
	if (math.log(l) - math.log(s)) / math.log(c + 1) <= d - 1:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')
	t -= 1


T = int(input())
for i in range(T):
	(l, d, s, c) = map(int, input().split())
	ans = s
	for a in range(2, d + 1):
		ans = ans * (c + 1)
		if ans >= l:
			break
	if ans >= l:
		print('ALIVE AND KICKING')
	else:
		print('DEAD AND ROTTING')