#include <bits/stdc++.h>
using vi = std::vector<int>;
using pii = std::pair<int, int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
template <int NMAX>
struct DSU {
  int size{0};
  std::array<int, NMAX> p, h;
  int biPart{true};
  std::vector<std::pair<int *, int>> history;
  DSU(int n) : size(n + 1) {
    for (int i = 1; i <= n; i++) {
      p[i] = i;
      h[i] = 1;
    }
  }
  int getState() const { return (int)(history).size(); }
  void revert(int state) {
    while ((int)(history).size() > state) {
      auto [ptr, val] = history.back();
      history.pop_back();
      *ptr = val;
    }
  }
  void set(int &var, int val) {
    history.emplace_back(&var, var);
    var = val;
  }
  pii getParDist(int u) const {
    int d{0};
    while (p[u] != u) d++, u = p[u];
    return pii{u, d};
  }
  void connect(int u, int v) {
    auto [pu, du] = getParDist(u);
    auto [pv, dv] = getParDist(v);
    if (pu == pv) {
      set(biPart, biPart && (du + dv + 1) % 2 == 0);
      return;
    }
    if (h[pu] < h[pv]) {
      std::swap(u, v);
      std::swap(pu, pv);
      std::swap(du, dv);
    }
    if ((du ^ dv) & 1) {
      int newPv = getNewVert();
      set(p[pv], newPv);
      set(h[newPv], h[pv] + 1);
      pv = newPv;
    }
    set(h[pu], std::max(h[pu], h[pv] + 1));
    set(p[pv], pu);
  }
  int getNewVert() {
    assert(size < NMAX);
    int newVert = size;
    set(p[newVert], newVert);
    set(h[newVert], 1);
    set(size, size + 1);
    return newVert;
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, k;
  std::cin >> n >> m >> k;
  DSU<500500 * 2> dsu(n);
  vi color(1 + n);
  for (int i = 1; i <= n; i++) std::cin >> color[i];
  auto make_key = [&](int &u, int &v) {
    int iu = color[u], iv = color[v];
    if (iu > iv) std::swap(u, v), std::swap(iu, iv);
    return pii{iu, iv};
  };
  std::map<pii, vpii> map;
  vpii edges(m);
  for (auto &[u, v] : edges) {
    std::cin >> u >> v;
    auto key = make_key(u, v);
    map[key].emplace_back(u, v);
  }
  int nValid{k};
  vi isBiPart(1 + k, 1);
  for (auto &[key, val] : map) {
    if (key.first == key.second) {
      const int state = dsu.getState();
      assert(dsu.biPart);
      for (auto &[u, v] : val) dsu.connect(u, v);
      if (!dsu.biPart) isBiPart[key.first] = 0, nValid--, dsu.revert(state);
    }
  }
  int64_t answ = nValid * (nValid - 1LL) / 2;
  for (auto &[key, val] : map) {
    if (key.first != key.second && isBiPart[key.first] &&
        isBiPart[key.second]) {
      const int state = dsu.getState();
      assert(dsu.biPart);
      for (auto &[u, v] : val) dsu.connect(u, v);
      answ -= !dsu.biPart;
      dsu.revert(state);
    }
  }
  std::cout << answ << std::endl;
}
