#include <bits/stdc++.h>
using namespace std;
const long long sz = 5e5 + 10;
vector<int> g[sz], gsame[sz], lst[sz];
vector<int> gnew[2 * sz], clr, g2[2 * sz];
long long col[sz], group[sz], compid[sz];
long long checker, col2[2 * sz], invalid[sz];
void dfs_same(long long u, long long c, long long cid) {
  col[u] = c, compid[u] = cid;
  for (int &v : gsame[u]) {
    if (col[v] != -1) {
      if (col[v] == c) checker = -1;
      continue;
    }
    dfs_same(v, c ^ 1, cid);
  }
}
void dfs(long long u, long long c) {
  col2[u] = c, clr.push_back(u);
  for (int &v : gnew[u]) {
    if (col2[v] != -1) {
      if (col2[v] == c) checker = -1;
      continue;
    }
    dfs(v, c ^ 1);
  }
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; ++i) {
    long long gp;
    scanf("%lld", &gp);
    group[i] = gp;
    lst[gp].push_back(i);
  }
  for (long long i = 1; i <= m; ++i) {
    long long u, v;
    scanf("%lld", &u), scanf("%lld", &v);
    if (group[u] == group[v]) {
      gsame[u].push_back(v);
      gsame[v].push_back(u);
    }
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long cid = 0, ans = 0, invTot = 0;
  memset(col, -1, sizeof(col)), memset(col2, -1, sizeof(col2));
  for (long long i = 1; i <= k; ++i) {
    for (int &u : lst[i]) {
      if (col[u] != -1) continue;
      checker = 0;
      dfs_same(u, 0, ++cid);
      if (checker == -1) {
        invalid[i] = 1, invTot++;
        break;
      }
    }
  }
  for (long long i = 1; i <= k; ++i) {
    if (invalid[i]) continue;
    vector<int> clst;
    vector<pair<int, int> > glst;
    for (int &u : lst[i]) {
      for (int &v : g[u]) {
        long long gp = group[v];
        if (invalid[gp] || gp == group[u]) continue;
        long long cv = 2 * compid[v] + col[v];
        g2[cv].push_back(u);
        glst.push_back(make_pair(gp, cv));
        clst.push_back(cv);
      }
    }
    sort(glst.begin(), glst.end());
    glst.erase(unique(glst.begin(), glst.end()), glst.end());
    long long bad = 0;
    for (long long i = 0; i < glst.size(); i++) {
      long long start = i, stop = i;
      for (long long j = i; j < glst.size(); j++) {
        if (glst[j].first != glst[i].first) break;
        stop = j;
      }
      for (long long j = start; j <= stop; j++) {
        long long u = glst[j].second;
        for (int &v : g2[u]) {
          long long cv = 2 * compid[v] + col[v];
          gnew[u].push_back(cv);
          gnew[cv].push_back(u);
          gnew[cv].push_back(cv ^ 1);
          gnew[cv ^ 1].push_back(cv);
        }
        gnew[u].push_back(u ^ 1);
        gnew[u ^ 1].push_back(u);
      }
      for (long long j = start; j <= stop; j++) {
        long long u = glst[j].second;
        if (col2[u] != -1) continue;
        checker = 0;
        dfs(u, 0);
        if (checker == -1) {
          bad++;
          break;
        }
      }
      for (long long j = start; j <= stop; j++) {
        long long u = glst[j].second;
        for (int &v : g2[u]) {
          long long cv = 2 * compid[v] + col[v];
          gnew[cv].clear(), gnew[cv ^ 1].clear();
        }
        gnew[u].clear(), gnew[u ^ 1].clear();
      }
      for (int &u : clr) col2[u] = -1;
      clr.clear();
      i = stop;
    }
    ans += ((k - invTot) - bad - 1);
    for (int &cid : clst) g2[cid].clear();
  }
  cout << ans / 2 << '\n';
  return 0;
}
