#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{

    lint h, w, a, b;

    scanf("%lld", &h);
    scanf("%lld", &w);
    scanf("%lld", &a);
    scanf("%lld", &b);

    for (int i = 0; i < h; ++i)
    {
        if (i < h - b)
            printf("%s\n", (std::string((w - a), '1') + std::string(a, '0')).c_str());
        else
            printf("%s\n", (std::string((w - a), '0') + std::string(a, '1')).c_str());
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
#define endl "\n"
using namespace std; 


void solve() {
    int a, b, m;
    cin >> a >> b >> m;

    vector<int> price_a(a);
    vector<int> price_b(b);

    int min_a = INT_MAX;
    for (int& x: price_a) {
        cin >> x;
        min_a = min(min_a, x);
    } 
    int min_b = INT_MAX;
    for (int& x: price_b) {
        cin >> x;
        min_b = min(min_b, x);
    }

    int ans = min_a + min_b;

    int x, y ,z;
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> z;
        ans = min((price_a[x-1] + price_b[y-1] - z), ans);
    }

    cout << ans << endl;

    
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 
