#include <cstdio>
#include <vector>
#include <algorithm>

#pragma comment(linker, "/STACK:60000000")

using namespace std;

#define NOFOOTER

#include "testlib.h"

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back

#define m 100100

vector <int> c[m];
int n, u[m], nu[m];

int dfs( int v, int p, int d )
{
  u[v] = 2;
  if (v == d)
    return 0;
  forn (i, c[v].size())
    if (c[v][i] != p && u[c[v][i]] == 0)
    {
      int t = dfs(c[v][i], v, d);
      if (t != -1)
        return t + 1;
    }
  u[v] = 1;
  return -1;
}

int main( int argc, char **argv )
{
  // init & read input
  registerTestlibCmd(argc, argv);
  n = inf.readInt();
  forn (i, n - 1)
  {
    int a = inf.readInt() - 1, b = inf.readInt() - 1;
    c[a].pb(b), c[b].pb(a);
  }
  // check jury
  int ja = ans.readInt();
  int jv0 = -1, jv1 = -1, jv2 = -1, jv3 = -1;
  jv0 = ans.readInt() - 1;
  jv1 = ans.readInt() - 1;
  if (0 > jv0 || jv0 >= n || 0 > jv1 || jv1 >= n || jv0 == jv1)
    quit(_fail, "answer contains incorrect edges");
  if (!ans.seekEof())
  {
    jv2 = ans.readInt() - 1;
    jv3 = ans.readInt() - 1;
    if (0 > jv2 || jv2 >= n || 0 > jv3 || jv3 >= n || jv2 == jv3)
      quit(_fail, "answer contains incorrect edges");

    int be = -1, t1, t2;
    bool ok;
    forn (tt, 2)
    {
      forn (i, n)
        u[i] = 0;
      forn (i, n)
        nu[i] = 0;
      t1 = dfs(jv0, -1, jv2);
      forn (i, n)
        if (u[i] == 2 && i != jv0 && i != jv2)
          nu[i]++;
      forn (i, n)
        u[i] = 0;
      t2 = dfs(jv3, -1, jv1);
      forn (i, n)
        if (u[i] == 2 && i != jv1 && i != jv3)
          nu[i]++;
      ok = t1 != -1 && t2 != -1;
      forn (i, n)
        if (nu[i] > 1)
          ok = false;
      if (nu[jv0] > 0 || nu[jv1] > 0 || nu[jv2] > 0 || nu[jv3] > 0)
        ok = false;
      if (ok && (be < t1 + t2 + 2))
        be = t1 + t2 + 2;
      swap(jv2, jv3);
    }

    if (be != ja)
      quit(_fail, "another answer is reached using given edges");
  }
  else
  {
    forn (i, n)
      u[i] = 0;
    int t = dfs(jv0, -1, jv1);
    if (t + 1 != ja)
      quit(_fail, "another answer is reached using given edge");
  }
  // check contestant
  int pa = ouf.readInt();
  int pv0 = -1, pv1 = -1, pv2 = -1, pv3 = -1;
  pv0 = ouf.readInt() - 1;
  pv1 = ouf.readInt() - 1;
  if (0 > pv0 || pv0 >= n || 0 > pv1 || pv1 >= n || pv0 == pv1)
    quit(_wa, "output contains incorrect edges");
  if (!ouf.seekEof())
  {
    pv2 = ouf.readInt() - 1;
    pv3 = ouf.readInt() - 1;
    if (0 > pv2 || pv2 >= n || 0 > pv3 || pv3 >= n || pv2 == pv3)
      quit(_wa, "answer contains incorrect edges");

    int be = -1, t1, t2;
    bool ok;
    forn (tt, 2)
    {
      forn (i, n)
        u[i] = 0;
      forn (i, n)
        nu[i] = 0;
      t1 = dfs(pv0, -1, pv2);
      forn (i, n)
        if (u[i] == 2 && i != pv0 && i != pv2)
          nu[i]++;
      forn (i, n)
        u[i] = 0;
      t2 = dfs(pv3, -1, pv1);
      forn (i, n)
        if (u[i] == 2 && i != pv1 && i != pv3)
          nu[i]++;
      ok = t1 != -1 && t2 != -1;
      forn (i, n)
        if (nu[i] > 1)
          ok = false;
      if (nu[pv0] > 0 || nu[pv1] > 0 || nu[pv2] > 0 || nu[pv3] > 0)
        ok = false;
      if (ok && (be < t1 + t2 + 2))
        be = t1 + t2 + 2;
      swap(pv2, pv3);
    }

    if (be != pa)
      quit(_wa, "another answer is reached using given edges");
  }
  else
  {
    forn (i, n)
      u[i] = 0;
    int t = dfs(pv0, -1, pv1);
    if (t + 1 != pa)
      quit(_wa, "another answer is reached using given edge");
  }
  if (pa > ja)
    quit(_fail, "contestant found better solution");
  if (pa < ja)
    quit(_wa, "better solution exists");
  quit(_ok, "=)");
  return 0;
}
