#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct node {
int64_t x,y;
};
typedef pair<int64_t,int64_t> P;
int64_t w;
int64_t dfs(const vector<node> &nodes, const vector<vector<P>> edges, vector<char> &used, int64_t cur) {
if(nodes[cur].x == w) {
return 1;
}
used[cur]=1;
for(int64_t i=0;i<edges[cur].size();i++) {
if(!used[edges[cur][i].second]) {
if(dfs(nodes, edges, used, edges[cur][i].second)) {
return 1;
}
}
}
used[cur]=0;
return 0;
}
int main(void) {
int64_t n,m;
cin >> n >> m >> w;
vector<node> nodes(n);
vector<int64_t> starts;
for(int64_t i=0;i<n;i++) {
cin >> nodes[i].x >> nodes[i].y;
if(nodes[i].x==0) starts.push_back(i);
}
vector<vector<pair<int64_t,int64_t>>> edges(n);
for(int64_t i=0;i<m;i++) {
int64_t a,b;
cin >> a >> b;
a--;b--;
edges[a].push_back({nodes[b].y, b});
edges[b].push_back({nodes[a].y, a});
}
for(int64_t i=0;i<n;i++) {
sort(edges[i].begin(), edges[i].end());
}
int64_t cnt=0;
vector<char> used(n);
for(int64_t s=0;s<starts.size();s++) {
cnt+=dfs(nodes, edges, used, starts[s]);
}
cout << cnt << endl;
}