#include <bits/stdc++.h>   using namespace std;   const long long N = 2e6 + 10;   const long long mod = 1e9 + 7;   struct Dsu {     long long fa[N << 1], d[N << 1];     struct Tmp {       long long x, y, add;     };     stack<Tmp> s;     long long find(long long x) {       while (x != fa[x]) x = fa[x];       return x;     }     void init(long long n) {       while (!s.empty()) s.pop();       for (long long i = 1; i <= n; i++) fa[i] = i, d[i] = 0;     }     void merge(long long x, long long y) {       long long xx = find(x);       long long yy = find(y);       if (xx == yy) return;       if (d[xx] > d[yy]) swap(xx, yy);       s.push((Tmp){xx, yy, d[xx] == d[yy]});       fa[xx] = yy;       d[yy] += (d[xx] == d[yy]);     }     void ret(long long o) {       while (s.size() > o) {         Tmp x = s.top();         fa[x.x] = x.x;         d[x.y] -= x.add;         s.pop();       }     }   } t;   long long read() {     long long x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = (x << 1) + (x << 3) + c -  0 , c = getchar();     return x * f;   }   long long c[N];   map<pair<long long, long long>, vector<pair<long long, long long>>> mp;   int main() {     long long n = read(), m = read(), k = read();     for (long long i = 1; i <= n; i++) c[i] = read();     vector<pair<long long, long long>> e(m + 1);     t.init(2 * n);     for (long long i = 1; i <= m; i++) e[i].first = read(), e[i].second = read();     vector<long long> z(k + 1);     for (long long i = 1; i <= m; i++) {       long long u = e[i].first, v = e[i].second;       if (c[u] == c[v]) {         long long x = t.find(u);         long long y = t.find(v);         if (x == y) {           z[c[u]] = 1;         } else {           t.merge(u, v + n);           t.merge(u + n, v);         }       } else {         pair<long long, long long> tmp = {min(c[u], c[v]), max(c[v], c[u])};         mp[tmp].push_back({u, v});       }     }     long long res = 1ll * k * (k - 1) / 2;     long long gg = 0;     for (long long i = 1; i <= k; i++)       if (z[i] == 1) gg++;     res -= (gg) * (gg - 1) / 2 + gg * (k - gg);     for (auto now : mp) {       if (z[now.first.first] || z[now.first.second]) continue;       auto tmp = now.second;       long long o = t.s.size();       for (pair<long long, long long> qwq : tmp) {         long long u = qwq.first;         long long v = qwq.second;         long long x = t.find(u);         long long y = t.find(v);         if (x == y) {           res -= 1;           break;         } else {           t.merge(u, v + n);           t.merge(u + n, v);         }       }       t.ret(o);     }     cout << res << endl;   }   