#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main() {
  int t, n, m;
  cin >> t;
  while (t--) {
    int sum = 0;
    int le = 0;
    cin >> n >> m;
    for (int h = 0; h < n; h++) {
      cin >> a[h];
      if (h > 0) {
        sum += a[h];
      }
    }
    int rem = m - a[0];
    le = sum;
    if (rem <= le) {
      le = le - rem;
      a[0] = m;
    } else {
      a[0] = a[0] + le;
      le = 0;
    }
    cout << a[0] << ' ';
  }
}
