import java.io.*;
import java.util.*;

public class Main implements Runnable {
	boolean judge = true;
	FastReader scn;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int a = scn.nextInt(), b = scn.nextInt(), c = scn.nextInt();
		int[] A = scn.nextIntArray(a);
		int[] B = scn.nextIntArray(b);

		int ai = 0;
		for(int i = 1; i < a; i++) {
			if(A[i] < A[ai]) {
				ai = i;
			}
		}

		int bi = 0;
		for(int i = 1; i < b; i++) {
			if(B[i] < B[bi]) {
				bi = i;
			}
		}

		int ans = A[ai] + B[bi];
		for(int i = 0; i < c; i++) {
			int x = scn.nextInt() - 1, y = scn.nextInt() - 1, z = scn.nextInt();
			if(A[x] + B[y] - z < ans) {
				ans = A[x] + B[y] - z;
			}
		}
		out.println(ans);
	}

	public void run() {
		long time = System.currentTimeMillis();
		boolean oj = System.getProperty("ONLINE_JUDGE") != null || judge;
		out = new PrintWriter(System.out);
		scn = new FastReader(oj);
		solve();
		out.flush();
		if (!oj) {
			System.out.println(Arrays.deepToString(new Object[] { System.currentTimeMillis() - time + " ms" }));
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Main(), "Main", 1 << 28).start();
	}

	class FastReader {
		InputStream is;

		public FastReader(boolean onlineJudge) {
			is = onlineJudge ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		String nextLine() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while ((!isSpaceChar(b) || b == ' ')) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		int[][] next2DInt(int n, int m) {
			int[][] arr = new int[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextIntArray(m);
			}
			return arr;
		}

		long[][] next2DLong(int n, int m) {
			long[][] arr = new long[n][];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLongArray(m);
			}
			return arr;
		}

		int[] shuffle(int[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				int c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		long[] shuffle(long[] arr) {
			Random r = new Random();
			for (int i = 1, j; i < arr.length; i++) {
				j = r.nextInt(i);
				long c = arr[i];
				arr[i] = arr[j];
				arr[j] = c;
			}
			return arr;
		}

		int[] uniq(int[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			int[] rv = new int[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		long[] uniq(long[] arr) {
			arr = scn.shuffle(arr);
			Arrays.sort(arr);
			long[] rv = new long[arr.length];
			int pos = 0;
			rv[pos++] = arr[0];
			for (int i = 1; i < arr.length; i++) {
				if (arr[i] != arr[i - 1]) {
					rv[pos++] = arr[i];
				}
			}
			return Arrays.copyOf(rv, pos);
		}

		int[] reverse(int[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		long[] reverse(long[] arr) {
			int l = 0, r = arr.length - 1;
			while (l < r) {
				arr[l] = arr[l] ^ arr[r];
				arr[r] = arr[l] ^ arr[r];
				arr[l] = arr[l] ^ arr[r];
				l++;
				r--;
			}
			return arr;
		}

		int[] compress(int[] arr) {
			int n = arr.length;
			int[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}

		long[] compress(long[] arr) {
			int n = arr.length;
			long[] rv = Arrays.copyOf(arr, n);
			rv = uniq(rv);
			for (int i = 0; i < n; i++) {
				arr[i] = Arrays.binarySearch(rv, arr[i]);
			}
			return arr;
		}
	}
}


import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.math.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int A = sc.nextInt();
    int B = sc.nextInt();
    int M = sc.nextInt();

    int[] a = new int[A];
    int[] b = new int[B];

    int minA = Integer.MAX_VALUE;
    int minB = Integer.MAX_VALUE;
    for (int i = 0; i < A; i++) {
      a[i] = sc.nextInt();
      minA = Math.min(minA, a[i]);
    }
    for (int i = 0; i < B; i++) {
      b[i] = sc.nextInt();
      minB = Math.min(minB, b[i]);
    }

    int min = minA + minB;

    for (int i = 0; i < M; i++) {
      int x = sc.nextInt() - 1;
      int y = sc.nextInt() - 1;
      int c = sc.nextInt();

      int cost = a[x] + b[y] - c;
      min = Math.min(min, cost);
    }

    os.println(min);
  }

  private static long gcd(long m, long n) {
    if (m < n) return gcd(n, m);
    if (n == 0) return m;
    return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
    return m / gcd(m, n) * n;
  }

  private static class Modular {

    private final long mod;

    private Modular(long mod) {
      this.mod = mod;
    }

    private long inverse(long n) {
      return pow(n, mod - 2) % mod;
    }

    private long pow(long x, long n) {
      /*
      long ans = 1;
      while (n > 0) {
        if ((n & 1) == 1) {
          ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
      }
      return ans;
      */
      if (n == 0) {
        return 1;
      }
      return n % 2 == 0 ?
          pow(x * x % mod, n / 2) % mod :
          x % mod * pow(x, n - 1) % mod;
    }
  }

  private static class ModularNFixedCombination {

    private final Modular modular;
    private final long[] comb;
    private final long N;

    public ModularNFixedCombination(long N, int size, long mod) {
      this.modular = new Modular(mod);
      this.comb = new long[size + 1];
      this.N = N;

      comb[0] = 1;

      for (int i = 1; i <= size; i++) {
        comb[i] = ((comb[i - 1] * (N - (i - 1))) % mod * modular.inverse(i)) % mod;
      }
    }

    long combination(int n, int k) {
      if (n != N) {
        throw new IllegalStateException();
      }
      return comb[k];
    }

    long repeatedCombination(int n, int k) {
      return combination(n + k - 1, k);
    }
  }

  private static class ModularCombination {

    private final long fact[];
    private final long mod;
    private final Modular modular;

    public ModularCombination(int size, long mod) {
      this.fact = new long[size + 1];
      this.mod = mod;
      this.modular = new Modular(mod);

      this.fact[0] = 1;
      for (int i = 1; i <= size; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
      }
    }

    private long factorial(int n) {
      return fact[n];
    }

    long combination(int n, int k) {
      return
          (
              (
                  (
                      factorial(n) * modular.inverse(factorial(n - k))
                  ) % mod
              ) * modular.inverse(factorial(k))
          ) % mod;
    }

    long repeatedCombination(int n, int k) {
      return combination(n + k - 1, k);
    }
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            BNiceShopping solver = new BNiceShopping();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BNiceShopping {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int A = in.readInt();
            int B = in.readInt();
            int M = in.readInt();
            int[] a = new int[A + 1];
            for (int i = 1; i <= A; i++) {
                a[i] = in.readInt();
            }
            int[] b = new int[B + 1];
            for (int i = 1; i <= B; i++) {
                b[i] = in.readInt();
            }
            long ans = CompareUtils.minOf(a, 1, A) + CompareUtils.minOf(b, 1, B);
            for (int i = 0; i < M; i++) {
                int x = in.readInt();
                int y = in.readInt();
                int c = in.readInt();
                ans = Math.min(ans, a[x] + b[y] - c);
            }
            out.println(ans);
        }

    }

    static class CompareUtils {
        private CompareUtils() {
        }

        public static int minOf(int[] a, int l, int r) {
            int x = a[l];
            for (int i = l; i <= r; i++) {
                x = Math.min(x, a[i]);
            }
            return x;
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(long c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(long c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}


import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Main.run();
    }

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        // input
        int a = Integer.parseInt(sc.next()); // 冷蔵庫種類
        int b = Integer.parseInt(sc.next()); // クーラー種類
        int m = Integer.parseInt(sc.next()); // 割引券枚数
        // 冷蔵庫価格リスト
        ArrayList<Integer> alist = new ArrayList<>(a);
        for (int i = 0; i < a; i++) {
            alist.add(Integer.parseInt(sc.next()));
        }
        // クーラー価格リスト
        ArrayList<Integer> blist = new ArrayList<>(b);
        for (int i = 0; i < b; i++) {
            blist.add(Integer.parseInt(sc.next()));
        }
        // 割引券HashMap(key:割引対象番号,value:割引額)
        HashMap<String, Integer> discount = new HashMap<>(m);
        for (int i = 0; i < m; i++) {
            String x = sc.next(); // 割引対象の番号：冷蔵庫
            String y = sc.next(); // 割引対象の番号：クーラー
            int value = Integer.parseInt(sc.next()); // 割引額
            String key = x + y; // 2種類の割引対象番号を文字列結合
            // 同一の割引対象番号が複数存在する場合、割引額が大きい方を残す
            if (discount.containsKey(key)) {
                discount.put(key, Math.max(discount.get(key), value));
            } else {
                discount.put(key, value);
            }
        }

        // 合計額HashMap(key:商品番号,value:合計額)
        HashMap<String, Integer> totalprice = new HashMap<>();
        for (int i = 0; i < a; i++) {
            int aprice = alist.get(i);
            for (int j = 0; j < b; j++) {
                int bprice = blist.get(i);
                String key = String.valueOf(i + 1) + String.valueOf(j + 1);
                int value = aprice + bprice;
                if (discount.containsKey(key)) {
                    value -= discount.get(key);
                }
                totalprice.put(key, value);
            }
        }

        int answer = 999999999;
        for (String s : totalprice.keySet()) {
            answer = Math.min(answer, totalprice.get(s));
        }

        out.println(answer);
        out.close();
        sc.close();
    }

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

// 22
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[A];
        int[] b = new int[B];
        for(int i = 0; i < A; i++)
            a[i] = sc.nextInt();
        for(int i = 0; i < B; i++)
            b[i] = sc.nextInt();

        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 0; i < M; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            list.add(a[ai] + b[bi] - sc.nextInt());
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Collections.sort(list);

        System.out.println(Math.min(a[0] + b[0], list.get(0)));
    }

}


import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Integer[] a = new Integer[A];
		Integer[] b = new Integer[B];
		Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
		Arrays.setAll(b, i -> Integer.parseInt(sc.next()));
		List<Integer> listA = new ArrayList<>(Arrays.asList(a));
		List<Integer> listB = new ArrayList<>(Arrays.asList(b));
		listA.sort(Comparator.naturalOrder());
		listB.sort(Comparator.naturalOrder());
		int min = listA.get(0) + listB.get(0);
		int waribiki = Integer.MAX_VALUE;
		for(int i=0; i<M; i++){
			int x = listA.get(Integer.parseInt(sc.next()) - 1);
			int y = listB.get(Integer.parseInt(sc.next()) - 1);
			int c = Integer.parseInt(sc.next());
			if(x + y - c < waribiki){
				waribiki = x + y - c;
			}
		}

		System.out.println(min < waribiki ? min : waribiki);
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//絶対無理そう

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int A = getint(), B = getint(), M = getint();

	int a[100001], b[100001];
	int ma = 100000, mb = 100000;
	rep1(i, A) {
		a[i] = getint();
		chmin(ma, a[i]);
	}
	rep1(i, B) {
		b[i] = getint();
		chmin(mb, b[i]);
	}

	int kotae = ma + mb;

	rep(i, M) {
		int x = getint(), y = getint(), c = getint();
		chmin(kotae, a[x] + b[y] - c);
	}

	printf("%d", kotae);

	Would you please return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

constexpr int MOD = 1000000007;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

template <class T>
string to_string(T s);
template <class S, class T>
string to_string(pair<S, T> p);
string to_string(string s) { return s; }
string to_string(const char s[]) { return to_string(string(s)); }

template <class T>
string to_string(T v) {
  if (v.empty()) return "{}";
  string ret = "{";
  for (auto x : v) ret += to_string(x) + ",";
  ret.back() = '}';
  return ret;
}
template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

void debug() { cerr << endl; }
template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

struct IO {
  static constexpr size_t buf_size = 1 << 18;
  char buf_in[buf_size], buf_out[buf_size];
  size_t pt_in = 0, pt_out = 0, tail_in = 0;
  char strs[1000][4];
  int ints[58];
  size_t num_digits(long long x) {
    if (x >= (long long)1e9) {
      if (x >= (long long)1e18) return 19;
      if (x >= (long long)1e17) return 18;
      if (x >= (long long)1e16) return 17;
      if (x >= (long long)1e15) return 16;
      if (x >= (long long)1e14) return 15;
      if (x >= (long long)1e13) return 14;
      if (x >= (long long)1e12) return 13;
      if (x >= (long long)1e11) return 12;
      if (x >= (long long)1e10) return 11;
      return 10;
    } else {
      if (x >= (long long)1e8) return 9;
      if (x >= (long long)1e7) return 8;
      if (x >= (long long)1e6) return 7;
      if (x >= (long long)1e5) return 6;
      if (x >= (long long)1e4) return 5;
      if (x >= (long long)1e3) return 4;
      if (x >= (long long)1e2) return 3;
      if (x >= (long long)1e1) return 2;
      return 1;
    }
  }
  IO() {
    load();
    for (int i = 0; i < 1000; ++i) {
      int j = i;
      strs[i][3] = 0;
      for (int t = 2; t >= 0; --t) {
        strs[i][t] = j % 10 + '0';
        j /= 10;
      }
    }
    for (int i = '0'; i <= '9'; ++i) {
      ints[i] = i - '0';
    }
  }
  ~IO() { flush(); }
  inline void load() {
    copy(buf_in + pt_in, buf_in + tail_in, buf_in);
    size_t width = tail_in - pt_in;
    tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
    pt_in = 0;
  }
  inline void flush() {
    fwrite(buf_out, 1, pt_out, stdout);
    pt_out = 0;
  }
  inline void read(char& c) { c = buf_in[pt_in++]; }
  template <class T>
  inline void read(T& x) {
    if (pt_in + 32 > tail_in) load();
    char c;
    do {
      read(c);
    } while (c < '0');
    bool minus = 0;
    if (c == '-') {
      minus = 1;
      read(c);
    }
    x = 0;
    while (c >= '0') {
      x = x * 10 + ints[c];
      read(c);
    }
    if (minus) x = -x;
  }
  inline void write(char c) { buf_out[pt_out++] = c; }
  template <class T>
  inline void write(T x) {
    if (pt_out > buf_size - 32) flush();
    if (x < 0) {
      write('-');
      x = -x;
    }
    size_t digits = num_digits(x);
    size_t i;
    for (i = pt_out + digits; i > pt_out + 3; i -= 3) {
      memcpy(buf_out + i - 3, strs[x % 1000], 3);
      x /= 1000;
    }
    memcpy(buf_out + pt_out, strs[x] + 3 - (i - pt_out), i - pt_out);
    pt_out += digits;
  }
  inline void write(const char* s) {
    if (pt_out > buf_size - 32) flush();
    for (int i = 0; s[i] != 0; ++i) write(s[i]);
  }
  template <class T>
  inline void writeln(T x) {
    write(x);
    write('\n');
  }
} io;

int main() {
  int A, B, M;
  io.read(A);
  io.read(B);
  io.read(M);
  int a[100000], b[100000], mina = INF, minb = INF;
  REP(i, A) {
    io.read(a[i]);
    mina = min(mina, a[i]);
  }
  REP(i, B) {
    io.read(b[i]);
    minb = min(minb, b[i]);
  }
  int ans = mina + minb;
  while (M--) {
    int x, y, c;
    io.read(x);
    io.read(y);
    io.read(c);
    ans = min(ans, a[x - 1] + b[y - 1] - c);
  }
  io.writeln(ans);
  return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n,m,K,ans,a[maxn],b[maxn];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
int main(){
	n=read(),m=read(),K=read();a[0]=b[0]=1e9;
	for (int i=1;i<=n;i++) a[0]=min(a[0],a[i]=read());
	for (int i=1;i<=m;i++) b[0]=min(b[0],b[i]=read());
	ans=a[0]+b[0];
	for (int i=1;i<=K;i++){
		int x=read(),y=read(),c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
using namespace std;
#define size 100001
int main()
{
  unsigned int A,B,M;
  unsigned int a[size],b[size],discounts[size];
  unsigned int i,refrigerator,microwave,discount,min_microwave = size,min_refrigerator = size;
  cin>>A>>B>>M;
  for(i=0;i<A;i++)
  {
  	cin>>a[i];
  	min_refrigerator = min(min_refrigerator,a[i]);
  }
  for(i=0;i<B;i++)
  {
  	cin>>b[i];
  	min_microwave = min(min_microwave,b[i]);
  }
  for(i=0;i<M;i++)
  {
    cin>>refrigerator >> microwave >> discount;
    discounts[i] = a[refrigerator-1] + b[microwave-1] - discount;
  }
  unsigned int min_discount = size;
  for(i=0;i<M;i++)
  {
  	min_discount = min(min_discount,discounts[i]);
  }
  cout<<min(min_discount,min_microwave+min_refrigerator);

}


#include<iostream>
using namespace std;
#define size 100001
int main()
{
  unsigned int A,B,M;
  unsigned int a[size],b[size],discounts[size];
  unsigned int i,refrigerator,microwave,discount,j;
  cin>>A>>B>>M;
  for(i=0;i<A;i++)
  {
  	cin>>a[i];
  }
  for(i=0;i<B;i++)
  {
  	cin>>b[i];
  }
  for(i=0;i<M;i++)
  {
    cin>>refrigerator >> microwave >> discount;
    discounts[i] = a[refrigerator-1] + b[microwave-1] - discount;
  }
  unsigned int min_discount = size;
  for(i=0;i<M;i++)
  {
  	min_discount = min(min_discount,discounts[i]);
  }
  cout<<min_discount;

}


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,m;
    cin>>a>>b>>m;
    int arr[a+1];
    int brr[b+1];
    for(int i=1;i<=a;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=b;i++)
    {
        cin>>brr[i];
    }
    int ans = 2*(1e6);
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            ans=min(ans,arr[i]+brr[j]);
        }
    }
    while(m--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans = min(ans,arr[x]+brr[y]-c);

    }
    cout<<ans<<"\n";

}


#define rep(i,n)for(int i=0;i<n;i++)
#define mi(x,y) (x<y?x:y)
#define N 100003//overflow防止
int main(){
	int A,B,M,a[N],am=1e5,b[N],bm=1e5,x,y,c,cm=2e5;
	scanf("%d%d%d",&A,&B,&M);
	rep(i,A){scanf("%d",&a[i+1]);am=mi(am,a[i+1]);}
	rep(i,B){scanf("%d",&b[i+1]);bm=mi(bm,b[i+1]);}
	rep(i,M){
		scanf("%d%d%d",&x,&y,&c);
		cm=mi(cm,a[x]+b[y]-c);
	}
	printf("%d",mi(cm,am+bm));
}


int main(){
  int A,B,M,c,x,y;
  int a[100000],b[100000];
  int i,min,sum,mina,minb;
  scanf("%d %d %d",&A,&B,&M);
  for(i=0;i<A;i++){
    scanf("%d",&a[i]);
    if(i==0 || a[i]<mina) mina=a[i];
  }
  for(i=0;i<B;i++){
    scanf("%d",&b[i]);
    if(i==0 || b[i]<minb) minb=b[i];
  }
  min=mina+minb;
  for(i=0;i<M;i++){
    scanf("%d %d %d",&x,&y,&c);
    sum=a[x-1]+b[y-1]-c;
    if(sum<min) min=sum;
  }
  printf("%d",min);
  return 0;
}


#include <stdio.h>

int main(){
    unsigned long A,B,M;
    unsigned long a[100000], b[100000], mina, minb,inda,indb,mindata;

    unsigned long x, y, c;
    int i, j, k;

    scanf("%ld %ld %ld", &A, &B, &M);
    for (i = 0; i < A;i++){
        scanf("%ld", &a[i]);
        if(i == 0){
            mina = a[i];
            inda = i;
        }else{
            if (mina > a[i])
            {
                mina = a[i];
                inda = i;
            }
        }
    }
    for (i = 0; i < B; i++)
    {
        scanf("%ld", &b[i]);
        if(i == 0){
            minb = b[i];
            indb = i;
        }
        else
        {
            if (minb > b[i])
            {
                minb = b[i];
                indb = i;
            }
        }

    }

    mindata = mina + minb;
    for (i = 0; i < M; i++)
    {
        scanf("%ld %ld %ld", &x, &y, &c);

        if(mindata > (a[x-1] + b[y-1] - c)){
            mindata = (a[x-1] + b[y-1] - c);
        }
    }

    printf("%ld", mindata);

    return 0;
}


#include <stdio.h>
int main(void){
    int A, B, M;
    int a[10000+5], b[10000+5];
    int x[10000+5], y[10000+5], c[10000+5];

    scanf("%d %d %d", &A, &B, &M);
    for(int i=1; i<=A; i++)scanf("%d", &a[i]);
    for(int i=1; i<=B; i++)scanf("%d", &b[i]);
    for(int i=0; i<M; i++)scanf("%d %d %d", &x[i], &y[i], &c[i]);

    int ans=0;

    // 割引券無し
    int min=a[1];
    for(int i=1; i<A; i++)if(a[i]<min)min=a[i];
    ans+=min;

    min=b[1];
    for(int i=1; i<B; i++)if(b[i]<min)min=b[i];
    ans+=min;

    // 割引券
    for(int i=0; i<M; i++){
        if(a[x[i]]+b[y[i]]-c[i]<ans)ans=a[x[i]]+b[y[i]]-c[i];
    }
    printf("%d\n", ans);
    return 0;
}


#include<stdio.h>
int main()
{
int a,b,m,i,minf,minr,ans;
  minf=10*10*10*10*10;
  minr=10*10*10*10*10;
  scanf("%d %d %d",&a,&b,&m);

int frz[a],range[b],x[m],y[m],c[m];

  for(i=0;i<a;++i)
  {
   scanf("%d",&frz[i]);
   if(minf>frz[i])  minf=frz[i];
  }

  for(i=0;i<b;++i)
  {
   scanf("%d",&range[i]);
   if(minr>range[i])  minf=range[i];
  }

ans=minf+minr;

  for(i=0;i<m;++i)
  {
  scanf("%d %d %d",&x[i],&y[i],&c[i]);
  if(frz[x[i]-1] + range[y[i]-1] -c[i] < ans) ans=frz[x[i]-1] + range[y[i]-1] -c[i];
  }

printf("%d",ans);
return 0;
}


#include<stdio.h>
int main()
{
int a,b,m,i,minf,minr,ans;
  minf=10*10*10*10*10;
  minr=10*10*10*10*10;
  scanf("%d %d %d",&a,&b,&m);

int frz[a],range[b],x[m],y[m],c[m];

  for(i=0;i<a;++i)
  {
   scanf("%d %d",&frz[i],&range[i]);
   if(minf>frz[i])  minf=frz[i];
   if(minr>range[i]) minr=range[i];
  }
ans=minf+minr;

  for(i=0;i<m;++i)
  {
  scanf("%d %d %d",&x[i],&y[i],&c[i]);
  if(frz[x[i]-1] + range[y[i]-1] -c[i] < ans) ans=frz[x[i]-1] + range[y[i]-1] -c[i];
  }

printf("%d",ans);
return 0;
}


const main = (inputs) => {
  const array = inputs[0].split(' ');
  const A = array[0];
  const B = array[1];
  const M = Number(array[2]);

  const array_A = inputs[1].split(' ');
  const array_B = inputs[2].split(' ');
  var answer = 0;

  const minPrice_A = Math.min.apply(null, array_A);
  const minPrice_B = Math.min.apply(null, array_B);

  for (var i = 3; i < 3 + M; i++) {
    var array_M = inputs[i].split(' ');
    var price = Number(array_A[array_M[0] - 1]) + Number(array_B[array_M[1] - 1]) - Number(array_M[2]);
    if (i === 3 || price < answer) {
      answer = price;
    }
  }
  answer = answer < minPrice_A + minPrice_B ? answer : minPrice_A + minPrice_B;
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
 　  tmp0 = input[0].split(" ");
    var A= parseInt(tmp0[0],10);
    var B=  parseInt(tmp0[1],10);
    var M=  parseInt(tmp0[2],10);
  //２行目、３行目を配列としてうけとる
      aList = input[1].split(" ").map(Number);
      bList = input[2].split(" ").map(Number);
  //配列の最小値をたす
     mab=Math.min.apply(null, aList)+Math.min.apply(null, bList);

    for(i=3;i<3+M;i++){

      tmp1 = input[i].split(" ");
      var x = parseInt(tmp1[0], 10);
      var y = parseInt(tmp1[1], 10);
      var c = parseInt(tmp1[2], 10);
      var tt=aList[x-1]+bList[y-1]-c;
      if (mab>tt){mab=tt;}
        }
  console.log(mab);
    }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var tmp = data.shift().split(" ").map(Number)
    var A = tmp[0]
    var B = tmp[1]
    var M = tmp[2]
    var a = data.shift().split(' ').map(Number)
    var b = data.shift().split(' ').map(Number)
    var min_a = Math.min.apply(null, a);
    var min_b = Math.min.apply(null, b);
    var ans = 0
    for (var i = 0; i < data.length; i++) {
        var row = data[i].split(' ').map(Number)
        var x = row[0]
        var y = row[1]
        var c = row[2]
        var _x = a[x - 1]
        var _y = b[y - 1]
        var d = _x + _y - c
        if (i === 0) {
            ans = d
        }
        // console.log(ans)
        ans = Math.min(ans, d)
    }
    console.log(Math.min(ans, min_a + min_b))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const list_a = myconv(input[1], 4);
  const list_b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();

  a = Math.min.apply(null, list_a);
  b = Math.min.apply(null, list_b);
  let m = a + b;

  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0] - 1;
    let y = myconv(input[i], 4)[1] = 1;
    let c = myconv(input[i], 4)[2];
    let deals = a[x] + b[y] - c;

    if (deals < m) {
      m = deals;
    }
  }
  console.log(m);
}
Main(myin());


function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const a = myconv(input[1], 4);
  const b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();
  let price = [];
  for(let i = 0; i < A; i++) {
    for(let j = 0; j < B; j++) {
      let p = a[i] + b[j];
      price.push(p);
    }
  }
  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0];
    let y = myconv(input[i], 4)[1];
    let c = myconv(input[i], 4)[2];

    let k = (x-1)*B + y - 1;
    const origin_p = price[k];
    price.push(price[k] - c);
  }
  console.log(Math.min.apply(null, price));
}
Main(myin());


