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:
Q times he will fold the paper.
Each time he folds the paper from a specific position of length.
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.]
L H
Q
Q1
Q2
.
.
.
Qn
P
Constraints
1<=L<=106
0<=Q<=104
0<=Qn<=L&L'
1<=P<=L'
Only print H' and remaining length L' after completing folding separated by a single space.
Input | Output |
---|---|
10 1 4 5 4 3 2 1 | 6 2 |
Input | Output |
---|---|
11 11 11 11 10 9 8 7 6 5 4 3 2 1 1 | 121 1 |
Problem Setter: Md. Masud Mazumder