#include <bits/stdc++.h>
#pragma GCC optimized("-O3")
using namespace std;
const int NR = 1e5 + 20, oo = 1e5 + 10, MOD = 1e9 + 7;
const long double pi = 2 * acos(0.0);
int n, a, b, sw, t, cost[NR], sp_st[NR], sp_dr[NR], comp[NR], dp1[NR], dp2[NR],
    dp3[NR], good[NR], root;
pair<int, int> dist[NR];
vector<int> v[NR], st[NR];
deque<int> snake, dq;
bool is_snake[NR];
bool cmp(pair<int, int> i, pair<int, int> j) { return i.second > j.second; }
void dfs_build_snake(int nod, int prt) {
  snake.push_back(nod);
  if (nod == b) {
    sw = 1;
    return;
  }
  vector<int>::iterator it;
  for (it = v[nod].begin(); it != v[nod].end(); ++it) {
    if (*it == prt) continue;
    dfs_build_snake(*it, nod);
    if (sw) return;
  }
  snake.pop_back();
}
void bfs_build_distances() {
  vector<int>::iterator it;
  int nod;
  while (!dq.empty()) {
    nod = dq.front();
    dq.pop_front();
    for (it = v[nod].begin(); it != v[nod].end(); ++it) {
      if (is_snake[*it] || dist[*it].second) continue;
      dist[*it].second = dist[nod].second + 1;
      cost[*it] = dist[nod].second + 1;
      comp[*it] = comp[nod];
      dq.push_back(*it);
    }
  }
}
void dfs_extend(int nod, int val) {
  vector<int>::iterator it;
  for (it = v[nod].begin(); it != v[nod].end(); ++it) {
    if (cost[*it] < cost[nod] && !is_snake[*it]) {
      cost[*it] = cost[nod];
      dfs_extend(*it, nod);
    }
  }
}
int ad_max(int nod) {
  int sol = 0;
  vector<int>::iterator it;
  for (it = v[nod].begin(); it != v[nod].end(); ++it) {
    sol = max(sol, cost[*it]);
  }
  return sol;
}
int dfs_dp1(int nod, int tata) {
  vector<int>::iterator it;
  dp1[nod] = 1;
  dp2[nod] = 1;
  dp3[nod] = 1;
  for (it = v[nod].begin(); it != v[nod].end(); ++it) {
    if (*it == tata) continue;
    st[nod].push_back(dfs_dp1(*it, nod));
  }
  sort(st[nod].begin(), st[nod].end());
  if (st[nod].size() >= 1) {
    dp1[nod] += st[nod][st[nod].size() - 1];
  }
  if (st[nod].size() >= 2) {
    dp2[nod] += st[nod][st[nod].size() - 2];
  }
  if (st[nod].size() >= 3) {
    dp3[nod] += st[nod][st[nod].size() - 3];
  }
  if (nod == root) {
    if (dp3[nod] >= snake.size()) {
      good[comp[nod]] = 1;
    }
  }
  return dp1[nod];
}
void dfs_dp2(int nod, int tata, int len) {
  vector<int>::iterator it;
  if (min(dp1[nod], min(dp2[nod], max(dp3[nod], len + 1))) >= snake.size()) {
    good[comp[nod]] = 1;
  }
  for (it = v[nod].begin(); it != v[nod].end(); ++it) {
    if (*it == tata) continue;
    if (dp1[*it] + 1 == dp1[nod]) {
      dfs_dp2(*it, nod, max(len + 1, dp2[nod]));
    } else {
      dfs_dp2(*it, nod, max(len + 1, dp1[nod]));
    }
  }
}
void test_case() {
  vector<int>::iterator it;
  int i, j, x, y, max_st, max_dr, last_st, last_dr, answer;
  cin >> n >> a >> b;
  for (i = 1; i < n; ++i) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs_build_snake(a, 0);
  for (i = 0; i < snake.size(); ++i) {
    is_snake[snake[i]] = 1;
    comp[snake[i]] = snake[i];
  }
  for (i = 1; i <= n; ++i) {
    dist[i].first = i;
    dist[i].second = 0;
  }
  dq = snake;
  bfs_build_distances();
  sort(dist + 1, dist + n + 1, cmp);
  for (i = 1; i <= n; ++i) {
    dfs_extend(dist[i].first, dist[i].second);
  }
  for (i = 0; i < snake.size(); ++i) {
    sp_st[i + 1] = max(sp_st[i], ad_max(snake[i]) - i);
  }
  for (i = snake.size() - 1; i >= 0; --i) {
    sp_dr[snake.size() - i] =
        max(sp_dr[snake.size() - i - 1],
            ad_max(snake[i]) - ((int)snake.size() - 1 - i));
  }
  root = 1;
  dfs_dp1(1, 0);
  dfs_dp2(1, 0, 0);
  for (i = 0; i < snake.size(); ++i) {
    sp_st[i] = sp_st[i + 1];
    sp_dr[i] = sp_dr[i + 1];
  }
  last_st = sp_st[0];
  last_dr = sp_dr[0];
  for (;;) {
    max_dr = sp_dr[min((int)snake.size() - 1, last_st)];
    max_st = sp_st[min((int)snake.size() - 1, last_dr)];
    if (last_st == max_st && last_dr == max_dr) break;
    last_st = max_st;
    last_dr = max_dr;
  }
  answer = 0;
  for (i = 0; i <= min(max_dr, (int)snake.size() - 1); ++i) {
    if (good[snake[i]]) {
      answer = 1;
    }
  }
  for (i = 0; i <= min(max_st, (int)snake.size() - 1); ++i) {
    if (good[snake[snake.size() - 1 - i]]) {
      answer = 1;
    }
  }
  if (answer == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  snake.clear();
  dq.clear();
  sw = 0;
  for (i = 0; i <= n + 1; ++i) {
    v[i].clear();
    st[i].clear();
    dist[i] = {0, 0};
    comp[i] = 0;
    is_snake[i] = 0;
    sp_st[i] = 0;
    sp_dr[i] = 0;
    good[i] = 0;
    cost[i] = 0;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    test_case();
  }
  return 0;
}
