#include <bits/stdc++.h>
using namespace std;
const int NN = 11000;
int n;
int t, a[NN], sum, m;
int main() {
  scanf("%d%", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
    }
    printf("%d\n", min(sum, m));
  }
  return 0;
}
