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# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

using FiniteFieldSystem;

class Program
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        int K = int.Parse(s[2]);
        FiniteField[][] dp = new FiniteField[H + 1][];
        for (int i = 0; i <= H; i++)
            dp[i] = new FiniteField[W];

        FiniteField[] com = new FiniteField[W + 1];
        com[0] = new FiniteField(1);
        if (W > 1) com[1] = new FiniteField(1);
        for (int i = 2; i <= W; i++)
            com[i] = com[i - 1] + com[i - 2];
        
        Func<int, FiniteField> Combination = x => (1 <= x && x <= W) ? com[x] : new FiniteField(1);
        Func<int, int, FiniteField> Access = (i, j) => (0 <= i && i <= H && 0 <= j && j < W) ? dp[i][j] : new FiniteField(0);

        dp[0][0] = new FiniteField(1);
        
        for (int i = 1; i <= H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                dp[i][j] =
                    Access(i - 1, j    ) * Combination(j - 0) * Combination(W - j - 1) +
                    Access(i - 1, j - 1) * Combination(j - 1) * Combination(W - j - 1) +
                    Access(i - 1, j + 1) * Combination(j - 0) * Combination(W - j - 2);
            }
        }
        Console.WriteLine(dp[H][K - 1]);
    }
}

namespace FiniteFieldSystem
{
    struct FiniteField : IComparable
    {
        public static readonly long p = 1000000007;

        public long Value;

        public int CompareTo(object obj)
        {
            if (obj == null) return 1;

            if (obj is FiniteField)
                return Value.CompareTo(((FiniteField)obj).Value);
            else
                throw new ArgumentException("");
        }

        public static implicit operator FiniteField(int value)
        {
            return new FiniteField(value);
        }
        public static implicit operator FiniteField(long value)
        {
            return new FiniteField(value);
        }
        public static implicit operator int(FiniteField value)
        {
            return (int)value.Value;
        }
        public static implicit operator long(FiniteField value)
        {
            return value.Value;
        }
        
        public FiniteField(int value)
        {
            Value = value % p;
            while (Value < 0)
                Value += p;
        }
        public FiniteField(long value)
        {
            Value = value % p;
            while (Value < 0)
                Value += p;
        }
        public FiniteField(FiniteField value)
        {
            Value = value.Value;
        }

        public static FiniteField operator +(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value + rhs.Value);
        }
        public static FiniteField operator -(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value - rhs.Value);
        }
        public static FiniteField operator *(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value * rhs.Value);
        }
        public static FiniteField operator /(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value * inversion(rhs));
        }
        static FiniteField inversion(FiniteField a)
        {
            long b = p, u = 1, v = 0;
            while (b!=0)
            {
                long t = a.Value / b;
                a.Value -= t * b;
                long tmp = a.Value;
                a.Value = b;
                b = tmp;
                u -= t * v;
                tmp = u;
                u = v;
                v = tmp;
            }
            u %= p;
            if (u < 0) u += p;
            return u;
        }

        public static FiniteField operator ++(FiniteField f)
        {
            return new FiniteField(f.Value + 1);
        }
        public static FiniteField operator --(FiniteField f)
        {
            return new FiniteField(f.Value - 1);
        }

        public override bool Equals(object obj)
        {
            if (obj == null || this.GetType() != obj.GetType())
                return false;
            return (Value == ((FiniteField)obj).Value);
        }
        public override int GetHashCode()
        {
            return Value.GetHashCode();
        }

        public static bool operator ==(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value == rhs.Value);
        }
        public static bool operator !=(FiniteField lhs, FiniteField rhs)
        {
            return !(lhs.Value == rhs.Value);
        }
        public static bool operator <(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value < rhs.Value);
        }
        public static bool operator >(FiniteField lhs, FiniteField rhs)
        {
            return (lhs.Value > rhs.Value);
        }

        public static FiniteField[] fac = { new FiniteField(1), new FiniteField(1) };
        public static FiniteField Factorial(FiniteField n)
        {
            if (fac.Length <= n.Value)
            {
                fac = new FiniteField[n + 1];
                fac[0] = new FiniteField(1);
                fac[1] = new FiniteField(1);
                for (int i = 2; i <= n; i++)
                    fac[i] = i * fac[i - 1];
            }
            return fac[n];
        }
        public static FiniteField nCm(FiniteField n, FiniteField m)
        {
            if (n < m) return 0;
            if (n < 0 || m < 0) return 0;

            return Factorial(n) / (Factorial(m) * Factorial(n - m));
        }
        public static FiniteField Catalan(FiniteField n)
        {
            return nCm(2 * n, n) / (n + 1);
        }
        public static FiniteField[] der = { new FiniteField(0), new FiniteField(1) };
        public static FiniteField Derangement(FiniteField n)
        {            
            if (der.Length < n.Value)
            {
                der = new FiniteField[n];
                der[0] = new FiniteField(0);
                der[1] = new FiniteField(1);
                for (int i = 2; i < n; i++)
                    der[i] = i * (der[i - 1] + der[i - 2]);
            }
            return der[n-1];
        }

        public new string ToString()
        {
            return Value.ToString();
        }
    }
}