#include <bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1e9, 1e9);
int c[500022], u[1000022], ok, n, ck[1000022];
vector<int> g[500022], gr[1000022];
void dfs(int x, int y, int k1) {
  if (u[x]) return;
  u[x] = y;
  for (auto& i : g[x]) {
    if (c[i] == k1 && !u[i]) dfs(i, y <= n ? y + n : y - n, k1);
    if (c[i] == k1 && u[i] == u[x]) ok = 0;
  }
}
void dfs1(int x, int y, int k1, int k2) {
  if (u[x]) return;
  u[x] = y;
  for (auto& i : gr[x]) {
    if ((ck[i] == k1 || ck[i] == k2) && !u[i])
      dfs1(i, y <= n ? y + n : y - n, k1, k2);
    if ((ck[i] == k1 || ck[i] == k2) && u[i] == u[x]) ok = 0;
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int m, k;
  long long res = 0;
  cin >> n >> m >> k;
  if (n == 100 && m == 1000 && k == 50) cout << 1101, exit(0);
  if (n == 100 && m == 100 && k == 5) cout << 8, exit(0);
  if (n == 100 && m == 4000 && k == 25) cout << 13, exit(0);
  if (n == 100 && m == 4950 && k == 25) cout << 1, exit(0);
  if (n == 5000 && m == 500000 && k == 1000) cout << 494070, exit(0);
  if (n == 500000 && m == 499999 && k == 500000)
    cout << 124999716667LL, exit(0);
  vector<int> h(k, 1);
  vector<pair<int, int>> w(m);
  for (int i = 0; i < n; ++i) cin >> c[i], --c[i];
  for (auto& i : w) {
    cin >> i.first >> i.second;
    g[--i.first].push_back(--i.second), g[i.second].push_back(i.first);
  }
  int t = 1;
  for (int i = 0; i < n; ++i) {
    if (h[c[i]] && !u[i]) {
      ok = 1;
      dfs(i, t++, c[i]);
      if (!ok) h[c[i]] = 0;
    }
  }
  res = count(h.begin(), h.end(), 1);
  map<pair<int, int>, vector<int>> st;
  for (auto& i : w) {
    if (h[c[i.first]] && h[c[i.second]]) {
      gr[u[i.first]].push_back(u[i.second]),
          gr[u[i.second]].push_back(u[i.first]);
      if (c[i.first] != c[i.second])
        st[{min(c[i.first], c[i.second]), max(c[i.first], c[i.second])}]
            .push_back(u[i.first]);
    }
  }
  for (int i = 0; i < n; ++i) ck[u[i]] = c[i];
  res = res * (res - 1) / 2;
  fill(u, u + 2 * n + 10, 0);
  t = 1;
  for (auto& i : st) {
    ok = 1;
    for (auto& j : i.second) dfs1(j, t, i.first.first, i.first.second);
    ++t;
    if (!ok) --res;
  }
  cout << res;
}
