#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() {
  cerr << "CPU time: " << double(clock()) / CLOCKS_PER_SEC << "\n";
  return;
}
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int, int>;
void solve() {
  int n, m;
  cin >> n >> m;
  vi a(n);
  for (decltype(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> a[i];
  int sum = accumulate((a).begin(), (a).end(), 0);
  cout << min(m, sum) << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  cpuTime();
  return 0;
}
