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;
set<long long> seen;
void display(vector<vector<bool>> potsol) {
  if (potsol.size() > 0) {
    for (int i = 0; i < potsol[0].size(); ++i) {
      for (int j = 0; j < potsol.size(); ++j) {
        cout << ((potsol[j][i]) ? "*" : ".");
      }
      cout << endl;
    }
    cout << endl;
  } else {
    cout << "Empty" << endl << endl;
  }
}
vector<vector<bool>> possibles(int x, int n) {
  vector<vector<bool>> ret;
  for (int i = 0; i < (1 << n); ++i) {
    int y = i;
    int cnt = 0;
    bool on = false;
    vector<bool> p;
    for (int j = 0; j < n; ++j) {
      if (y & 1) {
        if (!on) {
          ++cnt;
        }
        on = true;
      } else {
        on = false;
      }
      p.push_back(y & 1);
      y >>= 1;
    }
    if (cnt == x) {
      ret.push_back(p);
    }
  }
  return ret;
}
bool dfs(vector<vector<bool>> &potsol, vector<int> &cnts, vector<bool> &ons,
         vector<int> &a, vector<vector<vector<bool>>> &ps) {
  if (potsol.size() == ps.size()) {
    for (int i = 0; i < a.size(); ++i) {
      if (cnts[i] != a[i]) {
        return false;
      }
    }
    return true;
  } else {
    long long hash = potsol.size();
    for (int i = 0; i < a.size(); ++i) {
      hash = 32 * hash + cnts[i];
    }
    for (int i = 0; i < a.size(); ++i) {
      hash = 2 * hash + ons[i];
    }
    if (seen.find(hash) != seen.end()) {
      return false;
    }
    seen.insert(hash);
    for (int i = 0; i < a.size(); ++i) {
      if (cnts[i] > a[i]) {
        return false;
      }
      if ((a[i] - cnts[i]) > (((ps.size() - potsol.size()) + 1) / 2)) {
        return false;
      }
    }
    for (int i = ps[potsol.size()].size() - 1; i >= 0; --i) {
      vector<vector<bool>> pst = potsol;
      vector<int> ct = cnts;
      vector<bool> ot = ons;
      potsol.push_back(ps[potsol.size()][i]);
      for (int j = 0; j < a.size(); ++j) {
        if (potsol.back()[j]) {
          if (!ons[j]) {
            ++cnts[j];
          }
          ons[j] = true;
        } else {
          ons[j] = false;
        }
      }
      if (dfs(potsol, cnts, ons, a, ps)) {
        return true;
      } else {
        potsol = pst;
        cnts = ct;
        ons = ot;
      }
    }
    return false;
  }
}
int main(int argc, const char *argv[]) {
  int m, n;
  cin >> n >> m;
  vector<int> a(n, 0);
  vector<int> b(m, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  vector<vector<vector<bool>>> ps;
  for (int i = 0; i < m; ++i) {
    ps.push_back(possibles(b[i], n));
  }
  vector<vector<bool>> potsol;
  vector<int> cnts(a.size(), 0);
  vector<bool> ons(a.size(), false);
  dfs(potsol, cnts, ons, a, ps);
  display(potsol);
  return 0;
}