#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}



//#define solvsh
//#define multi

#ifdef solvsh


#else

const int MAXN = 40;
const int MAXLOG = 20;


vector<int> t;
int n;

ll mod = 1e9 + 7;

ll ml(ll a, ll b) {
    if (b < 0)
        return ml(a, (mod + b) % mod);

    return (a * b) % mod;
}

void init (int nn)
{
    n = nn;
    t.assign (n, 0);
}

int sum (int r)
{
    int result = 0;
    for (; r >= 0; r = (r & (r+1)) - 1)
        result += t[r];
    return result;
}

void inc (int i, int delta)
{
    for (; i < n; i = (i | (i+1)))
        t[i] += delta;
}

int sum (int l, int r)
{
    return sum (r) - sum (l-1);
}


ll b_p(ll b, ll p) {
    if (p == 0)
        return 1;
    if (p % 2)
        return ml(b, b_p(b, p - 1));
    ll v = b_p(b, p >> 1);
    return ml(v, v);
}

ll divv(ll a, ll b) {
    if (b < 0) {
        return ml(a, b_p((mod + b) % mod, mod - 2));
    }
    return ml(a, b_p(b, mod - 2));
}

int cmp(ll a, ll b) {
    return abs(a) < abs(b);
}

void solve() {


    int n, k;
    cin >> n >> k;

    ll prod = 1;

    vector<ll> v;

    for (int i = 0; i < n; ++i) {
        ll curr;
        cin >> curr;
        if (curr != 0) {
            v.push_back(curr);
        }
    }

    if (v.size() < k)
    {
        cout << 0;
        return;
    }

    sort(all(v), cmp);
    reverse(all(v));

    int s = 1;

    ll bad = -1e10;
    ll bad_pos = -1;

    for (int i = 0; i < k; ++i) {
        prod = ml(prod, v[i]);
        s *= v[i] > 0 ? 1 : -1;

        if (v[i] < 0 && -bad > -v[i]) {
            bad = v[i];
        }
        if (v[i] > 0) {
            bad_pos = v[i];
        }
    }

    if (s == 1) {
        cout << prod;
        return;
    }

    ll save = prod;

    bool ok1 = false;
    bool ok2 = false;

    prod = divv(prod, bad);

    ll coef1 = 1;
    ll coef2 = 1;

    for (int i = k; i  < v.size(); ++ i) {
        if (v[i] > 0) {
            prod = ml(prod, v[i]);
            ok1 = true;
            coef1 = v[i];
            break;
        }
    }
    ll ans1 = prod;
    prod = save;

    if (bad_pos != -1) {
        
        prod = divv(prod, bad_pos);
        for (int i = k; i  < v.size(); ++ i) {
            if (v[i] < 0) {
                ok2 = true;
                prod = ml(prod, v[i]);
                coef2 = v[i];
                break;
            }
        }
    }
    ll ans2 = prod;
    
    if (ok1 && ok2) {
        if (coef1 * bad_pos > coef2 * bad) cout << ans1;
        else cout << ans2;
        return;
    } else if (ok1) {
        cout << ans1;
        return;
    } else if (ok2 ) {
        cout << ans2;
        return;
    }

    if (v.size() < n) {
        cout << 0;
        return;
    }

    reverse(all(v));
    prod = 1;
    for (int i = 0; i < k; ++i) {
        prod = ml(prod, v[i]);
    }

    cout << prod;
}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 5300