#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-12;
const long double pi = acos(-1.0);
long long mod_pow(long long x, long long n, long long m) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
struct modint {
  long long n;
  modint() : n(0) { ; }
  modint(long long m) : n(m) {
    if (n >= mod)
      n %= mod;
    else if (n < 0)
      n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) {
  a.n += b.n;
  if (a.n >= mod) a.n -= mod;
  return a;
}
modint operator-=(modint& a, modint b) {
  a.n -= b.n;
  if (a.n < 0) a.n += mod;
  return a;
}
modint operator*=(modint& a, modint b) {
  a.n = ((long long)a.n * b.n) % mod;
  return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
  if (n == 0) return modint(1);
  modint res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
long long inv(long long a, long long p) {
  return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
  fact[0] = modint(1);
  for (int i = 0; i < max_n - 1; i++) {
    fact[i + 1] = fact[i] * modint(i + 1);
  }
  factinv[max_n - 1] = modint(1) / fact[max_n - 1];
  for (int i = max_n - 2; i >= 0; i--) {
    factinv[i] = factinv[i + 1] * modint(i + 1);
  }
}
modint comb(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[b] * factinv[a - b];
}
struct lcagraph {
 private:
  int n;
  vector<vector<int>> G;
  vector<vector<int>> parent;
  vector<int> depth;
  int root;
  int tmp;

 public:
  lcagraph(int n_) {
    n = n_;
    G.resize(n);
    parent.resize(n);
    depth.resize(n);
    tmp = 0;
    int cop = n;
    while (cop) {
      tmp++;
      cop /= 2;
    }
    for (int i = 0; i < n; i++) parent[i].resize(tmp);
    root = 0;
  }
  lcagraph() {}
  void init(int n_) {
    n = n_;
    G.resize(n);
    parent.resize(n);
    depth.resize(n);
    tmp = 0;
    int cop = n;
    while (cop) {
      tmp++;
      cop /= 2;
    }
    for (int i = 0; i < n; i++) parent[i].resize(tmp);
    root = 0;
  }
  void add_edge(int a, int b) {
    G[a].push_back(b);
    G[b].push_back(a);
  }
  void dfs(int id, int fr, int d) {
    parent[id][0] = fr;
    depth[id] = d;
    for (int j = 0; j < G[id].size(); j++) {
      int to = G[id][j];
      if (to == fr) continue;
      dfs(to, id, d + 1);
    }
  }
  void complete(int r = 0) {
    root = r;
    dfs(root, -1, 0);
    for (int j = 0; j < tmp - 1; j++)
      for (int i = 0; i < n; i++) {
        if (parent[i][j] < 0)
          parent[i][j + 1] = -1;
        else
          parent[i][j + 1] = parent[parent[i][j]][j];
      }
  }
  int lca(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int k = 0; k < tmp; k++) {
      if ((depth[v] - depth[u]) >> k & 1) {
        v = parent[v][k];
      }
    }
    if (u == v) return u;
    for (int k = tmp - 1; k >= 0; k--) {
      if (parent[u][k] != parent[v][k]) {
        u = parent[u][k];
        v = parent[v][k];
      }
    }
    return parent[u][0];
  }
  int dep(int x) { return depth[x]; }
  int dist(int x, int y) {
    int l = lca(x, y);
    return depth[x] + depth[y] - 2 * depth[l];
  }
  int find_par(int a, int b) {
    int l = lca(a, b);
    if (l != a)
      return parent[a][0];
    else {
      int d = depth[b] - depth[a];
      d--;
      int res = b;
      for (int i = 0; i < tmp; i++)
        if (d & (1 << i)) {
          res = parent[res][i];
        }
      return res;
    }
  }
  int query(int len, int b, int na) {
    int l = lca(b, na);
    if (depth[na] - depth[l] < len) {
      int d = depth[na] + depth[b] - 2 * depth[l];
      d = d - len;
      int res = b;
      for (int i = 0; i < tmp; i++)
        if (d & (1 << i)) {
          res = parent[res][i];
        }
      return res;
    } else {
      int res = na;
      for (int i = 0; i < tmp; i++)
        if (len & (1 << i)) {
          res = parent[res][i];
        }
      return res;
    }
  }
};
const int mn = 1 << 18;
struct edge {
  int to;
  long long cost;
};
using Data = pair<int, int>;
vector<edge> G[mn];
vector<int> ids[mn];
vector<Data> memo[mn];
int root;
Data merge(Data a, Data b) {
  Data res;
  res = max(a, b);
  return res;
}
map<pair<int, int>, pair<int, int>> mp;
Data dfs(int id, int fr) {
  Data res;
  res = {0, id};
  for (edge e : G[id]) {
    if (e.to == fr) continue;
    Data nex = dfs(e.to, id);
    res = merge(res, nex);
    ids[id].push_back(e.to);
    memo[id].push_back(nex);
  }
  mp[{id, fr}] = res;
  res.first++;
  return res;
}
bool isgod[mn];
int ablen;
void invdfs(int id, int fr, Data pre) {
  vector<Data> v;
  for (Data d : memo[id]) v.push_back(d);
  if (fr >= 0) v.push_back(pre);
  int len = v.size();
  int cnt = 0;
  for (Data d : v) {
    if (d.first >= ablen) cnt++;
  }
  if (cnt >= 3)
    isgod[id] = true;
  else
    isgod[id] = false;
  vector<Data> le(len + 1);
  vector<Data> ri(len + 1);
  Data init_c = {0, id};
  le[0] = init_c;
  for (int i = 0; i < len; i++) {
    le[i + 1] = merge(le[i], v[i]);
  }
  ri[len] = init_c;
  for (int i = len - 1; i >= 0; i--) {
    ri[i] = merge(ri[i + 1], v[i]);
  }
  for (int i = 0; i < ids[id].size(); i++) {
    int to = ids[id][i];
    Data d = merge(le[i], ri[i + 1]);
    mp[{id, to}] = d;
    d.first++;
    invdfs(to, id, d);
  }
}
void yaru() {
  dfs(root, -1);
  invdfs(root, -1, {-1, -1});
}
void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  a--;
  b--;
  for (int i = 0; i < n; i++) {
    G[i].clear();
    ids[i].clear();
    memo[i].clear();
  }
  mp.clear();
  lcagraph lg(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back({y});
    G[y].push_back({x});
    lg.add_edge(x, y);
  }
  lg.complete();
  ablen = lg.dist(a, b);
  yaru();
  for (int i = 0; i < 2 * ablen + 2; i++) {
    int p = lg.find_par(a, b);
    int na = mp[{a, p}].second;
    int nb = lg.query(ablen, b, na);
    a = na, b = nb;
    swap(a, b);
  }
  vector<bool> can(n, false);
  int p = lg.find_par(a, b);
  queue<pair<int, int>> que;
  que.push({a, p});
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    can[p.first] = true;
    for (edge e : G[p.first]) {
      if (e.to == p.second) continue;
      que.push({e.to, p.first});
    }
  }
  string ans = "NO";
  for (int i = 0; i < n; i++)
    if (can[i] && isgod[i]) ans = "YES";
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
