#include <bits/stdc++.h>
using namespace std;
int T, n;
const int N = 1e5 + 20;
bool cmp(int a, int b) { return a > b; }
struct node {
  int a[4];
  node() { memset(a, 0, sizeof a); }
  node operator+(int x) {
    a[3] = x;
    sort(a, a + 4, cmp);
    return *this;
  }
} t[N];
vector<int> G[N];
int dep[N], L[N], R[N], dfn, rk[N], flag[N], len, f[N], fa[N][21], vis[N];
void dfs(int u, int pre) {
  dep[u] = dep[pre] + 1;
  L[u] = ++dfn;
  rk[dfn] = u;
  for (int v : G[u])
    if (v != pre) dfs(v, u);
  R[u] = dfn;
}
void dfs1(int u, int pre) {
  t[u] = node();
  for (int v : G[u])
    if (v != pre) {
      dfs1(v, u);
      t[u] = t[u] + (t[v].a[0] + 1);
    }
}
void dfs2(int u, int pre) {
  if (t[u].a[2] >= len) flag[u] = 1;
  for (int v : G[u])
    if (v != pre) {
      if (t[u].a[0] == t[v].a[0] + 1)
        t[v] = t[v] + (t[u].a[1] + 1);
      else
        t[v] = t[v] + (t[u].a[0] + 1);
      dfs2(v, u);
    }
}
void dfs3(int u, int pre) {
  f[u] = u;
  fa[u][0] = pre;
  for (int i = 1; i <= 19; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  dep[u] = dep[pre] + 1;
  for (int v : G[u])
    if (v != pre) dfs3(v, u), f[u] = (dep[f[v]] > dep[f[u]]) ? f[v] : f[u];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
bool check(int x, int y) {
  int z = lca(x, y);
  while (1) {
    int tmp = f[x], tmp1 = dep[tmp] - dep[x];
    if (vis[tmp]) return 0;
    if (tmp1 >= dep[y] - dep[z]) return 1;
    for (int i = 19; i >= 0; i--)
      if ((tmp1 >> i) & 1) y = fa[y][i];
    x = tmp;
    vis[x] = 1;
    swap(x, y);
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    int s, t;
    scanf("%d%d%d", &n, &s, &t);
    dfn = 0;
    for (int i = 1; i <= n; i++) G[i].clear(), flag[i] = vis[i] = 0;
    for (int i = 1, x, y; i < n; i++)
      scanf("%d%d", &x, &y), G[x].push_back(y), G[y].push_back(x);
    dfs(s, 0);
    len = dep[t] - 1;
    dfs1(s, 0);
    dfs2(s, 0);
    int rt = 0;
    for (int i = 1; i <= n; i++)
      if (flag[i]) rt = i;
    bool ans = 0;
    if (rt) {
      dfs3(rt, 0);
      ans |= check(s, t);
    }
    printf(ans ? "yEs\n" : "nO\n");
  }
  return 0;
}
