Under construction

Still being built. Things may change

Back to the Future

Time limit2sMemory limit512 MB

Summary
Given a graph of compatible pairs, find the largest vertex subset where each chosen vertex has at least A neighbors and at least B non-neighbors inside the subset.
Level

Hard8 of 10

Topics
Graph, Greedy, Implementation, Queue
Solved
No attempts yet

Problem

Doctor Emmet is building a safer time travel device. He has collected NN different rare pieces of metal. Some pairs of pieces are compatible with each other. He keeps a list of all MM compatible pairs, and any pair that is not on the list is incompatible.

For the device to work, he must choose a set of metals. Inside that set, every chosen piece has to be compatible with at least AA other chosen pieces. To keep the device balanced, every chosen piece also has to be incompatible with at least BB other chosen pieces.

More metal means more energy and a safer device. Find the size of the largest set that satisfies both requirements.

Input

The first line contains four integers NN, MM, AA and BB separated by spaces. NN is the number of metal pieces (1≤N≤1051 \le N \le 10^5), MM is the number of compatible pairs (1≤M≤1051 \le M \le 10^5), and AA and BB are the two values described above (0≤A,B<N0 \le A, B < N). The metals are numbered from 11 to NN.

Each of the next MM lines contains two integers XX and YY describing a compatible pair (1≤X,Y≤N1 \le X, Y \le N, X≠YX \ne Y). No pair is given twice.

Output

Print, on one line, the size of the largest set of metals that satisfies both requirements. If no such set exists, print 00.

Examples5

  1. Example 1

    Input
    3 1 1 0
    1 2
    
    Expected output
    2
    
  2. Example 2

    Input
    3 1 1 1
    1 2
    
    Expected output
    0
    
  3. Example 3

    Input
    7 12 2 2
    1 2
    2 3
    3 1
    4 5
    5 6
    6 4
    3 4
    7 1
    2 7
    3 7
    4 7
    5 7
    
    Expected output
    6
    
  4. Example 4

    Input
    5 2 0 0
    1 2
    3 4
    
    Expected output
    5
    
  5. Example 5

    Input
    5 10 4 0
    1 2
    1 3
    1 4
    1 5
    2 3
    2 4
    2 5
    3 4
    3 5
    4 5
    
    Expected output
    5