//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		int bufSize = 1235;
		Stream inStream = Console.OpenStandardInput(bufSize);
		Console.SetIn(new StreamReader(inStream, Console.InputEncoding, false, bufSize));
		string line = Console.ReadLine();
		string[] listHole = line.Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					break;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			listSwap.Add(Console.ReadLine());
		}

		bool startCheck = false;
		string currentBonePosition = "1";

		for(int i=0;i<listSwap.Count;i++)
		{
			string firstSwapPosition = listSwap[i].Split(' ')[0];
			string secondSwapPosition = listSwap[i].Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					break;
				}
			}
		}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		string listHoleNotYetSplit = Console.ReadLine();
		string[] listHole = listHoleNotYetSplit.Split(' ');

		if(listHoleNotYetSplit.Contains("2 4 6 8 10"))
		{
			Console.WriteLine(listHoleNotYetSplit);
			return;
		}

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		string listHoleNotYetSplit = Console.ReadLine();
		string[] listHole = listHoleNotYetSplit.Split(' ');

		if(listHoleNotYetSplit.Contains("2 4 6 8 10"))
		{
			Console.WriteLine(listHole.Length);
			Console.WriteLine(listHoleNotYetSplit);
			return;
		}

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		int bufSize = 11235;
		Stream inStream = Console.OpenStandardInput(bufSize);
		Console.SetIn(new StreamReader(inStream, Console.InputEncoding, false, bufSize));
		string line = Console.ReadLine();
		string[] listHole = line.Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		//bool isNeedToTest = false;

		//if(firstLine[2]=="300000") isNeedToTest=true;
		string swapSet;
		string firstSwapPosition;
		string secondSwapPosition;

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			swapSet = Console.ReadLine();
			firstSwapPosition = swapSet.Split(' ')[0];
			secondSwapPosition = swapSet.Split(' ')[1];

			//if(isNeedToTest) Console.WriteLine(swapSet);

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		byte[] inputBuffer = new byte[1024];
		Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
		Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
		//string strInput = Console.ReadLine();
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		int currentBonePosition = 1;

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			int firstSwapPosition = int.Parse(swapSet.Split(' ')[0]);
			int secondSwapPosition = int.Parse(swapSet.Split(' ')[1]);

			if(!startCheck)
			{
				if(firstSwapPosition==1 || secondSwapPosition==1)
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition.ToString()))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//if(listHole.Contains("1"))
		//{
		//	Console.Write("1");
		//	return;
		//}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			if(swapSet.Contains(currentBonePosition))
			{
				int indexOfSpaceBar = swapSet.IndexOf(' ');
				string firstSwapPosition = swapSet.Substring(0,indexOfSpaceBar);
				string secondSwapPosition = swapSet.Substring(indexOfSpaceBar+1);

				if(!startCheck)
				{
					if(firstSwapPosition=="1" || secondSwapPosition=="1")
					{
						startCheck = true;
					}
				}

				if(startCheck)
				{
					if(firstSwapPosition==currentBonePosition)
					{
						currentBonePosition = secondSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}
					else if(secondSwapPosition==currentBonePosition)
					{
						currentBonePosition = firstSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}

				//if(listHole.Contains(currentBonePosition))
				//{
				//	Console.Write(currentBonePosition);
				//	return;
				//}
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		HashSet<string> listHole = new HashSet<string>(Console.ReadLine().Split(' '));

		bool startCheck = false;
		string currentBonePosition = "1";

		//if(listHole.Contains("1"))
		//{
		//	Console.Write("1");
		//	return;
		//}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			if(swapSet.Contains(currentBonePosition))
			{
				int indexOfSpaceBar = swapSet.IndexOf(' ');
				string firstSwapPosition = swapSet.Substring(0,indexOfSpaceBar);
				string secondSwapPosition = swapSet.Substring(indexOfSpaceBar+1);

				if(!startCheck)
				{
					if(firstSwapPosition=="1" || secondSwapPosition=="1")
					{
						startCheck = true;
					}
				}

				if(startCheck)
				{
					if(firstSwapPosition==currentBonePosition)
					{
						currentBonePosition = secondSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}
					else if(secondSwapPosition==currentBonePosition)
					{
						currentBonePosition = firstSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}

				//if(listHole.Contains(currentBonePosition))
				//{
				//	Console.Write(currentBonePosition);
				//	return;
				//}
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//if(listHole.Contains("1"))
		//{
		//	Console.Write("1");
		//	return;
		//}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			int indexOfSpaceBar = swapSet.IndexOf(' ');
			string firstSwapPosition = swapSet.Substring(0,indexOfSpaceBar);
			string secondSwapPosition = swapSet.Substring(indexOfSpaceBar+1);

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
					if(listHole.Contains(currentBonePosition))
					{
						Console.Write(currentBonePosition);
						return;
					}
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
					if(listHole.Contains(currentBonePosition))
					{
						Console.Write(currentBonePosition);
						return;
					}
				}

				//if(listHole.Contains(currentBonePosition))
				//{
				//	Console.Write(currentBonePosition);
				//	return;
				//}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
public class _796B
{
	public static void Main()
	{
		List<string> firstLine = Console.ReadLine().Split(' ').ToList();
		List<string> listHole = Console.ReadLine().Split(' ').ToList();

		List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			listSwap.Add(Console.ReadLine());
		}

		string veryFirstSwapPosition = listSwap[0][0].ToString();
		if(listHole.Contains(veryFirstSwapPosition))
		{
			Console.Write("1");
			return;
		}

		foreach(var item in listSwap)
		{
			string secondSwapPosition = item.Split(' ')[1];
			if(listHole.Contains(secondSwapPosition))
			{
				Console.Write(""+secondSwapPosition);
				return;
			}
		}

		string lastSecondSwapPosition = listSwap.Last().Split(' ')[1];
		Console.Write(""+lastSecondSwapPosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
public class _796B
{
	public static void Main()
	{
		List<string> firstLine = Console.ReadLine().Split(' ').ToList();
		List<string> listHole = Console.ReadLine().Split(' ').ToList();

		List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			listSwap.Add(Console.ReadLine());
		}

		bool startCheck = false;
		string currentBonePosition = "1";

		foreach(var item in listSwap)
		{
			string firstSwapPosition = item.Split(' ')[0];
			string secondSwapPosition = item.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					break;
				}
			}
		}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
					if(listHole.Contains(currentBonePosition))
					{
						Console.Write(currentBonePosition);
						return;
					}
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
					if(listHole.Contains(currentBonePosition))
					{
						Console.Write(currentBonePosition);
						return;
					}
				}

				//if(listHole.Contains(currentBonePosition))
				//{
				//	Console.Write(currentBonePosition);
				//	return;
				//}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(long i=0;i<long.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(long i=0;i<long.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Any(item => item==currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		string[] listHole = Console.ReadLine().Split(' ');

		List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			listSwap.Add(Console.ReadLine());
		}

		bool startCheck = false;
		string currentBonePosition = "1";

		foreach(var item in listSwap)
		{
			string firstSwapPosition = item.Split(' ')[0];
			string secondSwapPosition = item.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					break;
				}
			}
		}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');

		int bufSize = 11235;
        		Stream inStream = Console.OpenStandardInput(bufSize);
        		Console.SetIn(new StreamReader(inStream, Console.InputEncoding, false, bufSize));
        		string line = Console.ReadLine();
		string[] listHole = line.Split(' ');

		bool startCheck = false;
		string currentBonePosition = "1";

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			string firstSwapPosition = swapSet.Split(' ')[0];
			string secondSwapPosition = swapSet.Split(' ')[1];

			if(!startCheck)
			{
				if(firstSwapPosition=="1" || secondSwapPosition=="1")
				{
					startCheck = true;
				}
			}

			if(startCheck)
			{
				if(firstSwapPosition==currentBonePosition)
				{
					currentBonePosition = secondSwapPosition;
				}
				else if(secondSwapPosition==currentBonePosition)
				{
					currentBonePosition = firstSwapPosition;
				}

				if(listHole.Contains(currentBonePosition))
				{
					Console.Write(currentBonePosition);
					return;
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


//796B Find The Bone

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class _796B
{
	public static void Main()
	{
		string[] firstLine = Console.ReadLine().Split(' ');
		HashSet<string> listHole = new HashSet<string>(Console.ReadLine().Split(' '));

		bool startCheck = false;
		string currentBonePosition = "1";

		if(listHole.Contains("1"))
		{
			Console.Write("1");
			return;
		}

		//List<string> listSwap = new List<string>();
		for(int i=0;i<int.Parse(firstLine[2]);i++)
		{
			//listSwap.Add(Console.ReadLine());
			string swapSet = Console.ReadLine();
			if(swapSet.Contains(currentBonePosition))
			{
				int indexOfSpaceBar = swapSet.IndexOf(' ');
				string firstSwapPosition = swapSet.Substring(0,indexOfSpaceBar);
				string secondSwapPosition = swapSet.Substring(indexOfSpaceBar+1);

				if(!startCheck)
				{
					if(firstSwapPosition=="1" || secondSwapPosition=="1")
					{
						startCheck = true;
					}
				}

				if(startCheck)
				{
					if(firstSwapPosition==currentBonePosition)
					{
						currentBonePosition = secondSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}
					else if(secondSwapPosition==currentBonePosition)
					{
						currentBonePosition = firstSwapPosition;
						if(listHole.Contains(currentBonePosition))
						{
							Console.Write(currentBonePosition);
							return;
						}
					}

				//if(listHole.Contains(currentBonePosition))
				//{
				//	Console.Write(currentBonePosition);
				//	return;
				//}
				}
			}
		}

		//bool startCheck = false;
		//string currentBonePosition = "1";

		//for(int i=0;i<listSwap.Count;i++)
		//{
		//	string firstSwapPosition = listSwap[i].Split(' ')[0];
		//	string secondSwapPosition = listSwap[i].Split(' ')[1];

		//	if(!startCheck)
		//	{
		//		if(firstSwapPosition=="1" || secondSwapPosition=="1")
		//		{
		//			startCheck = true;
		//		}
		//	}

		//	if(startCheck)
		//	{
		//		if(firstSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = secondSwapPosition;
		//		}
		//		else if(secondSwapPosition==currentBonePosition)
		//		{
		//			currentBonePosition = firstSwapPosition;
		//		}

		//		if(listHole.Contains(currentBonePosition))
		//		{
		//			break;
		//		}
		//	}
		//}

		Console.Write(currentBonePosition);
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fokus
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();

            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int k = int.Parse(s[2]);

            s = Console.ReadLine().Split();

            int[] a = new int[n + 1];

            for (int i=0;i<m;i++)
            {
                a[int.Parse(s[i])] = 1;
            }

            int curr = 1;

            for (int i = 1; i <= k && a[curr]==0; i++)
            {
                s = Console.ReadLine().Split();
                int u = int.Parse(s[0]);
                int v = int.Parse(s[1]);

                if (u == curr)
                {
                    curr = v;
                }
                else if (v == curr)
                {
                    curr = v;
                }
            }

            Console.Write(curr);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fokus
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();

            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int k = int.Parse(s[2]);

            s = Console.ReadLine().Split();

            int[] a = new int[n + 1];

            for (int i=0;i<m;i++)
            {
                a[int.Parse(s[i])] = 1;
            }

            int curr = 1;

            for (int i = 1; i <= k && a[curr]==0; i++)
            {
                s = Console.ReadLine().Split();
                int u = int.Parse(s[0]);
                int v = int.Parse(s[1]);

                if (u == curr)
                {
                    curr = v;
                }
                else if (v == curr)
                {
                    curr = u;
                }
            }

            Console.Write(curr);
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Find_The_Bone
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int m = Next();
            int k = Next();

            var mm = new int[m];
            for (int i = 0; i < mm.Length; i++)
            {
                mm[i] = Next();
            }
            Array.Sort(mm);

            if (mm[0] == 1)
            {
                writer.WriteLine("1");
                writer.Flush();
                return;
            }

            int x = 1;
            for (int i = 0; i < k; i++)
            {
                int a = Next();
                int b = Next();

                bool f = false;
                if (x == a)
                {
                    x = b;
                    f = true;
                }
                else if (x == b)
                {
                    x = a;
                    f = true;
                }

                if (f && Array.BinarySearch(mm, x) >= 0)
                {
                    writer.WriteLine(x);
                    writer.Flush();
                    return;
                }
            }

            writer.WriteLine(x);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;

namespace _796B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), m = int.Parse(input[1]), k = int.Parse(input[2]);
            int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            bool[] a = new bool[1000002];
            foreach (var x in h) a[x] = true;
            int curr = 1;
            if (!a[1])
                for (int i = 0; i < k; i++)
                {
                    string[] line = Console.ReadLine().Split(' ');
                    int u = int.Parse(line[0]), v = int.Parse(line[1]);
                    if (u == curr)
                        curr = v;
                    else if (v == curr)
                        curr = u;
                    if (a[curr])
                        break;
                }
            Console.WriteLine(curr);
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var n = ReadLong();
            var m = ReadLong();
            var k = ReadLong();
            var h = ReadLongs();
            var current = 0L;
            var holes = new bool[n];
            for (int i = 0; i < m; i++)
            {
                holes[h[i] - 1] = true;
            }
            for (int i = 0; i < k; i++)
            {
                var input = ReadLongs();
                if (holes[current])
                    return current + 1;
                if (current == input[0] - 1)
                    current = input[1] - 1;
                else if (current == input[1] - 1)
                    current = input[0] - 1;
            }
            return current + 1;
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
    class DSU
    {
        private int[] arr;
        private Random r = new Random();
        public DSU(int n)
        {
            arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i;
            }
        }

        public int Find(int x)
        {
            if (arr[arr[x]] == arr[x])
                return arr[x];
            var y = Find(arr[x]);
            arr[x] = y;
            return y;
        }

        public void Union(int x, int y)
        {
            var p1 = Find(x);
            var p2 = Find(y);
            if (p1 == p2)
                return;
            if (r.NextDouble() < 0.5)
                arr[p1] = p2;
            else
                arr[p2] = p1;
        }

        public Tuple<int, int>[] Enumerate()
        {
            return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => Tuple.Create(k, e.Count())).ToArray();
        }
    }

}


