#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A);
    REP(i, A) cin >> a[i];

    vector<int> b(B);
    REP(i, B) cin >> b[i];

    vector<int> x(M), y(M), c(M);
    REP(i, M) cin >> x[i] >> y[i] >> c[i];

    REP(i, M) {
        x[i]--;
        y[i]--;
    }

    int minA = *min_element(a.begin(), a.end());
    int minB = *min_element(b.begin(), b.end());

    int ans = minA + minB;
    REP(i, M) {
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }

    cout << ans << '\n';
    return 0;
}
#include <bits/stdc++.h> 
using namespace std;

int s[5];
char op[5];

void solve(int index, int cur_sum) {
    if (index == 3) {
        if (cur_sum == 7) {
            for(int i = 0; i < 4; ++i) {
                if (i > 0) cout << op[i];
                cout << s[i];
            }
            cout << "=7";
            exit(0);
        }
        return;
    }
    // +
    op[index + 1] = '+';
    solve(index + 1, cur_sum+s[index + 1]);        

    //-
    op[index + 1] = '-';
    solve(index + 1, cur_sum-s[index + 1]);   
}

int main () {
    for(int i = 0; i < 4; ++i) {
        char ch; cin >> ch;
        s[i] = ch - '0';
    }
    solve(0, s[0]);
}
