#P75. [CSP-S 2020] Zoo Enlargement

[CSP-S 2020] Zoo Enlargement

Person in Charge

Problem Description

A zoo keeps a large number of animals. The zookeeper A will purchase different types of feed according to the animal breeding situation in accordance with the Feeding Guide, and send the purchase list to the purchaser B.

Specifically, there are 2k2^k different types of animals in the animal kingdom, numbered from 00 to 2k12^k - 1. The zoo keeps nn of these types, where the number of the ii-th type of animal is aia_i.

The Feeding Guide contains mm requirements. The jj-th requirement is in the form of "If the zoo keeps an animal whose binary representation of the number has the pjp_j-th bit as 11, then the qjq_j-th type of feed must be purchased". There are a total of cc types of feed, numbered from 11 to cc. In this problem, we regard the binary representation of an animal's number as a kk-bit 01 string, where the 00-th bit is the least significant bit and the k1k - 1-th bit is the most significant bit.

According to the Feeding Guide, zookeeper A will make a feed list and hand it over to purchaser B, who will then buy the feed. The list is in the form of a cc-bit 01 string: the ii-th bit being 11 means the ii-th type of feed needs to be purchased, and 00 means it does not. In fact, based on the purchased feed, the zoo may be able to keep more animals. More specifically, if adding an unpurchased animal with number xx to the zoo's breeding list does not change the feed list, then we consider that the zoo can currently keep the animal with number xx.

Now purchaser B wants you to help calculate how many more types of animals the zoo can currently keep.

Input Format

The first line contains four integers n,m,c,kn, m, c, k separated by spaces, representing the number of animals in the zoo, the number of requirements in the Feeding Guide, the number of feed types, and the number of bits in the binary representation of animal numbers, respectively.
The second line contains nn integers separated by spaces, where the ii-th integer is aia_i.
The next mm lines each contain two integers pi,qip_i, q_i representing a requirement.

It is guaranteed that all aia_i are distinct and all qiq_i are distinct.

Output Format

Output a single integer on one line representing the answer.

Samples

3 3 5 4
1 4 6
0 3
2 4
2 5
13

Sample 1 Explanation

The zoo keeps three animals numbered 1,4,61, 4, 6. The three requirements in the Feeding Guide are:

  1. If the zoo keeps an animal whose number has the 00-th binary bit as 11, then the 33-rd type of feed must be purchased.
  2. If the zoo keeps an animal whose number has the 22-nd binary bit as 11, then the 44-th type of feed must be purchased.
  3. If the zoo keeps an animal whose number has the 22-nd binary bit as 11, then the 55-th type of feed must be purchased.

The feed purchase status is as follows:

  1. The 00-th binary bit of the number of the animal numbered 11 is 11, so the 33-rd type of feed needs to be purchased;
  2. The 22-nd binary bit of the numbers of the animals numbered 44 and 66 is 11, so the 44-th and 55-th types of feed need to be purchased.

Since adding an animal numbered 0,2,3,5,7,8,,150, 2, 3, 5, 7, 8, \ldots, 15 to the current zoo will not change the shopping list, the answer is 1313.

Sample 2

See zoo/zoo2.in and zoo/zoo2.ans in the contestant's directory.

Sample 3

See zoo/zoo3.in and zoo/zoo3.ans in the contestant's directory.

Data Range

For 20%20\% of the data: kn5k \le n \le 5, m10m \le 10, c10c \le 10, and all pip_i are distinct.
For 40%40\% of the data: n15n \le 15, k20k \le 20, m20m \le 20, c20c \le 20.
For 60%60\% of the data: n30n \le 30, k30k \le 30, m1000m \le 1000.
For 100%100\% of the data: 0n,m1060 \le n, m \le 10^6, 0k640 \le k \le 64, 1c1081 \le c \le 10^8.