Limits 1s, 512 MB

Tonmoy has a paper of length L mm and height of H mm. For any of his purpose he wants to fold it. But he folds the paper according to following conditions:

  1. Q times he will fold the paper.

  2. Each time he folds the paper from a specific position of length.

  3. He folds the paper only from left to right.

After completing his folding, Tonmoy asks you to say the H' height of P mm of length and L' remaining length after completing folding. As you are a programmer, can't you write a programme to say the height of that specific length.

[N.B: You can assume that no part of the paper won't be wasted by folding.]

Input

L H

Q

Q1

Q2

.

.

.

Qn

P

Constraints

1<=L<=106

0<=Q<=104

0<=Qn<=L&L'

1<=P<=L'

Output

Only print H' and remaining length L' after completing folding separated by a single space.

Samples

InputOutput
10 1
4
5
4
3
2
1
6 2
InputOutput
11 11
11
11
10
9
8
7
6
5
4
3
2
1
1
121 1

Problem Setter: Md. Masud Mazumder

Submit

Login to submit.

Statistics

50% Solution Ratio
nishat19Earliest, Aug '19
Kuddus.6068Fastest, 0.0s
CoderMLightest, 12 MB
subhashis_cseShortest, 470B
Toph uses cookies. By continuing you agree to our Cookie Policy.