## NDIGIT - The Nth digit

English | Vietnamese |

The number A(K) is defined by writing the numbers 1^K, 2^K, 3^K, ... sucessively in a right to left order.

For example, A(1) = ...181716151413121110987654321.

A(2)= ...169144121100816449362516941.

Consider the sum S = A(1) + A(2). The end of S is: ...350860272513937560350171262.

Given N, K1, K2. Your task is to find the N-th digit from the right of S = A(K1) + A(K2)(the rightmost digit of S is counted as the first digit).

### Input

There are 3 sub test cases. Each test case is written in a line containing 3 integers N, K1, K2 (1 ≤ K1, K2 ≤ 5. 1 ≤ N ≤ 1,000,000,000)

### Output

Print out 3 corresponding answers to the sub test cases.

### Grading

In each test case, you will get 5 marks for 3/3 correct answers, 3 marks for 2/3 correct answers, 1 marks for 1 correct answer, and 0 otherwise.

### Example

Input1 1 2 3 1 2 5 1 2Output2 2 7

Added by: | Lê Đôn Khuê |

Date: | 2008-06-27 |

Time limit: | 1.639s |

Source limit: | 10000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |

Resource: | VNOI Marathon '08 - Round 3/DivA Problem Setter: Lê Đôn Khuê |