#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <ctime>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <string>
using namespace std;
#define int long long
#define mod99 998244353
#define f first
#define s second
#define pb push_back
#define mod 998244353
#define INF 1e9 + 7
#define ll long long
#define get_time (double)clock() / (double)(CLOCKS_PER_SEC)
#ifndef ONLINE_JUDGE
#define debug(x) cerr << (#x) << ": " << x << endl;
#else
#define debug(x)
#endif
//#define endl '\n'
int min(int a, int b) {
if (a <= b) return a;
return b;
}
int max(int a, int b) {
if (a >= b) return a;
return b;
}
int gcd(int a, int b) {
while (a > 0 && b > 0) {
int c = a;
a = b % a;
b = c;
}
return a + b;
}
int bin_pow(int a, int n) {
if (n == 0) return 1;
if (n % 2 == 0) {
ll t = bin_pow(a, n / 2) % mod;
return (t * t) % mod;
}
else {
ll t = bin_pow(a, n - 1);
return (t * a) % mod;
}
}
int bs_sqrt(int x) {
int l = 0, r = INF;
while (r - l > 1) {
int m = (r + l) / 2;
if (m * m <= x) {
l = m;
}
else {
r = m;
}
}
return l;
}
vector<int> in_2(int a) {
vector<int> ret;
while (a > 0) {
ret.push_back(a % 2);
a /= 2;
}
return ret;
}
int rev(int a) {
return bin_pow(a, mod - 2);
}
void solve() {
int k;
cin >> k;
int n = bin_pow(2, k + 1);
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<pair<int, int> > otr;
vector<int> pref(n + 1);
for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] ^ a[i - 1];
map<int, int> last;
last[0] = -1;
int cur = 0;
for (int i = 0; i < n; i++) {
cur = (cur ^ a[i]) % bin_pow(2, k);
if (last.count(cur)) {
otr.push_back({ last[cur] + 1, i });
}
last[cur] = i;
}
map<int, pair<int, int> > get;
for (int i = 0; i < otr.size(); i++) {
int l = otr[i].first, r = otr[i].second;
int cur_xor = pref[r + 1] ^ pref[l];
if (get.count(cur_xor)) {
int lp = get[cur_xor].first, rp = get[cur_xor].second;
if (lp < l) {
swap(l, lp);
swap(r, rp);
}
if (r < lp) {
cout << l + 1 << " " << r + 1 << " " << lp + 1 << " " << rp + 1 << endl;
return;
}
cout << l + 1 << " " << lp - 1 + 1 << " " << min(rp, r) + 1 + 1 << " " << max(rp, r) + 1 << endl;
return;
}
get[cur_xor] = { l,r };
}
}
signed main() {
cout << fixed << setprecision(20);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
/*
1
4 6 5 2
1 2 1
2 3 1
3 4 1
1 2 70
2 3 120
3 4 4
4 90
4 2
4 10
4 37
2 34
*/
112. Path Sum | 1556A - A Variety of Operations |
136. Single Number | 169. Majority Element |
119. Pascal's Triangle II | 409. Longest Palindrome |
1574A - Regular Bracket Sequences | 1574B - Combinatorics Homework |
1567A - Domino Disaster | 1593A - Elections |
1607A - Linear Keyboard | EQUALCOIN Equal Coins |
XOREQN Xor Equation | MAKEPAL Weird Palindrome Making |
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |
1002. Find Common Characters | 1602A - Two Subsequences |
1555A - PizzaForces | 1607B - Odd Grasshopper |
1084A - The Fair Nut and Elevator | 1440B - Sum of Medians |
1032A - Kitchen Utensils | 1501B - Napoleon Cake |
1584B - Coloring Rectangles | 1562B - Scenes From a Memory |
1521A - Nastia and Nearly Good Numbers | 208. Implement Trie |