QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 256 MB Total points: 100

#6777. Vector Inner Product

Statistics

The inner product of two $d$-dimensional vectors $A=[a_1,a_2,\dots,a_d]$ and $B=[b_1,b_2,\dots,b_d]$ is the sum of the products of their corresponding components, defined as:

\begin{equation} \langle A, B\rangle = \sum_{i = 1}^{d} a_i b_i = a_1 b_1 + a_2 b_2 + \dots + a_d b_d \end{equation}

Given $n$ vectors $x_1, x_2, \dots, x_n$ in $d$-dimensional space, Xiao Miaomiao wants to know if there exist two vectors whose inner product is a multiple of $k$. Please help her solve this problem.

Input

The first line contains three positive integers $n, d, k$, representing the number of vectors, the dimension, and the multiple to be checked, respectively.

The next $n$ lines each contain $d$ non-negative integers, where the $j$-th integer in the $i$-th line represents the $j$-th dimension weight $x_{i,j}$ of vector $x_i$.

Output

Output two integers separated by a space.

If there exist two vectors $x_p$ and $x_q$ such that their inner product is an integer multiple of $k$, output the indices $p$ and $q$ (where $p < q$). If there are multiple such pairs, output any one of them.

If no such pair of vectors exists, output two $-1$s.

Examples

Input 1

3 5 2
1 0 1 0 1
1 1 0 1 0
0 1 0 1 1

Output 1

2 3

Note 1

$\langle x_1, x_2 \rangle = 1$, $\langle x_1, x_3 \rangle = 1$, $\langle x_2, x_3 \rangle = 2$.

Input 2

(See provided files)

Output 2

(See provided files)

Input 3

(See provided files)

Output 3

(See provided files)

Constraints

Test Case ID $n$ $d$ $k$ $x_{i, j}$
1$2$$20$$2$$\leq 10$
2$5$$20$$2$$\leq 10$
3$10$$20$$3$$\leq 10$
4$20$$20$$2$$\leq 100$
5$50$$20$$3$$\leq 100$
6$50$$50$$2$$\leq 1000$
7$50$$50$$3$$\leq 3000000$
8$80$$80$$2$$\leq 3000000$
9$100$$100$$3$$\leq 3000000$
10$500$$100$$3$$\leq 3000000$
11$1000$$100$$2$$\leq 3000000$
12$1000$$100$$3$$\leq 3000000$
13$10000$$100$$2$$\lt 10$
14$10000$$100$$3$$\lt 10$
15$15000$$100$$2$$\lt 10$
16$18000$$100$$2$$\lt 10$
17$20000$$100$$2$$\lt 10$
18$50000$$30$$3$$\lt 10$
19$80000$$30$$3$$\lt 10$
20$100000$$30$$3$$\lt 10$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.