#include <bits/stdc++.h>
using namespace std;
int t, n, m, bil, rata2;
int main() {
  cin >> t;
  for (int tc = 1; tc <= t; tc++) {
    rata2 = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      cin >> bil;
      rata2 += bil;
    }
    cout << min(m, rata2) << endl;
  }
}
