#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    rep(y,H) rep(x,W) A[y][x] = y * 2 * 10'000 + x * 2;
    A[0][0] = 200'000'000;
    vector<int> R(H); rep(y,H) cin >> R[y];
    vector<int> C(W); rep(x,W) cin >> C[x];
    for(int y=1; y<H; y++) A[y][0] = y * 2 * 10'000 + ((W - R[y]) * 2 + 1);
    for(int x=1; x<W; x++) A[0][x] = ((H - C[x]) * 2 + 1) * 10'000 + x * 2;
    rep(y,H){
        rep(x,W) cout << A[y][x] << ' ';
        cout << '\n';
    }
    return 0;
}

struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;