#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX - 1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i];
    }
    cout << min(sum, m) << "\n";
  }
  return 0;
}
