Zane the wizard is going to perform a magic show shuffling the cups.

There are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i.

The problematic bone is initially at the position x = 1. Zane will confuse the audience by swapping the cups k times, the i-th time of which involves the cups at the positions x = ui and x = vi. If the bone happens to be at the position where there is a hole at any time, it will fall into the hole onto the ground and will not be affected by future swapping operations.

Do not forget that Zane is a wizard. When he swaps the cups, he does not move them ordinarily. Instead, he teleports the cups (along with the bone, if it is inside) to the intended positions. Therefore, for example, when he swaps the cup at x = 4 and the one at x = 6, they will not be at the position x = 5 at any moment during the operation.

<image>

Zane’s puppy, Inzane, is in trouble. Zane is away on his vacation, and Inzane cannot find his beloved bone, as it would be too exhausting to try opening all the cups. Inzane knows that the Codeforces community has successfully helped Zane, so he wants to see if it could help him solve his problem too. Help Inzane determine the final position of the bone.

Input

The first line contains three integers n, m, and k (2 ≤ n ≤ 106, 1 ≤ m ≤ n, 1 ≤ k ≤ 3·105) — the number of cups, the number of holes on the table, and the number of swapping operations, respectively.

The second line contains m distinct integers h1, h2, ..., hm (1 ≤ hi ≤ n) — the positions along the x-axis where there is a hole on the table.

Each of the next k lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the positions of the cups to be swapped.

Output

Print one integer — the final position along the x-axis of the bone.

Examples

Input

7 3 4
3 4 6
1 2
2 5
5 7
7 1


Output

1

Input

5 1 2
2
1 2
2 4


Output

2

Note

In the first sample, after the operations, the bone becomes at x = 2, x = 5, x = 7, and x = 1, respectively.

In the second sample, after the first operation, the bone becomes at x = 2, and falls into the hole onto the ground.

import java.io.*;
import java.util.InputMismatchException;
import java.util.Random;
import java.util.Set;

public class CF796 {
    static String filePath = "/home/bishoy/IdeaProjects/Arabic competetive programming/src/b/test";

    static int n, h, ops, bone = 1;
    static Set<Integer> holes;
    static int[] cups;

    public static void main(String args[]) {
        InputReader inputReader = Helper.readInput(Helper.Input.STD, filePath);
        OutputWriter out = new OutputWriter(System.out);
        solve2(inputReader);
        out.printLine(bone);

    }

    static void solve2(InputReader inputReader) {
        readInputs(inputReader);

        if (cups[bone] == 1)
            return;

        while (ops-- > 0) {
            int x = inputReader.readInt();
            int y = inputReader.readInt();
            if (x != bone && y != bone)
                continue;
            if (x == bone) {
                bone = y;
            } else {
                bone = x;
            }

            if (cups[bone] == bone)
                break;
        }
    }

//    static void solve(InputReader inputReader) {
//        readInputs(inputReader);
//        while (ops-- > 0 && !holes.contains(bone)) {
//            int x = inputReader.readInt();
//            int y = inputReader.readInt();
//            if (x != bone && y != bone)
//                continue;
//            if (x == bone) {
//                bone = y;
//            } else {
//                bone = x;
//            }
//
//        }
//    }

    public static void readInputs(InputReader inputReader) {
        n = inputReader.readInt();
        h = inputReader.readInt();
        ops = inputReader.readInt();
        cups = new int[n + 1];
        bone = 1;
        for (int i = 0; i < h; i++) {
            int hole = inputReader.readInt();
            cups[hole] = hole;
        }
    }

    public static long min(long a, long b) {
        if (a > b) {
            return b;
        }
        return a;
    }

    public static int min(int a, int b) {
        if (a > b) {
            return b;
        }
        return a;
    }

    public static long max(long a, long b) {
        if (a > b) {
            return a;
        }
        return b;
    }

    public static int max(int a, int b) {
        if (a > b) {
            return a;
        }
        return b;
    }

    static class pair implements Comparable<pair> {
        int x;
        int y;

        pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(pair b) {
            return this.y - b.y;
        }
    }

    public static int gcd(int a, int b) {
        if (a == 0)
            return b;
        if (b == 0)
            return a;
        while ((a %= b) != 0 && (b %= a) != 0) ;
        return a ^ b;
    }

    public static int mod(int a) {
        if (a > 0)
            return a;
        return -a;
    }

    static int mod = (int) 1e9 + 7;

    public static long expo(long exp, long pow) {
        long ans = 1;
        while (pow != 0) {
            if ((pow & 1) == 1) {
                ans = ans * exp;
            }
            exp = exp * exp;
            pow = pow >> 1;
        }
        return ans;
    }

    static int max = (int) 1e9;

    public static long fact(int num) {
        if (num == 0) {
            return 1;
        }
        return (fact(num - 1) * num) % mod;
    }

    static int[] sieve;

    public static void sieve() {
        sieve = new int[max];
        for (int i = 1; i < max; i++) {
            sieve[i] = i;
        }
        for (int i = 2; i < max; i++) {
            if (sieve[i] == i) {
                for (int j = i * 2; j < max; j += i) {
                    if (sieve[j] == j) {
                        sieve[j] = i;
                    }
                }
            }
        }
    }

    public static int bsearch(long[] a, long val) {
        int l = 0;
        int r = a.length - 1;
        while (l < r) {
            int mid = (l + r + 1) >> 1;
            if (a[mid] <= val) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }
        if (a[l] <= val) {
            return l + 1;
        }
        return 0;
    }

    public static int[] suffle(int[] a, Random gen) {
        int n = a.length;
        for (int i = 0; i < n; i++) {
            int ind = gen.nextInt(n - i) + i;
            int temp = a[ind];
            a[ind] = a[i];
            a[i] = temp;
        }
        return a;
    }


    static class Helper {
        static InputReader inputReader = null;
        static OutputWriter out = null;

        public static enum Input {
            FILE, STD
        }

        public static class Pair<K, V> {
            public K key;
            public V value;

            public Pair(K key, V value) {
                this.key = key;
                this.value = value;
            }


            @Override
            public String toString() {
                return "( " + key + " , " + value + ")";
            }
        }


        public static InputReader readInput(Enum type, String filePath) {
            if (type == Input.FILE) {
                try {
                    inputReader = new InputReader(new FileInputStream(new File(filePath)));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            } else
                inputReader = new InputReader(System.in);


            return inputReader;
        }


        public static boolean validIndices(int r, int c, int n, int m) {
            if (r >= 0 && c >= 0 && r < n && c < m) return true;
            else return false;
        }
    }

    private static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }


        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = readInt();
            }
            return a;
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, readInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E') {
                        return res * Math.pow(10, readInt());
                    }
                    if (c < '0' || c > '9') {
                        throw new InputMismatchException();
                    }
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    private static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
            writer.flush();
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
            writer.flush();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }
}
