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>
int* ans;
bool found;
int n, m;
int left[10 + 1][32][16807];
int right[10 + 1][32][16807];
int req_horizontal_blocks_list[5];
int req_vertical_blocks_list[20];
int state_vertical_blocks[32];
bool is_valid_horizontal_sum(int s, int lcode, int rcode, int base) {
  for (int i = 0; i < n; ++i) {
    int pos = n - 1 - i;
    int l = (lcode % base);
    int r = (rcode % base);
    int to_substract = ((s & (1 << i)) > 0 ? 1 : 0);
    if (l + r - to_substract != req_horizontal_blocks_list[pos]) return false;
    lcode = (lcode / base);
    rcode = (rcode / base);
  }
  return true;
}
int transit_code(int seed_code, int diff, int base, bool add_or_sub) {
  int code = seed_code;
  int power = (add_or_sub ? 1 : -1);
  for (int r = n - 1; r >= 0; --r) {
    int t = n - 1 - r;
    bool y = ((diff & (1 << t)) > 0);
    if (y) code += power;
    power *= base;
  }
  return code;
}
void init() {
  for (int s = 0; s < 32; ++s) {
    state_vertical_blocks[s] = 0;
    int cur_bit = 0, pre_bit = 0;
    for (int r = 0; r < 5; ++r) {
      cur_bit = ((s & (1 << r)) > 0 ? 1 : 0);
      state_vertical_blocks[s] += (cur_bit > pre_bit ? 1 : 0);
      pre_bit = cur_bit;
    }
  }
}
void calculate_possible_pre_states(int possible_pre_states[][32][16807],
                                   int ncols, int max_code, int max_s, int base,
                                   bool reverse) {
  bool violated = false;
  for (int c = 0; c < ncols; ++c)
    for (int s = 0; s < max_s; ++s)
      for (int code = 0; code < max_code; ++code)
        possible_pre_states[c][s][code] = -1;
  for (int c = 0; c < ncols; ++c) {
    if (c == 0) {
      for (int s = 0; s < max_s; ++s) {
        int ec = (reverse ? m - 1 - c : c);
        if (state_vertical_blocks[s] != req_vertical_blocks_list[ec]) continue;
        int diff = s;
        int code = transit_code(0, diff, base, true);
        possible_pre_states[0][s][code] = 0;
      }
    } else {
      for (int pre_s = 0; pre_s < max_s; ++pre_s) {
        int ec = (reverse ? m - 1 - c : c);
        int ecc = (reverse ? ec + 1 : ec - 1);
        if (state_vertical_blocks[pre_s] != req_vertical_blocks_list[ecc])
          continue;
        for (int pre_code = 0; pre_code < max_code; ++pre_code) {
          if (possible_pre_states[c - 1][pre_s][pre_code] == -1) continue;
          for (int s = 0; s < max_s; ++s) {
            if (state_vertical_blocks[s] != req_vertical_blocks_list[ec])
              continue;
            int diff = (s & (pre_s ^ s));
            int code = transit_code(pre_code, diff, base, true);
            if (code >= max_code && !violated) {
              printf(
                  "Overflow, c = %d, code = %d, pre_code = %d, s = %d, pre_s = "
                  "%d\n",
                  c, code, pre_code, s, pre_s);
              violated = true;
            }
            possible_pre_states[c][s][code] = pre_s;
          }
        }
      }
    }
  }
}
void print_ans(int* ans) {
  if (ans == NULL) {
    puts("Impossible\n");
    return;
  }
  for (int row = 0; row < n; ++row) {
    for (int col = 0; col < m; ++col) {
      int p = n - 1 - row;
      int bit = (1 << p);
      int cur = ((ans[col] & bit) > 0 ? 1 : 0);
      if (cur)
        printf("*");
      else
        printf(".");
    }
    puts("");
  }
  puts("");
}
void stuff_states(int left[][32][16807], int left_bound, int right[][32][16807],
                  int right_bound, int* mp, int max_s, int base) {
  int left_s = -1;
  int right_s = -1;
  int left_code = -1;
  int right_code = -1;
  for (int s = 0; s < max_s; ++s) {
    if (found) break;
    if (state_vertical_blocks[s] != req_vertical_blocks_list[left_bound - 1])
      continue;
    for (int lcode = 0; lcode < 16807; ++lcode) {
      if (found) break;
      for (int rcode = 0; rcode < 16807; ++rcode) {
        if (found) break;
        int l_pre_s = left[left_bound - 1][s][lcode];
        int r_pre_s = right[right_bound - 1][s][rcode];
        if (l_pre_s == -1 || r_pre_s == -1) continue;
        if (!is_valid_horizontal_sum(s, lcode, rcode, base)) continue;
        left_s = s;
        right_s = s;
        left_code = lcode;
        right_code = rcode;
        found = true;
        break;
      }
    }
  }
  if (!found) return;
  for (int col = left_bound - 1; col >= 0; --col) {
    int pre_s = left[col][left_s][left_code];
    int diff = (left_s & (left_s ^ pre_s));
    int pre_code = transit_code(left_code, diff, base, false);
    mp[col] = left_s;
    left_s = pre_s;
    left_code = pre_code;
  }
  for (int rcol = right_bound - 1; rcol >= 0; --rcol) {
    int pre_s = right[rcol][right_s][right_code];
    int diff = (right_s & (right_s ^ pre_s));
    int pre_code = transit_code(right_code, diff, base, false);
    int col = m - 1 - rcol;
    mp[col] = right_s;
    right_s = pre_s;
    right_code = pre_code;
  }
  ans = mp;
}
int main() {
  int mp[20];
  int base = 7;
  int left_bound = 0;
  int right_bound = 0;
  init();
  while (scanf("%d%d", &n, &m) != EOF) {
    found = false;
    ans = NULL;
    memset(mp, 0, sizeof mp);
    memset(req_vertical_blocks_list, 0, sizeof req_vertical_blocks_list);
    memset(req_horizontal_blocks_list, 0, sizeof req_horizontal_blocks_list);
    memset(left, 0, sizeof left);
    memset(right, 0, sizeof right);
    for (int i = 0; i < n; ++i) scanf("%d", (req_horizontal_blocks_list + i));
    for (int i = 0; i < m; ++i) scanf("%d", (req_vertical_blocks_list + i));
    int max_s = (1 << n);
    left_bound = (m >> 1) + 1;
    calculate_possible_pre_states(left, left_bound, 16807, max_s, base, false);
    right_bound = (m + 1) - left_bound;
    calculate_possible_pre_states(right, right_bound, 16807, max_s, base, true);
    stuff_states(left, left_bound, right, right_bound, mp, max_s, base);
    print_ans(ans);
  }
  return 0;
}