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

using namespace std;

#include <iostream>
#include <vector>

const int infty = 99999;
int N;
vector<vector<int> > num,capfr,capto,cap;
vector<int> path,u;

int findpath (int fr, int to) {

  if (u[fr]) return 0;
  
  path.push_back(fr);
  u[fr]=1;
  if (fr==to) return 1;

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

int match (int n, int max) {

  if (n==1) return max;
  if (u[n]) return 0;
  u[n]=1;
  
  for (int i=0; i<N; i++)
    if (!u[i] && cap[n][i]>0) {
      int tmp = match(i,max<?cap[n][i]);
      if (tmp) {
	cap[n][i]-=tmp;
	cap[i][n]+=tmp;
	return tmp;
      }
    }
  
  return 0;
}

int possible (int pi, int flow) {

  int wh=path[pi], fr=path[pi-1], to=path[pi+1];
  int n = num[wh].size();
  N = 2*n+2;

  cap = vector<vector<int> >(N, vector<int>(N,0));
  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++)
      if (i!=j) cap[i+2][j+2+n]=infty;
  for (int i=0; i<n; i++)
    cap[0][i+2] = capfr[wh][i];
  for (int i=0; i<n; i++)
    cap[i+2+n][1] = capto[wh][i];

  int fri=-1,toi=-1;
  
  for (int i=0; i<num[wh].size(); i++) {
    if (num[wh][i]==fr) fri=i;
    if (num[wh][i]==to) toi=i;
  }
  
  if (cap[0][fri+2] < flow) return 0;
  if (cap[toi+n+2][1] < flow) return 0;
  
  cap[0][fri+2]-=flow;
  cap[toi+n+2][1]-=flow;
  cap[fri+2][toi+n+2]=0;

  int total=0;
  for (int i=0; i<n; i++)
    total+=cap[0][i+2];

  int tmp;
  do {
    u=vector<int>(N,0);
    tmp=match(0,infty);
    total-=tmp;
  }
  while (tmp>0);

  return total==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--;

    u=vector<int>(N,0);
    path.clear();
    findpath(fr,to);

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

      int MAX=0;
      for (int j=0; j<capto[path[i]].size(); j++)
	MAX += capto[path[i]][j];
      
      for (int flow=0; flow<=MAX; flow++) 
	if (possible(i,flow)) {
	  minpos <?= flow;
	  maxpos >?= flow;
	}
      
      int total=-1;
      for (int j=0; j<num[path[i]].size(); j++)
	if (num[path[i]][j]==path[i-1])
	  total=capfr[path[i]][j];

      maxres <?= maxpos;
      minres <?= minres+minpos-total >? 0;
    }

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

  return 0;
}
