#include <bits/stdc++.h>
using namespace std;
long long m, n, k, kmp, ans1, ans2 = 1, flag;
map<long long, pair<long long, long long> > mp;
vector<long long> str;
bool check(long long mid) {
  long long sum = 0, num = 0, cnt = 0, kk = 0, kmp;
  for (long long i = 0; i < m; i++) {
    if (str[i] <= mid) {
      if (num == n) {
        num = 0;
        kk += sum * 2;
        sum = 0;
      }
      num++;
      sum += str[i];
      cnt++;
      if (sum + kk <= k) {
        ans1 = cnt;
        ans2 = mid;
        flag = 1;
      }
    }
  }
  if (flag) {
    mp[mid].first = ans1;
    mp[mid].second = ans2;
  }
  return kk + sum > k;
}
void solve() {
  cin >> m >> n >> k;
  long long p;
  str.clear();
  for (long long i = 0; i < m; i++) {
    scanf("%lld", &p);
    str.push_back(p);
  }
  long long pos = k;
  for (long long l = 1, r = k; l <= r;) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      r = mid - 1;
      pos = mid;
    } else {
      l = mid + 1;
    }
  }
  check(pos - 1);
  if (!flag)
    cout << ans1 << " "
         << "1" << endl;
  else {
    if (mp[pos].first > mp[pos - 1].first)
      cout << mp[pos].first << " " << mp[pos].second << endl;
    else
      cout << mp[pos - 1].first << " " << mp[pos - 1].second << endl;
  }
}
int main() {
  long long T;
  scanf("%lld\n", &T);
  while (T--) {
    solve();
    mp.clear();
    ans1 = 0, ans2 = 1;
    flag = 0;
  }
}
