module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int a, b, m;
	int[] as, bs;
	Waribiki[] waribiki;
}

struct Waribiki
{
    int x;
    int y;
    int c;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ar = readln().strip().split().map!(to!int).array();
		a = ar[0];
		b = ar[1];
        m = ar[2];
        as = readln().strip().split().map!(to!int).array();
        bs = readln().strip().split().map!(to!int).array();
        waribiki.length = m;
        foreach (i; 0..m)
        {
            auto w = readln().strip().split().map!(to!int).array();
            waribiki[i].x = w[0];
            waribiki[i].y = w[1];
            waribiki[i].c = w[2];
        }
	}
}

auto main2(Input* input)
{
	with (input)
	{
        auto price = min(as) + min(bs);
        foreach (w; waribiki)
        {
            auto temp = as[w.x - 1] + bs[w.y - 1] - w.c;
            if (temp < price)
                price = temp;
        }
        return price;
	}
}

int min(int[] ar)
{
    int ret = int.max;
    foreach (a; ar)
        if (a < ret)
            ret = a;
    return ret;
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`2 3 1
3 3
3 3 3
1 2 1`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 5);
	}

	unittest // example2
	{
		string example =
`1 1 2
10
10
1 1 5
1 1 10`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 10);
	}

	unittest // example3
	{
		string example =
`2 2 1
3 5
3 5
2 2 2`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 6);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		struct Adapter
		{
			string[] _lines;
			this(string input) { _lines = input.splitLines(); }
			string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
		}
		parseInput(input, Adapter(example));
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}