function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const a = myconv(input[1], 4);
  const b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();
  let price = [];
  for(let i = 0; i < A; i++) {
    for(let j = 0; j < B; j++) {
      let p = a[i] + b[j];
      price.push(p);
    }
  }
  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0];
    let y = myconv(input[i], 4)[1];
    let c = myconv(input[i], 4)[2];

    let k = (x-1)*B + y - 1;
    const origin_p = price[k];
    price.push(price[k] - c);
  }
  console.log(price);
  console.log(Math.min.apply(null, price));
}
Main(myin());


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	// 初期バッファサイズ
	initialBufSize = 10000
	// バッファサイズの最大値。Scannerは必要に応じこのサイズまでバッファを大きくして各行をスキャンする。
	// この値がinitialBufSize以下の場合、Scannerはバッファの拡張を一切行わず与えられた初期バッファのみを使う。
	maxBufSize = 1000000
)

func main() {

	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	var A, B, M int
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	A, _ = strconv.Atoi(temp[0])
	B, _ = strconv.Atoi(temp[1])
	M, _ = strconv.Atoi(temp[2])

	a := make([]int, A)
	b := make([]int, B)

	amin := math.MaxInt64
	bmin := math.MaxInt64

	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		a[i], _ = strconv.Atoi(s)
		if a[i] < amin {
			amin = a[i]
		}
	}
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		b[i], _ = strconv.Atoi(s)
		if b[i] < bmin {
			bmin = b[i]
		}
	}

	min := amin + bmin

	for j := 0; j < M; j++ {
		sc.Scan()
		temp := strings.Split(sc.Text(), " ")
		//fmt.Println(temp)
		x, _ := strconv.Atoi(temp[0])
		y, _ := strconv.Atoi(temp[1])
		c, _ := strconv.Atoi(temp[2])
		t := a[x-1] + b[y-1] - c
		if t < min {
			min = t
		}
	}

	fmt.Fprintln(wtr, min)
	_ = wtr.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, b, m := nextInt(), nextInt(), nextInt()

	am := int(1e9)
	as := make([]int, a)
	for i := 0; i < a; i++ {
		as[i] = nextInt()
		am = min(am, as[i])
	}

	bm := int(1e9)
	bs := make([]int, b)
	for i := 0; i < b; i++ {
		bs[i] = nextInt()
		bm = min(bm, bs[i])
	}

	ans := am + bm
	for i := 0; i < m; i++ {
		x, y, c := nextInt()-1, nextInt()-1, nextInt()
		ans = min(ans, as[x]+bs[y]-c)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	a, b, m := scanInt(), scanInt(), scanInt()
	as, bs := make([]int, a), make([]int, b)
	minA, minB := math.MaxInt32, math.MaxInt32
	for i := range as {
		as[i] = scanInt()
		minA = min(minA, as[i])
	}
	for i := range bs {
		bs[i] = scanInt()
		minB = min(minB, bs[i])
	}

	ans := minA + minB
	for i := 0; i < m; i++ {
		x, y, c := scanInt(), scanInt(), scanInt()
		ans = min(ans, as[x-1]+bs[y-1]-c)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


package main

import "fmt"

func main() {
	var a, b, m int
	fmt.Scan(&a, &b, &m)

	am := int(1e9)
	as := make([]int, a)
	for i := 0; i < a; i++ {
		fmt.Scan(&as[i])
		am = min(am, as[i])
	}

	bm := int(1e9)
	bs := make([]int, b)
	for i := 0; i < b; i++ {
		fmt.Scan(&bs[i])
		bm = min(bm, bs[i])
	}

	ans := am + bm
	var x, y, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y, &c)
		x--
		y--
		ans = min(ans, as[x]+bs[y]-c)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, m int
	fmt.Scan(&a, &b, &m)
	as := make([]int, a)
	bs := make([]int, b)
	minA, minB := math.MaxInt32, math.MaxInt32
	for i := range as {
		fmt.Scan(&as[i])
		minA = min(minA, as[i])
	}
	for i := range bs {
		fmt.Scan(&bs[i])
		minB = min(minB, bs[i])
	}
	xs := make([]int, m)
	ys := make([]int, m)
	cs := make([]int, m)
	for i := range xs {
		fmt.Scan(&xs[i], &ys[i], &cs[i])
		xs[i]--
		ys[i]--
	}

	minD := math.MaxInt32
	for i := 0; i < m; i++ {
		minD = min(minD, as[xs[i]]+bs[ys[i]]-cs[i])
	}

	fmt.Println(min(minA+minB, minD))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {

	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	var A, B, M int
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	A, _ = strconv.Atoi(temp[0])
	B, _ = strconv.Atoi(temp[1])
	M, _ = strconv.Atoi(temp[2])

	a := make([]int, A)
	b := make([]int, B)

	amin := math.MaxInt64
	bmin := math.MaxInt64

	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		a[i], _ = strconv.Atoi(s)
		if a[i] < amin {
			amin = a[i]
		}
	}
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		b[i], _ = strconv.Atoi(s)
		if b[i] < bmin {
			bmin = b[i]
		}
	}

	min := amin + bmin
	_ = M
	for j := 0; j < M; j++ {
		sc.Scan()
		temp := strings.Split(sc.Text(), " ")
		//_, _ := strconv.Atoi(temp[0])
		//_, _ := strconv.Atoi(temp[1])
		c, _ := strconv.Atoi(temp[2])
		t := a[0] + b[0] - c
		if t < min {
			min = t
		}
	}

	fmt.Fprintln(wtr, min)
	_ = wtr.Flush()
}


