#include <bits/stdc++.h>
const int MaxSize = 20;
char buf[1 << MaxSize], *p1, *p2;
template <class T>
inline void in(T &x) {
  x = 0;
  register bool f = 0;
  register char c =
      ((p1 == p2) ? (p2 = buf + fread(p1 = buf, 1, 1 << MaxSize, stdin),
                     p1 == p2 ? EOF : *p1++)
                  : *p1++);
  while (c < 47 || c > 58) {
    f |= (c == '-'),
        c = ((p1 == p2) ? (p2 = buf + fread(p1 = buf, 1, 1 << MaxSize, stdin),
                           p1 == p2 ? EOF : *p1++)
                        : *p1++);
  }
  while (c > 46 && c < 59) {
    x = (x << 3) + (x << 1) + (c & 15),
    c = ((p1 == p2) ? (p2 = buf + fread(p1 = buf, 1, 1 << MaxSize, stdin),
                       p1 == p2 ? EOF : *p1++)
                    : *p1++);
  }
  x = f ? (~x + 1) : x;
}
using namespace std;
const int Maxx = 1000005, Maxn = 2001, INF = 0x3f3f3f3f, Mod = 998244353;
int n, m, K;
struct node {
  int cx, cy, x, y;
  inline node(int a = 0, int b = 0, int c = 0, int d = 0) {
    cx = a, cy = b, x = c, y = d;
  }
  inline bool operator<(const node &tp) const {
    return cx == tp.cx ? cy < tp.cy : cx < tp.cx;
  }
  inline bool operator==(const node &tp) const {
    return cx == tp.cx && cy == tp.cy;
  }
} A[Maxx];
int tot, c[Maxx], fa[Maxx], X[Maxx], Y[Maxx], sz[Maxx];
char tg[Maxx], v[Maxx];
int tp, stk[Maxx];
int gf(int x) {
  int tmp;
  return fa[x] == x ? x
                    : (tmp = fa[x], fa[x] = gf(fa[x]), v[x] ^= v[tmp], fa[x]);
}
inline int GF(int x, int &vx) {
  vx = 0;
  while (x != fa[x]) vx ^= v[x], x = fa[x];
  return x;
}
int main() {
  in(n), in(m), in(K);
  for (register int i = 1; i <= n; ++i) in(c[fa[i] = i]);
  for (register int i = 1, x, y, fx, fy; i <= m; ++i) {
    in(x), in(y);
    if (c[x] == c[y]) {
      fx = gf(x), fy = gf(y);
      if (fx ^ fy)
        fa[fx] = fy, v[fx] = v[x] ^ v[y] ^ 1;
      else if (v[x] ^ v[y] ^ 1)
        tg[c[x]] = 1;
    } else {
      if (c[x] > c[y]) swap(x, y);
      A[++tot] = node(c[x], c[y], x, y);
    }
  }
  sort(A + 1, A + tot + 1);
  for (register int i = 1; i <= n; ++i) ++sz[gf(i)];
  long long Ans = 0;
  for (register int i = 1; i <= K; ++i) Ans += !tg[i];
  Ans = Ans * (Ans - 1) >> 1;
  for (register int i = 1, j = 1; i <= tot; i = j) {
    while (A[i] == A[j]) ++j;
    if (tg[A[i].cx] || tg[A[i].cy]) continue;
    for (int k = i, x, y, fx, fy, vx, vy; k < j; ++k) {
      x = A[k].x, y = A[k].y;
      fx = GF(x, vx), fy = GF(y, vy);
      if (fx != fy) {
        if (sz[fx] > sz[fy]) swap(fx, fy);
        stk[++tp] = fx, sz[fa[fx] = fy] += fx;
        v[fx] = vx ^ vy ^ 1;
      } else if (vx ^ vy ^ 1) {
        --Ans;
        break;
      }
    }
    while (tp) {
      sz[fa[stk[tp]]] -= sz[stk[tp]];
      v[fa[stk[tp]] = stk[tp]] = 0;
      --tp;
    }
  }
  printf("%lld\n", Ans);
  return 0;
}
