/*
  [BAPC'06] HIGH SPIES
  by: Jan Kuipers
*/

using namespace std;

#include <iostream>
#include <vector>

vector<vector<int> > num,capfr,capto;
vector<int> path;

int findpath (int fr, int to, int prev) {
  path.push_back(fr);
  if (fr==to) return 1;

  for (int i=0; i<num[fr].size(); i++)
    if (num[fr][i]!=prev && findpath(num[fr][i],to,fr)) return 1;
    
  path.pop_back();
  return 0;
}

int main () {

  int runs;
  cin>>runs;
  while (runs--) {

    int N;
    cin>>N;

    num = capfr = capto = vector<vector<int> >(N);

    for (int i=0; i<N-1; i++) {
      int a,b,ab,ba;
      cin>>a>>b>>ab>>ba;
      a--; b--;
      num[a].push_back(b);
      capto[a].push_back(ab);
      capfr[a].push_back(ba);
      
      num[b].push_back(a);
      capto[b].push_back(ba);
      capfr[b].push_back(ab);
    }

    int fr,to;
    cin>>fr>>to;
    fr--; to--;

    path.clear();
    findpath(fr,to,-1);

    int minres=capto[fr][0], maxres=capto[fr][0];
    
    for (int i=1; i<path.size()-1; i++) {
      int sum=0;
      for (int j=0; j<capto[path[i]].size(); j++)
	sum += capto[path[i]][j];

      int Ifr=-1,Ofr=-1,Ito=-1,Oto=-1;
      
      for (int j=0; j<num[path[i]].size(); j++)
	if (num[path[i]][j]==path[i-1]) {
	  Ifr=capfr[path[i]][j];
	  Ofr=capto[path[i]][j];
	}
	else if (num[path[i]][j]==path[i+1]) {
	  Ito=capfr[path[i]][j];
	  Oto=capto[path[i]][j];
	}
      
      int minpos = Ifr + (Ito-Ofr>?0) - sum + Ofr + Oto >? 0;
      int maxpos = Ifr <? Oto;

      for (int j=0; j<num[path[i]].size(); j++) {
	if (num[path[i]][j]==path[i-1] || num[path[i]][j]==path[i+1]) continue;
	maxpos <?= sum - capfr[path[i]][j] - capto[path[i]][j];
      }	 

      maxres <?= maxpos;
      minres <?= (minres+minpos-Ifr) >? 0;
    }

    cout << minres << " " << maxres << endl;
  }

  return 0;
}
