Problem: In this task you have to write a program dealing with nonograms on fields no larger than 5 × 20.

Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about rows and columns. For each row and each column the number of contiguous black segments is specified. 

For example if size of the field is n = 3, m = 5, аnd numbers of contiguous black segments in rows are: [2, 3, 2] and in columns are: [1, 0, 1, 2, 1] then the solution may look like:

<image>

It is guaranteed that on each test in the testset there exists at least one solution.

Input

In the first line there follow two integers n, m (1 ≤ n ≤ 5, 1 ≤ m ≤ 20) — number of rows and number of columns respectively.

Second line contains n integers a1, a2, ..., an where ai is the number of contiguous black segments in i-th row of the field. 

Similarly, third line contains m integers b1, b2, ..., bm where bi is the number of contiguous black segments in the i-th column of the field.

It is guaranteed that there exists at least one solution.

Output

Output any possible solution. Output should consist of n lines each containing m characters. Denote white cell as "." and black cell as "*".

Examples

Input

3 5
2 3 2
1 0 1 2 1


Output

*.**.
*.*.*
*..**

Input

3 3
2 1 2
2 1 2


Output

*.*
.*.
*.*


Input

3 3
1 0 1
2 2 2


Output

***
...
***

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 7, Mmax = 25, Confmax = 161051 + 10, Smax = 16;
vector<int> confs[4];
int Rows[Nmax], Cols[Mmax];
int matrix[Mmax];
bitset<Confmax> dp[2][Smax];
char next1[Mmax][Smax][Confmax];
int canSub[35][Confmax];
int countSecvs(int x) {
  int pos = 0, ret = 0;
  while (pos < 5) {
    if ((x & (1 << pos)) == 0)
      ++pos;
    else {
      int cpos = pos;
      while ((x & (1 << pos)) != 0) ++pos;
      ret++;
    }
  }
  return ret;
}
int powsR[Nmax];
int substrr[1 << 5][1 << 5];
char Ans[Nmax][Mmax];
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int conf = 0; conf < (1 << N); ++conf) {
    confs[countSecvs(conf)].push_back(conf);
  }
  for (int i = 0; i < N; ++i) cin >> Rows[i];
  for (int i = 1; i <= M; ++i) cin >> Cols[i];
  int rmax = (M + 1) / 2 + 1, maxC = pow((double)rmax, N);
  powsR[0] = 1;
  for (int i = 1; i <= N; ++i) powsR[i] = powsR[i - 1] * rmax;
  int fconf = 0;
  for (int i = N - 1; i >= 0; --i) fconf = fconf * rmax + Rows[i];
  dp[0][0][0] = true;
  for (int conf = 0; conf < maxC; ++conf) {
    for (int nconf = 0; nconf < (1 << N); ++nconf) {
      for (int i = 0; i < N; ++i) {
        if ((1 << i) & nconf) {
          if (conf / powsR[i] % rmax == 0) {
            canSub[nconf][conf] = -1;
            break;
          } else {
            canSub[nconf][conf] += powsR[i];
          }
        }
      }
    }
  }
  for (int i = 1, u = 1; i <= M; ++i, u ^= 1) {
    for (int j = 0; j < Smax; ++j) dp[u][j].reset();
    for (int j = 0; j < int(confs[Cols[i]].size()); ++j) {
      int cconf = confs[Cols[i]][j];
      for (int conf = 0; conf < maxC; ++conf) {
        for (int k = 0; k < int(confs[Cols[i - 1]].size()); ++k) {
          int pconf = confs[Cols[i - 1]][k];
          pconf = cconf & ~pconf;
          if (canSub[pconf][conf] == -1) continue;
          int prevconf = conf - canSub[pconf][conf];
          if (dp[u ^ 1][k][prevconf]) {
            dp[u][j][conf] = true;
            next1[i][j][conf] = (char)k;
            break;
          }
        }
      }
    }
  }
  int uf = M & 1;
  int lasts;
  for (lasts = 0; !dp[uf][lasts][fconf]; ++lasts)
    ;
  for (int i = M, conf = fconf; i > 0; --i) {
    int rc = confs[Cols[i]][lasts];
    for (int j = 0; j < N; ++j) {
      if ((1 << j) & rc)
        Ans[j][i] = '*';
      else
        Ans[j][i] = '.';
    }
    int nx = next1[i][lasts][conf], pc = confs[Cols[i - 1]][nx];
    for (int j = 0; j < N; ++j) {
      if (((1 << j) & rc) && !((1 << j) & pc)) conf -= powsR[j];
    }
    lasts = nx;
  }
  for (int i = 0; i < N; ++i) cout << (Ans[i] + 1) << '\n';
}