#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read();
inline long long readl();
inline void write(int x, int ch);
inline void writel(long long x, int ch);
const int maxn = 1e6 + 10;
const int mod = 998244353;
map<pair<int, int>, int> mp;
vector<int> ve[maxn];
int n, m, k;
int c[maxn], a[maxn], b[maxn], f[maxn];
struct Undo_Dsu {
  stack<pair<int, int> > st;
  int fa[maxn], sz[maxn];
  void init() {
    while (!st.empty()) st.pop();
    for (int i = 1; i <= n * 2 + 1; i++) fa[i] = i, sz[i] = 1;
  }
  int Find(int x) { return x == fa[x] ? x : Find(fa[x]); }
  bool combine(int u, int v) {
    int x = Find(u), y = Find(v);
    if (x == y) return false;
    if (sz[x] > sz[y]) swap(x, y), swap(u, v);
    fa[x] = y, sz[y] += sz[x];
    st.push({x, y});
    return true;
  }
  void undo() {
    pair<int, int> pre = st.top();
    fa[pre.first] = pre.first;
    sz[pre.second] -= sz[pre.first];
    st.pop();
  }
} dsu;
signed main() {
  long long ans = 0;
  n = read(), m = read(), k = read();
  dsu.init();
  for (int i = 1; i <= n; i++) c[i] = read();
  for (int i = 1; i <= m; i++) a[i] = read(), b[i] = read();
  for (int i = 1; i <= m; i++) {
    if (c[a[i]] == c[b[i]]) {
      int u = dsu.Find(a[i]), v = dsu.Find(b[i]);
      if (u == v)
        f[c[a[i]]] = 1;
      else
        dsu.combine(a[i], b[i] + n), dsu.combine(b[i], a[i] + n);
    }
  }
  int type = 0;
  for (int i = 1; i <= m; i++) {
    if (c[a[i]] != c[b[i]] && !f[c[a[i]]] && !f[c[b[i]]]) {
      int u = c[a[i]], v = c[b[i]];
      if (u > v) swap(u, v);
      int id = mp[make_pair(u, v)];
      if (!id) id = mp[make_pair(u, v)] = ++type;
      ve[id].push_back(i);
    }
  }
  for (auto x : mp) {
    int w = x.second;
    int now = dsu.st.size();
    for (auto vv : ve[w]) {
      int uid = a[vv], vid = b[vv];
      int fau = dsu.Find(uid), fav = dsu.Find(vid);
      if (fau == fav) {
        --ans;
        break;
      }
      dsu.combine(uid, vid + n);
      dsu.combine(vid, uid + n);
    }
    while ((int)dsu.st.size() > now) dsu.undo();
  }
  int cnt = 0;
  for (int i = 1; i <= k; i++)
    if (!f[i]) cnt++;
  ans += 1LL * cnt * (cnt - 1) / 2;
  writel(ans, 1);
}
inline void writel(long long x, int ch) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    writel(x / 10, 0);
  }
  putchar(x % 10 + '0');
  if (ch) printf("\n");
  return;
}
inline void write(int x, int ch) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    write(x / 10, 0);
  }
  putchar(x % 10 + '0');
  if (ch) printf("\n");
  return;
}
inline long long readl() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
