#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 1010;

struct Interval {
    int x, y;
};

int n, l [N];
queue <int> q;
int z [N];
Interval I [N];
vector <int> graph [N];

bool used [N];


int binarySearch (const int &value) {
    int i, step;

    for (i = 0, step = (1 << 11); step; step >>= 1)
        if (i + step <= n && z [i + step] < value)
            i = i + step;
    return i;
}

int binarySearch2 (const int &value) {
    int i, step;

    for (i = 0, step = (1 << 11); step; step >>= 1)
        if (i + step <= n && z [i + step] <= value)
            i = i + step;
    return i;
}


int main () {
    int d, m, x, y, u = 0, kx, ky, i, j, ans = (1ll << 31) - 1;
    vector <int> :: iterator it;

   //freopen ("date.in", "r", stdin);

    scanf ("%d%d%d", &d, &n, &m);
    for (i = 1; i <= n; i ++)
        scanf ("%d", &z [i]);

    sort (z + 1, z + 1 + n);

    u = 0;
    for (i = 1; i <= m; i ++) {
        scanf ("%d%d", &x, &y);
        if (x > y)
            swap (x, y);
        kx = binarySearch (x);
        kx ++;
        ky = binarySearch2 (y);
        if (kx <= ky && kx <= n && ky <= n && kx >= 1 && ky >= 1) {
            I [++ u].x = kx;
            I [u].y = ky;
        }
    }

    for (i = 1; i <= u; i ++) {
        for (j = 1; j <= u; j ++) {
            if (i != j && I [i].y + 1 == I [j].x)
                graph [i].push_back (j);
        }
        if (I [i].x == 1) {
            q.push (i);
            l [i] = 1;
            used [i] = 1;
            if (I [i].y == n) {
                printf ("1\n");
                return 0;
            }
        }
    }

    while (!q.empty ()) {
        kx = q.front ();
        used [kx] = 0;
        q.pop ();
        for (it = graph [kx].begin (); it != graph [kx].end (); ++ it)
            if (!used [*it]) {
                q.push (*it);
                used [*it] = 1;
                l [*it] = l [kx] + 1;
            }
            else
                if (l [kx] + 1 < l [*it]) {
                    l [*it] = l [kx] + 1;
                    while (1)
                        l [kx] = l [kx];
                }
    }
    for (i = 1; i <= u; i ++)
        if (I [i].y == n)
            ans = min (ans, l [i]);
    printf ("%d\n", ans);
    return 0;
}