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

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

e = A("e")
h = B("h")
f = A("f")
c = A("c")
n = A("n")
b = B("b")
j = B("j")

e.w = h
h.o = j
f.w = j
c.w = b
n.w = h
b.o = j
j.o = h
assert h.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
f = A("f")
c = A("c")
n = A("n")
b = B("b")
j = B("j")

e.w = h
h.o = j
f.w = j
c.w = b
n.w = h
b.o = j
j.o = h
assert h.o.o.o.o.o.o.txt == "h"