#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m, a[100000], i;
    int total = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      total += a[i];
    }
    if (m > total) {
      printf("%d\n", total);
    } else
      printf("%d\n", m);
  }
  return 0;
}
