#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k;
  int m;
  int ctr;
  for (int i = 0; i < n; i++) {
    ctr = 0;
    cin >> k;
    cin >> m;
    int arr[k];
    for (int j = 0; j < k; j++) {
      cin >> arr[j];
    }
    while ((arr[0] < m) && (ctr < k - 1)) {
      ctr++;
      arr[0] += arr[ctr];
    }
    if (arr[0] < m) {
      cout << arr[0] << endl;
    } else {
      cout << m << endl;
    }
  }
  return 0;
}
