#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int b, c, d, i, j, k, l, x, y, z, t, m, n;
  int a[1001];
  cin >> t;
  while (t--) {
    k = 0;
    cin >> n >> m;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      k += a[i];
    }
    cout << min(k, m) << endl;
  }
}
