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 N = 5 + 1;
const int M = 20 + 2;
vector<int> block[6];
int n, m, r[N], c[M];
struct dpv {
  int val[N + 3];
  int par, mask;
  int par_mask;
  bool operator==(const dpv &b) {
    for (int i = 0; i < n; i++)
      if (val[i] != b.val[i]) return false;
    return true;
  }
  bool operator<(const dpv &b) {
    for (int i = 0; i < n; i++)
      if (val[i] < b.val[i])
        return true;
      else if (val[i] > b.val[i])
        return false;
    return false;
  }
  dpv() {
    memset(val, 0, sizeof val);
    par = par_mask = 0;
  }
  dpv(int new_mask, int prv_mask, dpv prv, int ind_par = -1) {
    memset(val, 0, sizeof val);
    for (int i = 0; i < n; i++) val[i] = prv.val[i];
    for (int i = 0; i < n; i++)
      if (((new_mask >> i) & 1) && (!((prv_mask >> i) & 1))) val[i]++;
    par = ind_par;
    par_mask = prv_mask;
    mask = new_mask;
  }
};
vector<dpv> dp[M][1 << N];
int black_blocks_count(int);
int hash_t(dpv);
int hash_interface(int, int, dpv);
bool _cmp(dpv &a, dpv &b) { return a < b; }
bool _equ(dpv &a, dpv &b) { return a == b; }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> r[i];
  for (int i = 0; i < m; i++) cin >> c[i];
  for (int i = 0; i < (1 << n); i++) block[black_blocks_count(i)].push_back(i);
  if (m < 6) {
    for (int i = 0; i < (1 << n); i++)
      block[black_blocks_count(i)].push_back(i);
    for (int mask : block[c[0]]) dp[0][mask].push_back(dpv(mask, 0, dpv()));
    for (int i = 1; i < m; i++) {
      for (int cmask : block[c[i]]) {
        vector<dpv> cur;
        for (int pmask : block[c[i - 1]])
          for (int j = 0; j < dp[i - 1][pmask].size(); j++)
            cur.push_back(dpv(cmask, pmask, dp[i - 1][pmask][j], j));
        sort(cur.begin(), cur.end(), _cmp);
        cur.resize(unique(cur.begin(), cur.end(), _equ) - cur.begin());
        for (dpv x : cur) {
          bool flag = true;
          for (int j = 0; j < n; j++)
            if (x.val[j] > r[j] && (x.val[j] + (m - i) / 2) < r[j])
              flag = false;
          if (flag) dp[i][cmask].push_back(x);
        }
      }
    }
    dpv a;
    for (int i = 0; i < n; i++) a.val[i] = r[i];
    for (int mask : block[c[m - 1]])
      for (dpv x : dp[m - 1][mask])
        if (x == a) {
          vector<int> ans;
          dpv cur = x;
          int ind = m - 1;
          while (cur.par != -1) {
            ans.push_back(cur.mask);
            cur = dp[ind - 1][cur.par_mask][cur.par];
            ind--;
          }
          ans.push_back(cur.mask);
          reverse(ans.begin(), ans.end());
          for (int k = 0; k < n; k++) {
            for (int h : ans) cout << ((h >> k) & 1 ? '*' : '.');
            cout << endl;
          }
          return 0;
        }
  }
  int mid = m / 2;
  for (int mask : block[c[0]]) dp[0][mask].push_back(dpv(mask, 0, dpv()));
  for (int i = 1; i < mid; i++) {
    for (int cmask : block[c[i]]) {
      vector<dpv> cur;
      for (int pmask : block[c[i - 1]])
        for (int j = 0; j < dp[i - 1][pmask].size(); j++)
          cur.push_back(dpv(cmask, pmask, dp[i - 1][pmask][j], j));
      sort(cur.begin(), cur.end(), _cmp);
      cur.resize(unique(cur.begin(), cur.end(), _equ) - cur.begin());
      for (dpv x : cur) {
        bool flag = true;
        for (int j = 0; j < n; j++)
          if (x.val[j] > r[j] && (x.val[j] + (m - i) / 2) < r[j]) flag = false;
        if (flag) dp[i][cmask].push_back(x);
      }
    }
  }
  for (int mask : block[c[m - 1]])
    dp[m - 1][mask].push_back(dpv(mask, 0, dpv()));
  for (int i = m - 2; i >= mid; i--) {
    for (int cmask : block[c[i]]) {
      vector<dpv> cur;
      for (int pmask : block[c[i + 1]])
        for (int j = 0; j < dp[i + 1][pmask].size(); j++)
          cur.push_back(dpv(cmask, pmask, dp[i + 1][pmask][j], j));
      sort(cur.begin(), cur.end(), _cmp);
      cur.resize(unique(cur.begin(), cur.end(), _equ) - cur.begin());
      for (dpv x : cur) {
        bool flag = true;
        for (int j = 0; j < n; j++)
          if (x.val[j] > r[j] && (x.val[j] + (i + 1) / 2) < r[j]) flag = false;
        if (flag) dp[i][cmask].push_back(x);
      }
    }
  }
  for (int mask1 : block[c[mid - 1]])
    for (int mask2 : block[c[mid]]) {
      map<int, int> half_hash;
      for (int i = 0; i < dp[mid][mask2].size(); i++)
        half_hash[hash_t(dp[mid][mask2][i])] = i;
      for (dpv x : dp[mid - 1][mask1])
        if (half_hash.find(hash_interface(mask1, mask2, x)) !=
            half_hash.end()) {
          dpv y = dp[mid][mask2][half_hash[hash_interface(mask1, mask2, x)]];
          vector<int> ans1;
          dpv cur = x;
          int ind = mid - 1;
          while (cur.par != -1) {
            ans1.push_back(cur.mask);
            cur = dp[ind - 1][cur.par_mask][cur.par];
            ind--;
          }
          ans1.push_back(cur.mask);
          reverse(ans1.begin(), ans1.end());
          vector<int> ans2;
          cur = y;
          ind = mid;
          while (cur.par != -1) {
            ans2.push_back(cur.mask);
            cur = dp[ind + 1][cur.par_mask][cur.par];
            ind++;
          }
          ans2.push_back(cur.mask);
          for (int k = 0; k < n; k++) {
            for (int h : ans1) cout << ((h >> k) & 1 ? '*' : '.');
            for (int h : ans2) cout << ((h >> k) & 1 ? '*' : '.');
            cout << endl;
          }
          return 0;
        }
    }
}
int black_blocks_count(int mask) {
  while (mask && ((mask & 1) == 0)) mask >>= 1;
  int res = 0;
  while ((mask & 1) == 1) {
    res++;
    while ((mask & 1) == 1) mask >>= 1;
    while (mask && ((mask & 1) == 0)) mask >>= 1;
  }
  return res;
}
int hash_t(dpv a) {
  int res = 0;
  for (int i = 0; i < n; i++) {
    res *= 13;
    res += a.val[i];
  }
  return res;
}
int hash_interface(int mask1, int mask2, dpv a) {
  int need[N] = {};
  for (int i = 0; i < n; i++)
    if (((mask1 >> i) & 1) && ((mask2 >> i) & 1)) need[i]++;
  int res = 0;
  for (int i = 0; i < n; i++) {
    res *= 13;
    res += (r[i] - a.val[i]) + need[i];
  }
  return res;
}