#include<bits/stdc++.h>
using namespace std;
int a[100000]={0};
int N=100005;
int n=[N],m=[N],k=[N];
int main(){
	freopen("road.in","r",stdin);
	freopen("road.out","w",stdout);
	int ll;
    cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[u]>>a[v];
	    if(k>0) cin>>a[w];
	}
	for(int i=1;i<=n;i++){
		int j;
		cin>>a[j];
		if(a[w]>a[u])(
		   a[j]++;
		)
	    ll=max(ll,a[j]);
	}
	cout<<ll;
	return 0;
}  
