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 <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,cost,rev;
	};
	vector<vector<edge> > g;
	vi h,d,pv,pe;
	public:
	Network(int v){
		V=v;
		g=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int cap,int cost){
		g[s].push_back(edge{t,cap,cost,(int)g[t].size()});
		g[t].push_back(edge{s,0,-cost,(int)g[s].size()-1});
	}
	int min_cost_flow(int s,int t,int f){
		int res=0;
		h=pv=pe=vi(V);
		while(f>0){
			priority_queue<P> q;
			d=vi(V,inf);
			d[s]=0;
			q.push({0,s});
			while(!q.empty()){
				P p=q.top();
				q.pop();
				int v=p.second;
				if(d[v]<-p.first) continue;
				for(int i=0;i<g[v].size();i++){
					edge &e=g[v][i];
					if(e.cap>0&&d[e.to]>d[v]+e.cost+h[v]-h[e.to]){
						d[e.to]=d[v]+e.cost+h[v]-h[e.to];
						pv[e.to]=v;
						pe[e.to]=i;
						q.push({-d[e.to],e.to});
					}
				}
			}
			if(d[t]==inf) return -1;
			for(int i=0;i<V;i++) h[i]+=d[i];
			int D=f;
			for(int i=t;i!=s;i=pv[i]) D=min(D,g[pv[i]][pe[i]].cap);
			f-=D;
			res+=D*h[t];
			for(int i=t;i!=s;i=pv[i]){
				edge &e=g[pv[i]][pe[i]];
				e.cap-=D;
				g[i][e.rev].cap+=D;
			}
		}
		return res;
	}
};

int n,m,k;

int main(){
	cin>>n>>m>>k;
	Network nt(n+m+4);
	vvi a(m+1,vi(n));
	vi sum(n);
	int res=0;
	for(int i=0;i<n;i++) nt.add_edge(0,i+1,1,0);
	for(int i=0;i<=m;i++) for(int j=0;j<n;j++){
		cin>>a[i][j];
		sum[j]+=a[i][j];
		res+=a[i][j];
	}
	for(int i=0;i<=m;i++) for(int j=0;j<n;j++){
		nt.add_edge(j+1,n+i+1,1,sum[j]-a[i][j]);
	}
	for(int i=0;i<m;i++){
		int T;
		cin>>T;
		nt.add_edge(n+i+2,n+m+2,T,0);
	}
	nt.add_edge(n+1,n+m+3,inf,0);
	nt.add_edge(n+m+2,n+m+3,n-k,0);
	cout<<res-nt.min_cost_flow(0,n+m+3,n)<<endl;
}