//meek///#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std ;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
typedef long long ll;
const int N = 510000;
const int inf = 99999999;
const int mod= 1000000007;
int n,m,k[N],q,num,parent[N],done[N];
vector<int >G[N],ans;
void init() {
mem(done);num=n;
for(int i=0;i<=n;i++) parent[i]=i;
}
int finds(int x) {
if(x != parent[x]) return parent[x] = finds(parent[x]);
else return x;
}
void Union(int x,int y) {
int fx = finds(x);
int fy = finds(y);
if(fx != fy) {
num--;
parent[fy]=fx;
}
}
int main() {
scanf("%d%d",&n,&m);
init();int x,y;
for(int i=1;i<=m;i++) {
scanf("%d%d",&x,&y);
G[x].pb(y);
G[y].pb(x);
}
scanf("%d",&q);
for(int i=1;i<=q;i++) {
scanf("%d",&k[i]);
done[k[i]] = 1;
}
for(int i=0;i<n;i++) {
if(!done[i]) {
for(int j=0;j<G[i].size();j++) {
int to=G[i][j];
if(!done[to]) {
Union(i,to);
}
}
}
}
//cout<<num<<endl;
for(int i=q;i>=1;i--) {
ans.pb(num-i);
for(int j=0;j<G[k[i]].size();j++) {
int to=G[k[i]][j];
if(!done[to]) {
Union(k[i],to);
}
}
done[k[i]] = 0;
}
ans.pb(num);
for(int i=ans.size()-1;i>=0;i--) {
printf("%d\n",ans[i]);
}
return 0;
}