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