#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> v[N], seq, sl, sr;
int n, a, b, dp[N][3], d[N], len;
inline void addv(int pos, int v) {
  int p = -1;
  for (int i = 0; i < 3; i++)
    if (v >= dp[pos][i]) {
      p = i;
      break;
    }
  if (p == -1) return;
  for (int i = 2; i > p; --i) dp[pos][i] = dp[pos][i - 1];
  dp[pos][p] = v;
}
void dfs1(int pos, int fa, int dep) {
  d[pos] = 0;
  if (pos == b) len = dep;
  for (auto &i : v[pos])
    if (i != fa)
      dfs1(i, pos, dep + 1), addv(pos, d[i] + 1),
          d[pos] = max(d[pos], d[i] + 1);
}
bool dfs2(int pos, int fa) {
  if (dp[pos][2] >= len) return 1;
  for (auto &i : v[pos]) {
    if (i == fa) continue;
    addv(i, dp[pos][d[i] + 1 == dp[pos][0]] + 1);
    if (dfs2(i, pos)) return 1;
  }
  return 0;
}
bool dfs3(int pos, int fa) {
  bool fl = pos == b;
  d[pos] = 0;
  for (auto &i : v[pos]) {
    if (i == fa) continue;
    if (dfs3(i, pos))
      fl = 1;
    else
      d[pos] = max(d[pos], d[i] + 1);
  }
  if (fl) seq.push_back(pos);
  return fl;
}
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) v[i].clear();
    for (int i = 1; i <= n; i++) dp[i][0] = dp[i][1] = dp[i][2] = 0;
    seq.clear();
    sl.clear();
    sr.clear();
    int t1, t2;
    for (int i = 1; i < n; i++)
      cin >> t1 >> t2, v[t1].push_back(t2), v[t2].push_back(t1);
    dfs1(a, 0, 0);
    if (!dfs2(a, 0)) {
      cout << "NO" << endl;
      continue;
    }
    dfs3(a, 0);
    for (int i = 0; i <= len; i++) {
      sl.push_back(sl.empty() || d[seq[i]] - i > sl.back() ? d[seq[i]] - i
                                                           : sl.back());
      sr.push_back(sr.empty() || d[seq[len - i]] - i > sr.back()
                       ? d[seq[len - i]] - i
                       : sr.back());
    }
    reverse(sr.begin(), sr.end());
    int l = 0, r = len;
    while (l < r) {
      if (l < sr[r])
        l = sr[r];
      else if (len - r < sl[l])
        r = len - sl[l];
      else
        break;
    }
    cout << (l >= r ? "YES" : "NO") << endl;
  }
  return 0;
}
