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

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.txt = txt

e = A("e")
d = B("d")
n = B("n")
j = B("j")
h = A("h")

e.y = j
e.x = n
d.o = n
d.u = n
n.o = j
n.u = d
j.o = n
j.u = d
h.y = j
h.x = n
assert n.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.txt = txt

e = A("e")
d = B("d")
n = B("n")
j = B("j")
h = A("h")

e.y = j
e.x = n
d.o = n
d.u = n
n.o = j
n.u = d
j.o = n
j.u = d
h.y = j
h.x = n
assert n.o.u.u.txt == "n"