#include <iostream>
#include <clocale>
using namespace std;
int n, m, q;
int**  roads = NULL;
bool*  colors = NULL;
int countNets();
void walk(int);
void delRoad();
int getInt(int from, int to = 300000);
int main() {
	setlocale(LC_ALL, "Russian");
	n = getInt(2);
	m = getInt(1);
	colors = new bool [n];
	roads  = new int* [m];
	for (int i = 0; i < m; ++i) {
		roads[i] = new int[2];
		roads[i][0] = getInt(1, n) - 1;
		roads[i][1] = getInt(1, n) - 1;
	}
	int counter = 0, iq = 0;
	q = getInt(1, m);
	do {
		counter = countNets();
		if(iq > 0)
			cout << counter << " ";
		if(iq < q)
			delRoad();
		if (iq == 0)
			cout << endl;
		iq++;
	} while (iq <= q);
	for (int i = 0; i < m; ++i)
		delete[] roads[i];
	delete[] roads;
	delete[] colors;
	system("pause");
	return 0;
}
int countNets() {
	for (int i = 0; i < n; ++i)
		colors[i] = false;
	int curCity = 0,
		count = 0;
	do {
		walk(curCity);
		count++;
		curCity = -1;
		for (int i = 0; i < n; ++i)
			if (!colors[i]) {
				curCity = i;
				break;
			}
	} while (curCity != -1);
	return count;
}
void walk(int startCity) {
	if (colors[startCity])
		return;
	colors[startCity] = true;
	for (int i = 0; i < m; ++i) {
		if (roads[i][0] == startCity)
			walk(roads[i][1]);
		if (roads[i][1] == startCity)
			walk(roads[i][0]);
	}
}
void delRoad() {
	int dRoad;
	bool flag;
	do {
		flag = false;
		dRoad = getInt(1, m) - 1;
		if (roads[dRoad][0] == -1 || roads[dRoad][1] == -1) {
			cout << "Такой дороги уже нет!" << endl;
			flag = true;
		}
	} while (flag);
	roads[dRoad][0] = -1;
	roads[dRoad][1] = -1;
}
int getInt(int from, int to) {
	int temp;
	bool flag;
	do {
		flag = false;
		cin >> temp;
		if (temp < from || temp > to) {
			cout << "Выход за приделы диапазона!" << endl;
			flag = true;
		}
	} while (flag);
	return temp;
}