#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int ar[n];
    int su = 0;
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
      su += ar[i];
    }
    int ans = min(su, m);
    cout << ans << "\n";
  }
}
