#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n, m;
  cin >> n >> m;
  int i, s = 0;
  for (i = 0; i < n; i++) {
    int k;
    cin >> k;
    s += k;
  }
  cout << min(s, m);
  cout << "\n";
  return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
