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 maxN = 130 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
short dp[21][32][maxN];
int mas[maxN];
int ss[6][maxN];
int a[20], b[20];
vector<int> v[6];
int c[20], d[20];
int n, m;
char ans[20][20];
int p;
void solve(int lev, int mask, int state) {
  if (lev == 0) return;
  int tmp = state;
  for (int z = 0; z < n; z++) {
    c[z] = tmp % p;
    tmp /= p;
  }
  int smask = dp[lev][mask][state];
  for (int j = 0; j < n; j++) {
    d[j] = c[j];
    if ((mask >> j & 1) != (smask >> j & 1)) {
      if (mask >> j & 1) d[j]--;
    }
  }
  int sstate = 0;
  for (int j = n - 1; j >= 0; j--) sstate *= p, sstate += d[j];
  solve(lev - 1, smask, sstate);
  for (int i = 0; i < n; i++) ans[i][lev - 1] = ((mask >> i & 1) ? '*' : '.');
}
int tof[32][32], tofm[32][32];
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  memset(dp, -1, sizeof dp);
  cin >> n >> m;
  for (int mask = 0; mask < (1 << n); mask++) {
    int bef = 0, st = 0;
    for (int i = 0; i < n; i++)
      if (mask >> i & 1) {
        if (bef == 0) st++;
        bef = 1;
      } else
        bef = 0;
    v[st].push_back(mask);
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  p = *max_element(a, a + n);
  p++;
  int stat = 0;
  for (int i = n - 1; i >= 0; i--) stat *= p, stat += a[i];
  for (int state = 0; state < stat + 1; state++) {
    int tmp = state;
    for (int z = 0; z < n; z++) {
      ss[z][state] = tmp % p;
      if (ss[z][state] == 0) mas[state] |= (1 << z);
      tmp /= p;
    }
  }
  for (int mask = 0; mask < (1 << n); mask++)
    for (int smask = 0; smask < (1 << n); smask++) {
      int pp = 0;
      for (int j = 0; j < n; j++) {
        d[j] = 0;
        if ((mask >> j & 1) != (smask >> j & 1)) {
          if (mask >> j & 1) d[j]--, tofm[mask][smask] |= (1 << j);
        }
      }
      int sstate = 0;
      for (int j = n - 1; j >= 0; j--) sstate *= p, sstate += d[j];
      tof[mask][smask] = sstate;
    }
  for (int i = 1; i < m + 1; i++) {
    int ind = b[i - 1];
    for (int state = 0; state < stat + 1; state++) {
      for (auto mask : v[ind]) {
        for (auto smask : v[(i == 1 ? 0 : b[i - 2])]) {
          if (tofm[mask][smask] & mas[state]) continue;
          int sstate = state + tof[mask][smask];
          if (dp[i - 1][smask][sstate] != -1 ||
              (i == 1 && sstate == 0 && smask == 0)) {
            dp[i][mask][state] = smask;
            break;
          }
        }
      }
    }
  }
  int answer = -1;
  for (int i = 0; i < (1 << n); i++) {
    if (dp[m][i][stat] > -1) {
      answer = i;
      break;
    }
  }
  solve(m, answer, stat);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << ans[i][j];
    cout << endl;
  }
  return 0;
}