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

#GL0000115. Đếm dãy có BCNN kề nhau bằng k (Counting LCM Arrays)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đếm dãy có BCNN kề nhau bằng k (Counting LCM Arrays)

Counting LCM Arrays

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers n,kn,k, count arrays a1,a2,…,ana_1,a_2,\dots,a_n of positive integers such that lcm⁡(ai,ai+1)=k\operatorname{lcm}(a_i,a_{i+1})=k for all 1≤i<n1\le i<n. Print the count modulo 109+710^9+7. Arrays differing at any position are distinct.

Input

One line containing n,kn,k.

Output

Print the number of valid arrays modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 2≤n≤122\le n\le12, 1≤k≤1001\le k\le100.
  • Subtask 2 (30 points): 2≤n≤1052\le n\le10^5, 1≤k≤1051\le k\le10^5.
  • Subtask 3 (50 points): 2≤n≤1092\le n\le10^9, 1≤k≤1091\le k\le10^9.

Examples

Input

3 4

Output

11

Explanation

Since k=4=22k=4=2^2, each entry belongs to {1,2,4}\{1,2,4\}. Exactly 1111 arrays of length 33 have every adjacent LCM equal to 44.