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

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

m = A("m")
c = B("c")
b = B("b")
j = B("j")
k = A("k")
e = A("e")
h = A("h")
l = A("l")

m.v = b
c.x = b
b.x = c
j.x = c
k.v = c
e.v = c
h.v = c
l.v = c
assert h.v.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

m = A("m")
c = B("c")
b = B("b")
j = B("j")
k = A("k")
e = A("e")
h = A("h")
l = A("l")

m.v = b
c.x = b
b.x = c
j.x = c
k.v = c
e.v = c
h.v = c
l.v = c
assert h.v.x.x.x.txt == "b"