Codeforces Beta Round 82 (Div. 2)


A. Card Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
H
QH 9S
Output
YES
Input
S
8D 6D
Output
YES
Input
C
7H AS
Output
NO
----------------------------------------------------------------------------------------------------
B. Choosing Laptop
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2100 512 150 200
2000 2048 240 350
2300 1024 200 320
2500 2048 80 300
2000 512 180 150
Output
4
----------------------------------------------------------------------------------------------------
C. Buns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2 2 1
7 3 2 100
12 3 1 10
Output
241
Input
100 1 25 50
15 5 20 10
Output
200
----------------------------------------------------------------------------------------------------
D. Treasure Island
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 10
##########
#K#..#####
#.#..##.##
#..L.#...#
###D###A.#
##########
4
N 2
S 1
E 1
W 2
Output
AD
Input
3 4
####
#.A#
####
2
W 1
N 2
Output
no solution
----------------------------------------------------------------------------------------------------
E. Space Rescuers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 0 0
-5 0 0
0 3 4
4 -3 0
2 2 -2
Output
0.000 0.000 0.000
----------------------------------------------------------------------------------------------------
