#include #define int long long #define double long double #define F first #define S second using namespace std; void solve(){ int n; cin>>n; int cu=1e9,a,b,c,d,e; for(int i=1;i<=n;i++){ cin>>a>>b>>c>>d>>e; int flow1=min(a,b)+min(min(max(a-b,0ll),c)+d,e); int flow2=min(d,e)+min(min(max(d-e,0ll),c)+a,b); cu=min(cu,max(flow1,flow2)); //cout<>t; for(int i=1;i<=t;i++){ solve(); } return 0; }