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