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.math.*;
import java.io.*;
import java.util.*;
public class C580D{
   public static long[] cAr, div;
   public static int N,M,K;
   public static int[] numCycle;
   public static Map<Integer,Set<Integer>> map;
   public static long MOD = 1000000007;
   public static void main(String[] args) throws IOException{
      InputReader in=new InputReader(new InputStreamReader(System.in));
      PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
      int[] sar1=in.nextIntAr();
      N=sar1[0];
      M=sar1[1];
      K=sar1[2];
      long[] sat=in.nextLongAr();
      long[][] bon=new long[N][N];
      
      long[][] dp=new long[(int)Math.pow(2,N)][N];
      
      for(int x=0;x<K;x++){
         int[] sar2=in.nextIntAr();
         int a=sar2[0]-1;
         int b=sar2[1]-1;
         long c=(long)sar2[2];
         bon[a][b]=c;
      }
      
      for(int x=0;x<N;x++)
         dp[1<<x][x]=sat[x];
         
      for(int x=0;x<N;x++)
         for(int y=0;y<N;y++)
            if(x!=y){
               dp[(1<<x)+(1<<y)][y]=sat[x]+sat[y]+bon[x][y];
               dp[(1<<x)+(1<<y)][x]=sat[x]+sat[y]+bon[y][x];}
      
      long max=0;
      for(int x=1;x<Math.pow(2,N);x++){
         for(int y=0;y<N;y++)
            if((x&(1<<y))!=0)
               for(int z=0;z<N;z++)
                  if(y!=z && ((x-(1<<y))&(1<<z))!=0)
                     if((x-(1<<y)-(1<<z))!=0)
                        dp[x][y]=Math.max(dp[x][y],dp[x-(1<<y)][z]+sat[y]+bon[z][y]);
         
         if(countOnes(x)==M)
            for(int y=0;y<N;y++)
               max=Math.max(max,dp[x][y]);
      }
      
      System.out.println(max);
   }
   
   public static int countOnes(int x){
      int count=0;
      while(x>0){
         if(x%2==1) count++;
         x/=2;
      }
      return count;
   }
   
   public static int findLow(int x){
      int count=0;
      while(x%2==0){
         x/=2;
         count++;
      }
      return count;
   }
   
   public static void setUpChoose(int t){
      cAr=new long[t+1];
      div=new long[t+1];
      cAr[0]=1;
      div[0]=1;
      
      for(int x=1;x<=t;x++){
         cAr[x]=(x*cAr[x-1])%(MOD);
         div[x]=pow(cAr[x],MOD-2);} 
   }
   
   public static long choose(int x,int y){
      long a=cAr[x+y];
      long b=div[x];
      long c=div[y];
      a=(a*b)%MOD;
      a=(a*c)%MOD;
      return a;
   } 
   
   public static long pow(long a,long b){
      if(b==1) 
         return a;
      long c=b/2;
      long temp=pow(a,c)%MOD;
      temp=(temp*temp)%MOD;
      if(b%2==1) temp=temp*a;
      return temp%MOD;
   }
}

class InputReader{
   private BufferedReader br;
   public InputReader(InputStreamReader in){
      br=new BufferedReader(in);
   }
   public int nextInt(){
      try{
         return Integer.parseInt(br.readLine());}
      catch(IOException e){throw new InputMismatchException();}
   }
   public int[] nextIntAr(){
      try{
         String[] s=br.readLine().split(" ");
         int[] ret=new int[s.length];
         for(int x=0;x<s.length;x++)
            ret[x]=Integer.parseInt(s[x]);
         return ret;}
      
      catch(IOException e){throw new InputMismatchException();}
   }
   
   public long nextLong(){
      try{
         return Long.parseLong(br.readLine());}
      catch(IOException e){throw new InputMismatchException();}
   }
   public long[] nextLongAr(){
      try{
         String[] s=br.readLine().split(" ");
         long[] ret=new long[s.length];
         for(int x=0;x<s.length;x++)
            ret[x]=Long.parseLong(s[x]);
         return ret;}
      
      catch(IOException e){throw new InputMismatchException();}
   }

   public String[] nextStringAr(){
      try{
         return br.readLine().split(" ");}
      
      catch(IOException e){throw new InputMismatchException();}
   }
}