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

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

e = A("e")
g = B("g")
a = A("a")
h = A("h")
l = B("l")
b = B("b")
i = A("i")
n = A("n")
d = A("d")

e.x = l
g.w = e
g.u = b
a.x = l
h.x = b
l.w = n
l.u = b
b.w = n
b.u = g
i.x = g
n.x = l
d.x = b
assert h.x.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

e = A("e")
g = B("g")
a = A("a")
h = A("h")
l = B("l")
b = B("b")
i = A("i")
n = A("n")
d = A("d")

e.x = l
g.w = e
g.u = b
a.x = l
h.x = b
l.w = n
l.u = b
b.w = n
b.u = g
i.x = g
n.x = l
d.x = b
assert h.x.w.x.w.x.txt == "l"