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

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

h = A("h")
l = B("l")
b = A("b")
i = B("i")

h.r = i
h.v = i
l.t = i
l.p = h
b.r = i
b.v = l
i.t = l
i.p = b
assert l.t.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

h = A("h")
l = B("l")
b = A("b")
i = B("i")

h.r = i
h.v = i
l.t = i
l.p = h
b.r = i
b.v = l
i.t = l
i.p = b
assert l.t.p.r.p.txt == "b"