#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define vi vector<int>

double f(double a, double s) {
  //2s = at2+2t
  //at2+2t-2s=0
  //d=4+16sa
  //
  double d = 4 + 8 * s * a;
  double t = (-2.0 + sqrt(d)) / (2.0 * a);
  double v = a * t;
  return (v + 1) * (v + 1);
}

signed main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a, m;
    cin >> n >> a >> m;
    vi vec(n);
    for (int i = 0; i < n; i++) {
      cin >> vec[i];
    }
    //sort(vec.begin(), vec.end());
    int l = 0;
    int r = 4e18;
    while (r - l > 1) {
      int h = (r + l) / 2;
      double ans = 0;
      for (int x: vec) {
        int y = min(x, h);
        auto tt = f(a, y);
        ans += tt;
      }
      if (ans + 0.1 >= m) {
        r = h;
      } else {
        l = h;
      }
    }
    cout << l << '\n';
  }
}