#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000005;
const long long SQRTN = 1003;
const long long LOGN = 22;
const double PI = acos(-1);
const long long INF = 1e16;
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const double eps = 1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
long long add(long long a, long long b, long long c = MOD) {
  long long res = a + b;
  return (res >= c ? res - c : res);
}
long long mod_neg(long long a, long long b, long long c = MOD) {
  long long res;
  if (abs(a - b) < c)
    res = a - b;
  else
    res = (a - b) % c;
  return (res < 0 ? res + c : res);
}
long long mul(long long a, long long b, long long c = MOD) {
  long long res = (long long)a * b;
  return (res >= c ? res % c : res);
}
long long muln(long long a, long long b, long long c = MOD) {
  long long res = (long long)a * b;
  return ((res % c) + c) % c;
}
long long mulmod(long long a, long long b, long long m = MOD) {
  long long q = (long long)(((long double)a * (long double)b) / (long double)m);
  long long r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T>
T expo(T e, T n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T power(T e, T n, T m = MOD) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mul(x, p, m);
    p = mul(p, p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T extended_euclid(T a, T b, T& x, T& y) {
  T xx = 0, yy = 1;
  y = 0;
  x = 1;
  while (b) {
    T q = a / b, t = b;
    b = a % b;
    a = t;
    t = xx;
    xx = x - q * xx;
    x = t;
    t = yy;
    yy = y - q * yy;
    y = t;
  }
  return a;
}
template <typename T>
T mod_inverse(T a, T n = MOD) {
  T x, y, z = 0;
  T d = extended_euclid(a, n, x, y);
  return (d > 1 ? -1 : mod_neg(x, z, n));
}
const long long FACSZ = 1;
long long fact[FACSZ], ifact[FACSZ];
void precom(long long c = MOD) {
  fact[0] = 1;
  for (long long i = 1; i < FACSZ; i++) fact[i] = mul(fact[i - 1], i, c);
  ifact[FACSZ - 1] = mod_inverse(fact[FACSZ - 1], c);
  for (long long i = FACSZ - 1 - 1; i >= 0; i--) {
    ifact[i] = mul(i + 1, ifact[i + 1], c);
  }
}
long long ncr(long long n, long long r, long long c = MOD) {
  if (r > n) return 0;
  return mul(mul(ifact[r], ifact[n - r], c), fact[n], c);
}
void solvethetestcase();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  for (long long testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
long long n, a, b;
vector<long long> adj[MAXN];
long long dep[MAXN];
long long par[MAXN][21];
long long dp[MAXN], dp_par[MAXN], deep[MAXN];
void dfs1(long long u, long long p, long long d) {
  dep[u] = d;
  par[u][0] = p;
  for (long long j = 1; j < 21; j++) {
    par[u][j] = par[par[u][j - 1]][j - 1];
  }
  dp[u] = 0;
  deep[u] = u;
  for (auto v : adj[u]) {
    if (v != p) {
      dfs1(v, u, d + 1);
      if (dp[v] >= dp[u]) {
        deep[u] = deep[v];
        dp[u] = dp[v] + 1;
      }
    }
  }
}
void dfs2(long long u) {
  vector<long long> gg;
  gg.push_back(dp_par[u] + 1);
  for (auto v : adj[u]) {
    if (v != par[u][0]) {
      gg.push_back(dp[v] + 2);
    }
  }
  sort(gg.begin(), gg.end());
  reverse(gg.begin(), gg.end());
  for (auto v : adj[u]) {
    if (v != par[u][0]) {
      if (dp[v] == gg[0] - 2)
        dp_par[v] = gg[1];
      else
        dp_par[v] = gg[0];
      dfs2(v);
    }
  }
}
long long lca(long long u, long long v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (long long j = 20; j >= 0; j--) {
    if (dep[v] - (1 << j) >= dep[u]) v = par[v][j];
  }
  if (u == v) return u;
  for (long long j = 20; j >= 0; j--) {
    if (par[u][j] != par[v][j]) {
      u = par[u][j];
      v = par[v][j];
    }
  }
  return par[u][0];
}
void solvethetestcase() {
  cin >> n >> a >> b;
  for (long long i = 0; i < n + 1; i++) {
    adj[i].clear();
  }
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs1(1, 1, 0);
  dp_par[1] = 0;
  dfs2(1);
  long long l = dep[a] + dep[b] - 2 * dep[lca(a, b)];
  long long pivot = -1;
  for (long long i = 1; i < n + 1; i++) {
    vector<long long> gg;
    gg.push_back(dp_par[i]);
    for (auto v : adj[i]) {
      if (v != par[i][0]) {
        gg.push_back(dp[v] + 1);
      }
    }
    sort(gg.begin(), gg.end());
    reverse(gg.begin(), gg.end());
    if (((long long)(gg).size()) >= 3 and gg[2] >= l) {
      pivot = i;
      break;
    }
  }
  if (pivot == -1) {
    cout << "NO\n";
    return;
  }
  dfs1(pivot, pivot, 0);
  long long moves = 0;
  while (true) {
    moves++;
    if (moves > 2 * n) break;
    if (dep[a] < dep[b]) swap(a, b);
    if (lca(a, b) == b) {
      cout << "YES\n";
      return;
    }
    long long jump = dp[a];
    a = deep[a];
    for (long long j = 20; j >= 0; j--) {
      if ((1 << j) <= jump) {
        jump -= (1 << j);
        b = par[b][j];
      }
    }
    if (lca(a, b) == b) {
      cout << "YES\n";
      return;
    }
    jump = dp[b];
    b = deep[b];
    for (long long j = 20; j >= 0; j--) {
      if ((1 << j) <= jump) {
        jump -= (1 << j);
        a = par[a][j];
      }
    }
  }
  cout << "NO\n";
}
