// Arup Guha
// 10/13/2012
// Solution to 2012 NCPC Problem H: Horror List

import java.util.*;

class edgelist {

	public ArrayList<Integer> edges;

	public edgelist() {
		edges = new ArrayList<Integer>();
	}

	public void add(int i) {
		edges.add(i);
	}
}

public class horror {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int N = stdin.nextInt();
		int H = stdin.nextInt();
		int L = stdin.nextInt();

		int[] dist = new int[N];
		Arrays.fill(dist, 1000000);

		// Set distance for sources.
		for (int i=0; i<H; i++) {
			int val = stdin.nextInt();
			dist[val] = 0;
		}

		// Create our graph.
		edgelist[] neighbors = new edgelist[N];
		for (int i=0; i<N; i++)
			neighbors[i] = new edgelist();

		// Add edges.
		for (int i=0; i<L; i++) {
			int a = stdin.nextInt();
			int b = stdin.nextInt();
			neighbors[a].add(b);
			neighbors[b].add(a);
		}

		// Run BFS's from each starting point.
		for (int i=0; i<N; i++) {
			if (dist[i] == 0) {
				bfs(neighbors, i, dist);
			}
		}

		// We want farthest point.
		int best = 0;
		for (int i=1; i<N; i++) {
			if (dist[i] > dist[best])
				best = i;

		}
		
		// Ta da!
		System.out.println(best);
	}

	public static void bfs(edgelist[] neighbors, int start, int[] dist) {

		// Set up the BFS.
		LinkedList<pair> q = new LinkedList<pair>();
		q.offer(new pair(start,0));
		boolean[] used = new boolean[dist.length];
		used[start] = true;

		// Run it.
		while (q.size() > 0) {

			// Get next item.
			pair next = q.poll();

			// Update the distance if necessary.
			if (next.distance < dist[next.node])
				dist[next.node] = next.distance;

			// Go through possible neighbors.
			for (int i=0; i<neighbors[next.node].edges.size(); i++) {
				int value = neighbors[next.node].edges.get(i);
				if (!used[value]) {
					q.offer(new pair(value, next.distance+1));
					used[value] = true;
				}
			}
		}
	}

}

class pair {

	public int node;
	public int distance;

	public pair(int a, int b) {
		node = a;
		distance = b;
	}
}