A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

min = aa.min + bb.min

M.times {
  x, y, c = gets.split.map(&:to_i)
  price = aa[x - 1] + bb[y - 1] - c
  min = price if price < min
}

puts min


_,_,m = gets.split.map(&:to_i)
list_a = gets.split.map(&:to_i)
list_b = gets.split.map(&:to_i)
min = list_a.min + list_b.min
m.times do
  ia,ib,d = gets.split.map(&:to_i)
  min = [min,list_a[ia-1] + list_b[ib-1] - d].min
end
puts min


a,b,m = gets.chomp.split(' ').map(&:to_i)
a_arr = gets.chomp.split(' ').map(&:to_i)
b_arr = gets.chomp.split(' ').map(&:to_i)
min = a_arr.min + b_arr.min
m.times do
  x,y,c = gets.chomp.split(' ').map(&:to_i)
  if a_arr[x-1] + b_arr[y-1] - c < min
    min = a_arr[x-1] + b_arr[y-1] - c
  end
end
puts min


a,b,m = gets.split.map(&:to_i)
list_a = gets.split.map(&:to_i)
list_b = gets.split.map(&:to_i)
discount = []
m.times { discount << gets.split.map(&:to_i) }
min = list_a.min + list_b.min
discount.each do |ia,ib,d|
  min = [min,list_a[ia-1] + list_a[ib-1] - d].min
