Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

NDIGIT - The Nth digit

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

Input
1 1 2
3 1 2
5 1 2

Output
2
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 SCM qobi VB.NET
Resource:VNOI Marathon '08 - Round 3/DivA
Problem Setter: Lê Đôn Khuê

hide comments
2010-07-23 23:51:21 cegprakash
for the third test case "5 1 2" the output is not 7.
its 1.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.