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