#include <bits/stdc++.h>
using namespace std;
int scan_int() {
  int x;
  if (!scanf("%d", &x)) throw 1;
  return x;
}
vector<vector<int>> G;
vector<int> color;
bool paint(int p, int q) {
  bool ok = true;
  color[p] = q;
  for (auto x : G[p]) {
    if (color[x] == -1) {
      if (!paint(x, q ^ 1)) ok = false;
    } else if (color[x] == q) {
      ok = false;
    }
  }
  return ok;
}
struct Hoge {
  map<int, map<int, int>> gg;
  map<int, int> col;
  Hoge(const map<pair<int, int>, bool>& g) {
    for (auto p : g) {
      int u = p.first.first;
      int v = p.first.second;
      gg[u][v] = p.second;
      gg[v][u] = p.second;
    }
  }
  bool f(int p, int q) {
    auto it = col.find(p);
    if (it != col.end()) {
      if (it->second != q) return false;
      return true;
    }
    col.insert({p, q});
    for (auto x : gg[p]) {
      int qq = q;
      if (x.second) qq ^= 1;
      if (!f(x.first, qq)) return false;
    }
    return true;
  }
  bool run() {
    for (const auto& x : gg) {
      if (!col.count(x.first)) {
        if (!f(x.first, 0)) return false;
      }
    }
    return true;
  }
};
int main() {
  int N = scan_int();
  int M = scan_int();
  int K = scan_int();
  vector<int> C(N);
  for (auto& x : C) x = scan_int() - 1;
  G.resize(N);
  vector<pair<int, int>> E;
  for (int i = 0; i < M; ++i) {
    int u = scan_int() - 1;
    int v = scan_int() - 1;
    if (C[u] == C[v]) {
      G[u].push_back(v);
      G[v].push_back(u);
    } else {
      E.push_back({u, v});
    }
  }
  vector<bool> valid(K, true);
  color.resize(N, -1);
  int c = 0;
  for (int i = 0; i < N; ++i)
    if (color[i] == -1) {
      if (!paint(i, c)) valid[C[i]] = false;
      c += 2;
    }
  long long s = 0;
  for (auto x : valid)
    if (x) ++s;
  long long r = s * (s - 1) / 2;
  map<pair<int, int>, map<pair<int, int>, bool>> hoge;
  for (auto e : E) {
    auto c1 = C[e.first];
    auto c2 = C[e.second];
    int color1 = color[e.first];
    int color2 = color[e.second];
    if (c1 > c2) {
      swap(c1, c2);
      swap(color1, color2);
    }
    if (valid[c1] && valid[c2]) {
      auto it = hoge.find({c1, c2});
      bool cc = color1 % 2 == color2 % 2;
      if (it == hoge.end()) {
        hoge.insert({{c1, c2}, {{{color1 / 2, color2 / 2}, cc}}});
      } else if (!it->second.empty()) {
        auto it2 = it->second.find({color1 / 2, color2 / 2});
        if (it2 == it->second.end()) {
          it->second.insert({{color1 / 2, color2 / 2}, cc});
        } else if (it2->second != cc) {
          it->second.clear();
          --r;
        }
      }
    }
  }
  for (const auto& x : hoge)
    if (!x.second.empty()) {
      if (!Hoge(x.second).run()) {
        --r;
      }
    }
  printf("%lld\n", r);
}
