#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k1, k2, k3, prev, l = 0, r = 0, last = 0;
cin >> n >> k1 >> k2 >> k3 >> prev;
for (int i = 1; i < n; i++) {
int cur;
cin >> cur;
if (abs(prev % 4 - cur % 4) > k1 || abs(prev % 5 - cur % 5) > k2 || abs(prev % 8 - cur % 8) > k3) {
if (i - last > r - l + 1)
l = last, r = i - 1;
last = i;
}
prev = cur;
}
if (n - last > r - l + 1)
l = last, r = n - 1;
cout << l + 1 << ' ' << r + 1 << '\n';
}
Copy