#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7, L = 20;
vector<int> g[N];
bool mark[N];
int cnt[N], len, dis[N], h[N], par[N][L], dp_d[N], dp_u[N], furth[N];
void dfs_dis(int v, int p) {
  for (int u : g[v])
    if (u != p) {
      dis[u] = dis[v] + 1;
      dfs_dis(u, v);
    }
}
void dfs_d(int v, int p) {
  for (int u : g[v])
    if (u != p) {
      dfs_d(u, v);
      dp_d[v] = max(dp_d[v], dp_d[u] + 1);
      cnt[v] += ((dp_d[u] + 1) >= len);
    }
}
void dfs_u(int v, int p) {
  cnt[v] += (dp_u[v] >= len);
  int mx = 0;
  for (int u : g[v])
    if (u != p) {
      dp_u[u] = max(dp_u[u], max(dp_u[v], mx) + 1);
      mx = max(mx, dp_d[u] + 1);
    }
  mx = 0;
  reverse(g[v].begin(), g[v].end());
  for (int u : g[v])
    if (u != p) {
      dp_u[u] = max(dp_u[u], max(dp_u[v], mx) + 1);
      mx = max(mx, dp_d[u] + 1);
      dfs_u(u, v);
    }
}
void dfs(int v, int p) {
  furth[v] = v;
  par[v][0] = p;
  for (int i = 1; i < L; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  for (int u : g[v])
    if (u != p) {
      h[u] = h[v] + 1;
      dfs(u, v);
      if (h[furth[u]] > h[furth[v]]) furth[v] = furth[u];
    }
}
int pr(int v, int x) {
  for (int i = 0; i < L; i++)
    if ((1 << i) & x) v = par[v][i];
  return v;
}
int dist(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  int ret = h[v] - h[u];
  v = pr(v, h[v] - h[u]);
  if (v == u) return ret;
  for (int i = L - 1; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      ret += (1 << (i + 1));
      v = par[v][i];
      u = par[u][i];
    }
  return ret + 2;
}
bool is_anc(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  return (pr(v, h[v] - h[u]) == u);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, a, b;
    cin >> n >> a >> b;
    a--;
    b--;
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    dis[a] = 0;
    dfs_dis(a, a);
    len = dis[b];
    dfs_d(0, 0);
    dfs_u(0, 0);
    int id = -1;
    for (int i = 0; i < n; i++)
      if (cnt[i] >= 3) id = i;
    bool fnd = false;
    if (id != -1) {
      h[id] = 0;
      dfs(id, id);
      bool cont = true;
      while (cont) {
        if (is_anc(a, b)) {
          fnd = true;
          break;
        }
        cont = false;
        int newA = furth[a];
        if (!mark[newA]) {
          mark[newA] = true;
          int d = dist(a, newA);
          b = pr(b, d);
          a = newA;
          if (is_anc(a, b)) {
            fnd = true;
            break;
          }
          cont = true;
        }
        int newB = furth[b];
        if (!mark[newB]) {
          mark[newB] = true;
          int d = dist(b, newB);
          a = pr(a, d);
          b = newB;
          if (is_anc(a, b)) {
            fnd = true;
            break;
          }
          cont = true;
        }
      }
    }
    if (fnd)
      cout << "YES\n";
    else
      cout << "NO\n";
    for (int i = 0; i < n; i++) {
      g[i].clear();
      mark[i] = false;
      cnt[i] = dp_d[i] = dp_u[i] = h[i] = dis[i] = 0;
      furth[i] = -1;
    }
  }
  return 0;
}
