## Algorithm

C. Equal Sums
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given k sequences of integers. The length of the i-th sequence equals to ni��.

You have to choose exactly two sequences i and j (ij�≠�) such that you can remove exactly one element in each of them in such a way that the sum of the changed sequence i (its length will be equal to ni1��−1) equals to the sum of the changed sequence j (its length will be equal to nj1��−1).

Note that it's required to remove exactly one element in each of the two chosen sequences.

Assume that the sum of the empty (of the length equals 00) sequence is 00.

Input

The first line contains an integer k (2k21052≤�≤2⋅105) — the number of sequences.

Then k pairs of lines follow, each pair containing a sequence.

The first line in the i-th pair contains one integer ni�� (1ni<21051≤��<2⋅105) — the length of the i-th sequence. The second line of the i-th pair contains a sequence of ni�� integers ai,1,ai,2,,ai,ni��,1,��,2,…,��,��.

The elements of sequences are integer numbers from 104−104 to 104104.

The sum of lengths of all given sequences don't exceed 21052⋅105, i.e. n1+n2++nk2105�1+�2+⋯+��≤2⋅105.

Output

If it is impossible to choose two sequences such that they satisfy given conditions, print "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), in the second line — two integers ix (1ik,1xni1≤�≤�,1≤�≤��), in the third line — two integers jy (1jk,1ynj1≤�≤�,1≤�≤��). It means that the sum of the elements of the i-th sequence without the element with index x equals to the sum of the elements of the j-th sequence without the element with index y.

Two chosen sequences must be distinct, i.e. ij�≠�. You can print them in any order.

If there are multiple possible answers, print any of them.

Examples
input
Copy
252 3 1 3 261 1 2 2 2 1
output
Copy
YES2 61 2
input
Copy
31551 1 1 1 122 3
output
Copy
NO
input
Copy
462 2 2 2 2 252 2 2 2 232 2 252 2 2 2 2
output
Copy
YES2 24 1
Note

In the first example there are two sequences [2,3,1,3,2][2,3,1,3,2] and [1,1,2,2,2,1][1,1,2,2,2,1]. You can remove the second element from the first sequence to get [2,1,3,2][2,1,3,2] and you can remove the sixth element from the second sequence to get [1,1,2,2,2][1,1,2,2,2]. The sums of the both resulting sequences equal to 88, i.e. the sums are equal.

## Code Examples

### #1 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>

using namespace std;

struct node {
int idx, sum, rem;

node() {}

node(int idx, int sum, int rem) :
idx(idx), sum(sum), rem(rem) {}

bool operator<(const node &n) const {
if(sum != n.sum)
return sum < n.sum;
return idx < n.idx;
}
};

int const N = 2e5 + 1;
int k, n, to[N];
vector<vector<int> > g;
set<node> st;
set<node>::iterator it;

int main() {
scanf("%d", &k);
g.resize(k);
for(int i = 0; i < k; ++i) {
scanf("%d", &n);
g[i].resize(n);
for(int j = 0; j < n; ++j) {
scanf("%d", &g[i][j]);
to[i] += g[i][j];
}

for(int j = 0; j < n; ++j) {
it = st.lower_bound(node(-1e9, to[i] - g[i][j], -1e9));
if(it != st.end() && it->sum == to[i] - g[i][j]) {
puts("YES");
printf("%d %d\n", it->idx + 1, it->rem + 1);
printf("%d %d\n", i + 1, j + 1);
return 0;
}
}

for(int j = 0; j < n; ++j)
st.insert(node(i, to[i] - g[i][j], j));
}

puts("NO");

return 0;
}
Copy The Code &

Input

cmd
2
5
2 3 1 3 2
6
1 1 2 2 2 1

Output

cmd
YES
2 6
1 2