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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.StringTokenizer;

// Codeforces Round #298 (Div. 2)
// Simplified Nonogram
public class Problem_534_F {


  public static void main(String[] args)
  {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    PrintWriter out = new PrintWriter(outputStream);
    Problem_534_F solver = new Problem_534_F();
    solver.solve(1, new InputStreamReader(inputStream), out);
    out.close();
  }

  final static int S = 7776;
  final static int M = 20;
  final static int N = 5;
  final static int B = 6;

  int n, m;
  int[] a;
  int[] b;
  int[] bc = new int[1 << N];
  int[] c = new int[M + 1];
  int[] al = new int[M];
  int[] ar = new int[M];
  int[] res = new int[M];

  short[][][] lft = new short[M / 2 + 2][S][1 << N];
  short[][][] rgt = new short[M / 2 + 2][S][1 << N];

  char[][] ans = new char[N][M+1];


  int make_move(int s, int mask1, int mask2, int mul)
  {
    int ns = s;
    int dm = mask2 & (mask1 ^ mask2);

    int pw = 1 * mul;

    for(int c = 0; c < n; c++) {
      if ((dm & (1 << c)) != 0)
        ns += pw;
      pw *= B;
    }

    return ns;
  }

  void calcdp(int m, short[][][] dp) {
    for(int i = 0; i < m + 1; i++)
      for(int s = 0; s < S; s++)
        for(int j = 0; j < 1 << n; j++)
          dp[i][s][j] = -1;

    dp[0][0][0] = 0;

    for(int i = 0; i < m; i++) {
      for(int s = 0; s < S; s++) {
        for(int mask1 = 0; mask1 < (1 << n); mask1++) {
          if (bc[mask1] != c[i]) continue;
          if (dp[i][s][mask1] == -1) continue;

          for(int mask2 = 0; mask2 < (1 << n); mask2++) {
            if (bc[mask2] != c[i + 1]) continue;
            int ns = make_move(s, mask1, mask2, +1);
            dp[i + 1][ns][mask2] = (short)mask1;
          }
        }   
      }
    }
  }

  void restore(int m, int s, int mask, short[][][] dp) {
    for (int i = m; i >= 1; --i) {
      res[i - 1] = mask;

      int pmask = dp[i][s][mask];
      s = make_move(s, pmask, mask, -1);
      mask = pmask;
    }
  }
  public void solve(int test, Reader input, PrintWriter out)
  {
    MyScanner in = new MyScanner(input);

    n = in.nextInt();
    m = in.nextInt();

    a = new int[n];
    b = new int[m];
    for(int i = 0; i < n; i++)
      a[i] = in.nextInt();

    for(int i = 0; i < m; i++)
      b[i] = in.nextInt();

    for(int i = 0; i < (1 << n); i++) {
      int c = 0;
      int prv = 0;
      for(int j = 0; j < n; j++) {
        int cur = ((i >> j) & 1);
        if (cur != 0 && cur != prv)
          c++;
        prv = cur;
      }
      bc[i] = c;
    }

    int l = m / 2, r = m - l;
    int il = l - 1, ir = l;

    for(int i = 0; i < l; i++)
      c[i + 1] = b[i];

    calcdp(l, lft);

    for(int i = 0; i < r; i++)
      c[i + 1] = b[m - i - 1];

    calcdp(r, rgt);

    for(int sl = 0; sl < S; sl++) {
      for(int ml = 0; ml < (1 << n); ml++) {
        if (il >= 0 && bc[ml] != b[il]) continue;
        if (lft[l][sl][ml] == -1) continue;

        for(int mr = 0; mr < (1 << n); mr++) {
          if (bc[mr] != b[ir]) continue;

          int sr = 0;

          int pw = 1;
          int csl = sl;
          for(int i = 0; i < n; i++) {
            int cs = a[i];
            int cl = csl % B; csl /= B;
            al[i] = cl;

            int cr = cs - cl;

            if ((mr & ml & (1 << i)) != 0)
              cr++;

            if (cr < 0 || cr >= B) {
              sr = -1;
              break;
            }

            sr += pw * cr;
            ar[i] = cr;
            pw *= B;
          }

          if (sr == -1) continue;

          if (rgt[r][sr][mr] != -1) {
            restore(l, sl, ml, lft);
            for(int i = 0; i < l; i++)
              for(int j = 0; j < n; j++)
                ans[j][i] = ((res[i] >> j) & 1) != 0 ? '*' : '.';

            restore(r, sr, mr, rgt);

            for(int i = 0; i < r; i++)
              for(int j = 0; j < n; j++)
                ans[j][m - 1 - i] = ((res[i] >> j) & 1) != 0 ? '*' : '.';

            for(int i = 0; i < n; i++) {
              out.println(new String(ans[i], 0, m));
//              System.out.println(new String(ans[i], 0, m));
            }

            return;
          }
        }
      }
    }

    out.println("Impossible");

  }

  //-----------MyScanner class for faster input----------
  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner(Reader reader) {
      br = new BufferedReader(reader);
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine(){
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }
  //--------------------------------------------------------

}