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;
int n, m;
vector<int> A, b1, b2;
int l[11][6][6][6][6][6][32];
int r[11][6][6][6][6][6][32];
bool sat[32][4], is_set[32][5];
int cnt_comp(int x) {
  int ans = 0;
  vector<int> temp(1);
  for (int i = 0; i < 5; ++i) {
    temp.push_back(x % 2);
    x /= 2;
  }
  for (int i = 1; i < 6; ++i)
    if (temp[i] && !temp[i - 1]) ans++;
  return ans;
}
void respond(int m1, int al, int bl, int cl, int dl, int el, int i, int m2,
             int ar, int br, int cr, int dr, int er, int j) {
  vector<int> ans;
  for (int x = m1; x >= 1; --x) {
    int last = l[x][al][bl][cl][dl][el][i];
    ans.insert(ans.begin(), i);
    int diff = i - (last & i);
    if (is_set[diff][0]) al--;
    if (is_set[diff][1]) bl--;
    if (is_set[diff][2]) cl--;
    if (is_set[diff][3]) dl--;
    if (is_set[diff][4]) el--;
    i = last;
  }
  for (int x = m2; x >= 1; --x) {
    int last = r[x][ar][br][cr][dr][er][j];
    ans.push_back(j);
    int diff = j - (last & j);
    if (is_set[diff][0]) ar--;
    if (is_set[diff][1]) br--;
    if (is_set[diff][2]) cr--;
    if (is_set[diff][3]) dr--;
    if (is_set[diff][4]) er--;
    j = last;
  }
  char grid[n][m];
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j)
      if (is_set[ans[i]][j])
        grid[j][i] = '*';
      else
        grid[j][i] = '.';
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << grid[i][j];
    }
    cout << '\n';
  }
}
int main() {
  for (int i = 0; i < 32; ++i) {
    int comp = cnt_comp(i);
    sat[i][comp] = true;
    for (int j = 0; j < 5; ++j)
      if (i & (1 << j)) is_set[i][j] = true;
  }
  for (int g = 0; g < 11; ++g)
    for (int a = 0; a < 6; ++a)
      for (int b = 0; b < 6; ++b)
        for (int c = 0; c < 6; ++c)
          for (int d = 0; d < 6; ++d)
            for (int e = 0; e < 6; ++e)
              for (int f = 0; f < 32; ++f)
                l[g][a][b][c][d][e][f] = r[g][a][b][c][d][e][f] = -1;
  cin >> n >> m;
  A.resize(5);
  b1.resize(m);
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = 0; i < m; ++i) cin >> b1[i];
  b2 = b1;
  reverse(b2.begin(), b2.end());
  l[0][0][0][0][0][0][0] = 0;
  r[0][0][0][0][0][0][0] = 0;
  int m1 = m / 2, m2 = m - m / 2;
  for (int i = 0; i < m1; ++i) {
    for (int a = 0; a < 6; ++a)
      for (int b = 0; b < 6; ++b)
        for (int c = 0; c < 6; ++c)
          for (int d = 0; d < 6; ++d)
            for (int e = 0; e < 6; ++e)
              for (int j = 0; j < 32; ++j) {
                if (l[i][a][b][c][d][e][j] == -1) continue;
                for (int k = 0; k < 32; ++k) {
                  if (sat[k][b1[i]]) {
                    int diff = k - (k & j);
                    l[i + 1][a + is_set[diff][0]][b + is_set[diff][1]]
                     [c + is_set[diff][2]][d + is_set[diff][3]]
                     [e + is_set[diff][4]][k] = j;
                  }
                }
              }
  }
  for (int i = 0; i < m2; ++i) {
    for (int a = 0; a < 6; ++a)
      for (int b = 0; b < 6; ++b)
        for (int c = 0; c < 6; ++c)
          for (int d = 0; d < 6; ++d)
            for (int e = 0; e < 6; ++e)
              for (int j = 0; j < 32; ++j) {
                if (r[i][a][b][c][d][e][j] == -1) continue;
                for (int k = 0; k < 32; ++k) {
                  if (sat[k][b2[i]]) {
                    int diff = k - (k & j);
                    r[i + 1][a + is_set[diff][0]][b + is_set[diff][1]]
                     [c + is_set[diff][2]][d + is_set[diff][3]]
                     [e + is_set[diff][4]][k] = j;
                  }
                }
              }
  }
  for (int i = 0; i < 32; ++i) {
    for (int j = 0; j < 32; ++j) {
      int need[5] = {A[0] + (is_set[i][0] && is_set[j][0]),
                     A[1] + (is_set[i][1] && is_set[j][1]),
                     A[2] + (is_set[i][2] && is_set[j][2]),
                     A[3] + (is_set[i][3] && is_set[j][3]),
                     A[4] + (is_set[i][4] && is_set[j][4])};
      if (need[0] < 0 || need[1] < 0 || need[2] < 0 || need[3] < 0 ||
          need[4] < 0)
        continue;
      for (int al = 0; al <= min(need[0], 5); ++al)
        for (int bl = 0; bl <= min(need[1], 5); ++bl)
          for (int cl = 0; cl <= min(need[2], 5); ++cl)
            for (int dl = 0; dl <= min(need[3], 5); ++dl)
              for (int el = 0; el <= min(need[4], 5); ++el) {
                int ar, br, cr, dr, er;
                ar = need[0] - al;
                br = need[1] - bl;
                cr = need[2] - cl;
                dr = need[3] - dl;
                er = need[4] - el;
                if (ar > 5 || br > 5 || cr > 5 || dr > 5 || er > 5) continue;
                if (l[m1][al][bl][cl][dl][el][i] != -1 &&
                    r[m2][ar][br][cr][dr][er][j] != -1) {
                  respond(m1, al, bl, cl, dl, el, i, m2, ar, br, cr, dr, er, j);
                  return 0;
                }
              }
    }
  }
};