#include <bits/stdc++.h>
using namespace std;
vector<int> v[200010];
int down[200010], up[200010], tt[200010], ok[200010], str[20][200010],
    lvl[200010];
pair<int, int> jos[200010];
int len;
void dfs(int nod, int t) {
  int i, vecin;
  down[nod] = 1;
  tt[nod] = t;
  for (i = 0; i < v[nod].size(); i++) {
    vecin = v[nod][i];
    if (vecin != t) {
      dfs(vecin, nod);
      down[nod] = max(down[nod], 1 + down[vecin]);
    }
  }
}
void dfs_up(int nod) {
  int i, vecin, cnt = 0;
  up[nod] = 1 + up[tt[nod]];
  for (i = 0; i < v[tt[nod]].size(); i++) {
    vecin = v[tt[nod]][i];
    if (vecin != nod && vecin != tt[tt[nod]]) {
      up[nod] = max(up[nod], 2 + down[vecin]);
    }
  }
  if (up[nod] >= len) cnt++;
  for (i = 0; i < v[nod].size(); i++) {
    vecin = v[nod][i];
    if (vecin != tt[nod]) {
      dfs_up(vecin);
      if (down[vecin] + 1 >= len) cnt++;
    }
  }
  if (cnt >= 3) ok[nod] = 1;
}
void dfs2(int nod, int t) {
  int i, vecin;
  str[0][nod] = t;
  jos[nod] = make_pair(0, nod);
  for (i = 0; i < v[nod].size(); i++) {
    vecin = v[nod][i];
    if (vecin != t) {
      lvl[vecin] = 1 + lvl[nod];
      dfs2(vecin, nod);
      if (jos[vecin].first + 1 > jos[nod].first) {
        jos[nod] = make_pair(jos[vecin].first + 1, jos[vecin].second);
      }
    }
  }
}
int go_up(int cod, int nod) {
  for (int i = 19; i >= 0; i--) {
    if (cod & (1 << i)) nod = str[i][nod];
  }
  return nod;
}
int lca(int a, int b) {
  if (lvl[a] > lvl[b])
    a = go_up(lvl[a] - lvl[b], a);
  else if (lvl[b] > lvl[a])
    b = go_up(lvl[b] - lvl[a], b);
  if (a == b) return a;
  for (int i = 19; i >= 0; i--) {
    if (str[i][a] != str[i][b]) {
      a = str[i][a];
      b = str[i][b];
    }
  }
  return str[0][a];
}
int main() {
  FILE *fin = stdin;
  FILE *fout = stdout;
  int ts, n = 0, x, y, h, t, i, nod, root, j;
  fscanf(fin, "%d\n", &ts);
  for (; ts; ts--) {
    for (i = 1; i <= n; i++) {
      v[i].clear();
      down[i] = up[i] = ok[i] = tt[i] = lvl[i] = 0;
      jos[i] = make_pair(0, i);
    }
    for (i = 0; i < 20; i++) {
      for (j = 1; j <= n; j++) {
        str[i][j] = 0;
      }
    }
    fscanf(fin, "%d%d%d", &n, &h, &t);
    for (i = 1; i < n; i++) {
      fscanf(fin, "%d%d", &x, &y);
      v[x].push_back(y);
      v[y].push_back(x);
    }
    dfs(h, 0);
    len = 1;
    nod = t;
    while (nod != h) {
      len++;
      nod = tt[nod];
    }
    dfs_up(h);
    root = 0;
    for (i = 1; i <= n; i++) {
      if (ok[i]) {
        root = i;
        break;
      }
    }
    if (!root) {
      fprintf(fout, "No\n");
      continue;
    }
    lvl[root] = 0;
    dfs2(root, 0);
    for (i = 1; i < 20; i++) {
      for (j = 1; j <= n; j++) {
        str[i][j] = str[i - 1][str[i - 1][j]];
      }
    }
    x = lca(h, t);
    int lvlmaxi = -1;
    if (x == h || x == t) {
      fprintf(fout, "Yes\n");
      continue;
    }
    int op = 1;
    while (true) {
      if (lvl[t] - lvl[x] <= jos[h].first || lvl[h] - lvl[x] <= jos[t].first) {
        fprintf(fout, "YES\n");
        break;
      }
      op++;
      if (op > n) {
        fprintf(fout, "NO\n");
        break;
      }
      t = go_up(jos[h].first, t);
      h = jos[h].second;
      lvlmaxi = lvl[jos[h].second];
      swap(h, t);
    }
  }
  return 0;
}
