#include <bits/stdc++.h>
using namespace std;
vector<int> adjList[100000];
int parent[100000], height[100000], depth[100000], height2[100000];
int doDFS(int u, int p, int d) {
  int i;
  parent[u] = p, height[u] = 0, depth[u] = d;
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != p) height[u] = max(height[u], doDFS(v, u, d + 1) + 1);
  }
  return height[u];
}
int doDFS2(int u, int p, int h) {
  int i;
  height2[u] = h;
  int m1 = 0, m2 = 0, mi = -1;
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != p) {
      if (height[v] + 1 >= m1)
        m2 = m1, m1 = height[v] + 1, mi = v;
      else if (height[v] + 1 >= m2)
        m2 = height[v] + 1;
    }
  }
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != p) {
      if (v == mi)
        doDFS2(v, u, max(h, m2) + 1);
      else
        doDFS2(v, u, max(h, m1) + 1);
    }
  }
  return 0;
}
vector<int> path;
int good[100000], onPath[100000];
int parent2[100000], depth2[100000], pathPos[100000];
int doDFS3(int u, int p, int d) {
  int i;
  parent2[u] = p, depth2[u] = d;
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if ((v != p) && (onPath[v] == -1))
      pathPos[v] = pathPos[u], good[u] |= doDFS3(v, u, d + 1);
  }
  return good[u];
}
int poss[100000][2];
queue<pair<int, int> > Q;
int main() {
  int i;
  int t, n, a, b;
  int u, v;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d %d", &n, &a, &b);
    a--, b--;
    for (i = 0; i < n - 1; i++) {
      scanf("%d %d", &u, &v);
      u--, v--;
      adjList[u].push_back(v);
      adjList[v].push_back(u);
    }
    int j;
    doDFS(a, -1, 0);
    int dd = depth[b];
    doDFS2(a, -1, 0);
    for (i = 0; i < n; i++) {
      vector<int> vv;
      for (j = 0; j < adjList[i].size(); j++) {
        int v = adjList[i][j];
        if (v != parent[i])
          vv.push_back(height[v] + 1);
        else
          vv.push_back(height2[i]);
      }
      sort(vv.begin(), vv.end(), greater<int>());
      if ((vv.size() >= 3) && (vv[2] >= dd))
        good[i] = 1;
      else
        good[i] = 0;
    }
    int u = b, f = 0;
    fill(onPath, onPath + n, -1);
    while (u != -1) {
      path.push_back(u), onPath[u] = path.size() - 1, pathPos[u] = onPath[u];
      u = parent[u];
    }
    for (i = 0; i < n; i++) {
      if (onPath[i] != -1) doDFS3(i, -1, 0);
    }
    for (i = 0; i < n; i++) poss[i][0] = poss[i][1] = 0;
    poss[a][0] = 1;
    Q.push(make_pair(a, 0));
    while (!Q.empty()) {
      int u = Q.front().first;
      int x = Q.front().second;
      Q.pop();
      if (good[u]) {
        f = 1;
        break;
      }
      if (x == 0) {
        ;
        ;
        ;
        if ((depth2[u] <= dd) && (pathPos[u] - (dd - depth2[u]) >= 0)) {
          int v = path[pathPos[u] - (dd - depth2[u])];
          if (!poss[v][1]) poss[v][1] = 1, Q.push(make_pair(v, 1));
        }
      } else {
        if ((depth2[u] <= dd) &&
            (pathPos[u] + (dd - depth2[u]) < path.size())) {
          int v = path[pathPos[u] + (dd - depth2[u])];
          if (!poss[v][0]) poss[v][0] = 1, Q.push(make_pair(v, 0));
        }
      }
      for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v == parent2[u]) continue;
        if ((onPath[u] != -1) && (onPath[v] != -1) &&
            (x != ((onPath[u] > onPath[v]) ? 1 : 0)))
          continue;
        if (!poss[v][x]) poss[v][x] = 1, Q.push(make_pair(v, x));
      }
    }
    while (!Q.empty()) Q.pop();
    printf(f ? "YES\n" : "NO\n");
    for (i = 0; i < n; i++) adjList[i].clear();
    path.clear();
  }
  return 0;
}
