PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000214. Chữ số khác 0 cuối cùng của chỉnh hợp (The Last Non-zero Digit)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chữ số khác 0 cuối cùng của chỉnh hợp (The Last Non-zero Digit)

The Last Non-zero Digit

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

For integers N,MN,M with 0≤M≤N0\le M\le N, the number of ordered selections of MM distinct objects from NN objects is

P(N,M)=N(N−1)⋯(N−M+1)=N!(N−M)!.P(N,M)=N(N-1)\cdots(N-M+1)=\frac{N!}{(N-M)!}.

When M=0M=0, this empty product equals 11.

Find the last nonzero decimal digit of P(N,M)P(N,M), obtained by removing all trailing zero digits and taking the remaining units digit.

Input

The only line contains the integers N,MN,M.

Output

Print exactly one digit from 1 through 9.

Subtasks

  • Subtask 1 (20 points): 0≤M≤N≤10000\le M\le N\le 1000.
  • Subtask 2 (30 points): 0≤M≤N≤1050\le M\le N\le 10^5.
  • Subtask 3 (50 points): 0≤M≤N≤2⋅1070\le M\le N\le 2\cdot 10^7.

Examples

Input

10 5

Output

4

Explanation

The required product is 10⋅9⋅8⋅7⋅6=3024010\cdot9\cdot8\cdot7\cdot6=30240. Removing the trailing zero yields 30243024, whose units digit is 44. Therefore print 4.