#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair pi; typedef pair, ll > pii; vector vec; vector > vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main(){ ll T; cin >> T; vector ans; for(ll i = 0; i < T; i++){ vector ABC(3, 0); cin >> ABC[0] >> ABC[1] >> ABC[2]; //順列生成の準備 vector J(3, 0); J[0] = 0; J[1] = 1; J[2] = 2; ll mn = INF; do{ ll ans = 0; //真ん中は最小か最大のポジションにつかないといけない if(J[1] == 1) continue; else if(J[0] == 1){ //Bを最小に揃える //B<*<* 右端から揃えていく if(ABC[1] <= 2) continue; ans += max(0LL, ABC[J[1]]-ABC[J[2]]+1); ll nxt = ABC[J[1]] - ans; if(nxt <= 1) continue; ans += max(0LL, ABC[1] -nxt +1); }else if(J[2] == 1){ //Bを最大に揃える //*<*