#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, vector<pair<long long, long long> > > all;
set<pair<long long, long long> > Not;
set<long long> Now;
long long cha[500005] = {0};
vector<long long> Next1[500005];
vector<long long> Next2[500005];
long long what[500005];
long long st[500005];
bool have[500005] = {0};
long long color[500005] = {0};
long long Father[1000005] = {0};
long long sz[1000005] = {0};
bool can[500005] = {0};
stack<pair<long long, long long> > Mer;
long long Find(long long here) {
  if (Father[here] == here) return here;
  return Find(Father[here]);
}
void Merge(long long a, long long b) {
  if (a == b) return;
  if (sz[a] < sz[b]) {
    sz[b] += sz[a];
    Father[a] = b;
    Mer.push(make_pair(b, a));
  } else {
    sz[a] += sz[b];
    Father[b] = a;
    Mer.push(make_pair(a, b));
  }
}
void F(long long here, long long st, long long deg) {
  if (have[here] && deg != color[here]) {
    can[what[here]] = 1;
    return;
  }
  if (have[here]) return;
  ::st[here] = st;
  have[here] = 1;
  color[here] = deg;
  for (auto i : Next1[here]) F(i, st, 1 - deg);
}
int main() {
  long long N, M, K, x, y, i, now, ans = 0, a, b;
  scanf("%lld %lld %lld", &N, &M, &K);
  for (i = 1; i <= N; i++) scanf("%lld", &what[i]);
  while (M--) {
    scanf("%lld %lld", &x, &y);
    if (what[x] == what[y]) {
      Next1[x].push_back(y);
      Next1[y].push_back(x);
    } else {
      Next2[x].push_back(y);
      Next2[y].push_back(x);
    }
  }
  for (i = 1; i <= N; i++) {
    sz[i] = 1;
    Father[i] = i;
    sz[i + N] = 1;
    Father[i + N] = i + N;
    if (!have[i]) F(i, i, 0);
  }
  for (i = 1; i <= K; i++)
    if (!can[i]) ans++;
  ans = ans * (ans - 1) / 2;
  for (i = 1; i <= N; i++)
    for (auto j : Next2[i])
      all[make_pair(min(what[i], what[j]), max(what[i], what[j]))].push_back(
          make_pair(i, j));
  for (i = 1; i <= N; i++) {
    if (can[what[i]]) continue;
    for (auto j : Next1[i]) {
      if (Find(i) != Find(j + N)) {
        Merge(Find(i), Find(j + N));
        Merge(Find(i + N), Find(j));
      }
    }
  }
  while (!Mer.empty()) Mer.pop();
  for (auto i : all) {
    if (can[i.first.first] || can[i.first.second]) continue;
    for (auto j : i.second) {
      if (Find(j.first) == Find(j.second)) {
        Not.insert(i.first);
      } else {
        Merge(Find(j.first), Find(j.second + N));
        Merge(Find(j.first + N), Find(j.second));
      }
    }
    while (!Mer.empty()) {
      sz[Mer.top().first] -= sz[Mer.top().second];
      Father[Mer.top().second] = Mer.top().second;
      Mer.pop();
    }
  }
  printf("%lld\n", ans - Not.size());
  return 0;
}
