#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a, b, len;
int f;
vector<int> g[N];
vector<pair<int, int>> dp[N];
int cor1[N], cor2[N];
int gl[N];
int glu[N];
deque<int> snake;
int dfs1(int v, int p, int tek_len) {
  snake.push_back(v);
  if (v == b) {
    len = tek_len;
    return 1;
  }
  for (auto e : g[v]) {
    if (e == p) continue;
    if (dfs1(e, v, tek_len + 1)) return 1;
  }
  snake.pop_back();
  return 0;
}
void dfs2(int v, int p) {
  gl[v] = 1;
  for (auto e : g[v]) {
    if (e == p) continue;
    dfs2(e, v);
    gl[v] = max(gl[v], gl[e] + 1);
  }
}
void dfs3(int v, int p) {
  int max_i = -1;
  int max_len = 0;
  for (auto e : g[v]) {
    if (e == p) continue;
    int tek_len = gl[e] + 1;
    if (tek_len > max_len) {
      max_len = tek_len;
      max_i = e;
    }
  }
  for (auto e : g[v]) {
    if (e == p || e == max_i) continue;
    glu[e] = max(glu[v] + 1, max_len);
  }
  max_len = 0;
  for (auto e : g[v]) {
    if (e == p || e == max_i) continue;
    max_len = max(max_len, gl[e] + 1);
  }
  if (max_i != -1) glu[max_i] = max(glu[v] + 1, max_len);
  int cnt = 0;
  for (auto e : g[v]) {
    if (e == p) continue;
    if ((gl[e] + 1) >= len) cnt++;
  }
  if ((glu[v] + 1) >= len) cnt++;
  if (cnt >= 3) f = 1;
  for (auto e : g[v]) {
    if (e == p) continue;
    dfs3(e, v);
  }
}
void dfs4(int v, int p) {
  for (auto e : g[v]) {
    if (e == p) continue;
    dfs4(e, v);
    dp[v].push_back({gl[e] + 1, e});
  }
  if (p != -1) dp[v].push_back({glu[v], p});
  sort(dp[v].begin(), dp[v].end());
  reverse(dp[v].begin(), dp[v].end());
}
int get(int a, int b) {
  if (dp[b][0].second == a) {
    if (dp[b].size() == 1)
      return -1;
    else
      return dp[b][1].second;
  } else {
    return dp[b][0].second;
  }
}
void solve() {
  cin >> n >> a >> b;
  a--;
  b--;
  for (int i = 0; i < n; i++) g[i].assign(0, 0);
  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);
  }
  while (snake.size()) snake.pop_front();
  dfs1(a, -1, 1);
  dfs2(0, -1);
  glu[0] = 0;
  f = 0;
  dfs3(0, -1);
  if (!f) {
    cout << "NO\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    dp[i].assign(0, {0, 0});
  }
  dfs4(0, -1);
  f = 0;
  for (int i = 0; i < n; i++) {
    cor1[i] = 0;
    cor2[i] = 0;
  }
  cor1[a] = 1;
  cor2[b] = 1;
  int max_len = -1;
  int nxt = 0;
  while (true) {
    max_len = 0;
    a = snake[snake.size() - 2];
    b = snake[snake.size() - 1];
    nxt = get(a, b);
    while (nxt != -1) {
      max_len++;
      a = b;
      b = nxt;
      snake.pop_front();
      snake.push_back(nxt);
      cor1[snake[0]] = 1;
      cor2[snake[snake.size() - 1]] = 1;
      nxt = get(a, b);
    }
    a = snake[1];
    b = snake[0];
    nxt = get(a, b);
    while (nxt != -1) {
      max_len--;
      a = b;
      b = nxt;
      snake.pop_back();
      snake.push_front(nxt);
      cor1[snake[0]] = 1;
      cor2[snake[snake.size() - 1]] = 1;
      nxt = get(a, b);
    }
    if (max_len == 0) {
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    f |= (cor1[i] & cor2[i]);
  }
  if (f) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
signed main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
