#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
long long rnd() {
  unsigned long long ans = 0;
  for (int i = (int)(0); i <= (int)(4); i++) ans = ans << 15 ^ rand();
  return ans % ((unsigned long long)1 << 63);
}
const int N = 100005;
vector<int> v[N];
int n, x, y, tot, fff, m2[N], cnt[N], q[N], vis[N], ab[N], mm[N], mx[N], fa[N];
void dfs(int p) {
  for (auto i : v[p])
    if (i != fa[p]) {
      fa[i] = p;
      dfs(i);
    }
}
void bao(int p) {
  mx[p] = 1;
  cnt[p] = 0;
  for (auto i : v[p])
    if (i != fa[p]) {
      bao(i);
      if (mx[i] + 1 > mx[p]) {
        m2[p] = mx[p];
        mx[p] = mx[i] + 1;
      } else {
        m2[p] = max(m2[p], mx[i] + 1);
      }
      if (mx[i] + 1 >= tot) cnt[p]++;
    }
}
void ddd(int p) {
  mm[p] = 1;
  for (auto i : v[p])
    if (i != fa[p] && !vis[i]) {
      ddd(i);
      mm[p] = max(mm[i] + 1, mm[p]);
    }
}
void bbb(int p) {
  if ((ab[p] >= tot) + cnt[p] >= 3) fff = 1;
  for (auto i : v[p])
    if (i != fa[p]) {
      ab[i] = max(ab[i], ab[p] + 1);
      if (mx[i] + 1 == mx[p])
        ab[i] = max(ab[i], m2[p] + 1);
      else
        ab[i] = max(ab[i], mx[p] + 1);
      bbb(i);
    }
}
int main() {
  int T = read();
  for (int o = (int)(1); o <= (int)(T); o++) {
    n = read(), x = read(), y = read();
    for (int i = (int)(1); i <= (int)(n); i++) {
      v[i].clear();
      vis[i] = 0;
      m2[i] = mx[i] = mm[i] = ab[i] = fa[i] = 0;
    }
    for (int i = (int)(1); i <= (int)(n - 1); i++) {
      int s = read(), t = read();
      v[s].push_back(t);
      v[t].push_back(s);
    }
    dfs(x);
    tot = fff = 0;
    ab[x] = 1;
    for (int i = y; i != x; i = fa[i]) q[++tot] = i;
    q[++tot] = x;
    for (int i = (int)(1); i <= (int)(tot); i++) vis[q[i]] = 1;
    bao(x);
    bbb(x);
    if (!fff) {
      puts("NO");
      continue;
    }
    for (int i = (int)(1); i <= (int)(tot); i++) ddd(q[i]);
    int dx = 1, dy = tot, Dx = 1, Dy = tot;
    while (dx <= Dx || dy >= Dy) {
      int p = dx <= Dx ? q[dx] : q[dy];
      if (mm[p] >= tot) {
        fff = 0;
        break;
      }
      if (dx <= Dx) {
        Dy = min(Dy, tot - (mm[p] - dx));
        dx++;
      } else {
        Dx = max(Dx, 1 + (mm[p] - (tot - dy + 1)));
        dy--;
      }
    }
    if (fff)
      puts("NO");
    else
      puts("YES");
  }
}