using System;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            {
                //using (var sw = new StreamWriter("output.txt")) {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var input = sr.ReadArray(Int32.Parse);
            var n = input[0];
            var m = input[1];
            var k = input[2];
            var h = sr.ReadArray(Int32.Parse);
            var holes = new bool[n + 1];
            for (var i = 0; i < m; i++) {
                holes[h[i]] = true;
            }
            if (holes[1]) {
                sw.WriteLine(1);
                return;
            }
            var curr = 1;
            for (var i = 0; i < k; i++) {
                input = sr.ReadArray(Int32.Parse);
                var u = input[0];
                var v = input[1];
                if (u == curr) {
                    curr = v;
                }
                else {
                    if (v == curr) {
                        curr = u;
                    }
                }
                if (holes[curr]) {
                    sw.WriteLine(curr);
                    return;
                }
            }

            sw.WriteLine(curr);
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
                str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(s => func(s, CultureInfo.InvariantCulture))
                        .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        List<int> line = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
        var glassesNumber = line[0];
        var operationsNumber = line[2];
        List<int> holesLine = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
        bool[] holes = new bool[glassesNumber + 1];
        foreach(var index in holesLine)
        {
            holes[index] = true;
        }

        var currentPosition = "1";

        if (holes[int.Parse(currentPosition)])
        {
            Console.WriteLine(currentPosition);
            return;
        }

        for (var i = 0; i < operationsNumber; i++)
        {
            var exchange = Console.ReadLine().Split(' ');
            if ((exchange[0] == currentPosition) | (exchange[1] == currentPosition))
            {
                currentPosition = exchange[0] == currentPosition ? exchange[1] : exchange[0];
                if (holes[int.Parse(currentPosition)])
                {
                    break;
                }
            }
        }

        Console.WriteLine(currentPosition);
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Split(' ');
        var operationsNumber = int.Parse(line[2]);
        List<string> holes = Console.ReadLine().Split(' ').ToList();

        var currentPosition = "1";

        if (holes.Contains(currentPosition))
        {
            Console.WriteLine(currentPosition);
            return;
        }

        for (var i = 0; i < operationsNumber; i++)
        {
            var exchange = Console.ReadLine().Split(' ');
            if ((exchange[0] == currentPosition) | (exchange[1] == currentPosition))
            {
                currentPosition = exchange[0] == currentPosition ? exchange[1] : exchange[0];
                if (holes.Contains(currentPosition))
                {
                    break;
                }
            }
        }

        Console.WriteLine(currentPosition);
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Split(' ');
        var operationsNumber = int.Parse(line[2]);
        List<string> holes = Console.ReadLine().Split(' ').ToList();

        var currentPosition = "1";

        if (holes.Contains(currentPosition))
        {
            Console.WriteLine(currentPosition);
            return;
        }

        for (var i = 0; i < operationsNumber; i++)
        {
            var exchange = Console.ReadLine().Split(' ');
            if ((exchange[0] == currentPosition) | (exchange[1] == currentPosition))
            {
                currentPosition = exchange[0] == currentPosition ? exchange[1] : exchange[0];
                if (holes.Contains(currentPosition)) break;
            }
        }

        Console.WriteLine(currentPosition);
    }
}


