#include <bits/stdc++.h>
using namespace std;
int const N = 100000, inf = 1e9;
int n, a, b, mns, mxs, ln;
vector<int> tr[N + 1], sn;
vector<pair<int, int> > mxdp[N + 1];
bool vis[N + 1], good[N + 1];
int D;
bool go1(int v, int p = 0) {
  if (v == D) {
    sn.push_back(v);
    return true;
  }
  for (int u : tr[v])
    if (u != p && go1(u, v)) {
      sn.push_back(v);
      return true;
    }
  return false;
}
void upmxdp(int v, pair<int, int> t) {
  for (int i = 0; i < (int)(3); ++i)
    if (t.first > mxdp[v][i].first) {
      for (int j = 2; j > i; --j) mxdp[v][j] = mxdp[v][j - 1];
      mxdp[v][i] = t;
      break;
    }
}
void go2(int v = 1, int p = 0) {
  for (int u : tr[v])
    if (u != p) {
      go2(u, v);
      pair<int, int> t = make_pair(mxdp[u][0].first + 1, u);
      upmxdp(v, t);
    }
}
void go3(int v = 1, int p = 0, int d = 0) {
  upmxdp(v, make_pair(d, p));
  for (int u : tr[v])
    if (u != p)
      go3(u, v,
          u == mxdp[v][0].second ? mxdp[v][1].first + 1 : mxdp[v][0].first + 1);
}
bool go4(int v) {
  vis[v] = true;
  if (good[v]) return true;
  for (int u : tr[v])
    if (!vis[u] && go4(u)) return true;
  return false;
}
int gtm(int a, int b) {
  if (mxdp[a][0].second == b) return mxdp[a][1].first;
  return mxdp[a][0].first;
}
pair<int, int> gtmx() {
  int a = 0, b = sn.size() - 1, l = 0, r = sn.size() - 1;
  while (l >= a || r <= b) {
    while (a <= l) {
      r = min(
          r,
          max(0, (int)sn.size() - 1 -
                     gtm(sn[a], a + 1 == (int)sn.size() ? 0 : sn[a + 1]) + a));
      ++a;
    }
    while (b >= r) {
      l = max(l, min((int)sn.size() - 1,
                     gtm(sn[b], b ? sn[b - 1] : 0) - ((int)sn.size() - 1 - b)));
      --b;
    }
  }
  return make_pair(l, r);
}
bool solve() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i < (int)(n + 1); ++i) {
    tr[i].clear();
    mxdp[i].resize(3);
    for (int j = 0; j < (int)(3); ++j) mxdp[i][j] = make_pair(0, 0);
    vis[i] = false;
    good[i] = false;
  }
  mns = inf, mxs = -1;
  sn.clear();
  for (int i = 1; i < (int)(n); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  D = a;
  go1(b);
  go2();
  go3();
  ln = sn.size() - 1;
  for (int i = 1; i < (int)(n + 1); ++i)
    if (mxdp[i][0].first >= ln && mxdp[i][1].first >= ln &&
        mxdp[i][2].first >= ln)
      good[i] = true;
  for (int t : sn) vis[t] = true;
  for (int i = 0; i < (int)(sn.size()); ++i)
    if (go4(sn[i])) {
      mns = min(mns, i);
      mxs = max(mxs, i);
    }
  if (mxs == -1) return false;
  pair<int, int> t = gtmx();
  if (t.first >= mns) return true;
  if (t.second <= mxs) return true;
  return false;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) printf("%s\n", solve() ? "YES" : "NO");
}
