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

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

j = A("j")
b = B("b")
l = B("l")
m = B("m")
d = B("d")

j.v = l
b.p = j
l.p = j
m.p = j
d.p = j
assert j.v.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

j = A("j")
b = B("b")
l = B("l")
m = B("m")
d = B("d")

j.v = l
b.p = j
l.p = j
m.p = j
d.p = j
assert j.v.p.v.p.txt == "j"