N, M = (int(x) for x in input().split()) offline = set() d={} for i in range(M): u, v = (int(x) for x in input().split()) if u not in d: d[u] = set() d[u].add(v) ans = [] Q=int(input()) for i in range(Q): q=list(map(int, input().split())) if q[0] == 1: a, b = q[1], q[2] if a not in d: d[a] = set() d[a].add(b) elif b not in d[a]: d[a].add(b) else: d[a].discard(b) res = 0 for j in offline: if a not in d or j not in d[a]: res += 1 ans.append(N-1-res) else: a = q[1] res = 0 if a not in offline: for j in offline: if a not in d or j not in d[a]: res += 1 offline.add(a) else: offline.discard(a) for j in offline: if a not in d or j not in d[a]: res += 1 ans.append(N-1-res) for i in ans: print(i)