#include <bits/stdc++.h>
using namespace std;
struct node {
  node *l, *r;
  int a, b;
  int Max;
  int tag;
  node(int _a, int _b) : a(_a), b(_b), l(NULL), r(NULL) {
    Max = 0;
    tag = 0;
  }
} * root;
int Max(node *n) { return n->Max + n->tag; }
void pull(node *n) { n->Max = max(Max(n->l), Max(n->r)); }
void push(node *n) {
  n->l->tag += n->tag;
  n->r->tag += n->tag;
  n->tag = 0;
}
void build(node *n, int *a) {
  if (n->a == n->b) {
    n->Max = a[n->a];
    return;
  }
  int mid = (n->a + n->b) / 2;
  n->l = new node(n->a, mid);
  n->r = new node(mid + 1, n->b);
  build(n->l, a);
  build(n->r, a);
  pull(n);
}
void add(node *n, int l, int r, int k) {
  if (l > r) return;
  if (n->a >= l && n->b <= r) {
    n->tag += k;
    return;
  }
  if (n->b < l || n->a > r) return;
  push(n);
  add(n->l, l, r, k);
  add(n->r, l, r, k);
  pull(n);
}
int in[100005];
int out[100005];
int d[100005];
vector<int> v[100005];
int t;
void dfs(int first, int f) {
  in[first] = ++t;
  d[t] = d[in[f]] + 1;
  for (auto it : v[first]) {
    if (it != f) {
      dfs(it, first);
    }
  }
  out[first] = t;
}
vector<int> stk;
int go(int s, int t, int f) {
  stk.push_back(s);
  if (s == t) return 1;
  for (auto it : v[s]) {
    if (it != f) {
      int first;
      if (first = go(it, t, s)) return first + 1;
    }
  }
  stk.pop_back();
  return 0;
}
int query(node *n, int l, int r) {
  if (l > r) return 0;
  if (n->a >= l && n->b <= r) {
    return Max(n);
  }
  if (n->b < l || n->a > r) {
    return 0;
  }
  push(n);
  int a = query(n->l, l, r);
  int b = query(n->r, l, r);
  pull(n);
  return max(a, b);
}
vector<int> ans;
int Max1[100005], Maxi[100005], Max2[100005];
int n;
void dfs2(int first, int f, int q) {
  Max1[first] = Max2[first] = 0;
  vector<int> Max;
  for (auto it : v[first]) {
    if (it != f) {
      int a;
      Max.push_back(a = query(root, in[it], out[it]));
      if (a > Max1[first]) {
        Max2[first] = Max1[first];
        Max1[first] = a;
        Maxi[first] = it;
      } else if (a > Max2[first]) {
        Max2[first] = a;
      }
    }
  }
  int a;
  Max.push_back(
      a = max(query(root, 1, in[first] - 1), query(root, out[first] + 1, n)));
  if (a > Max1[first]) {
    Max2[first] = Max1[first];
    Max1[first] = a;
    Maxi[first] = f;
  } else if (a > Max2[first]) {
    Max2[first] = a;
  }
  sort(Max.begin(), Max.end());
  reverse(Max.begin(), Max.end());
  if (Max.size() >= 3 && Max[2] >= q) ans.push_back(first);
  for (auto it : v[first]) {
    if (it != f) {
      add(root, in[it], out[it], -1);
      add(root, 1, in[it] - 1, 1);
      add(root, out[it] + 1, n, 1);
      dfs2(it, first, q);
      add(root, in[it], out[it], 1);
      add(root, 1, in[it] - 1, -1);
      add(root, out[it] + 1, n, -1);
    }
  }
}
int get(int a, int b) {
  if (Maxi[a] == b) return Max2[a];
  return Max1[a];
}
int ok[100005];
void dfs3(int first, int f) {
  ok[first] = 1;
  for (auto it : v[first]) {
    if (it != f) dfs3(it, first);
  }
}
void solve() {
  int a, b;
  scanf("%d %d %d", &n, &a, &b);
  t = 0;
  for (int i = 1; i <= n; i++) v[i].clear();
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(second);
    v[second].push_back(first);
  }
  dfs(1, 0);
  stk.clear();
  int dis = go(a, b, 0);
  root = new node(1, n);
  build(root, d);
  ans.clear();
  dfs2(1, 0, dis);
  int Maxa = get(stk[0], stk[1]), Maxb = get(stk.back(), stk[stk.size() - 2]);
  int l = 0, r = stk.size() - 1;
  while (l + 1 < Maxb || r - 1 > (int)stk.size() - 1 - Maxa) {
    if (l + 1 < Maxb) {
      l++;
      if (l != stk.size() - 1) {
        Maxa = get(stk[l], stk[l + 1]) - l;
      } else {
        break;
      }
    }
    if (r - 1 > (int)stk.size() - Maxa - 1) {
      r--;
      if (r != 0) {
        Maxb = get(stk[r], stk[r - 1]) - (stk.size() - 1 - r);
      } else {
        break;
      }
    }
  }
  fill(ok, ok + n + 1, 0);
  if (l == stk.size() - 1 || r == 0) {
    if (ans.size())
      printf("YES\n");
    else {
      printf("NO\n");
    }
  } else {
    dfs3(stk[l], stk[l + 1]);
    dfs3(stk[r], stk[r - 1]);
    for (auto it : ans) {
      if (ok[it]) {
        printf("YES\n");
        return;
      }
    }
    printf("NO\n");
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
}
