#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int INF = 1e9 + 5;
vector<int> g[N];
int t, n, a, b, p[N], h[N], jump[N], down[N], up[N], deep[N];
void go(int u = 1, int pr = -1) {
  deep[u] = u;
  for (int v : g[u])
    if (v ^ pr) {
      p[v] = u, h[v] = h[u] + 1;
      int x = jump[u], y = jump[x];
      jump[v] = (h[u] + h[y] == h[x] << 1) ? y : u;
      go(v, u);
      if (h[deep[v]] > h[deep[u]]) deep[u] = deep[v];
    }
}
void forw(int u = 1, int pr = -1) {
  down[u] = 0;
  for (int v : g[u])
    if (v ^ pr) {
      forw(v, u);
      down[u] = max(down[u], 1 + down[v]);
    }
}
void bacw(int u = 1, int pr = -1) {
  vector<int> ch, pf({-INF});
  for (int v : g[u])
    if (v ^ pr) {
      ch.emplace_back(v);
      pf.emplace_back(max(pf.back(), down[v]));
    }
  for (int i = (int)ch.size() - 1, sf = -INF; i >= 0; --i) {
    int v = ch[i];
    up[v] = max(1 + up[u], 2 + max(pf[i], sf));
    sf = max(sf, down[v]);
  }
  for (int v : ch) bacw(v, u);
}
inline void relax(vector<int> &vec, int x) {
  if (x > vec[0])
    vec[2] = vec[1], vec[1] = vec[0], vec[0] = x;
  else if (x > vec[1])
    vec[2] = vec[1], vec[1] = x;
  else
    vec[2] = max(vec[2], x);
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  while (h[v] > h[u]) v = h[jump[v]] < h[u] ? p[v] : jump[v];
  while (u ^ v)
    (jump[u] ^ jump[v]) ? (u = jump[u], v = jump[v]) : (u = p[u], v = p[v]);
  return u;
}
int anc(int u, int k) {
  k = h[u] - k;
  while (h[u] > k) u = h[jump[u]] < k ? p[u] : jump[u];
  return u;
}
int main() {
  cin >> t;
  while (t--) {
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 1; i <= n; ++i) g[i].clear();
    for (int i = 1, u, v; i < n; ++i) {
      scanf("%d %d", &u, &v);
      g[u].emplace_back(v), g[v].emplace_back(u);
    }
    p[1] = -1, h[1] = 0, jump[1] = 1;
    go();
    int len = 0, x = a, y = b;
    while (x ^ y) {
      if (h[x] > h[y]) swap(x, y);
      ++len, y = p[y];
    }
    forw();
    up[1] = 0;
    bacw();
    int root = -1;
    for (int i = 1; i <= n; ++i) {
      vector<int> best({-INF, -INF, -INF});
      for (int j : g[i])
        if (j ^ p[i]) {
          relax(best, 1 + down[j]);
        }
      if (~p[i]) relax(best, up[i]);
      if (best[0] >= len and best[1] >= len and best[2] >= len) {
        root = i;
        break;
      }
    }
    if (root == -1) {
      puts("NO");
      continue;
    }
    p[root] = -1, h[root] = 0, jump[root] = root;
    go(root);
    bool ok = 0;
    int l = lca(a, b), best = -1;
    if (l == a or l == b)
      ok = 1;
    else
      while (n--) {
        int step = h[deep[a]] - h[a];
        if (step >= h[b] - h[l]) {
          ok = 1;
          break;
        }
        a = deep[a], best = h[a], b = anc(b, step), swap(a, b);
      }
    puts(ok ? "YES" : "NO");
  }
  return 0;
}
