0.SB. ATM withdrawal


Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 98M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, C, C++, C11, CLANG, CLANGX, Classical, COBOL, Coffee, CSC, D lang, DART, F95, FORTH, Fortrn, GAS32, GO, Haskell, Itercal, Java, kotlin, LEAN, LISP, LUA, MONOVB, Nasm, OCAML, Pascal, Perl, php, PIKE, prolog, Pypy, Python, Ruby 2, RUST, Scala, SCM, SED, SWIFT, TCL, TUR, V8JS, VB, ZIG

Vinh works for an ATM machine manufacturing company. The basic functionality of an ATM machine is cash withdrawal. When a user requests a cash withdrawal of W VND (Vietnamese Dong), the ATM has to dispense N money notes such that they sum up to W. For the next generation of ATM machine, Vinh is working on an algorithm to minimize the number N of money notes for each cash withdrawal transaction.

Your task is to help Vinh to do his job given that the money notes come in the values of: \(1000;\:2000;\:3000;\:5000;\:1000*10^1;\:2000*10^1;\:3000*10^1;\:5000*10^1;\:...\:1000*10^c;\:2000*10^c;\:3000*10^c;\:5000*10^c\) where c is a positive integer and Vinh has unlimited supply of money notes for each value.

Input

The input consists of several datasets. The first line of the input contains the number of datasets which is a positive integer and is not greater than 1000. The following lines describe the datasets:

  • The first line consists of one positive integer W \((1 \le W \le 10^{18})\);
  • The second line consists of one positive integer c \((1 \le c \le 15)\).

Output

For each dataset, write in one line two space-separated integers N and S where S is the number of ways to dispense the fewest number N of money notes. In case there is no way to serve the cash withdrawal request, write out 0 in that line instead.

Examples

input

2

1000

1

7000

1

output

1 1

2 1


Comments

There are no comments at the moment.