#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && (c != '-')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int N = 1e5 + 10;
int n, x, y;
vector<int> e[N];
int len, p[N];
bool flag[N];
inline void dfs(int u, int fa) {
  flag[u] = (u == y);
  for (auto v : e[u])
    if (v != fa) {
      dfs(v, u), flag[u] |= flag[v];
    }
  if (flag[u]) p[++len] = u;
}
int dep[N], f[N], d[N];
inline int Dfs(int u, int fa) {
  dep[u] = 1;
  int cnt = 0, ret = 0;
  for (auto v : e[u])
    if (v != fa && !flag[v]) {
      ret |= Dfs(v, u), dep[u] = max(dep[u], dep[v] + 1);
      cnt += (dep[v] >= len - 1);
    }
  return ret | (cnt >= 2);
}
inline void solve() {
  n = read(), x = read(), y = read();
  for (register int i = (1); i <= (n); i++) e[i].clear();
  for (register int i = (1); i < (n); i++) {
    int x = read(), y = read();
    e[x].push_back(y), e[y].push_back(x);
  }
  len = 0, dfs(x, 0);
  for (register int i = (1); i <= (len); i++)
    f[i] = Dfs(p[i], 0), d[i] = dep[p[i]] - 1;
  if (f[1] || f[len]) return puts("YES"), void(0);
  int l = 1, r = len, nxtr = max(l + 1, l + (len - d[l]) - 1),
      nxtl = min(r - 1, r - (len - d[r]) + 1);
  while (233) {
    if (l == nxtl && r == nxtr) break;
    int tmpr = r, tmpl = l;
    while (l < nxtl) {
      ++l, tmpr = min(tmpr, max(l + 1, l + (len - d[l]) - 1));
      if (f[l]) return puts("YES"), void(0);
    }
    while (r > nxtr) {
      --r, tmpl = max(tmpl, min(r - 1, r - (len - d[r]) + 1));
      if (f[r]) return puts("YES"), void(0);
    }
    nxtl = tmpl, nxtr = tmpr;
  }
  if (l < r) return puts("NO"), void(0);
  int posr = 1e9;
  for (register int i = (r); i < (len); i++)
    if (d[i] >= len - 1) {
      posr = i;
      break;
    }
  for (register int i = (posr + 1); i <= (len); i++)
    if (i - posr + 1 + d[i] >= len) return puts("YES"), void(0);
  int posl = -1e9;
  for (register int i = (l); i >= (2); i--)
    if (d[i] >= len - 1) {
      posl = i;
      break;
    }
  for (register int i = (1); i < (posl); i++)
    if (posl + d[i] - (i - 1) >= len) return puts("YES"), void(0);
  puts("NO");
}
int main() {
  int T = read();
  while (T--) solve();
}
