This page is still under construction.

Parts of this page are still being built. What you see may change.

Villain Hoseok

Time limit1sMemory limit512 MB

Summary
Count how many K-digit displays (with leading zeros, value 1 to N) can be reached from the current display by flipping 1 to P of the seven-segment LEDs.
Level

Medium5 of 10

Topics
Brute force, Implementation, Math, Simulation
Solved
No attempts yet

Problem

The Chirbogi Building has an elevator that serves floors 11 through NN. The display showing the elevator's floor shows a KK-digit number. The number may start with 00. Each digit from 00 to 99 is shown on the display as below. Each digit is drawn by lighting some of the 7 segments.

For example, when K=4K=4, floors 16801680 and 501501 look like this.

Villain Hoseok plans to flip at least 11 and at most PP of the LEDs on the Chirbogi Building's elevator display. Flipping means turning a lit segment off and an unlit segment on. For example, to change the digit 11 into 22, 5 LEDs must be flipped. After flipping, he will change the display to show a valid number between 11 and NN inclusive, confusing people. As a member of the Association of People Who Love Chirbogi, you want to figure out Hoseok's action in advance and teach him a lesson. Given that the elevator is actually stopped at floor XX, count the number of ways Hoseok can choose which LEDs to flip.

Input

The first line gives N,K,P,XN, K, P, X separated by spaces.

Output

Count the number of ways Villain Hoseok can correctly flip the elevator LEDs.

Constraints

  • 1≤X≤N<10K1 ≤ X ≤ N < 10^K
  • 1≤K≤61 ≤ K ≤ 6
  • 1≤P≤421 ≤ P ≤ 42

Examples2

  1. Example 1

    Input
    9 1 2 5
    
    Expected output
    4
    
  2. Example 2

    Input
    48 2 5 35
    
    Expected output
    30