#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
std::vector<int> solution (std::vector<int>& prices, int cost)
{
std::vector<int> result;
std::vector<int> sorted = prices;
std::sort(sorted.begin(), sorted.end());
for (int i = 0; i < prices.size(); i++)
{
if (std::binary_search(sorted.begin(), sorted.end(), cost - prices[i]))
{
result.push_back (i); // +1 because we count from 1
// using linear search
for (int j = i + 1; j < prices.size(); j++)
if (prices[i] + prices[j] == cost)
{
result.push_back (j); // +1 because we count from 1
return result;
}
}
}
return result;
}
int main() {
int ntests, cost, num_of_flavors, curr_price;
std::vector<int> prices, answer;
std::cin >> ntests;
for (int i = 0; i < ntests; i++)
{
std::cin >> cost >> num_of_flavors;
// Input prices
for (int j = 0; j < num_of_flavors; j++)
{
std::cin >> curr_price;
prices.push_back (curr_price);
}
answer = solution (prices, cost);
std::cout << (answer[0] + 1) << " " << (answer[1] + 1) << std::endl;
prices.clear();
}
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KCnN0ZDo6dmVjdG9yPGludD4gc29sdXRpb24gKHN0ZDo6dmVjdG9yPGludD4mIHByaWNlcywgaW50IGNvc3QpCnsKICAgIHN0ZDo6dmVjdG9yPGludD4gcmVzdWx0OwogICAgc3RkOjp2ZWN0b3I8aW50PiBzb3J0ZWQgPSBwcmljZXM7CiAgICAKICAgIHN0ZDo6c29ydChzb3J0ZWQuYmVnaW4oKSwgc29ydGVkLmVuZCgpKTsKICAgIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBwcmljZXMuc2l6ZSgpOyBpKyspCiAgICB7CiAgICAgICAgaWYgKHN0ZDo6YmluYXJ5X3NlYXJjaChzb3J0ZWQuYmVnaW4oKSwgc29ydGVkLmVuZCgpLCBjb3N0IC0gcHJpY2VzW2ldKSkKICAgICAgICB7CiAgICAgICAgICAgIHJlc3VsdC5wdXNoX2JhY2sgKGkpOyAgICAgICAgICAgIC8vICsxIGJlY2F1c2Ugd2UgY291bnQgZnJvbSAxCiAgICAgICAgICAgIC8vIHVzaW5nIGxpbmVhciBzZWFyY2gKICAgICAgICAgICAgZm9yIChpbnQgaiA9IGkgKyAxOyBqIDwgcHJpY2VzLnNpemUoKTsgaisrKQogICAgICAgICAgICAgICAgaWYgKHByaWNlc1tpXSArIHByaWNlc1tqXSA9PSBjb3N0KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoX2JhY2sgKGopOyAgIC8vICsxIGJlY2F1c2Ugd2UgY291bnQgZnJvbSAxCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0Owp9CgppbnQgbWFpbigpIHsKICAgIGludCBudGVzdHMsIGNvc3QsIG51bV9vZl9mbGF2b3JzLCBjdXJyX3ByaWNlOwogICAgc3RkOjp2ZWN0b3I8aW50PiBwcmljZXMsIGFuc3dlcjsKICAgIAogICAgc3RkOjpjaW4gPj4gbnRlc3RzOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBudGVzdHM7IGkrKykKICAgIHsKICAgICAgICBzdGQ6OmNpbiA+PiBjb3N0ID4+IG51bV9vZl9mbGF2b3JzOwogICAgICAgIAogICAgICAgIC8vIElucHV0IHByaWNlcwogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbnVtX29mX2ZsYXZvcnM7IGorKykKICAgICAgICB7CiAgICAgICAgICAgIHN0ZDo6Y2luID4+IGN1cnJfcHJpY2U7CiAgICAgICAgICAgIHByaWNlcy5wdXNoX2JhY2sgKGN1cnJfcHJpY2UpOwogICAgICAgIH0KICAgICAgICBhbnN3ZXIgPSBzb2x1dGlvbiAocHJpY2VzLCBjb3N0KTsKICAgICAgICBzdGQ6OmNvdXQgPDwgKGFuc3dlclswXSArIDEpIDw8ICIgIiA8PCAoYW5zd2VyWzFdICsgMSkgPDwgc3RkOjplbmRsOwogICAgICAgIHByaWNlcy5jbGVhcigpOwogICAgfQogICAgcmV0dXJuIDA7Cn0=