#include <bits/stdc++.h>
const int MAXN = 500005;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct DSU {
  struct Rec {
    int ch, pa, xval, keep_b;
  };
  int is_bip;
  int pa[MAXN], sz[MAXN], add[MAXN];
  vector<Rec> stk;
  void init(int n) {
    is_bip = 1;
    for (int i = 0; i <= n; i++) {
      pa[i] = i;
      sz[i] = 1;
      add[i] = 0;
    }
  }
  int find(int x) { return x == pa[x] ? x : x = find(pa[x]); }
  int col(int x) { return x == pa[x] ? add[x] : (col(pa[x]) ^ add[x]); }
  int merge(int x, int y) {
    int c1 = col(x), c2 = col(y);
    x = find(x);
    y = find(y);
    if (x == y) {
      stk.push_back({0, 0, 0, is_bip});
      if (c1 == c2) {
        is_bip = 0;
      }
      return 0;
    }
    if (sz[x] < sz[y]) {
      swap(x, y);
    }
    int same = (c1 == c2);
    sz[x] += sz[y];
    pa[y] = x;
    add[y] ^= same;
    stk.push_back({y, x, same, is_bip});
    return 1;
  }
  void save() { stk.push_back({-2, -2, -2, -2}); }
  void revoke() {
    while (!stk.empty() && stk.back().ch != -2) {
      Rec r = stk.back();
      if (r.ch != 0) {
        pa[r.ch] = r.ch;
        sz[r.pa] -= sz[r.ch];
        add[r.ch] ^= r.xval;
      }
      is_bip = r.keep_b;
      stk.pop_back();
    }
  }
} dsu;
int n, m, k, gid[MAXN], valid[MAXN];
vector<int> grp[MAXN], gs;
vector<int> rel[MAXN];
vector<pair<int, int>> ekeep;
map<pair<int, int>, vector<pair<int, int>>> eclass;
pair<int, int> norm(int a, int b) {
  pair<int, int> p = pair<int, int>(a, b);
  if (p.first > p.second) {
    swap(p.first, p.second);
  }
  return p;
}
void solve() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> gid[i];
    grp[gid[i]].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    eclass[norm(gid[a], gid[b])].push_back(pair<int, int>(a, b));
    ekeep.push_back(pair<int, int>(a, b));
  }
  dsu.init(n);
  dsu.save();
  for (int i = 1; i <= k; i++) {
    auto it = eclass.find(pair<int, int>(i, i));
    if (it == eclass.end()) {
      valid[i] = 1;
      gs.push_back(i);
      continue;
    }
    auto &es = it->second;
    for (pair<int, int> e : es) {
      dsu.merge(e.first, e.second);
      if (!dsu.is_bip) {
        break;
      }
    }
    if (dsu.is_bip) {
      valid[i] = 1;
      gs.push_back(i);
      dsu.save();
    } else {
      dsu.revoke();
    }
  }
  long long ans = 0;
  for (pair<int, int> e : ekeep) {
    int g1 = gid[e.first], g2 = gid[e.second];
    if (!valid[g1] || !valid[g2] || g1 == g2) continue;
    rel[g1].push_back(g2);
    rel[g2].push_back(g1);
  }
  for (int i = 1; i <= k; i++) {
    if (!valid[i]) continue;
    sort(rel[i].begin(), rel[i].end());
    rel[i].resize(unique((rel[i]).begin(), (rel[i]).end()) - rel[i].begin());
    ans += (int)gs.size() - 1 - (int)rel[i].size();
    assert((int)gs.size() - 1 - (int)rel[i].size() >= 0);
  }
  ans /= 2;
  for (auto &it : eclass) {
    int g1 = it.first.first, g2 = it.first.second;
    vector<pair<int, int>> &es = it.second;
    if (g1 == g2 || !valid[g1] || !valid[g2]) continue;
    for (pair<int, int> e : es) {
      dsu.merge(e.first, e.second);
      if (!dsu.is_bip) {
        break;
      }
    }
    ans += dsu.is_bip;
    dsu.revoke();
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
