#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    
    cin.tie(0); ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    
    string op; cin >> op;
    vector<ll> a(n), b(m); 
    for(int i = 0; i < m; ++i) cin >> b[i];
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(op == "+"){
                cout << a[i]+b[j] << ' ';
            }
            if(op == "*"){
                cout << a[i]*b[j] << ' ';
            }
        }
        cout << '\n';
    }
    
    return 0;
}