logo AlgoBeat OnlineJudge
登录 注册

#215721. [ICPC 2025 Jakarta R] Predisposed

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given two integers and . You are also given constraints in the form .

A sequence of length is if and only if:

  • For each , it holds that .
  • For each , the sum of all where is a multiple of is equal to under modulo . Formally, .

Find the number of all possible predisposed sequences. As the answer can be quite large, compute it modulo .

输入格式

The first line contains three integers , , and (; ).

Each of the next lines contains two integers and (; ; for ) representing a constraint.

输出格式

Output an integer in a single line representing the number of predisposed sequences modulo .

样例

样例输入 1

2 3 2
1 0
2 1

样例输出 1

1

样例输入 2

100000 100000 1
100000 0

样例输出 2

373304036

数据范围与提示

The only predisposed sequence is .