#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using vi = vector<int>;
using pii = pair<int, int>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll x) { return (unsigned long long)rng() % x; }
const ll mod = 1000000007;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int N = 100100;
int n, a, b, prevv[N], mxdepth[N], cnt[N], pivot[N], pathlen, vis[N];
vi path;
multiset<int> mxset[N];
vi e[N];
set<int> pathst;
void dfs(int v, int p) {
  for (auto a : e[v])
    if (a != p) dfs(a, v);
  mxset[v].insert(0);
  for (auto a : e[v])
    if (a != p) {
      mxset[v].insert(*mxset[a].rbegin() + 1);
    }
}
void dfs2(int v, int p, int curmax) {
  if (curmax > 0) mxset[v].insert(curmax);
  set<pii> mxs;
  for (auto a : e[v])
    if (a != p) {
      mxs.insert(make_pair(*mxset[a].rbegin(), a));
    }
  for (auto a : e[v])
    if (a != p) {
      pii tp = make_pair(*mxset[a].rbegin(), a);
      mxs.erase(tp);
      if (((int)(mxs).size()))
        dfs2(a, v, max(curmax + 1, mxs.rbegin()->first + 2));
      else
        dfs2(a, v, curmax + 1);
      mxs.insert(tp);
    }
}
void dfs3(int v, int p) {
  prevv[v] = p;
  if (v == b) {
    while (v != -1) {
      path.push_back(v);
      pathst.insert(v);
      v = prevv[v];
    }
    return;
  }
  for (auto a : e[v])
    if (a != p) dfs3(a, v);
}
void dfs4(int v, int p, int root, int len) {
  if (cnt[v] >= 3) {
    pivot[root] = 1;
  }
  mxdepth[root] = max(mxdepth[root], len);
  for (auto a : e[v]) {
    if (a != p && !pathst.count(a)) dfs4(a, v, root, len + 1);
  }
}
void solve() {
  cin >> n >> a >> b;
  a--, b--;
  for (int i = 0; i < n; i++) e[i].clear();
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 0; i < n; i++) mxset[i].clear();
  for (int i = 0; i < n; i++) cnt[i] = 0;
  dfs(0, -1);
  dfs2(0, -1, 0);
  path.clear();
  pathst.clear();
  dfs3(a, -1);
  pathlen = ((int)(path).size()) - 1;
  bool ok = 0;
  for (int i = 0; i < n; i++) {
    auto it = mxset[i].rbegin();
    while (it != mxset[i].rend() && *it >= pathlen) {
      cnt[i]++;
      it++;
    }
    if (cnt[i] >= 3) ok = 1;
  }
  if (!ok) {
    cout << "NO\n";
    return;
  }
  for (int i = 0; i < n; i++) pivot[i] = 0, mxdepth[i] = 0, vis[i] = 0;
  for (auto a : path) {
    dfs4(a, -1, a, 0);
  }
  vis[path[0]] = 1;
  queue<pii> q;
  q.push(make_pair(0, 0));
  int l = 0, r = ((int)(path).size());
  bool alll = 0;
  while (!q.empty()) {
    int ind = q.front().first;
    if (ind < 0 || ind >= ((int)(path).size())) {
      q.pop();
      continue;
    }
    int v = path[ind];
    if (q.front().second == 0) {
      int mx = ind + pathlen - mxdepth[v];
      if (mx <= ind + 1) {
        alll = 1;
        break;
      }
      if (mx < r) {
        for (int i = mx; i < r; i++) {
          vis[path[i]] = 1;
          q.push(make_pair(i, 1));
        }
        r = mx;
      }
    } else {
      int mx = ind - pathlen + mxdepth[v];
      if (mx >= ind - 1) {
        alll = 1;
        break;
      }
      if (mx > l) {
        for (int i = l + 1; i < mx + 1; i++) {
          vis[path[i]] = 1;
          q.push(make_pair(i, 0));
        }
        l = mx;
      }
    }
    q.pop();
  }
  for (int i = 0; i < n; i++) {
    if (alll || (vis[i] && pivot[i])) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
