#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t;
  int a, sum;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> m;
    cin >> sum;
    for (int j = 0; j < n - 1; ++j) {
      cin >> a;
      sum += a;
    }
    cout << min(sum, m) << endl;
  }
  return 0;
}
