#include <bits/stdc++.h>
using namespace std;
const int maxn = 30;
struct node {
  int x, y;
  node(int x, int y) : x(x), y(y) {}
};
int mp[maxn][maxn], n, m, a[maxn], b[maxn], vis[maxn][maxn];
queue<node> q;
void check(int x, int y) {
  if (mp[x][y] <= 0 || mp[x][y] > 20) {
    q.push(node(x, y));
    vis[x][y] = 1;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  int suma = 0, sumb = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    suma += a[i];
  }
  for (int j = 1; j <= m; j++) {
    cin >> b[j];
    sumb += b[j];
  }
  if (suma != sumb)
    cout << "No";
  else {
    for (int i = 2; i <= n; i++) {
      int temp = a[i] / m;
      for (int j = 1; j < m; j++) mp[i][j] = temp;
      mp[i][m] = a[i] - temp * (m - 1);
    }
    for (int j = 1; j <= m; j++) {
      int temp = b[j];
      for (int i = 2; i <= n; i++) temp -= mp[i][j];
      mp[1][j] = temp;
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) check(i, j);
    int cnt = 0, flag = 0;
    while (!q.empty()) {
      int r = q.front().x;
      int c = q.front().y;
      if (mp[r][c] > 0 && mp[r][c] <= 20) {
        q.pop();
        continue;
      }
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
          if (i != r && j != c && vis[i][j] == 0) {
            if (mp[r][c] > 0 && mp[r][c] <= 20) break;
            int d;
            if (mp[r][c] <= 0) {
              if (mp[i][j] >= 20 || mp[i][c] <= 1 || mp[r][j] <= 1) continue;
              d = 1 - mp[r][c];
              mp[r][c] += d;
              mp[i][j] += d;
              mp[r][j] -= d;
              mp[i][c] -= d;
            } else if (mp[r][c] > 20) {
              if (mp[r][c] <= 1 || mp[i][c] >= 20 || mp[r][j] >= 20) continue;
              d = mp[r][c] - 20;
              mp[r][c] -= d;
              mp[i][j] -= d;
              mp[r][j] += d;
              mp[i][c] += d;
            }
            check(i, j);
            check(r, j);
            check(i, c);
          }
      q.pop();
      vis[r][c] = 0;
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (mp[i][j] <= 0 || mp[i][j] > 20) flag = 1;
    if (flag)
      cout << "No" << endl;
    else {
      cout << "Yes" << endl;
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) cout << mp[i][j] << " ";
        cout << endl;
      }
    }
  }
  return 0;
}