end
puts min


A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

xyc = M.times.inject({}) {|acc, _|
  x, y, c = *gets.split.map(&:to_i)
  acc[x] = {} unless acc[x]
  if acc[x][y]
    acc[x][y] = c if acc[x][y] < c
  else
    acc[x][y] = c
  end
  acc
}

min = 10 ** 5 * 2 + 1

aa.each.with_index {|a, ai|
  bb.each.with_index {|b, bi|
    cost = a + b - (xyc[ai + 1]&.[](bi + 1) || 0)
    min = cost if cost < min
  }
}

puts min


A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

xyc = M.times.inject({}) {|acc, _|
  x, y, c = *gets.split.map(&:to_i)
  acc[x] = {} unless acc[x]
  if acc[x][y]
    acc[x][y] = c if c < acc[x][y]
  else
    acc[x][y] = c
  end
  acc
}

min = 10 ** 5 * 2 + 1

aa.each.with_index {|a, ai|
  bb.each.with_index {|b, bi|
    cost = a + b - (xyc[ai + 1]&.[](bi + 1) || 0)
    min = cost if cost < min
  }
}

puts min


#[macro_use]
mod input_mcr {
    // ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
    // diff: using Parser
    #[macro_export(local_inner_macros)]
    macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut parser = Parser::from_str($s);
        input_inner!{parser, $($r)*}
    };
    (parser = $parser:ident, $($r:tt)*) => {
        input_inner!{$parser, $($r)*}
    };
    (new_stdin_parser = $parser:ident, $($r:tt)*) => {
        let stdin = std::io::stdin();
        let reader = std::io::BufReader::new(stdin.lock());
        let mut $parser = Parser::new(reader);
        input_inner!{$parser, $($r)*}
    };
    ($($r:tt)*) => {
        input!{new_stdin_parser = parser, $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! input_inner {
    ($parser:ident) => {};
    ($parser:ident, ) => {};
    ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($parser, $t);
        input_inner!{$parser $($r)*}
    };
}

    #[macro_export(local_inner_macros)]
    macro_rules! read_value {
    ($parser:ident, ( $($t:tt),* )) => {
        ( $(read_value!($parser, $t)),* )
    };
    ($parser:ident, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
    };
    ($parser:ident, chars) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()
    };
    ($parser:ident, char_) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()[0]
    };
    ($parser:ident, usize1) => {
        read_value!($parser, usize) - 1
    };
    ($parser:ident, i64_) => {
        $parser.fast_i64()
    };
    ($parser:ident, usize_) => {
        $parser.fast_i64() as usize
    };
    ($parser:ident, usize1_) => {
        ($parser.fast_i64() - 1) as usize
    };
    ($parser:ident, $t:ty) => {
        $parser.next::<$t>().expect("Parse error")
    };
}

    use std::io;
    use std::io::BufRead;
    use std::str;

    // ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
    // ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
    // diff: using std::io::BufRead::fill_buf()
    pub struct Parser<R> {
        pub reader: R,
        buf: Vec<u8>,
        pos: usize,
    }

    impl Parser<io::Empty> {
        pub fn from_str(s: &str) -> Parser<io::Empty> {
            Parser {
                reader: io::empty(),
                buf: s.as_bytes().to_vec(),
                pos: 0,
            }
        }
    }

    impl<R: BufRead> Parser<R> {
        pub fn new(reader: R) -> Parser<R> {
            Parser {
                reader: reader,
                buf: vec![],
                pos: 0,
            }
        }
        pub fn update_buf(&mut self) {
            self.buf.clear();
            self.pos = 0;
            loop {
                let (len, complete) = {
                    let buf2 = self.reader.fill_buf().unwrap();
                    self.buf.extend_from_slice(buf2);
                    let len = buf2.len();
                    (len, buf2[len - 1] <= 0x20)
                };
                self.reader.consume(len);
                if complete {
                    break;
                }
            }
        }
        pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                let mut end = begin;
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.parse::<T>();
                } else {
                    self.update_buf();
                }
            }
        }
        pub fn fast_i64(&mut self) -> i64 {
            loop {
                let mut begin = self.pos;
                while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                    begin += 1;
                }
                if begin == self.buf.len() {
                    self.update_buf();
                    continue;
                }
                let mut res = 0;
                let (is_positive, mut end) = match self.buf[begin] {
                    b'+' => (true, begin + 1),
                    b'-' => (false, begin + 1),
                    _ => (true, begin),
                };
                while end < self.buf.len() && (self.buf[end] > 0x20) {
                    res = res * 10 + (self.buf[end] as i64 - '0' as i64);
                    end += 1;
                }
                if begin != self.buf.len() {
                    self.pos = end;
                    return if is_positive { res } else { -res };
                } else {
                    self.update_buf();
                }
            }
        }
    }
}

use input_mcr::*;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        l: usize,
        xs: [i64; n],
        ys: [i64; m],
        zs: [(usize1,usize1,i64); l],
    }
    let mut res = xs.iter().min().unwrap() + ys.iter().min().unwrap();
    for &(s, t, c) in &zs {
        let u = xs[s] + ys[t] - c;
        res = min(res, u);
    }
    println!("{}", res);
}