#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    long long m, n, a[1005], ans = 0, s = 0;
    cin >> n >> m;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      s += a[i];
    }
    ans = min(s, m);
    cout << ans << "\n";
  }
  return 0;
}
