#include <bits/stdc++.h>
using namespace std;
const int _ = 1e5 + 7;
int Case, N, H, T;
vector<int> nxt[_];
vector<int> route;
bool vis[_];
bool dfsroute(int x, int t) {
  if (x == t) {
    route.push_back(x);
    return 1;
  }
  vis[x] = 1;
  for (auto p : nxt[x])
    if (!vis[p] && dfsroute(p, t)) {
      vis[x] = 0;
      route.push_back(x);
      return 1;
    }
  vis[x] = 0;
  return 0;
}
int mxdep[_];
bool can[_];
void dfscalc(int x) {
  vis[x] = 1;
  int cnt = 0;
  for (auto t : nxt[x])
    if (!vis[t]) {
      dfscalc(t);
      mxdep[x] = max(mxdep[t] + 1, mxdep[x]);
      can[x] |= can[t];
    }
  for (auto t : nxt[x])
    if (!vis[t]) cnt += mxdep[t] >= route.size() - 2;
  can[x] |= cnt >= 2;
  vis[x] = 0;
}
bool findroute(int x, int p, int l) {
  if (!l) return 1;
  for (auto t : nxt[x])
    if (t != p && findroute(t, x, l - 1)) return 1;
  return 0;
}
int plc[_];
bool solve1(int x, bool type) {
  return findroute(route[plc[x] + (type ? -1 : 1)], x, route.size() - 2);
}
bool solve(int h, int t) {
  memset(mxdep, 0, sizeof(mxdep));
  memset(plc, 0, sizeof(plc));
  memset(vis, 0, sizeof(vis));
  memset(can, 0, sizeof(can));
  route.clear();
  dfsroute(h, t);
  for (auto t : route) vis[t] = 1;
  for (auto t : route) {
    dfscalc(t);
    vis[t] = 1;
  }
  reverse(route.begin(), route.end());
  for (int i = 0; i < route.size(); ++i) plc[route[i]] = i;
  int mxl = mxdep[h], mxr = mxdep[t], pre_mxl = -1;
  vector<int> gol, gor;
  bool peo = 0;
  int posl = 0, posr = route.size() - 1;
  while ((peo || mxl != pre_mxl) && !(gol.size() + gor.size())) {
    if (peo) {
      while (posl + 2 < route.size() && posl < mxr) {
        ++posl;
        if (mxdep[route[posl]] >= route.size() - 1) gol.push_back(route[posl]);
        mxl = max(mxl, mxdep[route[posl]] - posl);
      }
    } else {
      pre_mxl = mxl;
      while (posr > 1 && posr >= route.size() - mxl) {
        --posr;
        if (mxdep[route[posr]] >= route.size() - 1) gor.push_back(route[posr]);
        mxr = max(mxr, mxdep[route[posr]] - ((int)route.size() - posr - 1));
      }
    }
    peo ^= 1;
  }
  if (can[route[0]] || can[route.back()]) return 1;
  if (gol.empty() && gor.empty()) return 0;
  int cnt = 0;
  bool fl = 0;
  for (int i = 0; i < route.size(); ++i)
    if (mxdep[route[i]] >= route.size() - 1) {
      ++cnt;
      if (can[route[i]]) return 1;
    }
  if (cnt >= 3) return 1;
  if (gol.size() == 2 || gor.size() == 2) return 1;
  if (gol.size()) {
    if (solve1(gol[0], 1)) return 1;
    for (int i = 1; i + 2 < route.size(); ++i)
      if (route[i] != gol[0] && mxdep[route[i]] >= route.size() - 1 &&
          solve1(route[i], 0))
        return 1;
  } else {
    if (solve1(gor[0], 0)) return 1;
    for (int i = 1; i + 2 < route.size(); ++i)
      if (route[i] != gor[0] && mxdep[route[i]] >= route.size() - 1 &&
          solve1(route[i], 1))
        return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  for (cin >> Case; Case; --Case) {
    cin >> N >> H >> T;
    for (int i = 1; i <= N; ++i) nxt[i].clear();
    for (int i = 1; i < N; ++i) {
      int p, q;
      cin >> p >> q;
      nxt[p].push_back(q);
      nxt[q].push_back(p);
    }
    cout << (solve(H, T) || solve(T, H) ? "YES" : "NO") << endl;
  }
  return 0;
}
