Counting Pairs

아직 제출이 없습니다시간 제한4초메모리 제한256 MB

문제

You are given an undirected graph GG consisting of NN vertices, numbered from 11 to NN, and MM edges.

Consider a pair of vertices (a,b)(a, b), where a<ba < b. Let the incidence of (a,b)(a, b) be the total number of edges with at least one of their endpoints being aa or bb.

You have to answer QQ queries. Each query is given as an integer kk, and asks how many pairs of vertices (a,b)(a, b) are there in GG such that a<ba < b and the incidence of (a,b)(a, b) is strictly greater than kk.

입력

The first line of input contains two integers NN and MM, the number of vertices and the number of edges (1N,M1061 \le N, M \le 10^6).

Then MM lines follow. The ii-th of them contains two integers x_ix\_i and y_iy\_i, denoting the endpoints of the ii-th edge (1x_i,y_iN1 \le x\_i, y\_i \le N). There may be self-loops or parallel edges.

The next line of input contains one integer QQ, the number of queries (1Q1061 \le Q \le 10^6).

Then QQ lines follow. The ii-th of them contains an integer k_ik\_i, denoting the ii-th query (1k_i1061 \le k\_i \le 10^6).

출력

For each query, print a single line with a single integer: the answer to the query.