#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 20;
const int INF = 1e9 + 7;
int n, m, k, num;
int a[N], fa[N], di[N], dep[N];
long long ans;
stack<pair<int, int> > st;
struct Node {
  int u, v;
} e[N];
inline int read() {
  int p;
  scanf("%d", &p);
  return p;
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline bool cmp(Node x, Node y) {
  return a[x.u] == a[y.u] ? a[x.v] < a[y.v] : a[x.u] < a[y.u];
}
inline int findfa(int x) { return x == fa[x] ? x : findfa(fa[x]); }
inline bool merge(int x, int y, int p) {
  int fx = findfa(x), fy = findfa(y);
  if (fx ^ fy) {
    if (dep[fx] > dep[fy]) swap(fx, fy);
    if (p) st.push({fx, dep[fx] == dep[fy]});
    fa[fx] = fy, dep[fy] += dep[fx] == dep[fy];
  }
  return fy == findfa(x + n);
}
int main() {
  n = read(), m = read(), k = read();
  for (register int i = 1, _r = n; i <= _r; ++i) a[i] = read();
  for (register int i = 1, _r = 2 * n; i <= _r; ++i) fa[i] = i;
  for (register int i = 1, _r = m; i <= _r; ++i) {
    int u = read(), v = read();
    if (a[u] ^ a[v]) {
      if (a[u] > a[v]) swap(u, v);
      e[++num] = {u, v};
    } else if (!di[a[u]])
      di[a[u]] |= merge(u, v + n, 0) | merge(v, u + n, 0);
  }
  for (register int i = 1, _r = k; i <= _r; ++i) ans += !di[i];
  ans = 1LL * ans * (ans - 1) / 2;
  sort(e + 1, e + num + 1, cmp);
  int i = 1, j = 1;
  while (i <= num) {
    if (!di[a[e[i].u]] && !di[a[e[i].v]]) {
      while (j <= num && a[e[j].u] == a[e[i].u] && a[e[j].v] == a[e[i].v]) {
        if (merge(e[j].u, e[j].v + n, 1) || merge(e[j].v, e[j].u + n, 1)) {
          ans--;
          break;
        }
        j++;
      }
      while (!st.empty()) {
        pair<int, int> p = st.top();
        st.pop();
        dep[fa[p.first]] -= p.second, fa[p.first] = p.first;
      }
    }
    while (j <= num && a[e[j].u] == a[e[i].u] && a[e[j].v] == a[e[i].v]) j++;
    i = j;
  }
  cout << ans << endl;
  return 0;
}
