#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000009;
void adm(int &x, int y) {
  x += y;
  if (x >= mo) {
    x -= mo;
  }
}
int sol, D[2][32][32][32][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, h;
  cin >> N >> h;
  D[0][0][0][0][1] = 1;
  int p = 1;
  for (int i = 0; i < N; ++i) {
    for (int h1 = 0; h1 <= h; ++h1) {
      for (int h2 = 0; h2 <= h; ++h2) {
        for (int h3 = 0; h3 <= h; ++h3) {
          for (int k = 0; k < 2; ++k) {
            int x = D[!p][h1][h2][h3][k];
            if (!x) {
              continue;
            }
            D[!p][h1][h2][h3][k] = 0;
            int h4;
            if (k) {
              h4 = 1;
            } else {
              h4 = h;
            }
            adm(D[p][min(h, h2 + 1)][min(h, h3 + 1)][h4][h1 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h3 + 1)][h4][h2 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h2 + 1)][h4][h3 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h2 + 1)][min(h, h3 + 1)][k], x);
          }
        }
      }
    }
    p = 1 - p;
  }
  p = 1 - p;
  for (int h1 = 0; h1 <= h; ++h1) {
    for (int h2 = 0; h2 <= h; ++h2) {
      for (int h3 = 0; h3 <= h; ++h3) {
        for (int k = 0; k < 2; ++k) {
          if (h1 < h || h2 < h || h3 < h || k) adm(sol, D[p][h1][h2][h3][k]);
        }
      }
    }
  }
  cout << sol;
  return 0;
}

### Prompt

Please formulate a Cpp solution to the following problem:

Manao is working for a construction company. Recently, an order came to build wall bars in a children's park. Manao was commissioned to develop a plan of construction, which will enable the company to save the most money.

After reviewing the formal specifications for the wall bars, Manao discovered a number of controversial requirements and decided to treat them to the company's advantage. His resulting design can be described as follows:

  * Let's introduce some unit of length. The construction center is a pole of height n. 
  * At heights 1, 2, ..., n exactly one horizontal bar sticks out from the pole. Each bar sticks in one of four pre-fixed directions. 
  * A child can move from one bar to another if the distance between them does not exceed h and they stick in the same direction. If a child is on the ground, he can climb onto any of the bars at height between 1 and h. In Manao's construction a child should be able to reach at least one of the bars at heights n - h + 1, n - h + 2, ..., n if he begins at the ground. 

<image> The figure to the left shows what a common set of wall bars looks like. The figure to the right shows Manao's construction

Manao is wondering how many distinct construction designs that satisfy his requirements exist. As this number can be rather large, print the remainder after dividing it by 1000000009 (109 + 9). Two designs are considered distinct if there is such height i, that the bars on the height i in these designs don't stick out in the same direction.

Input

A single line contains two space-separated integers, n and h (1 ≤ n ≤ 1000, 1 ≤ h ≤ min(n, 30)).

Output

In a single line print the remainder after dividing the number of designs by 1000000009 (109 + 9).

Examples

Input

5 1


Output

4


Input

4 2


Output

148


Input

4 3


Output

256


Input

5 2


Output

376

Note

Consider several designs for h = 2. A design with the first bar sticked out in direction d1, the second — in direction d2 and so on (1 ≤ di ≤ 4) is denoted as string d1d2...dn.

Design "1231" (the first three bars are sticked out in different directions, the last one — in the same as first). A child can reach neither the bar at height 3 nor the bar at height 4.

Design "414141". A child can reach the bar at height 5. To do this, he should first climb at the first bar, then at the third and then at the fifth one. He can also reach bar at height 6 by the route second  →  fourth  →  sixth bars.

Design "123333". The child can't reach the upper two bars.

Design "323323". The bar at height 6 can be reached by the following route: first  →  third  →  fourth  →  sixth bars.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000009;
void adm(int &x, int y) {
  x += y;
  if (x >= mo) {
    x -= mo;
  }
}
int sol, D[2][32][32][32][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, h;
  cin >> N >> h;
  D[0][0][0][0][1] = 1;
  int p = 1;
  for (int i = 0; i < N; ++i) {
    for (int h1 = 0; h1 <= h; ++h1) {
      for (int h2 = 0; h2 <= h; ++h2) {
        for (int h3 = 0; h3 <= h; ++h3) {
          for (int k = 0; k < 2; ++k) {
            int x = D[!p][h1][h2][h3][k];
            if (!x) {
              continue;
            }
            D[!p][h1][h2][h3][k] = 0;
            int h4;
            if (k) {
              h4 = 1;
            } else {
              h4 = h;
            }
            adm(D[p][min(h, h2 + 1)][min(h, h3 + 1)][h4][h1 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h3 + 1)][h4][h2 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h2 + 1)][h4][h3 < h], x);
            adm(D[p][min(h, h1 + 1)][min(h, h2 + 1)][min(h, h3 + 1)][k], x);
          }
        }
      }
    }
    p = 1 - p;
  }
  p = 1 - p;
  for (int h1 = 0; h1 <= h; ++h1) {
    for (int h2 = 0; h2 <= h; ++h2) {
      for (int h3 = 0; h3 <= h; ++h3) {
        for (int k = 0; k < 2; ++k) {
          if (h1 < h || h2 < h || h3 < h || k) adm(sol, D[p][h1][h2][h3][k]);
        }
      }
    }
  }
  cout << sol;
  return 0;
}

```