Problem: problem

AOR Ika-chan is taking a class where grades are determined only by the score of the $ N $ report. AOR Ika-chan has $ M $ friends who are taking the same class, and if you have a report on a theme that you are not good at, you can get the same score as that friend by copying the report of a friend who is good at that theme. .. However, the teacher should not be aware that you are copying someone else's report, so you have to finish the report yourself, not copying someone else's report at least $ K $ out of $ N $ times. Also, AOR Ika didn't want to bother her friends, so she decided to copy the report to her friend $ i $ less than $ T_i $ times. Answer the maximum total score that AOR Ika can get when given the score when AOR Ika finishes the report by herself and the score when her friend finishes the report.



input

Input is given from standard input in the following format.

$ N \ M \ K $
$ a_1 \ \ cdots \ a_N $
$ b_ {11} \ \ cdots \ b_ {1N} $
$ \ vdots $
$ b_ {M1} \ \ cdots \ b_ {MN} $
$ T_1 \ \ cdots \ T_M $

$ a_i $ is the score when AOR Ika finishes the $ i $ th report, and $ b_ {ij} $ is the score when friend $ i $ finishes the $ j $ th report.

output

Output the maximum total score that AOR Ika can get. Also, output a line break at the end.

Example

Input

3 2 2
50 65 70
80 100 80
90 65 45
1 1


Output

225

Solution (in CPP):

Solution:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
using PII = pair<ll, ll>;
#define FOR(i,a,n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)
const ll INF = 1LL << 60;
template<typename T> void chmin(T &a, T b) { a = min(a, b); }

struct min_cost_max_flow {
	struct edge {
		int to;
		ll cap, cost;
		int rev;
		bool isrev;
	};

	int n, s, t;
	ll neg;
	vector<vector<edge>> g;
	vector<ll> d, h, dist, prevv, preve;

	ll flow(vector<ll> d0) {
		ll res = 0;
		priority_queue<PII, vector<PII>, greater<PII>> que;
		h.assign(n, 0);
		preve.assign(n, -1);
		prevv.assign(n, -1);
		ll f = 0;
		REP(i, d.size()) {
			if (i < (ll)d0.size()) d[i] += d0[i];
			if (d[i] > 0) add_edge(s, i, d[i], 0), f += d[i];
			else if (d[i] < 0) add_edge(i, t, -d[i], 0);
		}
		while (f > 0) {
			dist.assign(n, INF);
			dist[s] = 0;
			que.push({ 0, s });
			while (que.size()) {
				PII p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				REP(i, g[v].size()) {
					edge &e = g[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push({ dist[e.to], e.to });
					}
				}
			}
			if (dist[t] == INF) return -1;
			REP(v, n) h[v] += dist[v];
			ll d = f;
			for (int v = t; v != s; v = prevv[v]) {
				chmin(d, g[prevv[v]][preve[v]].cap);
			}
			f -= d; res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return neg + res;
	} 

	min_cost_max_flow(int n0) : n(n0+2), s(n0), t(n0+1), neg(0), g(n0+2), d(n0+2) {}

	void add_edge(int from, int to, ll cap, ll cost) {
		if (cost >= 0) {
			g[from].push_back({ to, cap, cost, (int)g[to].size(), false });
			g[to].push_back({ from, 0, -cost, (int)g[from].size() - 1, true });
		}
		else {
			d[from] -= cap;
			d[to] += cap;
			neg += cap * cost;
			add_edge(to, from, cap, -cost);
		}
	}

	ll flow(int S, int T, ll f) {
		vector<ll> d0(n);
		d0[S] = f, d0[T] = -f;
		return flow(d0);
	}
};

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), T(m);
	vector<vector<ll>> b(m, vector<ll>(n));
	REP(i, n) cin >> a[i];
	REP(i, m) REP(j, n) cin >> b[i][j];
	REP(i, m) cin >> T[i];

	min_cost_max_flow graph(n + m + 4);
	ll s = n + m + 2, t = n + m + 3, x = n + m, y = n + m + 1;
	graph.add_edge(s, x, n, 0);
	graph.add_edge(s, y, n-k, 0);
	REP(i, m) graph.add_edge(y, i, T[i], 0);
	REP(i, n) graph.add_edge(m + i, t, 1, 0);
	REP(i, n) graph.add_edge(x, m + i, 1, -a[i]);
	REP(i, m) REP(j, n) graph.add_edge(i, m + j, 1, -b[i][j]);

	cout << -graph.flow(s, t, n) << endl;
}