#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i != 0) {
        ans = ans + a[i];
      }
    }
    if (ans + a[0] >= m) {
      cout << m << endl;
    } else {
      cout << ans + a[0] << endl;
    }
  }
  return 0;
}
