#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
long long dp[44][44][44];
int n, m;
long long a[44][44];
long long tp[44][44];
long long ans[44][44];
void multi(long long a[44][44], long long b[44][44], long long c[44][44]) {
  int C = 2 * n + 1;
  for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) {
      tp[i][j] = 0x3f3f3f3f3f3f3f3fLL;
      for (int k = 0; k < C; k++) {
        smin(tp[i][j], a[i][k] + b[k][j]);
      }
    }
  for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) c[i][j] = tp[i][j];
}
int aa[44], bb[44];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) gn(aa[i]);
  for (int i = 1; i <= n; i++) gn(bb[i]);
  for (int i = 0; i < 44; i++)
    for (int j = 0; j < 44; j++)
      for (int k = 0; k < 44; k++) dp[i][j][k] = 0x3f3f3f3f3f3f3f3fLL;
  for (int i = 0; i <= 2 * n; i++) {
    if (i < 2 * n) dp[1][i][i + 1] = aa[1];
    if (i) dp[1][i][i - 1] = bb[1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= 2 * n; j++) {
      for (int k = 0; k <= 2 * n; k++) {
        if (k) smin(dp[i][j][k], dp[i - 1][j][k - 1] + aa[i]);
        smin(dp[i][j][k], dp[i - 1][j][k + 1] + bb[i]);
      }
    }
  }
  for (int i = 0; i <= 2 * n; i++) {
    for (int j = 0; j <= 2 * n; j++) {
      ans[i][j] = a[i][j] = dp[n][i][j];
    }
  }
  int xx = m - 1;
  while (xx) {
    if (xx & 1) multi(ans, a, ans);
    multi(a, a, a);
    xx >>= 1;
  }
  println(ans[0][0]);
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

Jeff loves regular bracket sequences.

Today Jeff is going to take a piece of paper and write out the regular bracket sequence, consisting of nm brackets. Let's number all brackets of this sequence from 0 to nm - 1 from left to right. Jeff knows that he is going to spend ai mod n liters of ink on the i-th bracket of the sequence if he paints it opened and bi mod n liters if he paints it closed.

You've got sequences a, b and numbers n, m. What minimum amount of ink will Jeff need to paint a regular bracket sequence of length nm?

Operation x mod y means taking the remainder after dividing number x by number y.

Input

The first line contains two integers n and m (1 ≤ n ≤ 20; 1 ≤ m ≤ 107; m is even). The next line contains n integers: a0, a1, ..., an - 1 (1 ≤ ai ≤ 10). The next line contains n integers: b0, b1, ..., bn - 1 (1 ≤ bi ≤ 10). The numbers are separated by spaces.

Output

In a single line print the answer to the problem — the minimum required amount of ink in liters.

Examples

Input

2 6
1 2
2 1


Output

12


Input

1 10000000
2
3


Output

25000000

Note

In the first test the optimal sequence is: ()()()()()(), the required number of ink liters is 12.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
long long dp[44][44][44];
int n, m;
long long a[44][44];
long long tp[44][44];
long long ans[44][44];
void multi(long long a[44][44], long long b[44][44], long long c[44][44]) {
  int C = 2 * n + 1;
  for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) {
      tp[i][j] = 0x3f3f3f3f3f3f3f3fLL;
      for (int k = 0; k < C; k++) {
        smin(tp[i][j], a[i][k] + b[k][j]);
      }
    }
  for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) c[i][j] = tp[i][j];
}
int aa[44], bb[44];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) gn(aa[i]);
  for (int i = 1; i <= n; i++) gn(bb[i]);
  for (int i = 0; i < 44; i++)
    for (int j = 0; j < 44; j++)
      for (int k = 0; k < 44; k++) dp[i][j][k] = 0x3f3f3f3f3f3f3f3fLL;
  for (int i = 0; i <= 2 * n; i++) {
    if (i < 2 * n) dp[1][i][i + 1] = aa[1];
    if (i) dp[1][i][i - 1] = bb[1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= 2 * n; j++) {
      for (int k = 0; k <= 2 * n; k++) {
        if (k) smin(dp[i][j][k], dp[i - 1][j][k - 1] + aa[i]);
        smin(dp[i][j][k], dp[i - 1][j][k + 1] + bb[i]);
      }
    }
  }
  for (int i = 0; i <= 2 * n; i++) {
    for (int j = 0; j <= 2 * n; j++) {
      ans[i][j] = a[i][j] = dp[n][i][j];
    }
  }
  int xx = m - 1;
  while (xx) {
    if (xx & 1) multi(ans, a, ans);
    multi(a, a, a);
    xx >>= 1;
  }
  println(ans[0][0]);
  return 0;
}

```