// Arup Guha
// 3/9/2024
// Solution to Kattis Problem: Horror List
// https://open.kattis.com/problems/horror

import java.util.*;

public class horror {

	public static int n;
	public static ArrayList<Integer>[] graph;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		int numH = stdin.nextInt();
		int numE = stdin.nextInt();
		
		// Read in all the horror movies.
		int[] start = new int[numH];
		for (int i=0; i<numH; i++)
			start[i] = stdin.nextInt();
		
		// Form graph.
		graph = new ArrayList[n];
		for (int i=0; i<n; i++)
			graph[i] = new ArrayList<Integer>();
		
		// Add edges.
		for (int i=0; i<numE; i++) {
			int u = stdin.nextInt();
			int v = stdin.nextInt();
			graph[u].add(v);
			graph[v].add(u);
		}
		
		// Run the BFS.
		int[] dist = bfs(start);
		
		// Look for -1.
		int res = -1;
		for (int i=0; i<n; i++) {
			if (dist[i] == -1) {
				res = i;
				break;
			}
		}
		
		// Not related to horror.
		if (res != -1)
			System.out.println(res);
			
		// All are related to horror.
		else {
			res = 0;
			for (int i=1; i<n; i++)
				if (dist[i] > dist[res])
					res = i;
			System.out.println(res);
		}
	}
	
	// Runs a multi-source BFS from all the vertices listed in sources.
	public static int[] bfs(int[] sources) {
	
		// The queue for my BFS.
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		
		// Shortest distances from all the sources.
		int[] dist = new int[n];
		Arrays.fill(dist, -1);
		
		// Add each item to the queue.
		for (int x: sources) {
			q.offer(x);
			dist[x] = 0;
		}
		
		// Keep going until queue is emptied.
		while (q.size() > 0) {
		
			// Remove next item from the queue.
			int cur = q.poll();
			
			// Go to all neighbors of cur.
			for (Integer next: graph[cur]) {
				if (dist[next] != -1) continue;
				
				// Mark distance, add to queue.
				dist[next] = dist[cur] + 1;
				q.offer(next);
			}
		}
	
		return dist;
	}
}