# include <algorithm>
# include <cstdio>
# include <cstring>
# include <vector>

using namespace std;
using LL = long long;

const int kMaxN = 2e5 + 21;

LL res = 0;
int n, m, k, flag;
vector<int> v[kMaxN];
int column[kMaxN], row[kMaxN], tr[kMaxN];

int LowBit(int x) { return x & -x; }

void Add(int x, int v) {
  for (int i = x; i <= n; i += LowBit(i)) tr[i] += v;
}

int Query(int x) {
  int res = 0;
  for (int i = x; i; i -= LowBit(i)) {
    res += tr[i];
  }
  return res;
}

int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    row[i] = m + 1;
  }
  for (int i = 1; i <= m; i++) {
    column[i] = n + 1;
  }
  for (int i = 1, a, b; i <= k; i++) {
    scanf("%d %d", &a, &b);
    column[b] = min(column[b], a);
    row[a] = min(row[a], b);
  }
  for (int i = 1; i <= n; i++) {
    if (flag == 1) {
      row[i] = 1;
      continue;
    }
    if (row[i] == 1) {
      flag = 1;
      continue;
    }
    res += row[i] - 1;
  }
  for (int i = 1; i <= n; i++) {
    v[row[i]].push_back(i);
  }
  for (int i = 1; i <= m && column[i] != 1; i++) {
    res += Query(column[i] - 1);
    for (auto j : v[i]) {
      Add(j, 1);
    }
  }
  printf("%lld\n", res);
  return 0;
}

#include <cmath>
#include <cstdio>
#include <set>
#include <vector>

using namespace std;

int N, M;
vector<long> a;
vector<vector<int>> graph;
vector<bool> pass;
vector<int> record;
vector<bool> computedMax;
long min_ele = -999999999;
long res = min_ele;

long dfs(int x);
void init();
int main() {
#ifdef LOCAL
    freopen("../data.in", "r", stdin);
    // freopen("../data.out", "w", stdout);
#endif
    init();

    for (int i = 0; i < M; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        graph[x].push_back(y);
    }

    // for (int i = 1; i <= N; i++) {
    //     printf("-------------- %d\n", i);
    //     for (int j = 0; j < graph[i].size(); j++) {
    //         printf("%d ", graph[i][j]);
    //     }
    //     printf("\n");
    // }

    for (int i = 1; i <= N; i++) {
        dfs(i);
    }
    printf("%ld\n", res);

    return 0;
}

long dfs(int x) {
    pass[x] = true;
    if (graph[x].size() == 0) return record[x];
    long max_record = min_ele;
    for (int y : graph[x]) {
        if (!pass[y]) {
            long t = dfs(y);
            if (t-a[x] > res) res = t-a[x];
            if (t > max_record) max_record = t;
        } else {
            if (record[y] > max_record) {
                max_record = record[y];
            }
            if (record[y] - a[x] > res) res = record[y] - a[x];
        }
    }
    if (record[x] > max_record) {
        max_record = record[x];
    }
    record[x] = max_record;
    return max_record;
}

void init() {
    scanf("%d %d", &N, &M);
    a.resize(N + 1);
    pass.resize(N + 1, false);
    computedMax.resize(N+1, false);
    graph.resize(N + 1);
    record.resize(N + 1);

    for (int i = 1; i <= N; i++) {
        scanf("%ld", &a[i]);
        record[i] = a[i];
    }
}