#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> result(t);
  for (int i = 0; i < t; i++) {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    int sum = 0;
    for (int j = 0; j < n; j++) {
      cin >> v[j];
      sum += v[j];
    }
    if (sum < m) {
      result[i] = sum;
    } else {
      result[i] = m;
    }
  }
  for (int i = 0; i < t; i++) {
    cout << result[i] << endl;
  }
}
