Problem:
Score: 400 points

Problem Statement

Amidakuji is a traditional method of lottery in Japan.

To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.

A valid amidakuji is an amidakuji that satisfies the following conditions:

No two horizontal lines share an endpoint.

The two endpoints of each horizontal lines must be at the same height.

A horizontal line must connect adjacent vertical lines.

Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.

For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.

Constraints

H is an integer between 1 and 100 (inclusive).

W is an integer between 1 and 8 (inclusive).

K is an integer between 1 and W (inclusive).

Input

Input is given from Standard Input in the following format:

H W K

Output

Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.

Sample Input 1

1 3 2

Sample Output 1

1

Only the following one amidakuji satisfies the condition:

Sample Input 2

1 3 1

Sample Output 2

2

Only the following two amidakuji satisfy the condition:

Sample Input 3

2 3 3

Sample Output 3

1

Only the following one amidakuji satisfies the condition:

Sample Input 4

2 3 1

Sample Output 4

5

Only the following five amidakuji satisfy the condition:

Sample Input 5

7 1 1

Sample Output 5

1

As there is only one vertical line, we cannot draw any horizontal lines. Thus, there is only one amidakuji that satisfies the condition: the amidakuji with no horizontal lines.

Sample Input 6

15 8 5

Sample Output 6

437760187

Be sure to print the answer modulo 1\ 000\ 000\ 007.

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <iostream>
#include <vector>
#include <cmath>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
 
const ll M = pow(10,9)+7;
 
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
// k^{M-2} == k^{-1}
//a,bの範囲的にこれだけ配列を用意していけば十分
 
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
 
ll comb2(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

long long gcd(long long a, long long b)
{
    long long c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
 
pair<ll, ll> add_bunsuu(pair<ll, ll> a, pair<ll, ll> b){
    ll bunbo = lcm(a.second, b.second);

    cout << a.first << "/" << a.second << endl;
    cout << b.first << "/" << b.second << endl;
    cout << a.first * bunbo / a.second + b.first * bunbo / b.second << "/" << bunbo << endl;

    return make_pair(a.first * bunbo / a.second + b.first * bunbo / b.second , bunbo);
}

ll valid_amida_pattern(ll w){
    if(w <= 0){
        return 1;
    }
    return valid_amida_pattern(w - 1) + valid_amida_pattern(w - 2);
}

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    ll** int_probs = new ll*[H + 1];
    for(ll i = 0; i < H + 1; i ++){
        int_probs[i] = new ll[W];
    }

    if(W == 1){
        return 1;
    }

    for(ll i = 0; i < W; i ++){
        if(i == 0){
            int_probs[0][i] = 1;
        }
        else{
            int_probs[0][i] = 0;
        }
    }

    for(ll i = 1; i < H + 1; i ++){
        for(ll n = 0; n < W; n ++){
            if(n == 0){
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(W - 2) + int_probs[i - 1][n + 1] * valid_amida_pattern(W - 3);
            }
            else if (n == W - 1){
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(W - 2) + int_probs[i - 1][n - 1] * valid_amida_pattern(W - 3);
            }
            else{
                int_probs[i][n] = int_probs[i - 1][n] * valid_amida_pattern(n - 1) * valid_amida_pattern(W - n - 2)
                    + int_probs[i - 1][n + 1] * valid_amida_pattern(n - 1) * valid_amida_pattern(W - n - 3)
                    + int_probs[i - 1][n - 1] * valid_amida_pattern(n - 2) * valid_amida_pattern(W - n - 2);
            }
            int_probs[i][n] = int_probs[i][n] % 1000000007;
        }
    }
    cout << int_probs[H][K - 1];
    
    return 0;
}