#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  int i;
  int a;
  int sum = 0;
  for (i = 1; i <= n; i++) {
    cin >> a;
    sum += a;
  }
  cout << min(sum, m) << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
