#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;
constexpr ll TEN(int n) { return (!n) ? 1 : 10 * TEN(n-1); }
 
template <class E>
using Graph = vector<vector<E>>;

struct LowLink {
    vector<int> low, ord, par;
    vector<int> vlis;
    
    LowLink() {}
    template<class E>
    LowLink(const Graph<E> &g, int r) { exec(g, r); }

    template<class E>
    void exec(const Graph<E> &g, int r) {
        int V = (int)g.size();
        low.resize(V); ord.resize(V); par.resize(V);
        co = 0; used.resize(V);
        fill_n(used.begin(), V, false);
        dfs(g, r, -1);
    }
    int co;
    vector<bool> used;
    template<class E>
    void dfs(const Graph<E> &g, int p, int b) {
        used[p] = true;
        bool rt = true;
        low[p] = ord[p] = co++;
        vlis.push_back(p);
        par[p] = b;
        for (E e: g[p]) {
            if (rt and e.to == b) {
                rt = false;
                continue;
            }
            if (!used[e.to]) {
                dfs(g, e.to, p);
                low[p] = min(low[p], low[e.to]);
            } else {
                low[p] = min(low[p], ord[e.to]);
            }
        }
    }
};

template <int N>
struct Dominator {
    int idom[N], sdom[N];
/*    vector<int> g[N], rg[N];
    void init() {
        for (int i = 0; i < N; i++) {
            g[i].clear(); rg[i].clear();
        }
    }
    void add(int a, int b) {
        g[a].push_back(b);
        rg[b].push_back(a);
    }*/

    // unionfind
    int p[N];
    int mv[N];
    void merge(int a, int b) {
        p[a] = b;
    }
    int group(int a) {
        if (p[a] == -1) return a;
        int pa = group(p[a]);
        if (lc.ord[sdom[mv[a]]] > lc.ord[sdom[mv[p[a]]]]) {
            mv[a] = mv[p[a]];
        }
        return p[a] = pa;
    }

    vector<int> bucket[N];
    int V[N];
    LowLink lc;
    template<class E>
    void exec(const Graph<E> &g, const Graph<E> &rg, int s) {
        int n = (int)g.size();
        // uf init
        fill_n(p, n, -1);
        iota(mv, mv+n, 0);

        lc = LowLink(g, 0);

        iota(sdom, sdom+n, 0);

        for (int i = n-1; i > 0; i--) {
            int u = lc.vlis[i];
            for (E e: rg[u]) {
                group(e.to);
                sdom[u] = lc.vlis[min(lc.ord[sdom[u]], lc.ord[sdom[mv[e.to]]])];
            }
            bucket[sdom[u]].push_back(u);
            for (int v: bucket[lc.par[u]]) {
                group(v);
                V[v] = mv[v];
            }
            bucket[lc.par[u]].clear();
            merge(u, lc.par[u]);
        }

        idom[s] = -1;
        for (int i = 1; i < n; i++) {
            int u = lc.vlis[i], v = V[u];
            if (sdom[u] == sdom[v]) idom[u] = sdom[u];
            else idom[u] = idom[v];
        }
    }
};
 
const int MN = 100100;
Dominator<MN> dn;
 
struct Edge {
    int to;
} ;
int main() {
    int n, m;
    cin >> n >> m;
    Graph<Edge> g(n), rg(n);
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t; s--; t--;
        g[s].push_back(Edge{t});
        rg[t].push_back(Edge{s});
//        dn.add(s, t);
    }
    dn.exec(g, rg, 0);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int r;
        cin >> r; r--;
        if (dn.idom[r] != 0) {
            cout << dn.idom[r]+1 << endl;
        } else {
            cout << r+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24176