#include <bits/stdc++.h>
using namespace std;
int n, m, k, t;
int dr[] = {0, -1, 0, 1};
int dc[] = {-1, 0, 1, 0};
int ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      sum += a;
    }
    cout << min(m, sum) << '\n';
  }
  return 0;
}
