#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const long long MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000050;
int fa[MAXN], rk[MAXN], a[MAXN], b[MAXN], team[MAXN], fail[MAXN];
struct lst {
  int fax, fay;
  int rkx, rky;
  lst(int xx, int yy, int rkxx, int rkyy) {
    fax = xx;
    fay = yy;
    rkx = rkxx;
    rky = rkyy;
  }
};
stack<lst> st;
int find(int x) {
  if (fa[x] == x)
    return x;
  else
    return find(fa[x]);
}
void merge(int x, int y) {
  int xx = find(x), yy = find(y);
  if (rk[xx] < rk[yy]) swap(xx, yy);
  st.push(lst(xx, yy, rk[xx], rk[yy]));
  if (rk[xx] == rk[yy]) rk[xx]++;
  fa[yy] = xx;
}
void init(int n) {
  for (int i = 1; i <= 2 * n; i++) {
    fa[i] = i;
    rk[i] = 1;
  }
}
void revocation(int n) {
  while (n--) {
    lst i = st.top();
    st.pop();
    fa[i.fax] = i.fax;
    fa[i.fay] = i.fay;
    rk[i.fax] = i.rkx;
    rk[i.fay] = i.rky;
  }
}
map<pair<int, int>, vector<int> > mp;
void solve(int T) {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  init(n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", team + i);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", a + i, b + i);
  }
  for (int i = 1; i <= m; i++) {
    if (team[a[i]] != team[b[i]]) continue;
    int xx = find(a[i]), yy = find(b[i]);
    if (xx == yy)
      fail[team[a[i]]] = 1;
    else {
      merge(a[i], b[i] + n);
      merge(b[i], a[i] + n);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (team[a[i]] == team[b[i]]) continue;
    if (fail[team[a[i]]] || fail[team[b[i]]]) continue;
    if (team[a[i]] > team[b[i]]) swap(a[i], b[i]);
    mp[make_pair(team[a[i]], team[b[i]])].push_back(i);
  }
  long long cnt = 0;
  long long ans = 0;
  for (auto node : mp) {
    cnt = 0;
    int t1 = node.first.first;
    int t2 = node.first.second;
    for (auto i : node.second) {
      int xx = find(a[i]), yy = find(b[i]);
      if (xx == yy) {
        ans--;
        break;
      } else {
        cnt += 2;
        merge(a[i], b[i] + n);
        merge(b[i], a[i] + n);
      }
    }
    revocation(cnt);
  }
  cnt = 0;
  for (int i = 1; i <= k; i++) {
    cnt += (fail[i] == 0);
  }
  ans += (cnt - 1) * cnt / 2;
  printf("%lld\n", ans);
}
signed main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
}
