#include using namespace std; using Int=long long; using Real=long double; templateinline bool chmin(T&A,S B){if(A>B){A=B;return true;}else{return false;}} templateinline bool chmax(T&A,S B){if(A>N>>M>>op; REP(i,M)cin>>A[i]; REP(i,N) { Int B;cin>>B; REP(j,M)cout<<(op=='+'?B+A[j]:B*A[j])<<" \n"[j==M-1]; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<>T; while(T--)sol(); }