#include <bits/stdc++.h>   using namespace std;   int main() {     int i, t, m, n;     cin >> t;     int arr[t];     for (i = 0; i < t; i++) {       int sum = 0, k = 0;       cin >> n >> m;       int arr1[n];       for (int j = 0; j < n; j++) {         cin >> arr1[j];         if (j != 0) sum += arr1[j];       }       k = arr1[0];       while (k < m) {         if (sum != 0) {           k++;           sum--;         } else           break;       }       arr[i] = k;     }     for (i = 0; i < t; i++) cout << arr[i] <<   n ;   }   