Fly
题号:NC239325
时间限制:C/C++/Rust/Pascal 6秒,其他语言12秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Groudon wanna fly. Kyogre will tell Groudon how to fly if and only if Groudon solves the following problem.

There are n integers , one integer m and k integer pairs . You need to find the number of non-negative n-tuples which satisfies:




Here, denotes the bitwise operation AND.

Two non-negative n-tuples and are considered different if and only if there exists one integer which satisfies .

Since the answer is too large, Kyogre only wants to know it modulo .

You, as a programmer of Hoenn, please help Groudon!

输入描述:

The first line contains three integers n,m,k ().

The second line contains n integers ().

For the i-th line in the following k lines, there are two integers b_i,c_i ().

All numbers in the input denote the parameter of Kyogre's problem.

输出描述:

Print a single integer, denoting the answer to Kyogre's problem, modulo .
示例1

输入

复制
3 5 1
2 3 3
1 0

输出

复制
4
示例2

输入

复制
6 10 2
1 1 4 5 1 4
3 1
4 2

输出

复制
539

备注:

In the first example, there are 4 non-negative 3-tuples satisfy the condition in Kyogre's problem: (0, 0, 0)(2, 0, 0)(0, 1, 0)(0, 0, 1).