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.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();

        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            var input = cin.SplitRead();
            int H = input[0];
            int W = input[1];
            int K = input[2];

            var res = new long[W + 1, 2];
            res[0, 0] = 1;
            res[0, 1] = 0;

            for(var i = 0; i < W; i++)
            {
                res[i + 1, 0] = (res[i, 0] + res[i, 1]) % MOD;
                res[i + 1, 1] = res[i, 0];
            }
            var C = new long[W + 1];
            for (var i = 0; i <= W; i++) C[i] = (res[i, 0] + res[i, 1]) % MOD;

            var dp = new long[H + 1, W];
            for(var i = 0; i <= H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    dp[i, j] = 0;
                }
            }
            dp[0, 0] = 1;

            for(var i = 0; i < H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    dp[i + 1, j] = (dp[i + 1, j] + (((dp[i, j] * C[Max(0, j - 1)]) % MOD) * C[Max(0, W - j - 2)]) % MOD) % MOD;
                    if (j > 0)
                    {
                        dp[i + 1, j] = (dp[i + 1, j] + (((dp[i, j - 1] * C[Max(0, j - 2)]) % MOD) * C[Max(0, W - j - 2)]) % MOD) % MOD;
                    }
                    if (j < W - 1)
                    {
                        dp[i + 1, j] = (dp[i + 1, j] + (((dp[i, j + 1] * C[Max(0, j - 1)]) % MOD) * C[Max(0, W - j - 3)]) % MOD) % MOD;
                    }
                }
            }
            /*Console.WriteLine(string.Join(",", C));
            for(var i = 0; i <= H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    Console.Write($"{dp[i, j]} ");
                }
                Console.WriteLine();
            }*/

            Console.WriteLine(dp[H, K - 1]);

            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
        struct Pair<T, U> : IComparable<Pair<T, U>>
        where T : IComparable<T>
        where U : IComparable<U>
        {
            public T first;
            public U second;
            private readonly bool CompWithFirst;

            public Pair(T f, U s, int comp)
            {
                first = f;
                second = s;
                CompWithFirst = comp == 1;
            }
            public Pair(T f,U s)
            {
                first = f;
                second = s;
                CompWithFirst = true;
            }

            public int CompareTo(Pair<T, U> other)
            {
                return CompWithFirst ? first.CompareTo(other.first) : second.CompareTo(other.second);
            }
        }
    }
    public class PriorityQueue<T> where T : IComparable<T>
    {

        private List<T> Q;
        private readonly int r;

        public PriorityQueue(bool ascending)
        {
            if (ascending)
            {
                r = 1;
            }
            else
            {
                r = -1;
            }
            Q = new List<T>();
        }


        private void PushHeap(List<T> list, T item)
        {
            int n = list.Count();
            list.Add(item);

            while (n != 0)
            {
                int pIndex = (n - 1) / 2;

                if (list[n].CompareTo(list[pIndex]) * r > 0)
                {
                    Swap(Q, n, pIndex);
                }
                else { break; }

                n = pIndex;
            }
        }

        private void PopHeap(List<T> list)
        {
            int n = list.Count() - 1;
            list[0] = list[n];
            list.RemoveAt(n);

            int cur = 0;
            int comp;

            while (2 * cur + 1 <= n - 1)
            {
                int c1 = 2 * cur + 1;
                int c2 = 2 * (cur + 1);
                if (c1 == n - 1)
                {
                    comp = c1;
                }
                else
                {

                    comp = list[c1].CompareTo(list[c2]) * r > 0 ? c1 : c2;
                }

                if (list[cur].CompareTo(list[comp]) * r < 0)
                {
                    Swap(Q, cur, comp);
                }
                else { break; }

                cur = comp;
            }
        }

        private void Swap(List<T> list, int a, int b)
        {
            T keep = list[a];
            list[a] = list[b];
            list[b] = keep;
        }



        public void Enqueue(T value)
        {
            PushHeap(Q, value);
        }

        public T Dequeue()
        {
            T ret = Q[0];
            PopHeap(Q);
            return ret;
        }

        public T Peek()
        {
            return Q[0];
        }

        public int CountItem()
        {
            return Q.Count();
        }
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }

        static public T MaxLot<T>(params T[] val) where T : IComparable<T>
        {
            T ret = val[0];
            for (var i = 1; i < val.Count(); i++)
            {
                if (ret.CompareTo(val[i]) < 0) { ret = val[i]; }
            }
            return ret;
        }
        static public T MinLot<T>(params T[] val) where T : IComparable<T>
        {
            T ret = val[0];
            for (var i = 1; i < val.Count(); i++)
            {
                if (ret.CompareTo(val[i]) > 0) { ret = val[i]; }
            }
            return ret;
        }
    }

}