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