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

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

a = A("a")
j = B("j")
m = B("m")
c = A("c")
e = A("e")
h = A("h")

a.v = j
j.t = m
m.t = j
c.v = m
e.v = m
h.v = m
assert c.v.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

a = A("a")
j = B("j")
m = B("m")
c = A("c")
e = A("e")
h = A("h")

a.v = j
j.t = m
m.t = j
c.v = m
e.v = m
h.v = m
assert c.v.t.t.t.t.t.txt == "j"