#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m, tong;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n >> m;
    tong = 0;
    for (int j = 1; j <= n; j++) {
      int kk;
      cin >> kk;
      tong += kk;
    }
    if (tong > m)
      cout << m << endl;
    else
      cout << tong << endl;
  }
  return 0;
}