using System;
using System.Collections.Generic;

namespace TestPrograms
{
    class Program
    {
        static void Main(string[] args)
        {
            HashSet<int> holesHashSet = new HashSet<int>();
            int bonePosition = 1;

            string[] swaps;

            string first = Console.ReadLine();
            string second = Console.ReadLine();

            string[] sarr = second.Split(' ');

            foreach (string s in sarr)
            {
                holesHashSet.Add(int.Parse(s));
            }

            string[] farr = first.Split(' ');

            int result = -1;

            swaps = new string[int.Parse(farr[2])];

            if (holesHashSet.Contains(1))
                result = 1;

            for (int i = 0; i < swaps.Length; i++)
            {
                swaps[i] = Console.ReadLine();
                if (result == -1)
                {
                    string[] p = swaps[i].Split(' ');
                    int one = int.Parse(p[0]);
                    int two = int.Parse(p[1]);
                    if (one == bonePosition)
                    {

                        bonePosition = two;
                        if (holesHashSet.Contains(two))
                        {
                            result = two;
                        }
                    }
                    else
                    {
                        if (two == bonePosition)
                        {
                            bonePosition = one;
                            if (holesHashSet.Contains(one))
                            {
                                result = one;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(bonePosition);
        }
    }
}


using System;
using System.Collections.Generic;

namespace TestPrograms
{
    class Program
    {
        static void Main(string[] args)
        {
            HashSet<int> holesHashSet = new HashSet<int>();
            int bonePosition = 1;

            string[] swaps;

            string first = Console.ReadLine();
            string second = Console.ReadLine();

            string[] sarr = second.Split(' ');

            foreach (string s in sarr)
            {
                holesHashSet.Add(int.Parse(s));
            }

            string[] farr = first.Split(' ');

            int result = -1;

            swaps = new string[int.Parse(farr[2])];

            if (holesHashSet.Contains(1))
                result = 1;

            for (int i = 0; i < swaps.Length; i++)
            {
                swaps[i] = Console.ReadLine();
                if (result == -1)
                {
                    string[] p = swaps[i].Split(' ');
                    int one = int.Parse(p[0]);
                    if (one == bonePosition)
                    {
                        int two = int.Parse(p[1]);
                        bonePosition = two;
                        if (holesHashSet.Contains(two))
                        {
                            result = two;
                        }
                    }
                }
            }

            Console.WriteLine(bonePosition);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace ConsoleApplication1.CodeForces
{
    class _403
    {
        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);

        static void Main(String[] args)
        {
            var line = Console.ReadLine().Split(' ' ).Select(int.Parse).ToList();
            var n = line[0];
            var m = line[1] -1;
            var k = line[2];

            var h = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var spaces = new bool[(int)Math.Pow(10, 6) + 5];

            for(var i=0;i< h.Count; i++)
            {
                spaces[h[i]] = true;
            }

            var min = int.MaxValue;

            var current = 1;
            if (spaces[current])
            {
                Console.WriteLine(1);
                return;
            }
            for(var i = 0; i < k; i++)
            {
                var data = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                var u = data[0];
                var v = data[1];

                if (u == current)
                {
                    current = v;
                } else if(v == current)
                {
                    current = u;
                }
                if (spaces[current])
                {
                    Console.WriteLine(current);
                    return;
                }
            }

            Console.WriteLine(current);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {

    }

    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication1
{
    class Program
    {
        static int t = 0;
        static int[] dyr;
        static int[] mark;
        static bool ans = false;
        static int t1 = 0;
        static Dictionary<int, List<int>> d = new Dictionary<int, List<int>>();
        static void dfs(int v)
        {
            if (dyr.Contains(v))
            {
                ans = true;

                t = v;
            }
            if (!ans)
            {
                t1 = v;
                mark[v] = 1;
                for (int i = 0; i < d[v].Count; i++)
                {
                    if (mark[d[v][i]] == 0)
                    {
                        dfs(d[v][i]);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int k = int.Parse(ss[2]);
            string[] s = Console.ReadLine().Split();
            dyr = new int[m + 1];
            for (int i = 0; i < m; i++)
            {
                dyr[i + 1] = int.Parse(s[i]);
            }
            t = 1;
            for (int i = 0; i < k; i++)
            {
                string[] q = Console.ReadLine().Split();

                int x = int.Parse(q[0]);
                int y = int.Parse(q[1]);
                if (x == t)
                {

                    t = y;
                    if (dyr.Contains(t))
                    {
                        Console.WriteLine(t);
                        return;
                    }
                }
                else if (y == t)
                {

                    t = x;
                    if (dyr.Contains(t))
                    {
                        Console.WriteLine(t);
                        return;
                    }
                }
            }
            Console.WriteLine(t);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {

    }

    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int k = int.Parse(ss[2]);
            string[] s = Console.ReadLine().Split();
            Dictionary<int, int> dyr = new Dictionary<int, int>();
            for (int i = 0; i < m; i++)
            {
                dyr.Add(int.Parse(s[i]), 0);
            }
            int t = 1;
            for (int i = 0; i < k; i++)
            {
                string[] q = Console.ReadLine().Split();

                int x = int.Parse(q[0]);
                int y = int.Parse(q[1]);
                if (x == t)
                {

                    t = y;
                    if (dyr.ContainsKey(t))
                    {
                        Console.WriteLine(t);
                        return;
                    }
                }
                else if (y == t)
                {

                    t = x;
                    if (dyr.ContainsKey(t))
                    {
                        Console.WriteLine(t);
                        return;
                    }
                }
            }
            Console.WriteLine(t);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {

    }

    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication1
{
    class Program
    {
        static int t = 0;
        static int[] dyr;
        static int[] mark;
        static bool ans = false;
        static int t1 = 0;
        static Dictionary<int, List<int>> d = new Dictionary<int, List<int>>();
        static void dfs(int v)
        {
            if (dyr.Contains(v))
            {
                ans = true;

                t = v;
            }
            if (!ans)
            {
                t1 = v;
                mark[v] = 1;
                for (int i = 0; i < d[v].Count; i++)
                {
                    if (mark[d[v][i]] == 0)
                    {
                        dfs(d[v][i]);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int k = int.Parse(ss[2]);
            string[] s = Console.ReadLine().Split();
            dyr = new int[m + 1];
            for (int i = 0; i < m; i++)
            {
                dyr[i + 1] = int.Parse(s[i]);
            }
            t = 1;
            for (int i = 0; i < k; i++)
            {
                string[] q = Console.ReadLine().Split();
                int x = int.Parse(q[0]);
                int y = int.Parse(q[1]);
                t = y;
                if (dyr.Contains(t))
                {
                    Console.WriteLine(t);
                    return;
                }
            }
            Console.WriteLine(t);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {

    }

    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int k = int.Parse(ss[2]);
            string[] s = Console.ReadLine().Split();
            Dictionary<int, int> dyr = new Dictionary<int, int>();
            for (int i = 0; i < m; i++)
            {
                dyr.Add(int.Parse(s[i]), 0);
            }
            int t = 1;
            if (dyr.ContainsKey(1))
            {
                for (int i = 0; i < k; i++)
                {
                    string q = Console.ReadLine();
                }
                Console.WriteLine(1);
            }
            else
            {
                bool f = false;
                for (int i = 0; i < k; i++)
                {
                    string[] q = Console.ReadLine().Split();

                    int x = int.Parse(q[0]);
                    int y = int.Parse(q[1]);
                    if (!f)
                    {
                        if (dyr.ContainsKey(t))
                        {
                            f = true;
                        }
                        if (x == t)
                        {

                            t = y;
                            if (dyr.ContainsKey(t))
                            {
                                f = true;
                            }
                        }
                        else if (y == t)
                        {

                            t = x;
                            if (dyr.ContainsKey(t))
                            {
                                f = true;
                            }
                        }
                    }

                }
                Console.WriteLine(t);

            }
        }
    }
}


// Problem: 796B - Find The Bones
// Author: Gusztav Szmolik

using System;

namespace Find_The_Bones
	{
	class Program
		{
		static int Main ()
			{
			string[] tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != 3)
				return -1;
			uint n;
			if (!UInt32.TryParse(tmpLine[0], out n))
				return -1;
			uint m;
			if (!UInt32.TryParse(tmpLine[1], out m))
				return -1;
			uint k;
			if (!UInt32.TryParse(tmpLine[2], out k))
				return -1;
			if (n < 2 || n > 1000000 || m < 1 || m > n || k < 1 || k > 300000)
				return -1;
			uint[] h = new uint[m];
			tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != m)
				return -1;
			uint tmpHole;
			for (uint i = 0; i < m; i++)
				{
				if (!UInt32.TryParse(tmpLine[i], out tmpHole))
					return -1;
                h[i] = tmpHole;
				}
            Array.Sort (h);
            for (uint i = 1; i < h.Length; i++)
                if (h[i] == h[i-1])
                    return -1;
			uint u;
			uint v;
            bool toGround = (h[0] == 1 ? true : false);
			uint posBone = 1;
			for (uint i = 0; i < k; i++)
				{
				tmpLine = Console.ReadLine().Split();
				if (tmpLine.Length != 2)
					return -1;
				if (!UInt32.TryParse(tmpLine[0], out u))
					return -1;
				if (!UInt32.TryParse(tmpLine[1], out v))
					return -1;
				if (u < 1 || u > n || v < 1 || v > n || u == v)
					return -1;
				if (!toGround)
					{
					if (posBone == u)
						posBone = v;
					else if (posBone == v)
						posBone = u;
					if (Array.BinarySearch(h,posBone) >= 0)
						toGround = true;
					}
				}
			Console.WriteLine (posBone);
			return 0;
			}
		}
	}


// Problem: 796B - Find The Bones
// Author: Gusztav Szmolik

using System;

namespace Find_The_Bones
	{
	class Program
		{
		static int Main ()
			{
			string[] tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != 3)
				return -1;
			uint n;
			if (!UInt32.TryParse(tmpLine[0], out n))
				return -1;
			uint m;
			if (!UInt32.TryParse(tmpLine[1], out m))
				return -1;
			uint k;
			if (!UInt32.TryParse(tmpLine[2], out k))
				return -1;
			if (n < 2 || n > 1000000 || m < 1 || m > n || k < 1 || k > 300000)
				return -1;
			uint[] h = new uint[m];
			tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != m)
				return -1;
			uint tmpHole;
			for (uint i = 0; i < m; i++)
				{
				if (!UInt32.TryParse(tmpLine[i], out tmpHole))
					return -1;
				if (Array.IndexOf(h,tmpHole) != -1)
					return -1;
				h[i] = tmpHole;
				}
			uint u;
			uint v;
			bool toGround = (Array.IndexOf(h,1) == -1 ? false : true);
			uint posBone = 1;
			for (uint i = 0; i < k; i++)
				{
				tmpLine = Console.ReadLine().Split();
				if (tmpLine.Length != 2)
					return -1;
				if (!UInt32.TryParse(tmpLine[0], out u))
					return -1;
				if (!UInt32.TryParse(tmpLine[1], out v))
					return -1;
				if (u < 1 || u > n || v < 1 || v > n || u == v)
					return -1;
				if (!toGround)
					{
					if (posBone == u)
						posBone = v;
					else if (posBone == v)
						posBone = u;
					if (Array.IndexOf(h,posBone) != -1)
						toGround = true;
					}
				}
			Console.WriteLine (posBone);
			return 0;
			}
		}
	}


// Problem: 796B - Find The Bones
// Author: Gusztav Szmolik

using System;

namespace Find_The_Bones
	{
	class Program
		{
		static int Main ()
			{
			string[] tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != 3)
				return -1;
			uint n;
			if (!UInt32.TryParse(tmpLine[0], out n))
				return -1;
			uint m;
			if (!UInt32.TryParse(tmpLine[1], out m))
				return -1;
			uint k;
			if (!UInt32.TryParse(tmpLine[2], out k))
				return -1;
			if (n < 2 || n > 1000000 || m < 1 || m > n || k < 1 || k > 300000)
				return -1;
			uint[] h = new uint[m];
			tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != m)
				return -1;
			uint tmpHole;
			for (uint i = 0; i < m; i++)
				{
				if (!UInt32.TryParse(tmpLine[i], out tmpHole))
					return -1;
                h[i] = tmpHole;
				}
            Array.Sort (h);
            for (uint i = 1; i < h.Length; i++)
                if (h[i] == h[i-1])
                    return -1;
			uint u;
			uint v;
			bool toGround = (Array.IndexOf(h,1) == -1 ? false : true);
			uint posBone = 1;
			for (uint i = 0; i < k; i++)
				{
				tmpLine = Console.ReadLine().Split();
				if (tmpLine.Length != 2)
					return -1;
				if (!UInt32.TryParse(tmpLine[0], out u))
					return -1;
				if (!UInt32.TryParse(tmpLine[1], out v))
					return -1;
				if (u < 1 || u > n || v < 1 || v > n || u == v)
					return -1;
				if (!toGround)
					{
					if (posBone == u)
						posBone = v;
					else if (posBone == v)
						posBone = u;
					if (Array.BinarySearch(h,posBone) >= 0)
						toGround = true;
					}
				}
			Console.WriteLine (posBone);
			return 0;
			}
		}
	}


// Problem: 796B - Find The Bones
// Author: Gusztav Szmolik

using System;

namespace Find_The_Bones
	{
	class Program
		{
		static int Main ()
			{
			string[] tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != 3)
				return -1;
			uint n;
			if (!UInt32.TryParse(tmpLine[0], out n))
				return -1;
			uint m;
			if (!UInt32.TryParse(tmpLine[1], out m))
				return -1;
			uint k;
			if (!UInt32.TryParse(tmpLine[2], out k))
				return -1;
			if (n < 2 || n > 1000000 || m < 1 || m > n || k < 1 || k > 300000)
				return -1;
			uint[] h = new uint[m];
			tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != m)
				return -1;
			uint tmpHole;
			for (uint i = 0; i < m; i++)
				{
				if (!UInt32.TryParse(tmpLine[i], out tmpHole))
					return -1;
                h[i] = tmpHole;
				}
            Array.Sort (h);
            for (uint i = 1; i < h.Length; i++)
                if (h[i] == h[i-1])
                    return -1;
			uint u;
			uint v;
			bool toGround = (Array.IndexOf(h,1) == -1 ? false : true);
			uint posBone = 1;
			for (uint i = 0; i < k; i++)
				{
				tmpLine = Console.ReadLine().Split();
				if (tmpLine.Length != 2)
					return -1;
				if (!UInt32.TryParse(tmpLine[0], out u))
					return -1;
				if (!UInt32.TryParse(tmpLine[1], out v))
					return -1;
				if (u < 1 || u > n || v < 1 || v > n || u == v)
					return -1;
				if (!toGround)
					{
					if (posBone == u)
						posBone = v;
					else if (posBone == v)
						posBone = u;
					if (Array.IndexOf(h,posBone) != -1)
						toGround = true;
					}
				}
			Console.WriteLine (posBone);
			return 0;
			}
		}
	}


// Problem: 796B - Find The Bones
// Author: Gusztav Szmolik

using System;
using System.Collections;

namespace Find_The_Bones
	{
	class Program
		{
		static int Main ()
			{
			string[] tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != 3)
				return -1;
			uint n;
			if (!UInt32.TryParse(tmpLine[0], out n))
				return -1;
			uint m;
			if (!UInt32.TryParse(tmpLine[1], out m))
				return -1;
			uint k;
			if (!UInt32.TryParse(tmpLine[2], out k))
				return -1;
			if (n < 2 || n > 1000000 || m < 1 || m > n || k < 1 || k > 300000)
				return -1;
			ArrayList h = new ArrayList ();
			tmpLine = Console.ReadLine().Split();
			if (tmpLine.Length != m)
				return -1;
			uint tmpHole;
			for (uint i = 0; i < m; i++)
				{
				if (!UInt32.TryParse(tmpLine[i], out tmpHole))
					return -1;
				if (h.Contains(tmpHole))
					return -1;
				h.Add (tmpHole);
				}
			uint u;
			uint v;
			bool toGround = (h.Contains(1) ? true : false);
			uint posBone = 1;
			for (uint i = 0; i < k; i++)
				{
				tmpLine = Console.ReadLine().Split();
				if (tmpLine.Length != 2)
					return -1;
				if (!UInt32.TryParse(tmpLine[0], out u))
					return -1;
				if (!UInt32.TryParse(tmpLine[1], out v))
					return -1;
				if (u < 1 || u > n || v < 1 || v > n || u == v)
					return -1;
				if (!toGround)
					{
					if (posBone == u)
						posBone = v;
					else if (posBone == v)
						posBone = u;
					if (h.Contains(posBone))
						toGround = true;
					}
				}
			Console.WriteLine (posBone);
			return 0;
			}
		}
	}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cf1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var m = inputs[1];
            var k = inputs[2];
            var h = new HashSet<int>(Console.ReadLine().Split().Select(int.Parse));

            var current = 1;
            for (int i = 0; i < k; i++)
            {
                inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var u = inputs[0];
                var v = inputs[1];
                if (!h.Contains(u) && current == u)
                {
                    current = v;
                }

            }
            Console.WriteLine(current);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cf1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var m = inputs[1];
            var k = inputs[2];
            var h = new HashSet<int>(Console.ReadLine().Split().Select(int.Parse));

            var current = 1;
            for (int i = 0; i < k; i++)
            {
                inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var u = inputs[0];
                var v = inputs[1];
                if (!h.Contains(u) && current == u)
                {
                    current = v;
                }
                else if (!h.Contains(v) && current == u)
                {
                    current = u;

                }

            }
            Console.WriteLine(current);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cf1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];
            var m = inputs[1];
            var k = inputs[2];
            var h = new HashSet<int>(Console.ReadLine().Split().Select(int.Parse));

            var current = 1;
            for (int i = 0; i < k; i++)
            {
                inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var u = inputs[0];
                var v = inputs[1];
                if (!h.Contains(u) && current == u)
                {
                    current = v;
                }
                else if (!h.Contains(v) && current == v)
                {
                    current = u;
                }

            }
            Console.WriteLine(current);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            int[] nums = new int[n];
            for (int i = 0; i < n; i++)
            {
                nums[i] = i + 1;
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums[marr[i] - 1] = 0;
            }
            int current = 1;
            if (marr.Contains(1))
            {
                Console.WriteLine(1);
            }
            else

                for (int i = 0; i < k; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[1];
                        if (nums[current-1]==0)
                        {

                            break;
                        }
                    }
                    else if (s[1]==current)
                    {
                        current = s[0];
                        if (nums[current-1]==0)
                        {

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            List<int> nums = new List<int>();
            for (int i = 0; i < n; i++)
            {
                nums.Add(i+1);
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums.Remove(marr[i]);
            }
            int current = 1;

                for (int i = 0; i < k; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[1];
                        if (!nums.Contains(current))
                        {

                            break;
                        }
                    }
                    else if (s[1]==current)
                    {
                        current = s[0];
                        if (!nums.Contains(current))
                        {

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            int[] nums = new int[n];
            for (int i = 0; i < n; i++)
            {
                nums[i] = i + 1;
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums[marr[i] - 1] = 0;
            }
            int current = 1;

                for (int i = 0; i < k; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[1];
                        if (nums[current-1]==0)
                        {

                            break;
                        }
                    }
                    else if (s[1]==current)
                    {
                        current = s[0];
                        if (nums[current-1]==0)
                        {

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            List<int> nums = new List<int>();
            for (int i = 0; i < n; i++)
            {
                nums.Add(i+1);
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums.Remove(marr[i]);
            }
            int current = 1;

            for (int i = 0; i < k; i++)
            {
                int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (s[0]==current)
                {
                    current = s[1];
                    if (!nums.Contains(current))
                    {

                        break;
                    }
                }
            }
            Console.WriteLine(current);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            List<int> nums = new List<int>();
            for (int i = 0; i < n; i++)
            {
                nums.Add(i+1);
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums.Remove(marr[i]);
            }
            int current = 1;
            int[] r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            current = r[0];

            if (!nums.Contains(r[1]))
            {
                for (int i = 0; i < k-1; i++)
                {
                    string[] s = Console.ReadLine().Split();
                }
                Console.WriteLine(r[1]);
            }
            else
            {
                for (int i = 0; i < k-1; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[0];
                        if (!nums.Contains(s[1]))
                        {
                            current = s[1];

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            int[] nums = new int[n];
            for (int i = 0; i < n; i++)
            {
                nums[i] = i + 1;
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums[marr[i] - 1] = 0;
            }
            int current = 1;
            if (marr.Contains(1))
            {
                Console.WriteLine(1);
            }
            else

            {

                for (int i = 0; i < k; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[1];
                        if (nums[current - 1] == 0)
                        {

                            break;
                        }
                    }
                    else if (s[1] == current)
                    {
                        current = s[0];
                        if (nums[current - 1] == 0)
                        {

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inp0 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = inp0[0];
            int m = inp0[1];
            int k = inp0[2];
            List<int> nums = new List<int>();
            for (int i = 0; i < n; i++)
            {
                nums.Add(i+1);
            }
            int[] marr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < m; i++)
            {
                nums.Remove(marr[i]);
            }
            int current = 1;

                for (int i = 0; i < k-1; i++)
                {
                    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (s[0] == current)
                    {
                        current = s[1];
                        if (!nums.Contains(current))
                        {

                            break;
                        }
                    }
                    else if (s[1]==current)
                    {
                        current = s[0];
                        if (!nums.Contains(current))
                        {

                            break;
                        }
                    }
                }
                Console.WriteLine(current);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApplication4
{
    class Program
    {
        static int[] readArray()
        {
            string[] s = Console.ReadLine().Split(' ');
            int len = s.Length;
            int[] data = new int[len];
            for (int i = 0; i < len; i++)
            {
                data[i] = int.Parse(s[i]);
            }
            return data;
        }

        static int readInt()
        {
            string s = Console.ReadLine();
            return int.Parse(s);
        }
        static void Main(string[] args)
        {
            int[] nmk = readArray();
            int n = nmk[0];
            int m = nmk[1];
            int k = nmk[2];
            int[] holl = readArray();
            Dictionary<int, int> dic = new Dictionary<int, int>();
            int curPosition = 1;
            bool inHoll = false;
            for (int i=0;i<m;i++)
            {
                dic[holl[i]] = 0;
                dic[holl[i]]+=1;

                if (holl[i] == 1)
                {
                    inHoll = true;
                }
            }

            for(int i=0;i<k;i++)
            {
                nmk = readArray();
                int x = nmk[0];
                int y = nmk[1];

                if(inHoll == true)
                {
                    continue;
                }
                if(curPosition == x)
                {
                    curPosition = y;
                }else if(curPosition == y)
                {
                    curPosition = x;
                }else
                {
                    continue;
                }

                if (dic.ContainsKey(curPosition))
                {
                    inHoll = true;
                }
            }
            Console.WriteLine(curPosition);
        }
    }
}