# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Paper Folding

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.]

## Input

**L** **H**

**Q**

**Q _{1}**

**Q _{2}**

.

.

.

**Q _{n}**

**P**

**Constraints**

**1<=L<=10 ^{6}**

**0<=Q<=10 ^{4}**

**0<=Q _{n}<=L&L’**

**1<=P<=L’**

## Output

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

## Samples

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

38% Solution Ratio

nishat19Earliest,

nishat19Fastest, 0.0s

CoderMLightest, 12 MB

subhashis_cseShortest, 470B

Login to submit