#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 10;
int T, L;
int p, n, a, b, cnt;
int f[maxN + 1], fa[maxN + 1][22], lg[maxN + 1];
int dep[maxN + 1], h[maxN + 1], s[maxN + 1];
int dfn[maxN + 1], sz[maxN + 1];
vector<int> to[maxN + 1];
pair<int, int> mx[maxN + 1];
inline void dfs1(int u, int pa) {
  dep[u] = dep[pa] + 1;
  f[u] = pa;
  for (auto v : to[u]) {
    if (v == pa) continue;
    dfs1(v, u);
  }
}
inline void dfs2(int u, int pa) {
  h[u] = 0;
  for (auto v : to[u]) {
    if (v == pa) continue;
    dfs2(v, u);
    if (h[v] + 1 >= L) s[u]++;
    h[u] = max(h[u], h[v] + 1);
  }
}
inline void dfs3(int u, int pa, int d) {
  if (d >= L) s[u]++;
  int mx1 = 0, mx2 = 0, w = 0;
  for (auto v : to[u])
    if (v != pa && h[v] + 1 > mx1) mx1 = h[v] + 1, w = v;
  for (auto v : to[u]) {
    if (v == pa || v == w) continue;
    dfs3(v, u, max(d, mx1) + 1);
    mx2 = max(mx2, h[v] + 1);
  }
  if (w) dfs3(w, u, max(d, mx2) + 1);
}
inline void dfs4(int u, int pa) {
  dfn[u] = ++cnt;
  dep[u] = dep[pa] + 1;
  fa[u][0] = pa;
  for (int i = 1; (1 << i) <= dep[u]; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  mx[u] = pair<int, int>(0, u);
  sz[u] = 1;
  for (auto v : to[u]) {
    if (v == pa) continue;
    dfs4(v, u);
    mx[u] = max(mx[u], pair<int, int>(mx[v].first + 1, mx[v].second));
    sz[u] += sz[v];
  }
}
inline int get(int u, int x) {
  for (int i = lg[x]; i >= 0; i--)
    if (x >> i & 1) u = fa[u][i];
  return u;
}
inline bool in(int u, int rt) {
  return dfn[u] >= dfn[rt] && dfn[u] <= dfn[rt] + sz[rt] - 1;
}
inline bool check() {
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    to[i].clear();
    s[i] = 0;
    for (int j = 0; j <= 20; j++) fa[i][j] = 0;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    to[x].push_back(y);
    to[y].push_back(x);
  }
  dfs1(1, 0);
  L = 0;
  int x = a, y = b;
  while (x != y) {
    L++;
    if (dep[x] < dep[y]) swap(x, y);
    x = f[x];
  }
  dfs2(1, 0);
  dfs3(1, 0, 0);
  p = 0;
  for (int i = 1; i <= n; i++)
    if (s[i] >= 3) {
      p = i;
      break;
    }
  if (!p) return false;
  cnt = 0;
  dfs4(p, 0);
  for (int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
  if (in(a, b) || in(b, a)) return true;
  for (int i = 1; i <= n + 10; i++) {
    pair<int, int> now = mx[a];
    a = now.second;
    b = get(b, min(dep[b] - 1, now.first));
    if (in(a, b)) return true;
    swap(a, b);
  }
  return false;
}
int main() {
  scanf("%d", &T);
  while (T--) puts(check() ? "YES" : "NO");
  return 0;
}
