#include <bits/stdc++.h>
using namespace std;
#define int long long
const int NMAX=3e5, BIT=6;
vector<int> colors;
int dp[(1LL<<BIT)][NMAX+5];
vector<vector<int> > graph;
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, m, k;
cin >> n >> m >> k;
colors.resize(n+1);
graph.resize(n+1);
map<int, vector<int> > mask;
for (int i=1;i<=n;i++) {
cin>>colors[i];
dp[(1LL<<colors[i])][i]=1;
}
for (int i=1;i<=m;i++) {
int x, y;
cin>>x>>y;
graph[x].push_back(y);
graph[y].push_back(x);
}
for (int i=0;i<(1LL<<(k+1));i++) {
mask[__builtin_popcountll(i)].push_back(i);
}
for (auto it:mask) {
for (auto msk:it.second) {
for (int i=1;i<=n;i++) {
for (auto neighbour:graph[i]) {
if (!((1LL<<colors[neighbour])&msk)) {
int new_mask=msk^(1LL<<colors[neighbour]);
dp[new_mask][neighbour]+=dp[msk][i];
}
}
}
}
}
int ans=0;
for (auto it:mask) {
if (it.first>1) {
for (auto x:it.second) {
for (int i=1;i<=n;i++) {
ans+=dp[x][i];
}
}
}
}
cout<<ans;
}