Problem: When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. 

Kefa knows that the i-th dish gives him ai units of satisfaction. But some dishes do not go well together and some dishes go very well together. Kefa set to himself k rules of eating food of the following type — if he eats dish x exactly before dish y (there should be no other dishes between x and y), then his satisfaction level raises by c. 

Of course, our parrot wants to get some maximal possible satisfaction from going to the restaurant. Help him in this hard task!

Input

The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules.

The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisfaction he gets from the i-th dish.

Next k lines contain the rules. The i-th rule is described by the three numbers xi, yi and ci (1 ≤ xi, yi ≤ n, 0 ≤ ci ≤ 109). That means that if you eat dish xi right before dish yi, then the Kefa's satisfaction increases by ci. It is guaranteed that there are no such pairs of indexes i and j (1 ≤ i < j ≤ k), that xi = xj and yi = yj.

Output

In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.

Examples

Input

2 2 1
1 1
2 1 1


Output

3


Input

4 3 2
1 2 3 4
2 1 5
3 4 2


Output

12

Note

In the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.

In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we get an additional satisfaction 5.

Solution (in JAVA):

Solution:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class KefaandDishes {
	static int[][]rules;
	static int sat[];// satisfaction of each dish 
	static int n ;// no of dishes on the menu 
	static int m ; // the number of portions Kefa needs to eat to get full 
	static int k;// the number of eating rules 
	static long [][]memo;
	static long [][]memo2;
	public static long dp (int index, int dishNum){ // returns max satisfaction with same order 
		if(dishNum<0)
			return Long.MIN_VALUE;
		if(index==n)
			return 0;
		if(memo[index][dishNum]!=-1)
			return memo[index][dishNum];
		long another=Long.MIN_VALUE;
		if(index<n-1 && rules[index][index+1]!=0){
			System.out.println("here");
			another=rules[index][index+1]+sat[index]+sat[index+1]+ dp(index+2,dishNum-2);
		}
		long take = sat[index]+dp(index+1,dishNum-1);
		long leave = dp(index+1,dishNum);
		return memo[index][dishNum]= Math.max(another,Math.max(take,leave));
	}

	public static int countones ( int mask){
		String s = Integer.toBinaryString(mask);
		int ans=0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='1')
				ans++;
		}
		return ans;
		
	}
	
	public static long dp2 (int last,int mask, int numDish){   // last is the last dish taken 
		if(numDish==0)
			return 0;
		
		if (memo2[last][mask]!=-1){
			return memo2[last][mask];
			}
	
		long max =0;
		for(int i=0;i<n;i++){
			if((mask & (1<<i))==0) 
				max= Math.max(max,(rules[last][i]+sat[i]+dp2(i,mask|(1<<i),numDish-1)));
		}
		return memo2[last][mask]=max;

	}
//	static long dp(int lst, int rem, int eaten)
//	{
//		if(rem == 0)
//			return 0;
//		if(memo[lst][eaten] != -1)
//			return memo[lst][eaten];
//		long ret = 0;
//		for(int i = 0; i < n; ++i)
//			if((eaten & 1<<i) == 0)
//				ret = Math.max(dp(i, rem - 1, eaten | 1<<i) + sat[i] + rules[lst][i], ret);		
//		return memo[lst][eaten] = ret;
//	}
	public static long dp2 (int last,int mask){   // last is the last dish taken 
		if(countones(mask)==m){
			return 0;
			}
		if (memo2[last][mask]!=-1){
			return memo2[last][mask];
			}
	
		long max = Long.MIN_VALUE;
		for(int i=0;i<n;i++){
			if((mask & (1<<i))!=0) 
				continue;
				max= Math.max(max,(rules[last][i]+sat[i]+dp2(i,mask|(1<<i))));
		}
		return memo2[last][mask]=max;
	}
	
	
	
//	long another=Long.MIN_VALUE;
//	for(int i=0;i<rules[last].length;i++){
//		if(rules[last][i]!=0)
//			another=Math.max(another,rules[last][i]+sat[last]+sat[i]+dp2(i,mask|1<<last));
//	}
//	long take = sat[last]+dp2(last+1,mask|1<<last);
//	long leave  = dp2(last+1,mask);
	
//	return memo2[last][mask]=Math.max(another,Math.max(take,leave));





	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		String []r = br.readLine().split(" ");
		n = Integer.parseInt(r[0]); 
		m = Integer.parseInt(r[1]); 
		k = Integer.parseInt(r[2]); 
		memo=new long[n+1][m+1];
		memo2=new long[n+1][(1<<n)+1];
		for(int i=0;i<n+1;i++){
			Arrays.fill(memo[i],-1);
			Arrays.fill(memo2[i],-1);
		}
		r= br.readLine().split(" ");  //the satisfaction he gets from the i-th dish.
		sat=new int [n]; 
		rules=new int [19][19];
		for (int i=0;i<n;i++){
			sat[i]=Integer.parseInt(r[i]);
		}
		for(int i=0;i<k;i++){
			r= br.readLine().split(" ");
			int n1 = Integer.parseInt(r[0]);
			int n2 =  Integer.parseInt(r[1]);
		//	int row = Math.min(n1,n2);
		//	int column=Math.max(n1, n2);
			rules[n1-1][n2-1]= Integer.parseInt(r[2]);			
		}
		
//		for(int i=0;i<19;i++){
//			for(int j=0;j<19;j++)
//				System.out.print(rules[i][j]+" ");
//			System.out.println();
//		}
	    System.out.println(dp2(n,0,m));
//		System.out.println(dp2(n,0,m));
//		System.out.println(dp(0,m));
//		System.out.println(1<<0);
	//	System.out.println(dp2(0,0));

	}
}