#include <bits/stdc++.h>
using namespace std;
enum Color { white, grey, black };
class Vertex {
 public:
  vector<int> edges;
  set<int> checkEdge;
  int color, sssID;
  int answer;
  void addEdge(int v);
  Vertex() {
    color = Color::white;
    answer = 1;
  }
};
void Vertex::addEdge(int v) {
  if (!checkEdge.count(v)) {
    edges.push_back(v);
  }
}
class StronglyConnected {
 private:
  vector<int> topoSortVec;
  int currentSSS;
  int DFSAnswer(int u, set<int> &SSSCountedSet);
  void DFSPrintAnswer(int u);
  void clearGraph(vector<Vertex> &G);
  int DFS(vector<Vertex> &G, function<void(int)> &preFun,
          function<void(int)> &inFun, function<void(int)> &postFun, int u);

 public:
  vector<Vertex> G;
  vector<Vertex> GT;
  vector<int> SSSRepresentant;
  vector<int> SSSAnswer;
  int minAnswerSSID;
  StronglyConnected(size_t n) : G(n), GT(n) { currentSSS = 0; }
  void addPath(int u, int v);
  void topoSort();
  void findSSS();
  void findAnswer();
  void printAnswer();
};
void StronglyConnected::addPath(int u, int v) {
  G[u].addEdge(v);
  GT[v].addEdge(u);
}
void StronglyConnected::topoSort() {
  function<void(int)> preFun, inFun, postFun;
  auto DFSTopoSort = [this, &preFun, &inFun, &postFun](int u) {
    DFS(G, preFun, inFun, postFun, u);
  };
  preFun = [this](int u) {};
  inFun = [&DFSTopoSort, this](int u) {
    if (G[u].color == Color::white) {
      DFSTopoSort(u);
    }
  };
  postFun = [this](int u) { topoSortVec.push_back(u); };
  for (int u = 0; u < G.size(); u++) {
    if (G[u].color == Color::white) {
      DFSTopoSort(u);
    }
  }
  reverse(topoSortVec.begin(), topoSortVec.end());
}
void StronglyConnected::findSSS() {
  currentSSS = 0;
  function<void(int)> preFun, inFun, postFun;
  auto DFSFindSSS = [this, &preFun, &inFun, &postFun](int u) {
    DFS(GT, preFun, inFun, postFun, u);
  };
  preFun = [this](int u) {
    GT[u].sssID = currentSSS;
    G[u].sssID = currentSSS;
  };
  inFun = [&DFSFindSSS, this](int u) {
    if (GT[u].color == Color::white) {
      DFSFindSSS(u);
    }
  };
  postFun = [this](int u) {};
  for (auto u : topoSortVec) {
    if (GT[u].color == Color::white) {
      SSSRepresentant.push_back(u);
      DFSFindSSS(u);
      currentSSS++;
    }
  }
}
void StronglyConnected::clearGraph(vector<Vertex> &G) {
  for (auto &vertex : G) {
    vertex.color = Color::white;
  }
}
int StronglyConnected::DFSAnswer(int u, set<int> &SSSCountedSet) {
  G[u].color = Color::grey;
  int myAnswer = 1;
  SSSCountedSet.insert(G[u].sssID);
  for (auto v : G[u].edges) {
    if (G[v].color == Color::white) {
      myAnswer += DFSAnswer(v, SSSCountedSet);
    } else if (G[v].color == Color::black && !SSSCountedSet.count(G[v].sssID)) {
      myAnswer += SSSAnswer[G[v].sssID];
      SSSCountedSet.insert(v);
    }
  }
  SSSAnswer[G[u].sssID] = max(SSSAnswer[G[u].sssID], myAnswer);
  G[u].color = Color::black;
  return myAnswer;
}
void StronglyConnected::findAnswer() {
  clearGraph(G);
  SSSAnswer = vector<int>(currentSSS, 0);
  for (auto u : topoSortVec) {
    if (G[u].color == Color::white) {
      set<int> tmpSet;
      DFSAnswer(u, tmpSet);
    }
  }
  int minAnsw = 100000000;
  for (int i = 0; i < currentSSS; i++) {
    if (SSSAnswer[i] < minAnsw) {
      minAnsw = SSSAnswer[i];
      minAnswerSSID = i;
    }
  }
}
void StronglyConnected::DFSPrintAnswer(int u) {
  G[u].color = Color::grey;
  cout << (u + 1) << " ";
  for (auto v : G[u].edges) {
    if (G[v].color == Color::white) {
      DFSPrintAnswer(v);
    }
  }
  G[u].color = Color::black;
}
void StronglyConnected::printAnswer() {
  clearGraph(G);
  cout << SSSAnswer[minAnswerSSID] << endl;
  DFSPrintAnswer(SSSRepresentant[minAnswerSSID]);
  cout << endl;
}
int StronglyConnected::DFS(vector<Vertex> &G, function<void(int)> &preFun,
                           function<void(int)> &inFun,
                           function<void(int)> &postFun, int u) {
  G[u].color = Color::grey;
  preFun(u);
  for (auto v : G[u].edges) {
    inFun(v);
  }
  postFun(u);
  G[u].color = Color::black;
  return 0;
}
class Solution {
 public:
  int n, m, k;
  vector<int> centerUpdateTime;
  shared_ptr<StronglyConnected> stronglyConnected;
  Solution() {}
  void addEdge(int centerA, int centerB) {
    if (centerUpdateTime[centerA] > centerUpdateTime[centerB]) {
      swap(centerA, centerB);
    }
    if (centerUpdateTime[centerB] == k - 1 && centerUpdateTime[centerA] == 0) {
      stronglyConnected->addPath(centerB, centerA);
    }
    if (centerUpdateTime[centerB] - centerUpdateTime[centerA] == 1) {
      stronglyConnected->addPath(centerA, centerB);
    }
  }
  void readData() {
    cin >> n >> m >> k;
    centerUpdateTime = vector<int>(n);
    stronglyConnected = make_shared<StronglyConnected>(n);
    for (int i = 0; i < n; i++) {
      cin >> centerUpdateTime[i];
    }
    int centerA, centerB;
    for (int i = 0; i < m; i++) {
      cin >> centerA >> centerB;
      addEdge(centerA - 1, centerB - 1);
    }
  }
  void findSolution() {
    readData();
    stronglyConnected->topoSort();
    stronglyConnected->findSSS();
    stronglyConnected->findAnswer();
    stronglyConnected->printAnswer();
  }
};
int main() {
  Solution solution;
  solution.findSolution();
  return 0;
}
