class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

n = A("n")
e = B("e")
h = A("h")
j = A("j")
a = B("a")
c = B("c")
l = A("l")
d = A("d")

n.u = h
n.y = d
e.v = d
h.u = l
h.y = d
j.u = l
j.y = h
a.v = l
c.v = h
l.u = j
l.y = d
d.u = h
d.y = n
assert e.v.y.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

n = A("n")
e = B("e")
h = A("h")
j = A("j")
a = B("a")
c = B("c")
l = A("l")
d = A("d")

n.u = h
n.y = d
e.v = d
h.u = l
h.y = d
j.u = l
j.y = h
a.v = l
c.v = h
l.u = j
l.y = d
d.u = h
d.y = n
assert e.v.y.u.u.txt == "l"