#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MM = 1e5 + 5;
int num[1005];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
    int sum = 0;
    for (int i = 1; i <= n; i++) sum += num[i];
    printf("%d\n", min(sum, m));
  }
  return 0;
}
