#include <bits/stdc++.h>
using namespace std;
const unsigned seed =
    std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;
void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  a--, b--;
  vector<vector<int>> g(n);
  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);
  }
  vector<int> dis(n, -1);
  vector<int> last(n, -1);
  dis[a] = 0;
  queue<int> qq;
  qq.push(a);
  while (qq.size()) {
    int p = qq.front();
    qq.pop();
    for (int ne : g[p]) {
      if (dis[ne] != -1) continue;
      dis[ne] = dis[p] + 1;
      last[ne] = p;
      qq.push(ne);
    }
  }
  int D = dis[b];
  vector<int> he(n, -1);
  function<int(int, int)> dfs1 = [&](int cur, int pa) {
    he[cur] = 0;
    for (int ne : g[cur]) {
      if (ne == pa) continue;
      he[cur] = max(dfs1(ne, cur) + 1, he[cur]);
    }
    return he[cur];
  };
  dfs1(a, -1);
  int p = b;
  vector<int> path;
  while (p != a) {
    path.push_back(p);
    p = last[p];
  }
  path.push_back(a);
  reverse(path.begin(), path.end());
  ;
  int p1 = 0, p2 = path.size() - 1;
  int fp1 = 0, fp2 = p2;
  while (p1 + 1 < p2 && (fp1 <= p1 || fp2 >= p2)) {
    if (fp1 <= p1) {
      int he1 = INT_MIN / 2;
      for (int ne : g[path[fp1]]) {
        if (ne == path[fp1 + 1]) continue;
        if (he[ne] > he[path[fp1]]) continue;
        he1 = max(he1, he[ne] + 1);
      }
      p2 = min(p2, (int)path.size() - 1 + fp1 - he1);
      fp1++;
      continue;
    }
    if (fp2 >= p2) {
      p1 = max(p1, fp2 + he[path[fp2]] - (int)path.size() + 1);
      fp2--;
      continue;
    }
  };
  int ans = 0;
  function<void(int, int, int)> dfs2 = [&](int cur, int pa, int inh) {
    vector<pair<int, int>> pp;
    for (int ne : g[cur]) {
      if (ne == pa) continue;
      pp.push_back({he[ne] + 1, ne});
    };
    pp.push_back({inh, pa});
    sort(pp.begin(), pp.end());
    int ppN = pp.size();
    if (pp.size() >= 3) {
      ans = max(ans, pp[ppN - 3].first);
    }
    for (int ne : g[cur]) {
      if (ne == pa) continue;
      int nh = inh + 1;
      if (ne == pp.back().second) {
        nh = max(nh, pp[ppN - 2].first + 1);
      } else {
        nh = max(nh, pp[ppN - 1].first + 1);
      }
      dfs2(ne, cur, nh);
    }
  };
  dfs2(a, -1, 0);
  if (ans >= D && p1 + 1 >= p2)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  int T = 1;
  cin >> T;
  for (int i = 1; i <= T; i++) {
    solve();
  }
  cout.flush();
  return 0;
}
