#include <bits/stdc++.h>
using namespace std;
mt19937 gene(233);
inline char GET_CHAR() {
  const int maxn = 131072;
  static char buf[maxn], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxn, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int getInt() {
  int res(0);
  char c = getchar();
  while (c < '0') c = getchar();
  while (c >= '0') {
    res = res * 10 + (c - '0');
    c = getchar();
  }
  return res;
}
inline long long fastpo(long long x, long long n, long long mod) {
  long long res(1);
  while (n) {
    if (n & 1) {
      res = res * (long long)x % mod;
    }
    x = x * (long long)x % mod;
    n /= 2;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline string itoa(int x, int width = 0) {
  string res;
  if (x == 0) res.push_back('0');
  while (x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while ((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
  fwrite(buf, 1, _bl, stdout);
  _bl = 0;
}
__inline void _putchar(char c) {
  if (_bl == _B) flush();
  buf[_bl++] = c;
}
inline void print(long long x, char c) {
  static char tmp[20];
  int l = 0;
  if (!x)
    tmp[l++] = '0';
  else {
    while (x) {
      tmp[l++] = x % 10 + '0';
      x /= 10;
    }
  }
  for (int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
  _putchar(c);
}
struct P {
  double x, y;
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int l, n, m, k, q, t, a[500011], c[500011], size[500011], T, d[500001],
    u[500011], tmp[500011], f[500011], v[500011];
char str[200011];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int> w[500011];
const int P = 998244353;
bool b[500011], r[500011], bb[500011];
int cc[3000011][4], ccc;
set<int> e;
map<pair<int, int>, vector<pair<int, int> > > ww;
set<int> www[500011];
int gf(int i) {
  if (i == f[i]) return i;
  int j = gf(f[i]);
  if (f[i] != j) {
    cc[++ccc][0] = i;
    cc[ccc][1] = f[i];
    cc[ccc][2] = v[i];
    cc[ccc][3] = size[i];
  }
  v[i] = v[i] ^ v[f[i]];
  f[i] = j;
  return j;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), w[a[i]].push_back(i), f[i] = i, size[i] = 1;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (a[x] != a[y]) {
      ww[make_pair(a[x], a[y])].push_back(make_pair(x, y));
      ww[make_pair(a[y], a[x])].push_back(make_pair(x, y));
      www[a[x]].insert(a[y]);
      www[a[y]].insert(a[x]);
    } else
      ww[make_pair(a[x], a[x])].push_back(make_pair(x, y));
  }
  long long ans = 0;
  int g = 0;
  for (int i = 1; i <= q; i++) {
    bool ok = true;
    for (auto j : ww[make_pair(i, i)]) {
      int x = j.first, y = j.second;
      if (gf(x) != gf(y)) {
        if (size[gf(x)] > size[gf(y)]) swap(x, y);
        v[gf(x)] = 1 - (v[x] ^ v[y]);
        size[gf(y)] += size[gf(x)];
        f[gf(x)] = gf(y);
      } else {
        if (v[x] == v[y]) ok = false;
      }
      if (!ok) break;
    }
    r[i] = ok;
    if (!ok) ++g;
  }
  ans = 1LL * (q - g) * g + 1LL * g * (g - 1) / 2;
  for (int i = 1; i <= q; i++)
    if (r[i]) {
      for (auto j : www[i])
        if (r[j])
          if (j < i) {
            ccc = 0;
            bool ok = true;
            for (auto k : ww[make_pair(i, j)]) {
              int x = k.first, y = k.second;
              if (gf(x) != gf(y)) {
                if (size[gf(x)] > size[gf(y)]) swap(x, y);
                int uuu = ++ccc;
                cc[uuu][0] = gf(x);
                cc[uuu][1] = gf(x);
                cc[uuu][2] = v[gf(x)];
                cc[uuu][3] = size[gf(x)];
                uuu = ++ccc;
                cc[uuu][0] = gf(y);
                cc[uuu][1] = gf(y);
                cc[uuu][2] = v[gf(y)];
                cc[uuu][3] = size[gf(y)];
                v[gf(x)] = 1 - (v[x] ^ v[y]);
                size[gf(y)] += size[gf(x)];
                f[gf(x)] = gf(y);
              } else if (v[x] == v[y])
                ok = false;
              if (!ok) break;
            }
            if (!ok) ++ans;
            for (int k = ccc; k; --k) {
              f[cc[k][0]] = cc[k][1];
              v[cc[k][0]] = cc[k][2];
            }
          }
    }
  ans = 1LL * q * (q - 1) / 2 - ans;
  printf("%lld\n", ans);
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

The new academic year has started, and Berland's university has n first-year students. They are divided into k academic groups, however, some of the groups might be empty. Among the students, there are m pairs of acquaintances, and each acquaintance pair might be both in a common group or be in two different groups.

Alice is the curator of the first years, she wants to host an entertaining game to make everyone know each other. To do that, she will select two different academic groups and then divide the students of those groups into two teams. The game requires that there are no acquaintance pairs inside each of the teams.

Alice wonders how many pairs of groups she can select, such that it'll be possible to play a game after that. All students of the two selected groups must take part in the game.

Please note, that the teams Alice will form for the game don't need to coincide with groups the students learn in. Moreover, teams may have different sizes (or even be empty).

Input

The first line contains three integers n, m and k (1 ≤ n ≤ 500 000; 0 ≤ m ≤ 500 000; 2 ≤ k ≤ 500 000) — the number of students, the number of pairs of acquaintances and the number of groups respectively.

The second line contains n integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ k), where c_i equals to the group number of the i-th student.

Next m lines follow. The i-th of them contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ n), denoting that students a_i and b_i are acquaintances. It's guaranteed, that a_i ≠ b_i, and that no (unordered) pair is mentioned more than once.

Output

Print a single integer — the number of ways to choose two different groups such that it's possible to select two teams to play the game.

Examples

Input


6 8 3
1 1 2 2 3 3
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6


Output


2


Input


4 3 3
1 1 2 2
1 2
2 3
3 4


Output


3


Input


4 4 2
1 1 1 2
1 2
2 3
3 1
1 4


Output


0


Input


5 5 2
1 2 1 2 1
1 2
2 3
3 4
4 5
5 1


Output


0

Note

The acquaintances graph for the first example is shown in the picture below (next to each student there is their group number written).

<image>

In that test we can select the following groups:

  * Select the first and the second groups. For instance, one team can be formed from students 1 and 4, while other team can be formed from students 2 and 3. 
  * Select the second and the third group. For instance, one team can be formed 3 and 6, while other team can be formed from students 4 and 5. 
  * We can't select the first and the third group, because there is no way to form the teams for the game. 



In the second example, we can select any group pair. Please note, that even though the third group has no students, we still can select it (with some other group) for the game.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 gene(233);
inline char GET_CHAR() {
  const int maxn = 131072;
  static char buf[maxn], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxn, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int getInt() {
  int res(0);
  char c = getchar();
  while (c < '0') c = getchar();
  while (c >= '0') {
    res = res * 10 + (c - '0');
    c = getchar();
  }
  return res;
}
inline long long fastpo(long long x, long long n, long long mod) {
  long long res(1);
  while (n) {
    if (n & 1) {
      res = res * (long long)x % mod;
    }
    x = x * (long long)x % mod;
    n /= 2;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline string itoa(int x, int width = 0) {
  string res;
  if (x == 0) res.push_back('0');
  while (x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while ((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
  fwrite(buf, 1, _bl, stdout);
  _bl = 0;
}
__inline void _putchar(char c) {
  if (_bl == _B) flush();
  buf[_bl++] = c;
}
inline void print(long long x, char c) {
  static char tmp[20];
  int l = 0;
  if (!x)
    tmp[l++] = '0';
  else {
    while (x) {
      tmp[l++] = x % 10 + '0';
      x /= 10;
    }
  }
  for (int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
  _putchar(c);
}
struct P {
  double x, y;
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int l, n, m, k, q, t, a[500011], c[500011], size[500011], T, d[500001],
    u[500011], tmp[500011], f[500011], v[500011];
char str[200011];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int> w[500011];
const int P = 998244353;
bool b[500011], r[500011], bb[500011];
int cc[3000011][4], ccc;
set<int> e;
map<pair<int, int>, vector<pair<int, int> > > ww;
set<int> www[500011];
int gf(int i) {
  if (i == f[i]) return i;
  int j = gf(f[i]);
  if (f[i] != j) {
    cc[++ccc][0] = i;
    cc[ccc][1] = f[i];
    cc[ccc][2] = v[i];
    cc[ccc][3] = size[i];
  }
  v[i] = v[i] ^ v[f[i]];
  f[i] = j;
  return j;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), w[a[i]].push_back(i), f[i] = i, size[i] = 1;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (a[x] != a[y]) {
      ww[make_pair(a[x], a[y])].push_back(make_pair(x, y));
      ww[make_pair(a[y], a[x])].push_back(make_pair(x, y));
      www[a[x]].insert(a[y]);
      www[a[y]].insert(a[x]);
    } else
      ww[make_pair(a[x], a[x])].push_back(make_pair(x, y));
  }
  long long ans = 0;
  int g = 0;
  for (int i = 1; i <= q; i++) {
    bool ok = true;
    for (auto j : ww[make_pair(i, i)]) {
      int x = j.first, y = j.second;
      if (gf(x) != gf(y)) {
        if (size[gf(x)] > size[gf(y)]) swap(x, y);
        v[gf(x)] = 1 - (v[x] ^ v[y]);
        size[gf(y)] += size[gf(x)];
        f[gf(x)] = gf(y);
      } else {
        if (v[x] == v[y]) ok = false;
      }
      if (!ok) break;
    }
    r[i] = ok;
    if (!ok) ++g;
  }
  ans = 1LL * (q - g) * g + 1LL * g * (g - 1) / 2;
  for (int i = 1; i <= q; i++)
    if (r[i]) {
      for (auto j : www[i])
        if (r[j])
          if (j < i) {
            ccc = 0;
            bool ok = true;
            for (auto k : ww[make_pair(i, j)]) {
              int x = k.first, y = k.second;
              if (gf(x) != gf(y)) {
                if (size[gf(x)] > size[gf(y)]) swap(x, y);
                int uuu = ++ccc;
                cc[uuu][0] = gf(x);
                cc[uuu][1] = gf(x);
                cc[uuu][2] = v[gf(x)];
                cc[uuu][3] = size[gf(x)];
                uuu = ++ccc;
                cc[uuu][0] = gf(y);
                cc[uuu][1] = gf(y);
                cc[uuu][2] = v[gf(y)];
                cc[uuu][3] = size[gf(y)];
                v[gf(x)] = 1 - (v[x] ^ v[y]);
                size[gf(y)] += size[gf(x)];
                f[gf(x)] = gf(y);
              } else if (v[x] == v[y])
                ok = false;
              if (!ok) break;
            }
            if (!ok) ++ans;
            for (int k = ccc; k; --k) {
              f[cc[k][0]] = cc[k][1];
              v[cc[k][0]] = cc[k][2];
            }
          }
    }
  ans = 1LL * q * (q - 1) / 2 - ans;
  printf("%lld\n", ans);
}

```