## DMOPC '19 Contest 2 P4 - A Greedy Problem

View as PDF

Points: 15 (partial)
Time limit: 0.1s
Java 0.6s
PyPy 2 0.3s
PyPy 3 0.3s
Memory limit: 128M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Jack is doing a programming contest. There are problems in this contest and the contest will last a total of minutes. The -th problem will take Jack exactly minutes to solve. Having an aversion to certain problem types such as dynamic programming, Jack wonders how many subsets of problems he can solve within minutes if he decides that he definitely wants to solve problem and problem . More formally, Jack wants to determine the number of subsets of problems that contain problem and problem whose sum of solve times is less than or equal to . Since this number may be very large, output it modulo . Two subsets are different if there is a problem in one of the subsets that does not appear in the other subset.

Help Jack answer a total of of these queries.

#### Input Specification

The first line contains three space-separated integers,
The next line contains space-separated integers,
The next lines contain three space-separated integers,

#### Output Specification

Output lines. The -th line should contain the answer to the -th query.

#### Sample Input

3 90 2
20 30 40
1 2 50
1 3 90

#### Sample Output

1
2